]> git.mxchange.org Git - jjobs-ejb.git/blobdiff - src/java/org/mxchange/jjobs/beans/ejb/BaseJobsEnterpriseBean.java
Don't cherry-pick:
[jjobs-ejb.git] / src / java / org / mxchange / jjobs / beans / ejb / BaseJobsEnterpriseBean.java
index c18d1bd083da27d366dfa468ebeaa631e3210d00..fbe1a43828b899e4c19facfec9127d063f57a895 100644 (file)
@@ -29,19 +29,15 @@ import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.Contacts;
-import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
-import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee;
+import org.mxchange.jcontactsbusiness.model.department.Department;
 import org.mxchange.jcontactsbusiness.model.employee.Employable;
-import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
+import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean;
 import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.jcountry.model.data.CountryData;
 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
@@ -50,8 +46,8 @@ import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
 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.Users;
 
@@ -110,7 +106,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final Contact managedContact = this.getEntityManager().find(UserContact.class, contact.getContactId());
+               final Contact managedContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
 
                // Should be there
                assert (managedContact instanceof Contact) : "managedContact is null"; //NOI18N
@@ -146,7 +142,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final Country managedCountry = this.getEntityManager().find(CountryData.class, country.getCountryId());
+               final Country managedCountry = this.getEntityManager().find(country.getClass(), country.getCountryId());
 
                // Should be there
                assert (managedCountry instanceof Country) : "managedCountry is null"; //NOI18N
@@ -182,7 +178,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final BasicData managedBasicData = this.getEntityManager().find(BusinessBasicData.class, basicData.getBasicDataId());
+               final BasicData managedBasicData = this.getEntityManager().find(basicData.getClass(), basicData.getBasicDataId());
 
                // Should be there
                assert (managedBasicData instanceof BasicData) : "managedBasicData is null"; //NOI18N
@@ -218,7 +214,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final BranchOffice managedBranchOffice = this.getEntityManager().find(BusinessBranchOffice.class, headquarter.getBranchId());
+               final BranchOffice managedBranchOffice = this.getEntityManager().find(headquarter.getClass(), headquarter.getBranchId());
 
                // Should be there
                assert (managedBranchOffice instanceof BranchOffice) : "managedBranchOffice is null"; //NOI18N
@@ -230,6 +226,42 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                return managedBranchOffice;
        }
 
+       /**
+        * Get back a managed instance from given department
+        * <p>
+        * @param department Unmanaged/detached department instance
+        * <p>
+        * @return Managed department instance
+        */
+       protected Department createManaged (final Department department) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: department={1} - CALLED!", this.getClass().getSimpleName(), department)); //NOI18N
+
+               // user should not be null
+               if (null == department) {
+                       // Abort here
+                       throw new NullPointerException("department is null"); //NOI18N
+               } else if (department.getDepartmentId() == null) {
+                       // Id is set
+                       throw new NullPointerException("department.departmentId is null"); //NOI18N
+               } else if (department.getDepartmentId() < 1) {
+                       // Id is set
+                       throw new IllegalArgumentException(MessageFormat.format("department.departmentId={0} is invalid", department.getDepartmentId())); //NOI18N
+               }
+
+               // Try to find it (should be there)
+               final Department managedDepartment = this.getEntityManager().find(department.getClass(), department.getDepartmentId());
+
+               // Should be there
+               assert (managedDepartment instanceof Department) : "managedDepartment is null"; //NOI18N
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedDepartment={1} - EXIT!", this.getClass().getSimpleName(), managedDepartment)); //NOI18N
+
+               // Return it
+               return managedDepartment;
+       }
+
        /**
         * Get back a managed instance from given employee
         * <p>
@@ -254,7 +286,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final Employable managedEmployee = this.getEntityManager().find(BusinessEmployee.class, employee.getEmployeeId());
+               final Employable managedEmployee = this.getEntityManager().find(employee.getClass(), employee.getEmployeeId());
 
                // Should be there
                assert (managedEmployee instanceof Employable) : "managedEmployee is null"; //NOI18N
@@ -266,6 +298,42 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                return managedEmployee;
        }
 
+       /**
+        * Get back a managed instance from given jobPosition
+        * <p>
+        * @param jobPosition Unmanaged/detached job position instance
+        * <p>
+        * @return Managed job position instance
+        */
+       protected HireableJobPosition createManaged (final HireableJobPosition jobPosition) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: jobPosition={1} - CALLED!", this.getClass().getSimpleName(), jobPosition)); //NOI18N
+
+               // user should not be null
+               if (null == jobPosition) {
+                       // Abort here
+                       throw new NullPointerException("jobPosition is null"); //NOI18N
+               } else if (jobPosition.getJobPositionId() == null) {
+                       // Id is set
+                       throw new NullPointerException("jobPosition.jobPositionId is null"); //NOI18N
+               } else if (jobPosition.getJobPositionId() < 1) {
+                       // Id is set
+                       throw new IllegalArgumentException(MessageFormat.format("jobPosition.jobPositionId={0} is invalid", jobPosition.getJobPositionId())); //NOI18N
+               }
+
+               // Try to find it (should be there)
+               final HireableJobPosition managedJobPosition = this.getEntityManager().find(jobPosition.getClass(), jobPosition.getJobPositionId());
+
+               // Should be there
+               assert (managedJobPosition instanceof HireableJobPosition) : "managedJobPosition is null"; //NOI18N
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedJobPosition={1} - EXIT!", this.getClass().getSimpleName(), managedJobPosition)); //NOI18N
+
+               // Return it
+               return managedJobPosition;
+       }
+
        /**
         * Get back a managed instance from given headquarter
         * <p>
@@ -290,7 +358,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final Headquarter managedHeadquarter = this.getEntityManager().find(BusinessHeadquarter.class, headquarter.getHeadquarterId());
+               final Headquarter managedHeadquarter = this.getEntityManager().find(headquarter.getClass(), headquarter.getHeadquarterId());
 
                // Should be there
                assert (managedHeadquarter instanceof Headquarter) : "managedHeadquarter is null"; //NOI18N
@@ -302,6 +370,42 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                return managedHeadquarter;
        }
 
+       /**
+        * Get back a managed instance from given mobile provider
+        * <p>
+        * @param mobileProvider Unmanaged/detached mobile provider instance
+        * <p>
+        * @return Managed mobile provider instance
+        */
+       protected MobileProvider createManaged (final MobileProvider mobileProvider) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: mobileProvider={1} - CALLED!", this.getClass().getSimpleName(), mobileProvider)); //NOI18N
+
+               // user should not be null
+               if (null == mobileProvider) {
+                       // Abort here
+                       throw new NullPointerException("mobileProvider is null"); //NOI18N
+               } else if (mobileProvider.getProviderId() == null) {
+                       // Id is set
+                       throw new NullPointerException("mobileProvider.providerId is null"); //NOI18N
+               } else if (mobileProvider.getProviderId() < 1) {
+                       // Id is set
+                       throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerId={0} is invalid", mobileProvider.getProviderId())); //NOI18N
+               }
+
+               // Try to find it (should be there)
+               final MobileProvider managedMobileProvider = this.getEntityManager().find(mobileProvider.getClass(), mobileProvider.getProviderId());
+
+               // Should be there
+               assert (managedMobileProvider instanceof MobileProvider) : "managedMobileProvider is null"; //NOI18N
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedMobileProvider={1} - EXIT!", this.getClass().getSimpleName(), managedMobileProvider)); //NOI18N
+
+               // Return it
+               return managedMobileProvider;
+       }
+
        /**
         * Get back a managed instance from given user
         * <p>
@@ -335,7 +439,7 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean {
                }
 
                // Try to find it (should be there)
-               final User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId());
+               final User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
 
                // Should be there
                assert (managedUser instanceof User) : "managedUser is null"; //NOI18N