X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjcontactsbusiness%2Fmodel%2Fbasicdata%2FJobsBusinessDataSessionBean.java;h=3b0082a1b0897738c3f9563bf6512b4fc424e0c2;hb=98fe46b531d78eef72c0543a990a674168a21f1e;hp=a0c473d981a842f3ad7048e23ff4ea206ed6b7b8;hpb=235c4eb1876fc4d231b41166226f3386d9fd246c;p=jjobs-ejb.git
diff --git a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java
index a0c473d..3b0082a 100644
--- a/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java
+++ b/src/java/org/mxchange/jcontactsbusiness/model/basicdata/JobsBusinessDataSessionBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Roland Häder
+ * 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
@@ -18,21 +18,17 @@ package org.mxchange.jcontactsbusiness.model.basicdata;
import java.text.MessageFormat;
import java.util.List;
-import java.util.Objects;
import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote;
-import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
-import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
/**
* A stateless session bean for business data
*
* @author Roland Häder
*/
-@Stateless (name = "businessData", description = "A general statless bean for handling business data (all)")
-public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements BusinessDataSessionBeanRemote {
+@Stateless (name = "basicCompanyData", description = "A general statless bean for handling business data (all)")
+public class JobsBusinessDataSessionBean extends BaseJobsEnterpriseBean implements BasicCompanyDataSessionBeanRemote {
/**
* Serial number
@@ -49,7 +45,7 @@ public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements
@Override
@SuppressWarnings ("unchecked")
- public List allCompanyBasicData () {
+ public List allBusinessBasicData () {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N
@@ -57,7 +53,7 @@ public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements
final Query query = this.getEntityManager().createNamedQuery("AllBusinessData"); //NOI18N
// Get list from it
- final List list = query.getResultList();
+ final List list = query.getResultList();
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBusinessContacts: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
@@ -66,76 +62,4 @@ public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements
return list;
}
- @Override
- public BusinessBasicData findBasicDataById (final Long basicDataId) throws BusinessDataNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
-
- // Set parameter
- query.setParameter("basicDataId", basicDataId); //NOI18N
-
- // Get single instance
- final BusinessBasicData basicData;
-
- // Try to find a result
- try {
- // Find a single result
- basicData = (BusinessBasicData) query.getSingleResult();
-
- // Log trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: Found basicData={1}", this.getClass().getSimpleName(), basicData)); //NOI18N
- } catch (final NoResultException ex) {
- // No result found
- throw new BusinessDataNotFoundException(basicDataId, ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: basicData={1} - EXIT!", this.getClass().getSimpleName(), basicData)); //NOI18N
-
- // Return it
- return basicData;
- }
-
- @Override
- public Boolean isCompanyNameUsed (final String companyName) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: companyName={1} - CALLED!", this.getClass().getSimpleName(), companyName)); //NOI18N
-
- // Is the parameter valid?
- if (null == companyName) {
- // Throw NPE
- throw new NullPointerException("companyName is null"); //NOI18N
- } else if (companyName.isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("companyName is empty"); //NOI18N
- }
-
- // Default is not found
- Boolean isCompanyNameUsed = Boolean.FALSE;
-
- // Get whole list
- final List list = this.allCompanyBasicData();
-
- // Check whole list
- for (final BusinessBasicData basicData : list) {
- // Is name used?
- if (Objects.equals(basicData.getCompanyName(), companyName)) {
- // Found one
- isCompanyNameUsed = Boolean.TRUE;
-
- // Abort search
- break;
- }
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: isCompanyNameUsed={1} - EXIT!", this.getClass().getSimpleName(), isCompanyNameUsed)); //NOI18N
-
- // Return it
- return isCompanyNameUsed;
- }
-
}