]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
removed sharing stuff (only in addressbook project) + renamed beans
authorRoland Haeder <roland@mxchange.org>
Wed, 2 Mar 2016 20:37:47 +0000 (21:37 +0100)
committerRoland Haeder <roland@mxchange.org>
Wed, 2 Mar 2016 20:37:47 +0000 (21:37 +0100)
src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java
src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java
src/java/org/mxchange/jphone/phonenumbers/smsprovider/AddressbookSmsProviderSingletonBean.java

index 55aaafd72860d3b8a80c4e0190f2c61d19729b94..93b1c8bc4ad880907a0e5b5e324f79f15fbe6c64 100644 (file)
@@ -38,7 +38,7 @@ import org.mxchange.jusercore.model.user.User;
  * <p>
  * @author Roland Haeder
  */
-@Stateless (name = "addressbook", mappedName = "ejb/stateless-addressbook", description = "A stateless bean for handling addressbooks")
+@Stateless (name = "jjobs-adr", mappedName = "ejb/stateless-jjobs-addressbook", description = "A stateless bean for handling JJobs addressbooks")
 public class AddressbookSessionBean extends BaseDatabaseBean implements AddressbookSessionBeanRemote {
 
        /**
@@ -84,143 +84,6 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb
                return query.getResultList();
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<User> 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); //NOI18N
-
-               // Set parameter
-               allUsersExceptQuery.setParameter("user", user); //NOI18N
-
-               // Get full list
-               List<User> allUsersExcept = allUsersExceptQuery.getResultList();
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allUsersExcept.size()={0}", allUsersExcept.size())); //NOI18N
-
-               // Now get all shares this user has created
-               Query allSharesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
-
-               // Set parameter
-               allSharesQuery.setParameter("user", user); //NOI18N
-
-               // Get full list again
-               List<ShareableAddressbook> allShares = allSharesQuery.getResultList();
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N
-
-               // List for users aharing with given
-               List<User> sharingUsers = new ArrayList<>(allShares.size());
-
-               // Check all entries
-               for (final ShareableAddressbook share : allShares) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N
-
-                       // Add it
-                       sharingUsers.add(share.getShareUserSharee());
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: sharingUsers.size()={0}", sharingUsers.size())); //NOI18N
-
-               // Init final user list
-               List<User> userList = new LinkedList<>();
-
-               // Walk through all users
-               for (final User foundUser : allUsersExcept) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0}", foundUser)); //NOI18N
-
-                       // Does the list contain it ?
-                       if (!sharingUsers.contains(foundUser)) {
-                               // Found one to add
-                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0} - ADDING!", foundUser)); //NOI18N
-
-                               // Add it
-                               userList.add(foundUser);
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: userList.size()={0} - EXIT!", userList.size())); //NOI18N
-
-               // Return it
-               return userList;
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public Integer countAllUserSharedAddressbooks (final User user) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: user={0} - CALLED!", user)); //NOI18N
-
-               // user should be valid
-               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
-               }
-
-               // Get named query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("user", user); //NOI18N
-
-               // Default is zero
-               Integer count = 0;
-
-               // Try it
-               try {
-                       // Get whole list
-                       List<ShareableAddressbook> dummy = query.getResultList();
-
-                       // Set size
-                       count = dummy.size();
-               } catch (final NoResultException ex) {
-                       // Need to catch this, so log it
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("countAllUserSharedAddressbooks: getResultList() failed: {0}", ex)); //NOI18N
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: count={0} - EXIT!", count)); //NOI18N
-
-               // Return count
-               return count;
-       }
-
        @Override
        public Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException {
                // Is it not null?
index da3e44a624689e56ba7fb41ec646c74483d932c9..f8314bf6799ae8396b62096059a95ad53fb387a0 100644 (file)
@@ -28,7 +28,7 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
  * @author Roland Haeder
  */
 @Startup
-@Singleton (name = "country", mappedName = "ejb/addressbook-singleton-country", description = "A singleton session bean for country informations")
+@Singleton (name = "country", mappedName = "ejb/jjobs-singleton-country", description = "A singleton session bean for country informations")
 public class AddressbookCountrySingletonBean extends BaseDatabaseBean implements AddressbookCountrySingletonBeanRemote {
 
        /**
index 3f348d2e62c380aafbe0082537e3b1b30cd1f2fa..ffc60e9309434818fbc72bdbbf0303cbd9d95c0c 100644 (file)
@@ -28,7 +28,7 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
  * @author Roland Haeder
  */
 @Startup
-@Singleton (name = "smsprovider", mappedName = "ejb/addressbook-singleton-smsprovider", description = "A singleton session bean for SMS provider informations")
+@Singleton (name = "smsprovider", mappedName = "ejb/jjobs-singleton-smsprovider", description = "A singleton session bean for SMS provider informations")
 public class AddressbookSmsProviderSingletonBean extends BaseDatabaseBean implements AddressbookSmsProviderSingletonBeanRemote {
 
        /**