From 2c3b3b9a03be3f92a82ac4eb20c53295e3a34a32 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 17 Oct 2017 22:33:22 +0200 Subject: [PATCH] Please cherry-pick: - removed find*ById() method + fixed interface name(s) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AddressbookAdminEmployeeSessionBean.java | 4 +- .../AddressbookEmployeeSessionBean.java | 56 ++----------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java index b7e06d5..4aa191e 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java @@ -25,7 +25,7 @@ import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean; * @author Roland Häder */ @Stateless (name = "adminEmployee", description = "An administrative statless bean for handling company employees") -public class AddressbookAdminCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements AdminCompanyEmployeeSessionBeanRemote { +public class AddressbookAdminEmployeeSessionBean extends BaseAddressbookDatabaseBean implements AdminEmployeeSessionBeanRemote { /** * Serial number @@ -35,7 +35,7 @@ public class AddressbookAdminCompanyEmployeeSessionBean extends BaseAddressbookD /** * Default constructor */ - public AddressbookAdminCompanyEmployeeSessionBean () { + public AddressbookAdminEmployeeSessionBean () { super(); } diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java index a4c51b2..0c102b3 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookEmployeeSessionBean.java @@ -19,9 +19,7 @@ package org.mxchange.jcontactsbusiness.model.employee; import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; -import javax.persistence.NoResultException; import javax.persistence.Query; -import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException; import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean; /** @@ -30,7 +28,7 @@ import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean; * @author Roland Häder */ @Stateless (name = "employee", description = "A general statless bean for handling company employees") -public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDatabaseBean implements CompanyEmployeeSessionBeanRemote { +public class AddressbookEmployeeSessionBean extends BaseAddressbookDatabaseBean implements EmployeeSessionBeanRemote { /** * Serial number @@ -40,69 +38,27 @@ public class AddressbookCompanyEmployeeSessionBean extends BaseAddressbookDataba /** * Default constructor */ - public AddressbookCompanyEmployeeSessionBean () { + public AddressbookEmployeeSessionBean () { super(); } @Override @SuppressWarnings ("unchecked") - public List allCompanyEmployees () { + public List allEmployees () { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N // Get named query final Query query = this.getEntityManager().createNamedQuery("AllCompanyEmployees"); //NOI18N // Get list form it - final List employees = query.getResultList(); + final List employees = query.getResultList(); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCompanyEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N // Return it return employees; } - @Override - public Employee findCompanyEmployeeById (final Long employeeId) throws CompanyEmployeeNotFoundException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById(): employeeId={1} - CALLED!", this.getClass().getSimpleName(), employeeId)); //NOI18N - - // Is the employee id valid? - if (null == employeeId) { - // Throw NPE - throw new NullPointerException("employeeId is null"); //NOI18N - } else if (employeeId < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is not valid", employeeId)); //NOI18N - } - - // Now get named query - final Query query = this.getEntityManager().createNamedQuery("SearchCompanyEmployeeById"); //NOI18N - - // Set parameter - query.setParameter("employeeId", employeeId); //NOI18N - - // Declare instance - final Employee employee; - - // Try to find a result - try { - // Find a single result - employee = (Employee) query.getSingleResult(); - - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: Found employee={1}", this.getClass().getSimpleName(), employee)); //NOI18N - } catch (final NoResultException ex) { - // No result found - throw new CompanyEmployeeNotFoundException(employeeId, ex); - } - - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCompanyEmployeeById: employee={1} - EXIT!", this.getClass().getSimpleName(), employee)); //NOI18N - - // Return found instance - return employee; - } - } -- 2.39.5