// 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());
}
}