From 539da196c0400430283d09e3d4331fb73cc9fb4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 24 Nov 2019 05:37:31 +0100 Subject: [PATCH] Please cherry-pick/repeat: - renamed/moved file MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../BaseFinancialsEnterpriseBean.java} | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) rename src/java/org/mxchange/jfinancials/{database/BaseFinancialsDatabaseBean.java => enterprise/BaseFinancialsEnterpriseBean.java} (96%) diff --git a/src/java/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java b/src/java/org/mxchange/jfinancials/enterprise/BaseFinancialsEnterpriseBean.java similarity index 96% rename from src/java/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java rename to src/java/org/mxchange/jfinancials/enterprise/BaseFinancialsEnterpriseBean.java index c08b2c4..f15bcf0 100644 --- a/src/java/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java +++ b/src/java/org/mxchange/jfinancials/enterprise/BaseFinancialsEnterpriseBean.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jfinancials.database; +package org.mxchange.jfinancials.enterprise; import java.text.MessageFormat; import java.util.Date; @@ -34,6 +34,7 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean; @@ -57,7 +58,7 @@ import org.mxchange.jusercore.model.user.Users; *

* @author Roland Häder */ -public abstract class BaseFinancialsDatabaseBean extends BaseEnterpriseBean { +public abstract class BaseFinancialsEnterpriseBean extends BaseEnterpriseBean { /** * Serial number @@ -67,7 +68,7 @@ public abstract class BaseFinancialsDatabaseBean extends BaseEnterpriseBean { /** * Protected constructor */ - protected BaseFinancialsDatabaseBean () { + protected BaseFinancialsEnterpriseBean () { // Call super contructor super(); } @@ -78,7 +79,7 @@ public abstract class BaseFinancialsDatabaseBean extends BaseEnterpriseBean { * @param factoryJndi JNDI name for queue factory * @param queueJndi JNDI name for email queue */ - protected BaseFinancialsDatabaseBean (final String factoryJndi, final String queueJndi) { + protected BaseFinancialsEnterpriseBean (final String factoryJndi, final String queueJndi) { // Call super constructor super(factoryJndi, queueJndi); } @@ -299,6 +300,42 @@ public abstract class BaseFinancialsDatabaseBean 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 *

-- 2.39.5