]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
opps, that was a ClassCastException, that came from confusion ... :-(
authorRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 13:20:02 +0000 (15:20 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 16 Oct 2015 13:20:02 +0000 (15:20 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java

index 4d2869dcdb39e1ce82edafcb4af18f8ffcab63cf..15c6a3e36fe2f8d6ac698eaf95fa6dc64cfb3084 100644 (file)
@@ -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<User> allSharees = allShareesQuery.getResultList();
+               List<ShareableAddressbook> 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<User> 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());
                        }
                }