From 57c4a8922da1ceb5dce81a95cd62209d12bdccf0 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 15 Oct 2015 20:31:16 +0200 Subject: [PATCH] Continued: - Implemented business method allUsersNotSharing() - updated jar(s) --- lib/juser-core.jar | Bin 26225 -> 26338 bytes .../addressbook/AddressbookSessionBean.java | 80 +++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 94920473f0bd2dcfee1d99e5be9f16c81e3bd70d..c8486cff6d9b8b49ad3e85bc50a515a504837d72 100644 GIT binary patch delta 1857 zcmaKse{7RQ7{{M`+qa`#*RE^J#@5+)Y=d^NbvPJ|F}JdHb9BjIY;n4uUHdX5W55Om z&;*HpD3TewCkPT2WuittWBK8*-ISmG zbmv;Nt25A%-IhBmyf0k}^@q<8dF&wNewF^3A0j?3v50~f>c6MD^-y6Nsp0S zkqV>@)N*61B^IkR2BP&EAD74*n%@}d%W{W~^pDs|(JqZk(@=X^{8FLEtWAO^+v_Fb zYZL3Wq^D8}gzA+Z;oFhELa2870ij2-PG~F}_>Ofu8;q=%^xG4SeeEZC?zg12*KXHera!k?4%cnl0uN6`p(3_cQJ4l%^9vppQlHb2N~Gf@nD4=S5}Nh=HzF}Nw%eGpewlC z+tE?it#)<$)(6$qYZ(+{N1@_W(u$P%>o`}cYs!2z%EBj=bve|o3@P5FrC49M&U(%W z=b_06jZ|%fXJg=dyjobQxd6i$aJwhPzz;@P0T=O!1+&;C9Ieib>|gM%q~8Ww*bcF< z1DlIqNbLhNya`iaH{V}BWW!r97xsV`-UdIsgZGLzP1(!+`#=XDfCcu0m1ipnBH)I@ z_*zLDJBnVP9Zg=BJODC$ifhUevBv9R#|7Wc`3cUy7W^{jLxL*{UGiDZ&j}t{=wZWx zzsLEHoL>?ACg(p1{%EO7{+aV%1b?Q~!>$W{jPu_)9~JyQ=XV4zD|5+zaekNca&}*^ zA11GYhuU_jsHYBxVCMvx9?8##_D_EP^TJ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7u-35M;QN| z@kz$L5L8JR4+V4Atc;%;6@MJB z1haTZHi0S<%i5ttt;#dctF%hOHYqz}Ij{EZeKWbMg8=ZhVaX>z@2kk&@Z#rdntM79 zrzCAhohU7?PNfIrWd<2M`aVYQ8dxzNEDR|k=OO>yiOUp#w!G$K(j`tcA@fZDn250jm0Ny-N8O^O>#(uGkZ0cKf=FrEdaniO!r85pjoVdwl z!Lc18#BD}TWGqlEW;HrQ(NQ;HRETzLYb+9JR6A3z9c4S3x2!0e&%HR_DDHY=lS+I1 jY~;i(O;(;pD allUsersNotSharing (final User user, final Addressbook addressbook) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: user={0},addressbook={1} - CALLED!", user, addressbook)); //NOI18N + + // Test parameter + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N + } else if (null == addressbook) { + // Again NPE + throw new NullPointerException("addressbook is null"); //NOI18N + } else if (addressbook.getAddressbookId() == null) { + // Again NPE + throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N + } else if (addressbook.getAddressbookId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("addressbook.getAddressbookId={0} is invalid", addressbook.getAddressbookId())); //NOI18N + } + + // Get named query for a user list without given user + Query allUsersExceptQuery = this.getEntityManager().createNamedQuery("SearchAllUsersExcept", List.class); + + // Set parameter + allUsersExceptQuery.setParameter("user", user); + + // Get full list + List allUsersExcept = allUsersExceptQuery.getResultList(); + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allUsersExcept.size()={0}", allUsersExcept.size())); + + // Now get all users this user is sharing with, first a new query + Query allShareesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); + + // Set parameter + allShareesQuery.setParameter("user", user); + + // Get full list again + List allSharees = allShareesQuery.getResultList(); + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allSharees.size()={0}", allSharees.size())); + + // Init final user list + List userList = new ArrayList<>(0); + + // Walk through all users + for (final User u : allUsersExcept) { + // Log message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: u={0}", u)); + + // Is this user not included? + if (!allSharees.contains(u)) { + // Found one to add! + // Log message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: u={0} - ADDING!", u)); + + // Add it + userList.add(u); + } + } + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: userList.size()={0} - EXIT!", userList.size())); + + // Return it + return userList; + } + @Override @SuppressWarnings ("unchecked") public Integer countAllUserSharedAddressbooks (final User user) { @@ -161,7 +239,7 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb @Override @SuppressWarnings ("unchecked") - public List getUsersList (final User loggedInUser) { + public List getUsersAddressbookList (final User loggedInUser) { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); //NOI18N -- 2.39.5