From: Roland Haeder Date: Fri, 16 Oct 2015 13:20:02 +0000 (+0200) Subject: opps, that was a ClassCastException, that came from confusion ... :-( X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0e1977337064d07b5d75a4a98a120918e800d879;p=addressbook-ejb.git opps, that was a ClassCastException, that came from confusion ... :-( Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java index 4d2869d..15c6a3e 100644 --- a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java +++ b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java @@ -96,52 +96,33 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb // Debug message this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allUsersExcept.size()={0}", allUsersExcept.size())); //NOI18N - // Now get all users this user is sharing with, first a new query - Query allShareesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N + // Now get all shares this user has created + Query allSharesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N // Set parameter - allShareesQuery.setParameter("user", user); //NOI18N + allSharesQuery.setParameter("user", user); //NOI18N // Get full list again - List allSharees = allShareesQuery.getResultList(); + List allShares = allSharesQuery.getResultList(); // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allSharees.size()={0}", allSharees.size())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N // Init final user list List userList = new LinkedList<>(); // Walk through all users - for (final User u : allUsersExcept) { + for (final ShareableAddressbook share : allShares) { // Log message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: u={0}", u)); //NOI18N - - // Some entries in allSharees? - if (!allSharees.isEmpty()) { - // Default is not found - boolean isFound = false; - - // Check all entries (user name matching) - for (final User sharee : allSharees) { - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: sharee={0}", sharee)); - - // Does it match? - if (sharee.equals(u)) { - // Skip this one - isFound = true; - break; - } - } - - // Still not found? - if (!isFound) { - // Found one to add - this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: u={0} - ADDING!", u)); //NOI18N - - // Add it - userList.add(u); - } + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N + + // Does the list contain it ? + if (!allUsersExcept.contains(share.getShareUserSharee())) { + // Found one to add + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0} - ADDING!", share.getShareUserSharee())); //NOI18N + + // Add it + userList.add(share.getShareUserSharee()); } }