]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 17 Oct 2017 20:30:29 +0000 (22:30 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 1 Feb 2020 03:14:01 +0000 (04:14 +0100)
- renamed employee as there will be no other employees
- added administrative country EJB due to remote interface separation
- removed find*ById() as this was causing load on EJB container which can be
  prevented by application's JCache
- fixed persistence unit as entities have been moved

Signed-off-by: Roland Häder <roland@mxchange.org>
20 files changed:
src/conf/persistence.xml
src/java/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java
src/java/org/mxchange/jcontacts/model/contact/AddressbookContactSessionBean.java
src/java/org/mxchange/jcontacts/model/phone/AddressbookAdminContactPhoneSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/basicdata/AddressbookAdminBusinessDataSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/basicdata/AddressbookBusinessDataSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/AddressbookAdminBranchOfficeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/AddressbookBranchOfficeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/department/AddressbookAdminDepartmentSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/department/AddressbookDepartmentSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookCompanyEmployeeSessionBean.java [deleted file]
src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookOpeningTimesSessionBean.java
src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java [new file with mode: 0644]
src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/AddressbookAdminMobileProviderSessionBean.java
src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookPhoneSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java

index 274981feaace376a2ee4ba250a0992e537051ae0..60be98df4895fd4aa87ffefacc355ce1700ee21c 100644 (file)
@@ -6,10 +6,10 @@
     <class>org.mxchange.jaddressbook.model.addressbook.entry.UserAddressbookEntry</class>
     <class>org.mxchange.jaddressbookshare.model.addressbook.shared.AddressbookShare</class>
     <class>org.mxchange.jcontacts.model.contact.UserContact</class>
-    <class>org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData</class>
-    <class>org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice</class>
-    <class>org.mxchange.jcontactsbusiness.model.department.CompanyDepartment</class>
-    <class>org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee</class>
+    <class>org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData</class>
+    <class>org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice</class>
+    <class>org.mxchange.jcontactsbusiness.model.department.BusinessDepartment</class>
+    <class>org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee</class>
     <class>org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersData</class>
     <class>org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition</class>
     <class>org.mxchange.jcontactsbusiness.model.logo.CompanyLogo</class>
index 678220cc96290c7bc8945ff19fa66ecd9222f808..0a4fa963dd5e337f3b432414c17fdd052ea5ca94 100644 (file)
@@ -31,11 +31,9 @@ import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactUtils;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployee;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee;
 import org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersData;
 import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
@@ -54,6 +52,8 @@ import org.mxchange.jphone.utils.PhoneUtils;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 
 /**
  * A helper class for beans that access the database.
@@ -372,7 +372,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed basic data instance
         */
-       protected BusinessBasicData createManaged (final BusinessBasicData basicData) {
+       protected BasicData createManaged (final BasicData basicData) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
 
@@ -389,10 +389,10 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Try to find it (should be there)
-               final BusinessBasicData managedBasicData = this.getEntityManager().find(CompanyBasicData.class, basicData.getBasicDataId());
+               final BasicData managedBasicData = this.getEntityManager().find(BusinessBasicData.class, basicData.getBasicDataId());
 
                // Should be there
-               assert (managedBasicData instanceof BusinessBasicData) : "managedBasicData is null"; //NOI18N
+               assert (managedBasicData instanceof BasicData) : "managedBasicData is null"; //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBasicData={1} - EXIT!", this.getClass().getSimpleName(), managedBasicData)); //NOI18N
@@ -425,10 +425,10 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Try to find it (should be there)
-               final BranchOffice managedBranchOffice = this.getEntityManager().find(CompanyBranchOffice.class, branchOffice.getBranchId());
+               final BranchOffice managedBranchOffice = this.getEntityManager().find(BusinessBranchOffice.class, branchOffice.getBranchId());
 
                // Should be there
-               assert (managedBranchOffice instanceof BusinessBasicData) : "managedBranchOffice is null"; //NOI18N
+               assert (managedBranchOffice instanceof BasicData) : "managedBranchOffice is null"; //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedBranchOffice={1} - EXIT!", this.getClass().getSimpleName(), managedBranchOffice)); //NOI18N
@@ -444,7 +444,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @return Managed employee instance
         */
-       protected Employee createManaged (final Employee employee) {
+       protected Employable createManaged (final Employable employee) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: employee={1} - CALLED!", this.getClass().getSimpleName(), employee)); //NOI18N
 
@@ -461,10 +461,10 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                }
 
                // Try to find it (should be there)
-               final Employee managedEmployee = this.getEntityManager().find(CompanyEmployee.class, employee.getEmployeeId());
+               final Employable managedEmployee = this.getEntityManager().find(BusinessEmployee.class, employee.getEmployeeId());
 
                // Should be there
-               assert (managedEmployee instanceof Employee) : "managedEmployee is null"; //NOI18N
+               assert (managedEmployee instanceof Employable) : "managedEmployee is null"; //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedEmployee={1} - EXIT!", this.getClass().getSimpleName(), managedEmployee)); //NOI18N
@@ -500,7 +500,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                final HeadquartersData managedHeadquarters = this.getEntityManager().find(CompanyHeadquartersData.class, headquarters.getHeadquartersId());
 
                // Should be there
-               assert (managedHeadquarters instanceof BusinessBasicData) : "managedHeadquarters is null"; //NOI18N
+               assert (managedHeadquarters instanceof BasicData) : "managedHeadquarters is null"; //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedHeadquarters={1} - EXIT!", this.getClass().getSimpleName(), managedHeadquarters)); //NOI18N
@@ -695,7 +695,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
         * <p>
         * @param basicData Company basic data instance to update
         */
-       protected void setAllPhoneEntriesCreated (final BusinessBasicData basicData) {
+       protected void setAllPhoneEntriesCreated (final BasicData basicData) {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("setAllPhoneEntriesCreated: basicData={0} - CALLED!", basicData)); //NOI18N
 
index 4092193b8cd25f5c38c8073dbf17351d2f0820ba..6c3eccfbf837ad78e783d06a432ae359c67ed2ff 100644 (file)
@@ -85,92 +85,6 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                return emailAddresses;
        }
 
-       @Override
-       public Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
-
-               // The parameter must be valid
-               if (null == emailAddress) {
-                       // Throw NPE
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
-                       // Not valid
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               }
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
-
-               // Set parameter and limit
-               query.setParameter("emailAddress", emailAddress); //NOI18N
-               query.setMaxResults(1);
-
-               // Init contact instance
-               final Contact contact;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       contact = (Contact) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new ContactNotFoundException(emailAddress, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Return found instance
-               return contact;
-       }
-
-       @Override
-       public Contact findContactById (final Long contactId) throws ContactNotFoundException {
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contactId={1} - CALLED!", this.getClass().getSimpleName(), contactId)); //NOI18N
-
-               // The parameter must be valid
-               if (null == contactId) {
-                       // Throw NPE
-                       throw new NullPointerException("contactId is null"); //NOI18N
-               } else if (contactId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N
-               }
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("contactId", contactId); //NOI18N
-               query.setMaxResults(1);
-
-               // Init contact instance
-               final Contact contact;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       contact = (Contact) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new ContactNotFoundException(contactId, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
-
-               // Return found instance
-               return contact;
-       }
-
        @Override
        public boolean isEmailAddressRegistered (final String emailAddress) {
                // Log trace message
@@ -328,4 +242,106 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                return detachedContact;
        }
 
+       /**
+        * Returns a contact instance which has the given email address.
+        * <p>
+        * @param emailAddress Email address
+        * <p>
+        * @return Contact instance
+        * <p>
+        * @throws ContactNotFoundException If the contact was not found
+        */
+       private Contact findContactByEmailAddress (final String emailAddress) throws ContactNotFoundException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: emailAddress={1} - CALLED!", this.getClass().getSimpleName(), emailAddress)); //NOI18N
+
+               // The parameter must be valid
+               if (null == emailAddress) {
+                       // Throw NPE
+                       throw new NullPointerException("emailAddress is null"); //NOI18N
+               } else if (emailAddress.isEmpty()) {
+                       // Not valid
+                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+               }
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactByEmailAddress", UserContact.class); //NOI18N
+
+               // Set parameter and limit
+               query.setParameter("emailAddress", emailAddress); //NOI18N
+               query.setMaxResults(1);
+
+               // Init contact instance
+               final Contact contact;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       contact = (Contact) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new ContactNotFoundException(emailAddress, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactByEmailAddress: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Return found instance
+               return contact;
+       }
+
+       /**
+        * Returns a contact instance which has the given id number.
+        * <p>
+        * @param contactId Contact id
+        * <p>
+        * @return Contact instance
+        * <p>
+        * @throws ContactNotFoundException If the contact was not found
+        */
+       private Contact findContactById (final Long contactId) throws ContactNotFoundException {
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contactId={1} - CALLED!", this.getClass().getSimpleName(), contactId)); //NOI18N
+
+               // The parameter must be valid
+               if (null == contactId) {
+                       // Throw NPE
+                       throw new NullPointerException("contactId is null"); //NOI18N
+               } else if (contactId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N
+               }
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchContactById", UserContact.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("contactId", contactId); //NOI18N
+               query.setMaxResults(1);
+
+               // Init contact instance
+               final Contact contact;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       contact = (Contact) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: Found contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new ContactNotFoundException(contactId, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findContactById: contact={1} - EXIT!", this.getClass().getSimpleName(), contact)); //NOI18N
+
+               // Return found instance
+               return contact;
+       }
+
 }
index 22ccf47f2bffe0fa5551193afa8386702627bfd7..b93841eb86da1d3f783eec135f181d3d92b50b71 100644 (file)
@@ -24,8 +24,8 @@ import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
-import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
-import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
+import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException;
+import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
index 8be82ff83c5b1eaf72d251b9dc96e39178a0393d..4e2d5e261f5eaaadb92305b51256d942acaabbe0 100644 (file)
@@ -23,9 +23,9 @@ import java.util.Objects;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataAlreadyAddedException;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
 
 /**
  * An administrative stateless session bean for business data
@@ -55,7 +55,7 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
        }
 
        @Override
-       public BusinessBasicData addCompanyBasicData (final BusinessBasicData basicData) throws BasicCompanyDataAlreadyAddedException {
+       public BasicData addBusinessBasicData (final BasicData basicData) throws BasicDataAlreadyAddedException {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addBusinessBasicData: basicData={1} - CALLED!", this.getClass().getSimpleName(), basicData)); //NOI18N
 
@@ -68,7 +68,7 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
                        throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} - is not null", basicData.getBasicDataId())); //NOI18N
                } else if (this.isSameCompanyNameAdded(basicData)) {
                        // Throw exception
-                       throw new BasicCompanyDataAlreadyAddedException(basicData);
+                       throw new BasicDataAlreadyAddedException(basicData);
                }
 
                // Now add current date
@@ -84,18 +84,18 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
                }
 
                // Is a founder set?
-               if (basicData.getCompanyFounder() instanceof Employee) {
+               if (basicData.getCompanyFounder() instanceof Employable) {
                        // Get managed instance
-                       final Employee managedEmployee = this.createManaged(basicData.getCompanyFounder());
+                       final Employable managedEmployee = this.createManaged(basicData.getCompanyFounder());
 
                        // Set it back
                        basicData.setCompanyFounder(managedEmployee);
                }
 
                // Is a contact person set?
-               if (basicData.getCompanyContactEmployee() instanceof Employee) {
+               if (basicData.getCompanyContactEmployee() instanceof Employable) {
                        // Get managed instance
-                       final Employee managedEmployee = this.createManaged(basicData.getCompanyContactEmployee());
+                       final Employable managedEmployee = this.createManaged(basicData.getCompanyContactEmployee());
 
                        // Set it back
                        basicData.setCompanyContactEmployee(managedEmployee);
@@ -121,15 +121,15 @@ public class AddressbookAdminBusinessDataSessionBean extends BaseAddressbookData
         *
         * @return Whether same company name has been used
         */
-       private boolean isSameCompanyNameAdded (final BusinessBasicData basicData) {
+       private boolean isSameCompanyNameAdded (final BasicData basicData) {
                // Get all available entries
-               final List<BusinessBasicData> list = this.businessDataBean.allCompanyBasicData();
+               final List<BasicData> list = this.businessDataBean.allBusinessBasicData();
 
                // Default is not found
                boolean isFound = false;
 
                // Then check each entry
-               for (final BusinessBasicData entry : list) {
+               for (final BasicData entry : list) {
                        // Is the company name matching?
                        if (Objects.equals(entry.getCompanyName(), basicData.getCompanyName())) {
                                // Found match
index 5f29a8551da14f1c7a8a07f7b3418f63f08b038f..2be6f91f41f4ef56f351bae697cbf5a7885453b1 100644 (file)
@@ -18,12 +18,9 @@ package org.mxchange.jcontactsbusiness.model.basicdata;
 
 import java.text.MessageFormat;
 import java.util.List;
-import java.util.Objects;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException;
 
 /**
  * A stateless session bean for business data
@@ -48,7 +45,7 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
 
        @Override
        @SuppressWarnings ("unchecked")
-       public List<BusinessBasicData> allCompanyBasicData () {
+       public List<BasicData> allBusinessBasicData () {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
@@ -56,7 +53,7 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
                final Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
 
                // Get list from it
-               final List<BusinessBasicData> list = query.getResultList();
+               final List<BasicData> list = query.getResultList();
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
@@ -65,85 +62,4 @@ public class AddressbookBusinessDataSessionBean extends BaseAddressbookDatabaseB
                return list;
        }
 
-       @Override
-       public BusinessBasicData findBasicDataById (final Long basicDataId) throws BasicCompanyDataNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Validate parameter
-               if (null == basicDataId) {
-                       // Throw NPE
-                       throw new NullPointerException("basicDataId is null"); //NOI18N
-               } else if (basicDataId < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("basicDataId={0}is invalid", basicDataId)); //NOI18N
-               }
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("basicDataId", basicDataId); //NOI18N
-
-               // Get single instance
-               final BusinessBasicData basicData;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       basicData = (BusinessBasicData) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: Found basicData={1}", this.getClass().getSimpleName(), basicData)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new BasicCompanyDataNotFoundException(basicDataId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: basicData={1} - EXIT!", this.getClass().getSimpleName(), basicData)); //NOI18N
-
-               // Return it
-               return basicData;
-       }
-
-       @Override
-       public Boolean isCompanyNameUsed (final String companyName) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: companyName={1} - CALLED!", this.getClass().getSimpleName(), companyName)); //NOI18N
-
-               // Is the parameter valid?
-               if (null == companyName) {
-                       // Throw NPE
-                       throw new NullPointerException("companyName is null"); //NOI18N
-               } else if (companyName.isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("companyName is empty"); //NOI18N
-               }
-
-               // Default is not found
-               Boolean isCompanyNameUsed = Boolean.FALSE;
-
-               // Get whole list
-               final List<BusinessBasicData> list = this.allCompanyBasicData();
-
-               // Check whole list
-               for (final BusinessBasicData basicData : list) {
-                       // Is name used?
-                       if (Objects.equals(basicData.getCompanyName(), companyName)) {
-                               // Found one
-                               isCompanyNameUsed = Boolean.TRUE;
-
-                               // Abort search
-                               break;
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: isCompanyNameUsed={1} - EXIT!", this.getClass().getSimpleName(), isCompanyNameUsed)); //NOI18N
-
-               // Return it
-               return isCompanyNameUsed;
-       }
-
 }
index 95d5961e22285240393f703e247f04f20a585e23..2a6c8c19fcf2bd2731596ca63f52a8218c45f12b 100644 (file)
@@ -23,10 +23,10 @@ import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
-import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 import org.mxchange.jcountry.model.data.Country;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 
 /**
  * A stateless session bean for administrative branch office purposes
@@ -76,9 +76,9 @@ public class AddressbookAdminBranchOfficeSessionBean extends BaseAddressbookData
                branchOffice.setBranchCreated(new Date());
 
                // Is user instance set?
-               if (branchOffice.getBranchCompany() instanceof BusinessBasicData) {
+               if (branchOffice.getBranchCompany() instanceof BasicData) {
                        // Get managed instance back
-                       final BusinessBasicData managedBasicData = this.createManaged(branchOffice.getBranchCompany());
+                       final BasicData managedBasicData = this.createManaged(branchOffice.getBranchCompany());
 
                        // Set it back in branch office
                        branchOffice.setBranchCompany(managedBasicData);
index 4f4621c2da7d0a74952e2aa5f029a719804376ff..c09b8be2d69c1b8a356dd02f61c5932dc2527289 100644 (file)
@@ -19,10 +19,8 @@ package org.mxchange.jcontactsbusiness.model.branchoffice;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException;
 
 /**
  * A stateless session bean for general branch office purposes
@@ -56,46 +54,4 @@ public class AddressbookBranchOfficeSessionBean extends BaseAddressbookDatabaseB
                return list;
        }
 
-       @Override
-       public BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Validate parameter
-               if (null == branchOfficeId) {
-                       // Throw NPE
-                       throw new NullPointerException("branchOfficeId is null"); //NOI18N
-               } else if (branchOfficeId < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("branchOfficeId={0}is invalid", branchOfficeId)); //NOI18N
-               }
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchBranchOfficeById", CompanyBranchOffice.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("branchOfficeId", branchOfficeId); //NOI18N
-
-               // Get single instance
-               final BranchOffice branchOffice;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       branchOffice = (BranchOffice) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: Found branchOffice={1}", this.getClass().getSimpleName(), branchOffice)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new BranchOfficeNotFoundException(branchOfficeId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: branchOffice={1} - EXIT!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
-
-               // Return it
-               return branchOffice;
-       }
-
 }
index 03b74b70aee5f9134724003fdbf09bb79a2884c8..34a2ca0f29d00c24d4631f06996c5131123dfad6 100644 (file)
@@ -22,12 +22,12 @@ import java.util.List;
 import javax.ejb.EJB;
 import javax.ejb.Stateless;
 import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException;
-import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.Employee;
 import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
 
 /**
  * A stateless session bean for administrative department purposes
@@ -92,7 +92,7 @@ public class AddressbookAdminDepartmentSessionBean extends BaseAddressbookDataba
                department.setDepartmentCreated(new Date());
 
                // Get managed basic data instance
-               final BusinessBasicData managedBasicData = this.createManaged(department.getDepartmentCompany());
+               final BasicData managedBasicData = this.createManaged(department.getDepartmentCompany());
 
                // Set it back
                department.setDepartmentCompany(managedBasicData);
@@ -116,9 +116,9 @@ public class AddressbookAdminDepartmentSessionBean extends BaseAddressbookDataba
                }
 
                // Is lead employee set?
-               if (department.getDepartmentLead()instanceof Employee) {
+               if (department.getDepartmentLead()instanceof Employable) {
                        // Get managed lead employee
-                       final Employee managedEmployee = this.createManaged(department.getDepartmentLead());
+                       final Employable managedEmployee = this.createManaged(department.getDepartmentLead());
 
                        // Set it back
                        department.setDepartmentLead(managedEmployee);
index 452aeec2665dd8556b074a478af021daf2b70919..24c3f1bc616822814f49537a9c6fe5ddccf30e9e 100644 (file)
@@ -19,9 +19,7 @@ package org.mxchange.jcontactsbusiness.model.department;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 
 /**
@@ -56,46 +54,4 @@ public class AddressbookDepartmentSessionBean extends BaseAddressbookDatabaseBea
                return list;
        }
 
-       @Override
-       public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Validate parameter
-               if (null == departmentId) {
-                       // Throw NPE
-                       throw new NullPointerException("departmentId is null"); //NOI18N
-               } else if (departmentId < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
-               }
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchDepartmentById", CompanyDepartment.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("departmentId", departmentId); //NOI18N
-
-               // Get single instance
-               final Department department;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       department = (Department) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new DepartmentNotFoundException(departmentId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
-               // Return it
-               return department;
-       }
-
 }
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index 11cb56f..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.employee;
-
-import javax.ejb.Stateless;
-import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-
-/**
- * A stateless bean for administrative purposes for company employees.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "adminEmployee", description = "An administrative statless bean for handling company employees")
-public class AddressbookAdminCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookAdminCompanyEmployeeSessionBean () {
-               super();
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..b7e06d5
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.employee;
+
+import javax.ejb.Stateless;
+import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+
+/**
+ * A stateless bean for administrative purposes for company employees.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminEmployee", description = "An administrative statless bean for handling company employees")
+public class AddressbookAdminCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookAdminCompanyEmployeeSessionBean () {
+               super();
+       }
+
+}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookCompanyEmployeeSessionBean.java
deleted file mode 100644 (file)
index f6dbe38..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.employee;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
-
-/**
- * A stateless bean for general purposes for company employees.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "employee", description = "A general statless bean for handling company employees")
-public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements CompanyEmployeeSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 26_458_796_703_761L;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookCompanyEmployeeSessionBean () {
-               super();
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Employee> allCompanyEmployees () {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Get named query
-               final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
-
-               // Get list form it
-               final List<Employee> employees = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
-
-               // Return it
-               return employees;
-       }
-
-       @Override
-       public Employee findCompanyEmployeeById (final Long employeeId) throws CompanyEmployeeNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById(): employeeId={1} - CALLED!", this.getClass().getSimpleName(), employeeId)); //NOI18N
-
-               // Is the employee id valid?
-               if (null == employeeId) {
-                       // Throw NPE
-                       throw new NullPointerException("employeeId is null"); //NOI18N
-               } else if (employeeId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is not valid", employeeId)); //NOI18N
-               }
-
-               // Now get named query
-               final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
-
-               // Set parameter
-               query.setParameter("employeeId", employeeId); //NOI18N
-
-               // Declare instance
-               final Employee employee;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       employee = (Employee) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: Found employee={1}", this.getClass().getSimpleName(), employee)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new CompanyEmployeeNotFoundException(employeeId, ex);
-               }
-
-               // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: employee={1} - EXIT!", this.getClass().getSimpleName(), employee)); //NOI18N
-
-               // Return found instance
-               return employee;
-       }
-
-}
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java
new file mode 100644 (file)
index 0000000..a4c51b2
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.employee;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException;
+import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+
+/**
+ * A stateless bean for general purposes for company employees.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "employee", description = "A general statless bean for handling company employees")
+public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements CompanyEmployeeSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 26_458_796_703_761L;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookCompanyEmployeeSessionBean () {
+               super();
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<Employee> allCompanyEmployees () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get named query
+               final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N
+
+               // Get list form it
+               final List<Employee> employees = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
+
+               // Return it
+               return employees;
+       }
+
+       @Override
+       public Employee findCompanyEmployeeById (final Long employeeId) throws CompanyEmployeeNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById(): employeeId={1} - CALLED!", this.getClass().getSimpleName(), employeeId)); //NOI18N
+
+               // Is the employee id valid?
+               if (null == employeeId) {
+                       // Throw NPE
+                       throw new NullPointerException("employeeId is null"); //NOI18N
+               } else if (employeeId < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is not valid", employeeId)); //NOI18N
+               }
+
+               // Now get named query
+               final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N
+
+               // Set parameter
+               query.setParameter("employeeId", employeeId); //NOI18N
+
+               // Declare instance
+               final Employee employee;
+
+               // Try to find a result
+               try {
+                       // Find a single result
+                       employee = (Employee) query.getSingleResult();
+
+                       // Log trace message
+                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: Found employee={1}", this.getClass().getSimpleName(), employee)); //NOI18N
+               } catch (final NoResultException ex) {
+                       // No result found
+                       throw new CompanyEmployeeNotFoundException(employeeId, ex);
+               }
+
+               // Log trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: employee={1} - EXIT!", this.getClass().getSimpleName(), employee)); //NOI18N
+
+               // Return found instance
+               return employee;
+       }
+
+}
index b7d041feca243a90afd6ef5c76b9227552f40947..3cae36d1012e29d5f09f531b57a775468ae9395c 100644 (file)
@@ -19,9 +19,7 @@ package org.mxchange.jcontactsbusiness.model.opening_time;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 
 /**
@@ -56,46 +54,4 @@ public class AddressbookOpeningTimesSessionBean extends BaseAddressbookDatabaseB
                return list;
        }
 
-       @Override
-       public OpeningTime findOpeningTimesById (final Long departmentId) throws OpeningTimeNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Validate parameter
-               if (null == departmentId) {
-                       // Throw NPE
-                       throw new NullPointerException("departmentId is null"); //NOI18N
-               } else if (departmentId < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
-               }
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchOpeningTimesById", BusinessOpeningTime.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("departmentId", departmentId); //NOI18N
-
-               // Get single instance
-               final OpeningTime department;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       department = (OpeningTime) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new OpeningTimeNotFoundException(departmentId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findOpeningTimesById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
-               // Return it
-               return department;
-       }
-
 }
diff --git a/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java
new file mode 100644 (file)
index 0000000..ed21d59
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2016, 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+package org.mxchange.jcountry.model.data;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
+
+/**
+ * A stateless EJB for administrative country purposes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "adminCountry", description = "A stateless session-scoped bean for administrative country purposes")
+public class AddressbookAdminCountrySingletonBean extends BaseAddressbookDatabaseBean implements AdminCountrySessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 15_846_983_298_691_208L;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookAdminCountrySingletonBean () {
+               // Call super constructor
+               super();
+       }
+
+       @Override
+       public Country addCountry (final Country country) throws CountryAlreadyAddedException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
+
+               // Is it already there?
+               if (null == country) {
+                       // Throw NPE
+                       throw new NullPointerException("country is null"); //NOI18N
+               } else if (country.getCountryCode().isEmpty()) {
+                       // Code is not set
+                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
+               } else if (country.getCountryI18nKey().isEmpty()) {
+                       // I18n key is not set
+                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
+               } else if (country.getCountryId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
+               } else if (this.isCountryAdded(country)) {
+                       // Yes, then abort here
+                       throw new CountryAlreadyAddedException(country);
+               }
+
+               // Add timestamp
+               country.setCountryEntryCreated(new Date());
+
+               // It is not added, so persist it
+               this.getEntityManager().persist(country);
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N
+
+               // Return updated instance
+               return country;
+       }
+
+       /**
+        * Checks whether given country is already added by i18n key or country
+        * code, what comes first.
+        * <p>
+        * @param country Country instance to check
+        * <p>
+        * @return Whether the country was found
+        */
+       private boolean isCountryAdded (final Country country) {
+               if (null == country) {
+                       // Throw NPE
+                       throw new NullPointerException("country is null"); //NOI18N
+               } else if (country.getCountryCode().isEmpty()) {
+                       // Code is not set
+                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
+               } else if (country.getCountryI18nKey().isEmpty()) {
+                       // I18n key is not set
+                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
+               } else if (country.getCountryId() != null) {
+                       // Should be null
+                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
+               }
+
+               // Default is not found
+               boolean isAdded = false;
+
+               // Get query instance
+               final Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
+
+               // Assign all parameters
+               query.setParameter("code", country.getCountryCode()); //NOI18N
+               query.setParameter("key", country.getCountryI18nKey()); //NOI18N
+
+               // Try to get a single result
+               try {
+                       // Get single result
+                       final Country foundCountry = (Country) query.getSingleResult();
+
+                       // Found it?
+                       isAdded = (foundCountry instanceof Country);
+               } catch (final NoResultException ex) {
+                       // Not found, don't log this
+               }
+
+               // Return result
+               return isAdded;
+       }
+
+}
index 621c2c1b47b4033f24a09f6583efa82d1336737b..148f82858c2b1f458fe9de122362bff3d63e92d5 100644 (file)
 package org.mxchange.jcountry.model.data;
 
 import java.text.MessageFormat;
-import java.util.Date;
 import java.util.List;
 import javax.ejb.Singleton;
 import javax.ejb.Startup;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
 
 /**
  * A singleton EJB for country informations
@@ -48,42 +45,6 @@ public class AddressbookCountrySingletonBean extends BaseAddressbookDatabaseBean
                super();
        }
 
-       @Override
-       public Country addCountry (final Country country) throws CountryAlreadyAddedException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - CALLED!", this.getClass().getSimpleName(), country)); //NOI18N
-
-               // Is it already there?
-               if (null == country) {
-                       // Throw NPE
-                       throw new NullPointerException("country is null"); //NOI18N
-               } else if (country.getCountryCode().isEmpty()) {
-                       // Code is not set
-                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
-               } else if (country.getCountryI18nKey().isEmpty()) {
-                       // I18n key is not set
-                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
-               } else if (country.getCountryId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
-               } else if (this.isCountryAdded(country)) {
-                       // Yes, then abort here
-                       throw new CountryAlreadyAddedException(country);
-               }
-
-               // Add timestamp
-               country.setCountryEntryCreated(new Date());
-
-               // It is not added, so persist it
-               this.getEntityManager().persist(country);
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addCountry: country={1} - EXIT!", this.getClass().getSimpleName(), country)); //NOI18N
-
-               // Return updated instance
-               return country;
-       }
-
        @Override
        @SuppressWarnings ("unchecked")
        public List<Country> allCountries () {
@@ -103,52 +64,4 @@ public class AddressbookCountrySingletonBean extends BaseAddressbookDatabaseBean
                return countries;
        }
 
-       /**
-        * Checks whether given country is already added by i18n key or country
-        * code, what comes first.
-        * <p>
-        * @param country Country instance to check
-        * <p>
-        * @return Whether the country was found
-        */
-       private boolean isCountryAdded (final Country country) {
-               if (null == country) {
-                       // Throw NPE
-                       throw new NullPointerException("country is null"); //NOI18N
-               } else if (country.getCountryCode().isEmpty()) {
-                       // Code is not set
-                       throw new IllegalArgumentException("country.countryCode is empty"); //NOI18N
-               } else if (country.getCountryI18nKey().isEmpty()) {
-                       // I18n key is not set
-                       throw new IllegalArgumentException("country.countryI18nKey is empty"); //NOI18N
-               } else if (country.getCountryId() != null) {
-                       // Should be null
-                       throw new IllegalArgumentException(MessageFormat.format("country.countryId is not null ({0})", country.getCountryId())); //NOI18N
-               }
-
-               // Default is not found
-               boolean isAdded = false;
-
-               // Get query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchCountryByCodeI18nKey", CountryData.class); //NOI18N
-
-               // Assign all parameters
-               query.setParameter("code", country.getCountryCode()); //NOI18N
-               query.setParameter("key", country.getCountryI18nKey()); //NOI18N
-
-               // Try to get a single result
-               try {
-                       // Get single result
-                       final Country foundCountry = (Country) query.getSingleResult();
-
-                       // Found it?
-                       isAdded = (foundCountry instanceof Country);
-               } catch (final NoResultException ex) {
-                       // Not found, don't log this
-               }
-
-               // Return result
-               return isAdded;
-       }
-
 }
index 09f300d70166e0c7431c746a6d96ea7c10eebc37..316f80f0c284d8b2231e348d75480e4ebca84c49 100644 (file)
@@ -20,7 +20,7 @@ import java.text.MessageFormat;
 import java.util.Date;
 import javax.ejb.Stateless;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderAlreadyAddedException;
 
 /**
  * An administrative singleton EJB for mobile provider informations
index 52067b7e2ff9fa00ad9340ec8f770c7117852950..94f5d68754a02c68ec2cf179b64a897820052af0 100644 (file)
@@ -19,7 +19,6 @@ package org.mxchange.jphone.model.phonenumbers.phone;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
@@ -108,121 +107,4 @@ public class AddressbookPhoneSessionBean extends BaseAddressbookDatabaseBean imp
                return list;
        }
 
-       @Override
-       public DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), faxNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == faxNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("faxNumberId is null"); //NOI18N
-               } else if (faxNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("faxNumberId={0} is not valid.", faxNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchFaxNumberId", FaxNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("faxNumberId", faxNumberId); //NOI18N
-
-               // Init instance
-               final DialableFaxNumber faxNumber;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       faxNumber = (DialableFaxNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(faxNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findFaxNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
-
-               // Return found instance
-               return faxNumber;
-       }
-
-       @Override
-       public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), landLineNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == landLineNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumberId is null"); //NOI18N
-               } else if (landLineNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is not valid.", landLineNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchLandLineNumberId", LandLineNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("landLineNumberId", landLineNumberId); //NOI18N
-
-               // Init instance
-               final DialableLandLineNumber landLineNumber;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       landLineNumber = (DialableLandLineNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(landLineNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findLandLineNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
-
-               // Return found instance
-               return landLineNumber;
-       }
-
-       @Override
-       public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), mobileNumberId)); //NOI18N
-
-               // The id number should be valid
-               if (null == mobileNumberId) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumberId is null"); //NOI18N
-               } else if (mobileNumberId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is not valid.", mobileNumberId)); //NOI18N
-               }
-
-               // Now find it
-               final Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
-
-               // Init instance
-               final DialableMobileNumber mobile;
-
-               // Try to get a result
-               try {
-                       // Get a single result
-                       mobile = (DialableMobileNumber) query.getSingleResult();
-               } catch (NoResultException ex) {
-                       // The entry was not found, so throw it again
-                       throw new PhoneEntityNotFoundException(mobileNumberId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findMobileNumberById: mobile={1} - EXIT!", this.getClass().getSimpleName(), mobile)); //NOI18N
-
-               // Return found instance
-               return mobile;
-       }
-
 }
index 6ce03f8e2a95d466c3b776412f1489135b80e0e8..6ba30ee60e46f88286ac6d75af776e622cc75a98 100644 (file)
@@ -246,39 +246,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                return foundUser;
        }
 
-       @Override
-       public User findUserById (final Long userId) throws UserNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
-
-               // Is the parameter valid?
-               if (null == userId) {
-                       // Throw NPE
-                       throw new NullPointerException("userId is null"); //NOI18N
-               } else if (userId < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
-               } else if (!this.ifUserIdExists(userId)) {
-                       // Does not exist
-                       throw new UserNotFoundException(userId);
-               }
-
-               // Create query instance
-               final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
-
-               // Set user id
-               query.setParameter("id", userId); //NOI18N
-
-               // Fetch the result, it should be there by now
-               final User user = (User) query.getSingleResult();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
-
-               // Return found user
-               return user;
-       }
-
        @Override
        public String generateRandomUserName () {
                // Trace message
@@ -373,54 +340,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                return true;
        }
 
-       @Override
-       public boolean ifUserIdExists (final Long userId) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
-
-               // userId should not be null
-               if (null == userId) {
-                       // Abort here
-                       throw new NullPointerException("userId is null"); //NOI18N
-               } else if (userId < 1) {
-                       // Invalid number
-                       throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", userId)); //NOI18N
-               }
-
-               // Generate query
-               final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("id", userId); //NOI18N
-
-               // Try this
-               try {
-                       // Try to get single result
-                       final User dummy = (User) query.getSingleResult();
-
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
-               } catch (final NoResultException ex) {
-                       // Log it
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
-
-                       // User name does not exist
-                       return false;
-               } catch (final PersistenceException ex) {
-                       // Something bad happened
-                       this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
-
-                       // Throw again
-                       throw ex;
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: Found userId={1} - EXIT!", this.getClass().getSimpleName(), userId)); //NOI18N
-
-               // Found it
-               return true;
-       }
-
        @Override
        public boolean ifUserNameExists (final String userName) {
                // Trace message