From a1c400aa270dc423ae5763d47658482c41309799 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Sat, 25 Oct 2014 19:58:59 +0200 Subject: [PATCH] =?UTF-8?q?Do=20po=C5=BEadavk=C5=AF=20materi=C3=A1lu=20i?= =?UTF-8?q?=20servisu=20p=C5=99id=C3=A1n=20checkbox=20"Studentsk=C3=BD=20p?= =?UTF-8?q?rojekt".=20Pokud=20je=20nastaven,=20polo=C5=BEky=20po=C5=BEadav?= =?UTF-8?q?k=C5=AF=20nevstupuj=C3=AD=20do=20schv=C3=A1len=C3=BDch=20polo?= =?UTF-8?q?=C5=BEek=20po=C5=BEadavk=C5=AF.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #166 --- .../java/info/bukova/isspst/BooleanUtils.java | 13 +++++++ .../java/info/bukova/isspst/data/Order.java | 13 ------- .../info/bukova/isspst/data/Requirement.java | 38 +++++++++++++++++++ .../isspst/data/RequirementSubject.java | 12 +++++- .../isspst/filters/RequirementFilter.java | 4 +- .../approved/ApprovedServiceImpl.java | 13 +++++-- .../info/bukova/isspst/ui/BoolConverter.java | 16 +++++--- .../orders/material/ReqMaterialListMy.java | 5 +-- .../orders/material/ReqMaterialListMyAll.java | 5 +-- .../material/ReqMaterialListMyCenters.java | 5 +-- .../material/ReqMaterialListMyWorkgroups.java | 5 +-- .../main/orders/requirements/ReqListMy.java | 5 +-- .../orders/requirements/ReqListMyAll.java | 5 +-- .../orders/requirements/ReqListMyCenters.java | 5 +-- .../requirements/ReqListMyWorkgroups.java | 5 +-- .../orders/services/ReqServicesListMy.java | 5 +-- .../orders/services/ReqServicesListMyAll.java | 5 +-- .../services/ReqServicesListMyCenters.java | 5 +-- .../services/ReqServicesListMyWorkgroups.java | 5 +-- .../ui/requirement/RequirementSubpage.java | 4 +- .../WEB-INF/locales/zk-label.properties | 3 ++ .../main/orders/requirements/reqForm.zul | 8 ++++ .../main/orders/requirements/reqListMy.zul | 18 +++++++++ .../main/orders/requirements/reqListMyAll.zul | 18 +++++++++ .../orders/requirements/reqListMyCenters.zul | 18 +++++++++ .../requirements/reqListMyWorkgroups.zul | 18 +++++++++ 26 files changed, 193 insertions(+), 63 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/BooleanUtils.java diff --git a/src/main/java/info/bukova/isspst/BooleanUtils.java b/src/main/java/info/bukova/isspst/BooleanUtils.java new file mode 100644 index 00000000..484e562a --- /dev/null +++ b/src/main/java/info/bukova/isspst/BooleanUtils.java @@ -0,0 +1,13 @@ +package info.bukova.isspst; + + +public class BooleanUtils +{ + public static boolean isEqualByBoolean(Boolean b1, Boolean b2) + { + boolean bool1 = ((b1 == null) ? false : b1.booleanValue()); + boolean bool2 = ((b2 == null) ? false : b2.booleanValue()); + boolean equals = (bool1 == bool2); + return equals; + } +} diff --git a/src/main/java/info/bukova/isspst/data/Order.java b/src/main/java/info/bukova/isspst/data/Order.java index c3879f25..79348edb 100644 --- a/src/main/java/info/bukova/isspst/data/Order.java +++ b/src/main/java/info/bukova/isspst/data/Order.java @@ -110,9 +110,6 @@ public class Order extends BaseData implements Cloneable @Column(name = "DELIVERED") private boolean delivered; - @Column(name = "INVOICED") - private boolean invoiced; - public Order() { this.items = new ArrayList(); @@ -225,16 +222,6 @@ public class Order extends BaseData implements Cloneable this.delivered = delivered; } - public boolean isInvoiced() - { - return invoiced; - } - - public void setInvoiced(boolean invoiced) - { - this.invoiced = invoiced; - } - public boolean isOrdered() { return ordered; diff --git a/src/main/java/info/bukova/isspst/data/Requirement.java b/src/main/java/info/bukova/isspst/data/Requirement.java index 661cfed7..084670e2 100644 --- a/src/main/java/info/bukova/isspst/data/Requirement.java +++ b/src/main/java/info/bukova/isspst/data/Requirement.java @@ -28,6 +28,9 @@ public class Requirement extends RequirementBase @Column(name = "KIND") private Long kind; + @Column(name = "PROJECT") + private Boolean project; + public Requirement() { this.setItems(new ArrayList()); @@ -78,4 +81,39 @@ public class Requirement extends RequirementBase { this.kind = kind; } + + public Boolean getProject() + { + return project; + } + + public void setProject(Boolean project) + { + this.project = project; + } + + @Override + public boolean equals(Object obj) + { + if (obj != null) + { + if (obj instanceof Requirement) + { + Requirement item = (Requirement) obj; + + int thisId = this.getId(); + int itemId = item.getId(); + boolean equalsId = (thisId == itemId); + + if (equalsId && (thisId == 0)) + { + return super.equals(obj); + } + + return equalsId; + } + } + + return false; + } } diff --git a/src/main/java/info/bukova/isspst/data/RequirementSubject.java b/src/main/java/info/bukova/isspst/data/RequirementSubject.java index 08f81012..8b05b9ea 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementSubject.java +++ b/src/main/java/info/bukova/isspst/data/RequirementSubject.java @@ -45,7 +45,6 @@ public abstract class RequirementSubject implements OwnedDataModel { @Column(name = "DESCRIPTION") private String description; - @NotEmpty(message = "{MaterialFormCodeConstr}") public String getCode() { return code; @@ -140,7 +139,16 @@ public abstract class RequirementSubject implements OwnedDataModel { { RequirementSubject item = (RequirementSubject) obj; - return (this.getId() == item.getId()); + int thisId = this.getId(); + int itemId = item.getId(); + boolean equalsId = (thisId == itemId); + + if (equalsId && (thisId == 0)) + { + return super.equals(obj); + } + + return equalsId; } } diff --git a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java index 4d857737..5710afcc 100644 --- a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java +++ b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java @@ -1,5 +1,6 @@ package info.bukova.isspst.filters; +import info.bukova.isspst.BooleanUtils; import info.bukova.isspst.DateTimeUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.Requirement; @@ -46,7 +47,8 @@ public class RequirementFilter implements Filter boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); - return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser); + boolean foundProject = BooleanUtils.isEqualByBoolean(item.getProject(), condition.getProject()); + return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject); } @Factory diff --git a/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java b/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java index 8234267d..8e177ab6 100644 --- a/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java @@ -34,9 +34,14 @@ public class ApprovedServiceImpl extends AbstractService implements public List getAll() { List wgList = workgroupService.getUserCentres(userService.getCurrent()); - Query q = queryDao - .getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList) and (item.orderNum Is Null or item.orderNum = '')"); - q.setParameterList("wgList", wgList); + Query q = queryDao.getQuery("select item " + + "from RequirementItem item left join item.requirement rq join rq.centre c " + + "where rq.kind is not null " + + "and rq.state = :state " + + "and (rq.project Is Null or rq.project = false) " + + "and c in (:wgList) " + + "and (item.orderNum Is Null or item.orderNum = '')"); + q.setParameterList("wgList", wgList); q.setParameter("state", RequirementState.APPROVED); List items = new ArrayList(); @@ -47,7 +52,7 @@ public class ApprovedServiceImpl extends AbstractService implements items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy())); } - + return items; } } diff --git a/src/main/java/info/bukova/isspst/ui/BoolConverter.java b/src/main/java/info/bukova/isspst/ui/BoolConverter.java index 4281a066..18c3393d 100644 --- a/src/main/java/info/bukova/isspst/ui/BoolConverter.java +++ b/src/main/java/info/bukova/isspst/ui/BoolConverter.java @@ -6,16 +6,22 @@ import org.zkoss.bind.BindContext; import org.zkoss.bind.Converter; import org.zkoss.zk.ui.Component; -public class BoolConverter implements Converter { - +public class BoolConverter implements Converter +{ @Override - public Boolean coerceToBean(String str, Component component, BindContext cx) { + public Boolean coerceToBean(String str, Component component, BindContext cx) + { return false; } @Override - public String coerceToUi(Boolean val, Component component, BindContext cx) { + public String coerceToUi(Boolean val, Component component, BindContext cx) + { + if (val == null) + { + val = new Boolean(false); + } + return StringUtils.localize(val.toString()); } - } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMy.java b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMy.java index 5219f39a..ee2467f4 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMy.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMy.java @@ -17,10 +17,9 @@ public class ReqMaterialListMy extends ReqListMy @WireVariable protected RequirementService reqMaterialService; - @Init - public void init() + @Init(superclass = true) + public void initReqMaterialListMy() { - super.init(); service = reqMaterialService; formZul = "/main/orders/material/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyAll.java b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyAll.java index cee34e38..b4488594 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyAll.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyAll.java @@ -17,10 +17,9 @@ public class ReqMaterialListMyAll extends ReqListMyAll @WireVariable protected RequirementService reqMaterialService; - @Init - public void init() + @Init(superclass = true) + public void initReqMaterialListMyAll() { - super.init(); service = reqMaterialService; formZul = "/main/orders/material/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyCenters.java b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyCenters.java index 158683e5..bed1d7b3 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyCenters.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyCenters.java @@ -17,10 +17,9 @@ public class ReqMaterialListMyCenters extends ReqListMyCenters @WireVariable protected RequirementService reqMaterialService; - @Init - public void init() + @Init(superclass = true) + public void initReqMaterialListMyCenters() { - super.init(); service = reqMaterialService; formZul = "/main/orders/material/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyWorkgroups.java b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyWorkgroups.java index 80bf4772..5ce19aad 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyWorkgroups.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/material/ReqMaterialListMyWorkgroups.java @@ -17,10 +17,9 @@ public class ReqMaterialListMyWorkgroups extends ReqListMyWorkgroups @WireVariable protected RequirementService reqMaterialService; - @Init - public void init() + @Init(superclass = true) + public void initReqMaterialListMyWorkgroups() { - super.init(); service = reqMaterialService; formZul = "/main/orders/material/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMy.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMy.java index a33e390c..bb004b53 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMy.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMy.java @@ -28,10 +28,9 @@ public class ReqListMy extends RequirementSubpage return workgroupService.getCentres(); } - @Init - public void init() + @Init(superclass = true) + public void initReqListMy() { - super.init(); service = requirementService; dataClass = Requirement.class; formZul = "/main/orders/requirements/reqForm.zul"; diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java index 97d184fb..e43b1ec2 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java @@ -30,10 +30,9 @@ public class ReqListMyAll extends RequirementSubpage return workgroupService.getCentres(); } - @Init - public void init() + @Init(superclass = true) + public void initReqListMyAll() { - super.init(); service = requirementService; dataClass = Requirement.class; formZul = "/main/orders/requirements/reqForm.zul"; diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java index 184b20ed..0c116134 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java @@ -30,10 +30,9 @@ public class ReqListMyCenters extends RequirementSubpage return workgroupService.getUserCentres(userService.getCurrent()); } - @Init - public void init() + @Init(superclass = true) + public void initReqListMyCenters() { - super.init(); service = requirementService; dataClass = Requirement.class; formZul = "/main/orders/requirements/reqForm.zul"; diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java index 9cf4f10d..90e0a2c2 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java @@ -30,10 +30,9 @@ public class ReqListMyWorkgroups extends RequirementSubpage return workgroupService.getCentres(); } - @Init - public void init() + @Init(superclass = true) + public void initReqListMyWorkgroups() { - super.init(); service = requirementService; dataClass = Requirement.class; formZul = "/main/orders/requirements/reqForm.zul"; diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMy.java b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMy.java index 3a30af37..3e2bb3b1 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMy.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMy.java @@ -17,10 +17,9 @@ public class ReqServicesListMy extends ReqListMy @WireVariable protected RequirementService reqServicesService; - @Init - public void init() + @Init(superclass = true) + public void initReqServicesListMy() { - super.init(); service = reqServicesService; formZul = "/main/orders/services/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyAll.java b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyAll.java index 273035c2..8ff3fd52 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyAll.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyAll.java @@ -17,10 +17,9 @@ public class ReqServicesListMyAll extends ReqListMyAll @WireVariable protected RequirementService reqServicesService; - @Init - public void init() + @Init(superclass = true) + public void initReqServicesListMyAll() { - super.init(); service = reqServicesService; formZul = "/main/orders/services/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyCenters.java b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyCenters.java index 57d8b5f2..af57bd67 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyCenters.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyCenters.java @@ -17,10 +17,9 @@ public class ReqServicesListMyCenters extends ReqListMyCenters @WireVariable protected RequirementService reqServicesService; - @Init - public void init() + @Init(superclass = true) + public void initReqServicesListMyCenters() { - super.init(); service = reqServicesService; formZul = "/main/orders/services/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyWorkgroups.java b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyWorkgroups.java index 2fa85640..f558e98c 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyWorkgroups.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/services/ReqServicesListMyWorkgroups.java @@ -17,10 +17,9 @@ public class ReqServicesListMyWorkgroups extends ReqListMyWorkgroups @WireVariable protected RequirementService reqServicesService; - @Init - public void init() + @Init(superclass = true) + public void initReqServicesListMyWorkgroups() { - super.init(); service = reqServicesService; formZul = "/main/orders/services/reqHeadForm.zul"; } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java index 5a79f111..a8168a3d 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java @@ -37,8 +37,8 @@ public class RequirementSubpage extends ListViewModel this.bigDecimalConverter = bigDecimalConverter; } - @Init - public void init() + @Init(superclass = true) + public void initRequirementSubpage() { this.bigDecimalConverter = new BigDecimalConverter(); } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index a1fae789..84d77705 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -311,6 +311,9 @@ AddItem=Přidat položku SelectGroup=Vybrat skupinu... RemoveItem=Smazat +StudentProject = Studentský projekt +StudentProjectAbr = St. projekt + Amount=Částka Owner=Vlastník CreateOrder=Vytvořit objednávku diff --git a/src/main/webapp/main/orders/requirements/reqForm.zul b/src/main/webapp/main/orders/requirements/reqForm.zul index e40e95c0..3ea2bc40 100644 --- a/src/main/webapp/main/orders/requirements/reqForm.zul +++ b/src/main/webapp/main/orders/requirements/reqForm.zul @@ -10,6 +10,14 @@ + + + + + + ${labels.RequirementsFormNumberSerie} : diff --git a/src/main/webapp/main/orders/requirements/reqListMy.zul b/src/main/webapp/main/orders/requirements/reqListMy.zul index 1ae8f2fd..f0d39069 100644 --- a/src/main/webapp/main/orders/requirements/reqListMy.zul +++ b/src/main/webapp/main/orders/requirements/reqListMy.zul @@ -5,6 +5,10 @@ onAfterRender="@command('afterRender')" selectedIndex="@bind(vm.selIndex)"> + + +
+
+ +
+
+ +
+
+
@@ -128,6 +145,7 @@