/*
- * 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
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.branchoffice.BranchOfficeNotFoundException;
-import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
/**
* A stateless session bean for general branch office purposes
* @author Roland Häder<roland@mxchange.org>
*/
@Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)")
-public class JobsBranchOfficeSessionBean extends BaseJobsDatabaseBean implements BranchOfficeSessionBeanRemote {
+public class JobsBranchOfficeSessionBean extends BaseJobsEnterpriseBean implements BranchOfficeSessionBeanRemote {
/**
* Serial number
@Override
@SuppressWarnings ("unchecked")
- public List<BranchOffice> allBranchOffices () {
+ public List<BranchOffice> fetchAllBranchOffices () {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allBranchOffices: CALLED!", this.getClass().getSimpleName())); //NOI18N
return list;
}
- @Override
- public BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: CALLED!", this.getClass().getSimpleName())); //NOI18N
-
- // Validate parameter
- if (null == branchOfficeId) {
- // Throw NPE
- throw new NullPointerException("branchOfficeId is null"); //NOI18N
- } else if (branchOfficeId < 1) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("branchOfficeId={0}is invalid", branchOfficeId)); //NOI18N
- }
-
- // Get query
- final Query query = this.getEntityManager().createNamedQuery("SearchBranchOfficeById", CompanyBranchOffice.class); //NOI18N
-
- // Set parameter
- query.setParameter("branchOfficeId", branchOfficeId); //NOI18N
-
- // Get single instance
- final BranchOffice branchOffice;
-
- // Try to find a result
- try {
- // Find a single result
- branchOffice = (BranchOffice) query.getSingleResult();
-
- // Log trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: Found branchOffice={1}", this.getClass().getSimpleName(), branchOffice)); //NOI18N
- } catch (final NoResultException ex) {
- // No result found
- throw new BranchOfficeNotFoundException(branchOfficeId, ex);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: branchOffice={1} - EXIT!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
-
- // Return it
- return branchOffice;
- }
-
}