From 73c3ce7180c2ebd1d12fc1483dbe1bda175e3f4a Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Fri, 26 Sep 2014 10:41:51 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1ny=20sloupce=20pro=20vlastn?= =?UTF-8?q?=C3=ADky,=20st=C5=99ediska=20a=20komise.=20P=C5=99id=C3=A1no=20?= =?UTF-8?q?kontextov=C3=A9=20menu=20pro=20budouc=C3=AD=20vytv=C3=A1=C5=99e?= =?UTF-8?q?n=C3=AD=20objedn=C3=A1vek.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #139 --- .../java/info/bukova/isspst/StringUtils.java | 33 +++++ .../java/info/bukova/isspst/data/User.java | 46 ++++++- .../info/bukova/isspst/data/Workgroup.java | 42 +++++- .../isspst/filters/JoinedItemFilter.java | 11 +- .../approved/ApprovedServiceImpl.java | 10 +- .../isspst/ui/main/approved/ApprovedList.java | 32 +++++ .../WEB-INF/locales/zk-label.properties | 2 + src/main/webapp/img/autotruck-016.png | Bin 0 -> 722 bytes src/main/webapp/img/autotruck-032.png | Bin 0 -> 2261 bytes src/main/webapp/main/orders/approved/grid.zul | 125 ++++++++++++++---- 10 files changed, 266 insertions(+), 35 deletions(-) create mode 100644 src/main/webapp/img/autotruck-016.png create mode 100644 src/main/webapp/img/autotruck-032.png diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index cd418556..71df933f 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -1,5 +1,7 @@ package info.bukova.isspst; +import java.util.List; + import org.zkoss.util.resource.Labels; public class StringUtils @@ -91,4 +93,35 @@ public class StringUtils return value; } + + public static String addSeparator(String value, String separator, boolean toTail) + { + if ((value != null) && (separator != null)) + { + if (!value.isEmpty() && !separator.isEmpty()) + { + value = (toTail ? value + separator : separator + value); + } + } + + return value; + } + + public static String addSeparator(String value, String separator) + { + return StringUtils.addSeparator(value, separator, true); + } + + public static String join(List list, String separator) + { + String result = ""; + + for (int i = 0; i < list.size(); i++) + { + result = StringUtils.addSeparator(result, separator); + result += list.get(i); + } + + return result; + } } diff --git a/src/main/java/info/bukova/isspst/data/User.java b/src/main/java/info/bukova/isspst/data/User.java index f1b36fe7..133be197 100644 --- a/src/main/java/info/bukova/isspst/data/User.java +++ b/src/main/java/info/bukova/isspst/data/User.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.StringUtils; + import java.util.ArrayList; import java.util.List; @@ -134,14 +136,22 @@ public class User extends Member implements UserDetails, DataModel { this.authorities.remove(role); } - public String getFullName() { - String ret = ""; - if (lastName != null && !lastName.isEmpty()) { - ret = lastName + " "; + public String getFullName() + { + List list = new ArrayList(); + + if (this.lastName != null) + { + list.add(this.lastName); } - ret = ret + (firstName == null ? "" : firstName); - - return ret; + + if (this.firstName != null) + { + list.add(this.firstName); + } + + String result = StringUtils.join(list, " "); + return result; } public String getFirstName() { @@ -193,6 +203,28 @@ public class User extends Member implements UserDetails, DataModel { } } + public static boolean isEqualByUserForFilter(User value, User search) + { + if (search == null) + { + return true; + } + + else if (value != null) + { + if (search.getFullName().isEmpty()) + { + return true; + } + + String valueS = value.getFullName(); + String searchS = search.getFullName(); + return (valueS.compareTo(searchS) == 0); + } + + return false; + } + @Override public String toString() { return getFullName(); diff --git a/src/main/java/info/bukova/isspst/data/Workgroup.java b/src/main/java/info/bukova/isspst/data/Workgroup.java index 0163d69b..28654853 100644 --- a/src/main/java/info/bukova/isspst/data/Workgroup.java +++ b/src/main/java/info/bukova/isspst/data/Workgroup.java @@ -1,5 +1,7 @@ package info.bukova.isspst.data; +import info.bukova.isspst.StringUtils; + import java.io.Serializable; import java.math.BigDecimal; import java.util.ArrayList; @@ -103,8 +105,22 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable { } @Override - public String getFullName() { - return code + " " + name; + public String getFullName() + { + List list = new ArrayList(); + + if (this.code != null) + { + list.add(this.code); + } + + if (this.name != null) + { + list.add(this.name); + } + + String result = StringUtils.join(list, " "); + return result; } @Override @@ -136,6 +152,28 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable { return false; } + public static boolean isEqualByWorkgroupForFilter(Workgroup value, Workgroup search) + { + if (search == null) + { + return true; + } + + else if (value != null) + { + if (search.getFullName().isEmpty()) + { + return true; + } + + String valueS = value.getFullName(); + String searchS = search.getFullName(); + return (valueS.compareTo(searchS) == 0); + } + + return false; + } + @Override public String toString() { return getFullName(); diff --git a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java index 313b065d..8955ad8a 100644 --- a/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java +++ b/src/main/java/info/bukova/isspst/filters/JoinedItemFilter.java @@ -4,6 +4,8 @@ import info.bukova.isspst.BigDecimalUtils; import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.MUnitEmb; +import info.bukova.isspst.data.User; +import info.bukova.isspst.data.Workgroup; import org.hamcrest.Description; import org.hamcrest.Factory; @@ -17,6 +19,10 @@ public class JoinedItemFilter implements Filter public JoinedItemFilter(JoinedItem cond) { this.condition = cond; + this.condition.setMunit(new MUnitEmb()); + this.condition.setWorkgroup(new Workgroup()); + this.condition.setCentre(new Workgroup()); + this.condition.setOwnedBy(new User()); } private static class JoinedItemMatcher extends TypeSafeMatcher @@ -44,8 +50,11 @@ public class JoinedItemFilter implements Filter boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice()); boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit()); boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal()); + boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getWorkgroup(), condition.getWorkgroup()); + boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre()); + boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); - return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundDescription); + return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription); } @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 c6fef229..f17d69be 100644 --- a/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/approved/ApprovedServiceImpl.java @@ -11,6 +11,7 @@ import info.bukova.isspst.services.workgroups.WorkgroupService; import java.util.ArrayList; import java.util.List; +import org.hibernate.Hibernate; import org.hibernate.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PostFilter; @@ -33,12 +34,17 @@ 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)"); + 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)"); q.setParameterList("wgList", wgList); q.setParameter("state", RequirementState.APPROVED); List items = new ArrayList(); - for (RequirementItem it : (List)q.list()) { + for (RequirementItem it : (List) q.list()) + { + // Kvůli lazy loadu načteme jakoukoli hodnotu objektu + Hibernate.initialize(it.getRequirement().getOwnedBy()); + items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy())); } diff --git a/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java b/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java index e4ad6144..e52f1b47 100644 --- a/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java +++ b/src/main/java/info/bukova/isspst/ui/main/approved/ApprovedList.java @@ -1,11 +1,16 @@ package info.bukova.isspst.ui.main.approved; import info.bukova.isspst.data.JoinedItem; +import info.bukova.isspst.data.User; +import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.filters.JoinedItemFilter; import info.bukova.isspst.services.approved.ApprovedService; +import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.BigDecimalConverter; import info.bukova.isspst.ui.ListViewModel; +import java.util.ArrayList; import java.util.List; import org.zkoss.bind.annotation.Init; @@ -16,6 +21,12 @@ public class ApprovedList extends ListViewModel @WireVariable protected ApprovedService approvedService; + @WireVariable + protected WorkgroupService workgroupService; + + @WireVariable + protected UserService userService; + private BigDecimalConverter bigDecimalConverter; @Init @@ -37,4 +48,25 @@ public class ApprovedList extends ListViewModel { return approvedService.getAll(); } + + public List getWorkgroups() + { + Workgroup empty = new Workgroup(); + empty.setCode(""); + empty.setName(""); + List list = new ArrayList(); + list.add(empty); + list.addAll(this.workgroupService.getWorkgroups()); + return list; + } + + public List getCenters() + { + return this.workgroupService.getCentres(); + } + + public List getUsers() + { + return this.userService.getAll(); + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 8b42b8b6..cee66227 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -292,6 +292,8 @@ SelectGroup=Vybrat skupinu... RemoveItem=Smazat Amount=Částka +Owner=Vlastník +CreateOrder=Vytvořit objednávku WorkgroupFormUserIsCenterMember=Uživatel je členem střediska, jehož je komise členem! WorkgroupFormMemberIsCenterMember=Některý ze členů přidávané komise je členem tohoto střediska! diff --git a/src/main/webapp/img/autotruck-016.png b/src/main/webapp/img/autotruck-016.png new file mode 100644 index 0000000000000000000000000000000000000000..e6ea477a8efb81bd8bdd672e94e2744c7634e0a5 GIT binary patch literal 722 zcmV;@0xkWCP)K?s)m!V8C&bACL$&mpjpQ!U&D0u2CB zxbnbtgF_YSmqv+o!x~|#I8xmIw!AfF@8)y_xn=ZwKjECV#LEPjob>_MquL*o-YrT` z*o`IlL$^q$f<{pT&9mCJ4FDqNZ=AIZi*B89324Sx84qMI_pV->Ca ziFTUhCcHK%^>Rd~MI$dwhGan!-hDH|KI}lHyafcO0SVPvJp^&b5%6vS;~?Q1VRiSW zBQl$(Ff=2;`1B}xzc#|`c#mZ+h}@(C#3Wn>JL%&AmebAFnT!jaeE~3j5&?D*4ab_G zYw{sSKY>@HBqw@H0nfpWxPa0pfW-mqO9md7f$cSs5mkllaQoQMM&jl@ z@aXRYzs4ZgmJ0uwOMoO1ghHX<%w{tr5(%VIDV$Cx+-^5yGTA>X{hw#G2XeW5Ua3@y z3+fe0}KoZ0}PID$&CgOB3;UPMq?wtsYX_Y~5_@l$qiqeDttQIfqOw zSj*N`msRWZIF!4YrUq8x11JGW&;){+0SAU*-t(XTUjDdl?t1pP(%f^;|2Ox4f4}eN z-v9mGdsY0Bzjc}%e9T3~ed1sI)z+Voslbo@yzD&kpDwCjM7S_$1S-`#`S;IzVC|$e zq-c@|5T*a;lHFWzHnIBXIzIdM;8A3GF|WFse>s2`gC~UqYs#yZorp*c9)(S|;}pe% zR}9>TO7o6_4LS=0cjyB{To3kl277| z$~UPuHL&Bs5*#i&v$xHy6l>zXTL&oAOr3bggd-)hw$tG=Ao)oHqnD*?0R2|K_}dkw z+@sB6QQBiH`T7|)C50Bbcn-~QdUMG-okBCY_at_sTo2p-wXp31#U z4$G$KSASI8IvfTHEw2*T?oa8*JKh@%K;!l$Z;ti`O0@U2^KRvPWDUQQDVb9QKtF_+ zkG}qh8AEc}G-2a4w{qLxS<<+abmu6J{Nu>^!2noSJzfy%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40kK08ASQZF6BAH!fC;QVdfpJQHaw-)$22crk^7@xh5BDO#Au(5Pr; zFDs>EVr4wffpdW;UDY?d_$xxtVh*cTu(F6+-Nm>*6@WBDr_zTAohOa^}pL8rA&y^X06p zEH-c6%-FGGX>4r7X0wr*nMrnbwi5X8;lor{R}&o_&4eMB=^mDg!|wc_=S556?btql z|Hg4l1X)opgUTr2+{fSZYPLx7Boj6kE&xKV7yk9s^FpLqUN jIIR`0Zhro6GR{8%ZBA<=;wz0d00000NkvXXu0mjfkB54V literal 0 HcmV?d00001 diff --git a/src/main/webapp/main/orders/approved/grid.zul b/src/main/webapp/main/orders/approved/grid.zul index d7a529cf..7239043f 100644 --- a/src/main/webapp/main/orders/approved/grid.zul +++ b/src/main/webapp/main/orders/approved/grid.zul @@ -26,6 +26,7 @@ multiple="true" checkmark="true" vflex="1" + context="popupMenu" model="@load(vm.dataList)"> @@ -61,7 +62,19 @@ sort="auto(total)" label="${labels.RequirementItemTotal}" /> + + + @@ -112,19 +125,19 @@ + - + + + + +
+
+ + + +
+
+
+
+ +
- + + + +
+
+
- +
+
+ +
+
+ + + +
+
+ +
+
@@ -190,9 +260,18 @@ + + + + + + \ No newline at end of file