]> git.mxchange.org Git - jfinancials-ejb.git/blobdiff - src/java/org/mxchange/jcontactsbusiness/model/department/FinancialsDepartmentSessionBean.java
Please cherry-pick:
[jfinancials-ejb.git] / src / java / org / mxchange / jcontactsbusiness / model / department / FinancialsDepartmentSessionBean.java
index f88605e2d7d4789a74e050db15ef4d0e768668ee..1dbeb09fbda36b2c22144c281efd1b4f0693b5f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Roland Häder
+ * Copyright (C) 2017 - 2020 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
@@ -19,10 +19,8 @@ package org.mxchange.jcontactsbusiness.model.department;
 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.department.DepartmentNotFoundException;
-import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
+import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
 
 /**
  * A stateless session bean for general department purposes
@@ -30,16 +28,16 @@ import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean;
  * @author Roland Häder<roland@mxchange.org>
  */
 @Stateless (name = "department", description = "A general statless bean for handling branch office data (all)")
-public class FinancialsDepartmentSessionBean extends BaseFinancialsDatabaseBean implements DepartmentSessionBeanRemote {
+public class FinancialsDepartmentSessionBean extends BaseFinancialsEnterpriseBean implements DepartmentSessionBeanRemote {
 
        /**
         * Serial number
         */
-       private static final long serialVersionUID = 58_467_386_571_701L;
+       private static final long serialVersionUID = 58_467_386_571_704L;
 
        @Override
        @SuppressWarnings ("unchecked")
-       public List<Department> allDepartments () {
+       public List<Department> fetchAllDepartments () {
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allDepartments: CALLED!", this.getClass().getSimpleName())); //NOI18N
 
@@ -56,46 +54,4 @@ public class FinancialsDepartmentSessionBean extends BaseFinancialsDatabaseBean
                return list;
        }
 
-       @Override
-       public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
-               // Validate parameter
-               if (null == departmentId) {
-                       // Throw NPE
-                       throw new NullPointerException("departmentId is null"); //NOI18N
-               } else if (departmentId < 1) {
-                       // Throw NPE
-                       throw new NullPointerException(MessageFormat.format("departmentId={0}is invalid", departmentId)); //NOI18N
-               }
-
-               // Get query
-               final Query query = this.getEntityManager().createNamedQuery("SearchDepartmentById", CompanyDepartment.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("departmentId", departmentId); //NOI18N
-
-               // Get single instance
-               final Department department;
-
-               // Try to find a result
-               try {
-                       // Find a single result
-                       department = (Department) query.getSingleResult();
-
-                       // Log trace message
-                       this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: Found department={1}", this.getClass().getSimpleName(), department)); //NOI18N
-               } catch (final NoResultException ex) {
-                       // No result found
-                       throw new DepartmentNotFoundException(departmentId, ex);
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findDepartmentById: department={1} - EXIT!", this.getClass().getSimpleName(), department)); //NOI18N
-
-               // Return it
-               return department;
-       }
-
 }