From: Roland Häder Date: Thu, 10 Oct 2019 23:36:29 +0000 (+0200) Subject: Don't cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bc7d58242091b1c2f0f0c67ec94cc6b44afb6bfd;p=jjobs-ejb.git Don't cherry-pick: - added missing createManaged() methods for Department and HireableJobPosition - You can do someInstance.getClass() to avoid importing the implementing class instead which is more flexible and allows other implementations - renamed BaseJobsDatabaseBean to BaseJobsEnterpriseBean and moved to proper package - renamed JobPosition to HireableJobPosition (maybe tpzo?) - renamed classes with "Headquarters" in it to "Headquarter" as "s" is plural and should be only used for utility classes - added missing imports of utility classes - the registration bean does no longer have isEmailAddressRegistered() and isUserNameRegistered() as this exists in user bean, fixed all occurances Signed-off-by: Roland Häder --- diff --git a/nbproject/project.properties b/nbproject/project.properties index 7753b2f..4d79ced 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -47,7 +47,7 @@ includes=** j2ee.compile.on.save=true j2ee.deploy.on.save=true j2ee.platform=1.7 -j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar +j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.enterprise-api.jar:${j2ee.server.home}/modules/javax.security.enterprise.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar diff --git a/src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java index a77eae0..4501968 100644 --- a/src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/contact/JobsAdminContactSessionBean.java @@ -23,7 +23,7 @@ import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * An administrative contact EJB @@ -31,7 +31,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "adminContact", description = "An administrative contact EJB") -public class JobsAdminContactSessionBean extends BaseJobsDatabaseBean implements AdminContactSessionBeanRemote { +public class JobsAdminContactSessionBean extends BaseJobsEnterpriseBean implements AdminContactSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java index fc6b96d..4a92d19 100644 --- a/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/contact/JobsContactSessionBean.java @@ -24,7 +24,7 @@ import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A contact EJB @@ -32,7 +32,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "contact", description = "A bean handling contact data") -public class JobsContactSessionBean extends BaseJobsDatabaseBean implements ContactSessionBeanRemote { +public class JobsContactSessionBean extends BaseJobsEnterpriseBean implements ContactSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java index 9f9ada3..f49b690 100644 --- a/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/phone/JobsAdminContactPhoneSessionBean.java @@ -22,7 +22,7 @@ import java.util.Objects; import javax.ejb.EJB; import javax.ejb.Stateless; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException; import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -35,7 +35,7 @@ import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; * @author Roland Häder */ @Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone (fax, land-line and mobile) data") -public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean implements AdminContactsPhoneSessionBeanRemote { +public class JobsAdminContactPhoneSessionBean extends BaseJobsEnterpriseBean implements AdminContactsPhoneSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java index cf0aa14..12846c0 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsAdminBusinessDataSessionBean.java @@ -25,7 +25,7 @@ import javax.ejb.Stateless; import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -34,7 +34,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "adminBasicCompanyData", description = "An administrative statless bean for handling business data (all)") -public class JobsAdminBusinessDataSessionBean extends BaseJobsDatabaseBean implements AdminBasicCompanyDataSessionBeanRemote { +public class JobsAdminBusinessDataSessionBean extends BaseJobsEnterpriseBean implements AdminBasicCompanyDataSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java index 9aab0df..cda0402 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless session bean for business data @@ -28,7 +28,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "basicCompanyData", description = "A general statless bean for handling business data (all)") -public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements BasicCompanyDataSessionBeanRemote { +public class JobsBusinessDataSessionBean extends BaseJobsEnterpriseBean implements BasicCompanyDataSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java index bcefcf4..adbc830 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsAdminBranchOfficeSessionBean.java @@ -25,7 +25,7 @@ import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlread import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -34,7 +34,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "adminBranchOffice", description = "An administrative statless bean for handling branch office data (all)") -public class JobsAdminBranchOfficeSessionBean extends BaseJobsDatabaseBean implements AdminBranchOfficeSessionBeanRemote { +public class JobsAdminBranchOfficeSessionBean extends BaseJobsEnterpriseBean implements AdminBranchOfficeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java index 48f48d0..d255fe7 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/JobsBranchOfficeSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless session bean for general branch office purposes @@ -28,7 +28,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)") -public class JobsBranchOfficeSessionBean extends BaseJobsDatabaseBean implements BranchOfficeSessionBeanRemote { +public class JobsBranchOfficeSessionBean extends BaseJobsEnterpriseBean implements BranchOfficeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/department/JobsAdminDepartmentSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/department/JobsAdminDepartmentSessionBean.java index 1672662..6a8cb26 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/department/JobsAdminDepartmentSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/department/JobsAdminDepartmentSessionBean.java @@ -26,7 +26,7 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -35,7 +35,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "adminDepartment", description = "An administrative statless bean for handling department data (all)") -public class JobsAdminDepartmentSessionBean extends BaseJobsDatabaseBean implements AdminDepartmentSessionBeanRemote { +public class JobsAdminDepartmentSessionBean extends BaseJobsEnterpriseBean implements AdminDepartmentSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/department/JobsDepartmentSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/department/JobsDepartmentSessionBean.java index 5758c15..1501b58 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/department/JobsDepartmentSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/department/JobsDepartmentSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless session bean for general department purposes @@ -28,7 +28,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "department", description = "A general statless bean for handling branch office data (all)") -public class JobsDepartmentSessionBean extends BaseJobsDatabaseBean implements DepartmentSessionBeanRemote { +public class JobsDepartmentSessionBean extends BaseJobsEnterpriseBean implements DepartmentSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java index c1fe683..0d3cb6d 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsAdminCompanyEmployeeSessionBean.java @@ -25,8 +25,8 @@ import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeAlreadyAddedEx import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.model.user.User; @@ -37,7 +37,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "adminEmployee", description = "An administrative statless bean for handling company employees") -public class JobsAdminCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote { +public class JobsAdminCompanyEmployeeSessionBean extends BaseJobsEnterpriseBean implements AdminEmployeeSessionBeanRemote { /** * Serial number @@ -177,9 +177,9 @@ public class JobsAdminCompanyEmployeeSessionBean extends BaseJobsDatabaseBean im } // Is headquarter set? - if (employee.getEmployeeJobPosition() instanceof JobPosition) { + if (employee.getEmployeeJobPosition() instanceof HireableJobPosition) { // Then make it managed - final JobPosition jobPosition = this.createManaged(employee.getEmployeeJobPosition()); + final HireableJobPosition jobPosition = this.createManaged(employee.getEmployeeJobPosition()); // Set it back employee.setEmployeeJobPosition(jobPosition); diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java index 89ae0a5..d505a61 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/employee/JobsCompanyEmployeeSessionBean.java @@ -20,8 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless bean for general purposes for company employees. @@ -29,7 +28,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "employee", description = "A general statless bean for handling company employees") -public class JobsCompanyEmployeeSessionBean extends BaseJobsDatabaseBean implements CompanyEmployeeSessionBeanRemote { +public class JobsCompanyEmployeeSessionBean extends BaseJobsEnterpriseBean implements EmployeeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquarterSessionBean.java new file mode 100644 index 0000000..7f6e77d --- /dev/null +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquarterSessionBean.java @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2017, 2018 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 . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.text.MessageFormat; +import java.util.Date; +import java.util.List; +import javax.ejb.EJB; +import javax.ejb.Stateless; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; +import org.mxchange.jusercore.model.user.User; + +/** + * A stateless session bean for administrative branch office purposes + *

+ * @author Roland Häder + */ +@Stateless (name = "adminHeadquarter", description = "An administrative statless bean for handling branch office data (all)") +public class JobsAdminHeadquarterSessionBean extends BaseJobsEnterpriseBean implements AdminHeadquarterSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_467_386_571_701L; + + /** + * General branch office bean + */ + @EJB (lookup = "java:global/jjobs-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") + private HeadquarterSessionBeanRemote headquarterBean; + + /** + * Default constructor + */ + public JobsAdminHeadquarterSessionBean () { + // Call super constructor + super(); + } + + @Override + public Headquarter addHeadquarter (final Headquarter headquarter) throws HeadquarterAlreadyAddedException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter={1} - CALLED!", this.getClass().getSimpleName(), headquarter)); //NOI18N + + // Validate parameter + if (null == headquarter) { + // Throw NPE + throw new NullPointerException("headquarter is null"); //NOI18N + } else if (headquarter.getHeadquarterId() instanceof Long) { + // Should not happen + throw new IllegalArgumentException("headquarter.branchId should not be set."); //NOI18N + } else if (this.isHeadquarterFound(headquarter)) { + // Already added, abort here + throw new HeadquarterAlreadyAddedException(headquarter); + } + + // Add created timestamp + headquarter.setHeadquarterCreated(new Date()); + + // Is user instance set? + if (headquarter.getHeadquarterUserOwner() instanceof User) { + // Get managed instance back + final User managedUser = this.createManaged(headquarter.getHeadquarterUserOwner()); + + // Set it back in branch office + headquarter.setHeadquarterUserOwner(managedUser); + } + + // Is user instance set? + if (headquarter.getHeadquarterCountry() instanceof Country) { + // Get managed instance back + final Country managedCountry = this.createManaged(headquarter.getHeadquarterCountry()); + + // Set it back in branch office + headquarter.setHeadquarterCountry(managedCountry); + } + + // Set "created" timestamp on any number assigned + this.setAllPhoneEntriesCreated(headquarter); + + // Get opening times + final List openingTimes = headquarter.getHeadquarterOpeningTimes(); + + // Debugging: + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addHeadquarter(): headquarter.headquarterOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes)); + + // Is opening times set and not empty? + if ((openingTimes instanceof List) && (!openingTimes.isEmpty())) { + // Add created timestamp for all times + this.setAllOpeningTimesCreated(openingTimes); + } else { + // Set all to null + headquarter.setHeadquarterOpeningTimes(null); + } + + // Persist it + this.getEntityManager().persist(headquarter); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter.branchId={1} - EXIT!", this.getClass().getSimpleName(), headquarter.getHeadquarterId())); //NOI18N + + // Return updated instance + return headquarter; + } + + /** + * Checks if given branch office's address is already persisted. The whole + * (persisted) list is being loaded and each address is being matched + * against the given branch office's address. + *

+ * @param headquarter Headquarter office being checked + *

+ * @return Whether it has been found + */ + private boolean isHeadquarterFound (final Headquarter headquarter) { + // Get whole list + final List headquarters = this.headquarterBean.allHeadquarters(); + + // Default is not found + boolean isFound = false; + + // Check all single addresses + for (final Headquarter hq : headquarters) { + // Is the same address found? + if (Headquarters.isSameAddress(hq, headquarter)) { + // Found one + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquartersSessionBean.java deleted file mode 100644 index 291a76d..0000000 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsAdminHeadquartersSessionBean.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2017, 2018 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 . - */ -package org.mxchange.jcontactsbusiness.model.headquarter; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.List; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; -import org.mxchange.jusercore.model.user.User; - -/** - * A stateless session bean for administrative branch office purposes - *

- * @author Roland Häder - */ -@Stateless (name = "adminHeadquarter", description = "An administrative statless bean for handling branch office data (all)") -public class JobsAdminHeadquarterSessionBean extends BaseJobsDatabaseBean implements AdminHeadquarterSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_467_386_571_701L; - - /** - * General branch office bean - */ - @EJB (lookup = "java:global/jjobs-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") - private HeadquarterSessionBeanRemote headquarterBean; - - /** - * Default constructor - */ - public JobsAdminHeadquarterSessionBean () { - // Call super constructor - super(); - } - - @Override - public Headquarter addHeadquarter (final Headquarter headquarter) throws HeadquarterAlreadyAddedException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter={1} - CALLED!", this.getClass().getSimpleName(), headquarter)); //NOI18N - - // Validate parameter - if (null == headquarter) { - // Throw NPE - throw new NullPointerException("headquarter is null"); //NOI18N - } else if (headquarter.getHeadquarterId() instanceof Long) { - // Should not happen - throw new IllegalArgumentException("headquarter.branchId should not be set."); //NOI18N - } else if (this.isHeadquarterFound(headquarter)) { - // Already added, abort here - throw new HeadquarterAlreadyAddedException(headquarter); - } - - // Add created timestamp - headquarter.setHeadquarterCreated(new Date()); - - // Is user instance set? - if (headquarter.getHeadquarterUserOwner() instanceof User) { - // Get managed instance back - final User managedUser = this.createManaged(headquarter.getHeadquarterUserOwner()); - - // Set it back in branch office - headquarter.setHeadquarterUserOwner(managedUser); - } - - // Is user instance set? - if (headquarter.getHeadquarterCountry() instanceof Country) { - // Get managed instance back - final Country managedCountry = this.createManaged(headquarter.getHeadquarterCountry()); - - // Set it back in branch office - headquarter.setHeadquarterCountry(managedCountry); - } - - // Set "created" timestamp on any number assigned - this.setAllPhoneEntriesCreated(headquarter); - - // Get opening times - final List openingTimes = headquarter.getHeadquarterOpeningTimes(); - - // Debugging: - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addHeadquarter(): headquarter.headquarterOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes)); - - // Is opening times set and not empty? - if ((openingTimes instanceof List) && (!openingTimes.isEmpty())) { - // Add created timestamp for all times - this.setAllOpeningTimesCreated(openingTimes); - } else { - // Set all to null - headquarter.setHeadquarterOpeningTimes(null); - } - - // Persist it - this.getEntityManager().persist(headquarter); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addHeadquarter(): headquarter.branchId={1} - EXIT!", this.getClass().getSimpleName(), headquarter.getHeadquarterId())); //NOI18N - - // Return updated instance - return headquarter; - } - - /** - * Checks if given branch office's address is already persisted. The whole - * (persisted) list is being loaded and each address is being matched - * against the given branch office's address. - *

- * @param headquarter Headquarter office being checked - *

- * @return Whether it has been found - */ - private boolean isHeadquarterFound (final Headquarter headquarter) { - // Get whole list - final List headquarters = this.headquarterBean.allHeadquarters(); - - // Default is not found - boolean isFound = false; - - // Check all single addresses - for (final Headquarter hq : headquarters) { - // Is the same address found? - if (Headquarters.isSameAddress(hq, headquarter)) { - // Found one - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - -} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquarterSessionBean.java new file mode 100644 index 0000000..85a1417 --- /dev/null +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquarterSessionBean.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2017, 2018 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 . + */ +package org.mxchange.jcontactsbusiness.model.headquarter; + +import java.text.MessageFormat; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.Query; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; + +/** + * A stateless session bean for general headquarter purposes + *

+ * @author Roland Häder + */ +@Stateless (name = "headquarter", description = "A general statless bean for handling headquarter data (all)") +public class JobsHeadquarterSessionBean extends BaseJobsEnterpriseBean implements HeadquarterSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_467_386_571_701L; + + @Override + @SuppressWarnings ("unchecked") + public List allHeadquarters () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: CALLED!", this.getClass().getSimpleName())); //NOI18N + + // Get query + final Query query = this.getEntityManager().createNamedQuery("AllHeadquarters"); //NOI18N + + // Get list from it + final List list = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N + + // Return it + return list; + } + +} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquartersSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquartersSessionBean.java deleted file mode 100644 index 1624b84..0000000 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/JobsHeadquartersSessionBean.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2017, 2018 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 . - */ -package org.mxchange.jcontactsbusiness.model.headquarter; - -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import java.text.MessageFormat; -import java.util.List; -import javax.ejb.Stateless; -import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; -import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; - -/** - * A stateless session bean for general headquarter purposes - *

- * @author Roland Häder - */ -@Stateless (name = "headquarter", description = "A general statless bean for handling headquarter data (all)") -public class JobsHeadquarterSessionBean extends BaseJobsDatabaseBean implements HeadquarterSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_467_386_571_701L; - - @Override - @SuppressWarnings ("unchecked") - public List allHeadquarters () { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: CALLED!", this.getClass().getSimpleName())); //NOI18N - - // Get query - final Query query = this.getEntityManager().createNamedQuery("AllHeadquarters"); //NOI18N - - // Get list from it - final List list = query.getResultList(); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allHeadquarters: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N - - // Return it - return list; - } - -} diff --git a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsAdminOpeningTimesSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsAdminOpeningTimesSessionBean.java index 6b57755..bc266c1 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsAdminOpeningTimesSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsAdminOpeningTimesSessionBean.java @@ -19,7 +19,7 @@ package org.mxchange.jcontactsbusiness.model.opening_time; import java.text.MessageFormat; import java.util.Date; import javax.ejb.Stateless; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless session bean for administrative opening times purposes @@ -27,7 +27,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "adminOpeningTimes", description = "An administrative statless bean for handling opening times") -public class JobsAdminOpeningTimesSessionBean extends BaseJobsDatabaseBean implements AdminOpeningTimeSessionBeanRemote { +public class JobsAdminOpeningTimesSessionBean extends BaseJobsEnterpriseBean implements AdminOpeningTimeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsOpeningTimesSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsOpeningTimesSessionBean.java index ffdb86f..82444dc 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsOpeningTimesSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/JobsOpeningTimesSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless session bean for general opening times purposes @@ -28,7 +28,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "openingTimes", description = "A general statless bean for handling branch office data (all)") -public class JobsOpeningTimesSessionBean extends BaseJobsDatabaseBean implements OpeningTimeSessionBeanRemote { +public class JobsOpeningTimesSessionBean extends BaseJobsEnterpriseBean implements OpeningTimeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcountry/model/data/JobsAdminCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/JobsAdminCountrySingletonBean.java index 24c8803..b4ee6da 100644 --- a/src/java/org/mxchange/jcountry/model/data/JobsAdminCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/model/data/JobsAdminCountrySingletonBean.java @@ -22,7 +22,7 @@ import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A stateless EJB for administrative country purposes @@ -30,7 +30,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; * @author Roland Häder */ @Stateless (name = "adminCountry", description = "A stateless session-scoped bean for administrative country purposes") -public class JobsAdminCountrySingletonBean extends BaseJobsDatabaseBean implements AdminCountrySessionBeanRemote { +public class JobsAdminCountrySingletonBean extends BaseJobsEnterpriseBean implements AdminCountrySessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java index 9af3476..8220021 100644 --- a/src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/model/data/JobsCountrySingletonBean.java @@ -21,7 +21,7 @@ import java.util.List; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A singleton EJB for country informations @@ -30,7 +30,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; */ @Startup @Singleton (name = "country", description = "A singleton session-scoped bean for country informations") -public class JobsCountrySingletonBean extends BaseJobsDatabaseBean implements CountrySingletonBeanRemote { +public class JobsCountrySingletonBean extends BaseJobsEnterpriseBean implements CountrySingletonBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jjobs/beans/ejb/BaseJobsEnterpriseBean.java b/src/java/org/mxchange/jjobs/beans/ejb/BaseJobsEnterpriseBean.java index c18d1bd..fbe1a43 100644 --- a/src/java/org/mxchange/jjobs/beans/ejb/BaseJobsEnterpriseBean.java +++ b/src/java/org/mxchange/jjobs/beans/ejb/BaseJobsEnterpriseBean.java @@ -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 + *

+ * @param department Unmanaged/detached department instance + *

+ * @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 *

@@ -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 + *

+ * @param jobPosition Unmanaged/detached job position instance + *

+ * @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 *

@@ -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 + *

+ * @param mobileProvider Unmanaged/detached mobile provider instance + *

+ * @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 *

@@ -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 diff --git a/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java b/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java index 1824cfb..b5730d8 100644 --- a/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java +++ b/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java @@ -17,7 +17,7 @@ package org.mxchange.jjobs.model.addressbook; import java.text.MessageFormat; -import java.util.GregorianCalendar; +import java.util.Date; import java.util.List; import javax.ejb.Stateless; import javax.persistence.NoResultException; @@ -28,7 +28,7 @@ import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException; import org.mxchange.jaddressbook.model.addressbook.Addressbook; import org.mxchange.jaddressbook.model.addressbook.UserAddressbook; import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -37,7 +37,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "addressbook", description = "A stateless bean for handling JJobs addressbooks") -public class JobsAddressbookSessionBean extends BaseJobsDatabaseBean implements AddressbookSessionBeanRemote { +public class JobsAddressbookSessionBean extends BaseJobsEnterpriseBean implements AddressbookSessionBeanRemote { /** * Serial number @@ -111,7 +111,7 @@ public class JobsAddressbookSessionBean extends BaseJobsDatabaseBean implements } // Add timestamp of creation - addressbook.setAddressbookCreated(new GregorianCalendar()); + addressbook.setAddressbookCreated(new Date()); // Persist it now this.getEntityManager().persist(addressbook); diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java index 9f48ec6..20907b5 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsAdminMobileProviderSessionBean.java @@ -19,7 +19,7 @@ package org.mxchange.jphone.model.phonenumbers.mobileprovider; import java.text.MessageFormat; import java.util.Date; import javax.ejb.Stateless; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderAlreadyAddedException; /** @@ -28,7 +28,7 @@ import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderAlreadyAddedE * @author Roland Häder */ @Stateless (name = "adminMobileProvider", description = "A singleton session-scoped bean for mobile provider informations, admin-edition") -public class JobsAdminMobileProviderSessionBean extends BaseJobsDatabaseBean implements AdminMobileProviderSessionBeanRemote { +public class JobsAdminMobileProviderSessionBean extends BaseJobsEnterpriseBean implements AdminMobileProviderSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java index aaf852c..4684721 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/JobsMobileProviderSingletonBean.java @@ -21,7 +21,7 @@ import java.util.List; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; /** * A singleton EJB for mobile provider informations @@ -30,7 +30,7 @@ import org.mxchange.jjobs.database.BaseJobsDatabaseBean; */ @Startup @Singleton (name = "mobileProvider", description = "A singleton session-scoped bean for SMS provider informations") -public class JobsMobileProviderSingletonBean extends BaseJobsDatabaseBean implements MobileProviderSingletonBeanRemote { +public class JobsMobileProviderSingletonBean extends BaseJobsEnterpriseBean implements MobileProviderSingletonBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java index 54b425d..5eb9c37 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsAdminPhoneSessionBean.java @@ -19,8 +19,10 @@ package org.mxchange.jphone.model.phonenumbers.phone; import java.text.MessageFormat; import java.util.Date; import javax.ejb.Stateless; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; -import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; +import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers; +import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers; +import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers; /** * An EJB for administrative phone purposes @@ -28,7 +30,7 @@ import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote; * @author Roland Häder */ @Stateless (name = "adminPhone", description = "An administrative bean handling phone data") -public class JobsAdminPhoneSessionBean extends BaseJobsDatabaseBean implements AdminPhoneSessionBeanRemote { +public class JobsAdminPhoneSessionBean extends BaseJobsEnterpriseBean implements AdminPhoneSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java index 6b53d1e..c6a29e4 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/phone/JobsPhoneSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -34,7 +34,7 @@ import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; * @author Roland Häder */ @Stateless (name = "phone", description = "A bean handling phone data") -public class JobsPhoneSessionBean extends BaseJobsDatabaseBean implements PhoneSessionBeanRemote { +public class JobsPhoneSessionBean extends BaseJobsEnterpriseBean implements PhoneSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java index 4f804a0..ae9c93a 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java @@ -21,7 +21,7 @@ import java.util.Date; import javax.ejb.EJB; import javax.ejb.Stateless; import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNotFoundException; @@ -29,7 +29,6 @@ import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * An administrative user EJB @@ -37,19 +36,13 @@ import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBe * @author Roland Häder */ @Stateless (name = "adminUser", description = "A bean handling the user data") -public class JobsAdminUserSessionBean extends BaseJobsDatabaseBean implements AdminUserSessionBeanRemote { +public class JobsAdminUserSessionBean extends BaseJobsEnterpriseBean implements AdminUserSessionBeanRemote { /** * Serial number */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Registration EJB - */ - @EJB - private UserRegistrationSessionBeanRemote registerBean; - /** * Regular user bean */ @@ -79,10 +72,10 @@ public class JobsAdminUserSessionBean extends BaseJobsDatabaseBean implements Ad } // Check if user is registered - if (this.registerBean.isUserNameRegistered(user)) { + if (this.userBean.isUserNameRegistered(user)) { // Abort here throw new UserNameAlreadyRegisteredException(user); - } else if (this.registerBean.isEmailAddressRegistered(user)) { + } else if (this.userBean.isEmailAddressRegistered(user)) { // Abort here throw new EmailAddressAlreadyRegisteredException(user); } diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index 570cf0f..4b060e4 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -27,7 +27,7 @@ import javax.persistence.PersistenceException; import javax.persistence.Query; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.Contacts; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -49,7 +49,7 @@ import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBe * @author Roland Häder */ @Stateless (name = "user", description = "A bean handling the user data") -public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSessionBeanRemote { +public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivityLogMessageBean.java b/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivityLogMessageBean.java index 2cdf04d..1999b58 100644 --- a/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivityLogMessageBean.java +++ b/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivityLogMessageBean.java @@ -23,7 +23,7 @@ import javax.ejb.Stateless; import javax.jms.JMSException; import javax.jms.ObjectMessage; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -32,7 +32,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "userActivity", description = "A stateless, session-scored user-activity bean.") -public class JobsUserActivitySessionBean extends BaseJobsDatabaseBean implements UserActivityLogSessionBeanRemote { +public class JobsUserActivityLogMessageBean extends BaseJobsEnterpriseBean implements UserActivityLogSessionBeanRemote { /** * Serial number @@ -42,7 +42,7 @@ public class JobsUserActivitySessionBean extends BaseJobsDatabaseBean implements /** * Default constructor */ - public JobsUserActivitySessionBean () { + public JobsUserActivityLogMessageBean () { // Invoke super constructor super("jms/jjobs-queue-factory", "jms/jjobs-user-activity-log"); //NOI18N } diff --git a/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java b/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java index bce8f4a..8eb0619 100644 --- a/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/activity/JobsUserActivitySessionBean.java @@ -17,25 +17,24 @@ package org.mxchange.jusercore.model.user.activity; import java.text.MessageFormat; -import java.util.Arrays; import java.util.List; import javax.ejb.EJBException; import javax.ejb.Stateless; import javax.jms.JMSException; import javax.jms.ObjectMessage; import javax.persistence.Query; -import org.mxchange.jcoreee.database.BaseDatabaseBean; +import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** - * An EJB for user activity log. This class extends BaseDatabaseBean and not + * An EJB for user activity log. This class extends BaseEnterpriseBean and not * project-specific "base class". The simple reason is that this class requires * no email queue as no emails are ever being sent from this class. *

* @author Roland Häder */ @Stateless (name = "userActivity", description = "A bean handling the user data") -public class JobsUserActivitySessionBean extends BaseDatabaseBean implements UserActivityLogSessionBeanRemote { +public class JobsUserActivitySessionBean extends BaseEnterpriseBean implements UserActivityLogSessionBeanRemote { /** * Serial number @@ -145,85 +144,4 @@ public class JobsUserActivitySessionBean extends BaseDatabaseBean implements Use return list; } - @Override - @SuppressWarnings ("unchecked") - public List fetchAllUsersActivityLogByMultipleType (final User user, final String[] activityTypes) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityTypes={2} - CALLED!", this.getClass().getSimpleName(), user, Arrays.toString(activityTypes))); //NOI18N - - // Is user valid? - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { - // Throw again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("user.userId{0} is not valid", user.getUserId())); //NOI18N - } else if (null == activityTypes) { - // Throw NPE again - throw new NullPointerException("activityTypes is null"); //NOI18N - } else if (activityTypes.length == 0) { - // Should not be empty - throw new IllegalArgumentException("activityTypes is empty"); //NOI18N - } - - // Search for user's activity - Query query = this.getEntityManager().createNamedQuery("FindUsersActivityByMultipleTypes", UserActivityLog.class); //NOI18N - - // Set parameters - query.setParameter("activityUser", user); //NOI18N - query.setParameter("activityTypes", Arrays.asList(activityTypes)); //NOI18N - - // Get list - List list = query.getResultList(); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N - - // Return it - return list; - } - - @Override - @SuppressWarnings ("unchecked") - public List fetchAllUsersActivityLogByType (final User user, final String activityType) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: user={1},activityType={2} - CALLED!", this.getClass().getSimpleName(), user, activityType)); //NOI18N - - // Is user valid? - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { - // Throw again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("user.userId{0} is not valid", user.getUserId())); //NOI18N - } else if (null == activityType) { - // Throw NPE again - throw new NullPointerException("activityType is null"); //NOI18N - } else if (activityType.isEmpty()) { - // Should not be empty - throw new IllegalArgumentException("activityType is empty"); //NOI18N - } - - // Search for user's activity - Query query = this.getEntityManager().createNamedQuery("FindUsersActivityByType", UserActivityLog.class); //NOI18N - - // Set parameters - query.setParameter("activityUser", user); //NOI18N - query.setParameter("activityType", activityType); //NOI18N - - // Get list - List list = query.getResultList(); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fetchAllUsersActivityLogByType: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N - - // Return it - return list; - } } diff --git a/src/java/org/mxchange/jusercore/model/user/email_address/JobsUserEmailChangeSessionBean.java b/src/java/org/mxchange/jusercore/model/user/email_address/JobsUserEmailChangeSessionBean.java index 9e5610f..0de0009 100644 --- a/src/java/org/mxchange/jusercore/model/user/email_address/JobsUserEmailChangeSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/email_address/JobsUserEmailChangeSessionBean.java @@ -24,7 +24,7 @@ import javax.ejb.EJBException; import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress; import org.mxchange.jusercore.model.email_address.EmailAddressChange; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; @@ -36,7 +36,7 @@ import org.mxchange.juserlogincore.login.UserLoginUtils; * @author Roland Häder */ @Stateless (name = "userEmailChange", description = "A bean handling user email changes") -public class JobsUserEmailChangeSessionBean extends BaseJobsDatabaseBean implements UserEmailChangeSessionBeanRemote { +public class JobsUserEmailChangeSessionBean extends BaseJobsEnterpriseBean implements UserEmailChangeSessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java b/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java index 24081d7..728e68d 100644 --- a/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/password_history/JobsUserPasswordHistorySessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -29,7 +29,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Stateless (name = "userPasswordHistory", description = "A stateless EJB for user's password history. This bean does return the full user's password history and not limited. The application then needs to limit it to it's purpose.") -public class JobsUserPasswordHistorySessionBean extends BaseJobsDatabaseBean implements UserPasswordHistorySessionBeanRemote { +public class JobsUserPasswordHistorySessionBean extends BaseJobsEnterpriseBean implements UserPasswordHistorySessionBeanRemote { /** * Serial number diff --git a/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java index 4dfd1f2..1b3f620 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java @@ -19,7 +19,7 @@ package org.mxchange.juserlogincore.model.user.login; import java.text.MessageFormat; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; @@ -29,7 +29,6 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; import org.mxchange.juserlogincore.container.login.LoginContainer; import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.juserlogincore.login.UserLoginUtils; -import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * A session EJB for user logins @@ -37,19 +36,13 @@ import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBe * @author Roland Häder */ @Stateless (name = "userLogin", description = "A bean handling the user login for Jobs project") -public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements UserLoginSessionBeanRemote { +public class JobsUserLoginSessionBean extends BaseJobsEnterpriseBean implements UserLoginSessionBeanRemote { /** * Serial number */ private static final long serialVersionUID = 21_785_978_127_581_965L; - /** - * Registration EJB - */ - @EJB - private UserRegistrationSessionBeanRemote registerBean; - /** * User EJB */ @@ -69,10 +62,6 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N - // Check some beans - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - assert (this.registerBean instanceof UserRegistrationSessionBeanRemote) : "this.registerBean is not set"; //NOI18N - // user should not be null if (null == container) { // Abort here @@ -89,7 +78,7 @@ public class JobsUserLoginSessionBean extends BaseJobsDatabaseBean implements Us } // Is the account there? - if (!this.registerBean.isUserNameRegistered(container.getUser())) { + if (!this.userBean.isUserNameRegistered(container.getUser())) { // Not registered throw new UserNotFoundException(container.getUser()); } diff --git a/src/java/org/mxchange/juserlogincore/model/user/register/JobsUserRegistrationSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/register/JobsUserRegistrationSessionBean.java index 6fd5fa1..069e17a 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/register/JobsUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/register/JobsUserRegistrationSessionBean.java @@ -23,7 +23,7 @@ import javax.ejb.Stateless; import javax.persistence.NoResultException; import javax.persistence.Query; import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote; @@ -38,7 +38,7 @@ import org.mxchange.juserlogincore.login.UserLoginUtils; * @author Roland Häder */ @Stateless (name = "userRegistration", description = "A bean handling the user registration") -public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implements UserRegistrationSessionBeanRemote { +public class JobsUserRegistrationSessionBean extends BaseJobsEnterpriseBean implements UserRegistrationSessionBeanRemote { /** * Serial number @@ -111,42 +111,6 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem return confirmationKey; } - @Override - public boolean isEmailAddressRegistered (final User user) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N - - // Check bean - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - - // user should not be null - if (null == user) { - // Abort here - throw new NullPointerException("user is null"); //NOI18N - } - - // Call other bean - return this.userBean.isEmailAddressRegistered(user); - } - - @Override - public boolean isUserNameRegistered (final User user) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N - - // Check bean - assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N - - // user should not be null - if (null == user) { - // Abort here - throw new NullPointerException("user is null"); //NOI18N - } - - // Call other bean - return this.userBean.isUserNameRegistered(user); - } - @Override public User registerUser (final User user, final String baseUrl, final String randomPassword) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException { // Trace message @@ -168,10 +132,10 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem } // Check if user is registered - if (this.isUserNameRegistered(user)) { + if (this.userBean.isUserNameRegistered(user)) { // Abort here throw new UserNameAlreadyRegisteredException(user); - } else if (this.isEmailAddressRegistered(user)) { + } else if (this.userBean.isEmailAddressRegistered(user)) { // Abort here throw new EmailAddressAlreadyRegisteredException(user); } diff --git a/src/java/org/mxchange/juserlogincore/model/user/resendlink/JobsResendLinkSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/resendlink/JobsResendLinkSessionBean.java index d252b23..0331596 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/resendlink/JobsResendLinkSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/resendlink/JobsResendLinkSessionBean.java @@ -20,7 +20,7 @@ import java.text.MessageFormat; import java.util.Locale; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; +import org.mxchange.jjobs.beans.ejb.BaseJobsEnterpriseBean; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; @@ -36,7 +36,7 @@ import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBe * @author Roland Häder */ @Stateless (name = "userResendConfirmationLink", description = "A bean resending confirmation links") -public class JobsResendLinkSessionBean extends BaseJobsDatabaseBean implements ResendLinkSessionBeanRemote { +public class JobsResendLinkSessionBean extends BaseJobsEnterpriseBean implements ResendLinkSessionBeanRemote { /** * Serial number