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=2092db5a557e553813fe74bf7ebee0329803c6bc;hpb=cacd03e588b6d2df9b32200d471274caf4b9b360;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 2092db5..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,12 +18,9 @@ package org.mxchange.jcontactsbusiness.model.basicdata; import java.text.MessageFormat; import java.util.List; -import java.util.Objects; import javax.ejb.Stateless; -import javax.persistence.NoResultException; import javax.persistence.Query; -import org.mxchange.jjobs.database.BaseJobsDatabaseBean; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException; +import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean; /** * A stateless session bean for business data @@ -31,7 +28,7 @@ import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFo * @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 @@ -48,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 @@ -56,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 @@ -65,76 +62,4 @@ public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements return list; } - @Override - public BusinessBasicData findBasicDataById (final Long basicDataId) throws BasicCompanyDataNotFoundException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N - - // Get query - final Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N - - // Set parameter - query.setParameter("basicDataId", basicDataId); //NOI18N - - // Get single instance - final BusinessBasicData basicData; - - // Try to find a result - try { - // Find a single result - basicData = (BusinessBasicData) query.getSingleResult(); - - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: Found basicData={1}", this.getClass().getSimpleName(), basicData)); //NOI18N - } catch (final NoResultException ex) { - // No result found - throw new BasicCompanyDataNotFoundException(basicDataId, ex); - } - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBasicDataById: basicData={1} - EXIT!", this.getClass().getSimpleName(), basicData)); //NOI18N - - // Return it - return basicData; - } - - @Override - public Boolean isCompanyNameUsed (final String companyName) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isCompanyNameUsed: companyName={1} - CALLED!", this.getClass().getSimpleName(), companyName)); //NOI18N - - // Is the parameter valid? - if (null == companyName) { - // Throw NPE - throw new NullPointerException("companyName is null"); //NOI18N - } else if (companyName.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("companyName is empty"); //NOI18N - } - - // Default is not found - Boolean isCompanyNameUsed = Boolean.FALSE; - - // Get whole list - final List 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; - } - }