From e96934e971ec3a885efe6626e5fb85dd74ecb893 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 17 Oct 2017 23:42:44 +0200 Subject: [PATCH] Please cherry-pick: - switched converters/validators which are converting primary keys (id numbers) into entities from EJB-based lookup to backing-bean-based lookup as this is much better performing (EJB calls are relative "expensive") - the backing bean will then check cache which is basically a distributed Map (Cache interface) where the primary key is also the key for cache entries - a SomeEntityNotFoundException is being thrown when containsKey() returns false which is then caught by the calling method - fixed imports from "renaming season" ;-) - renamed contactsCache -> contactCache as other caches are named same way - no need for company employee, basic data, branch offices and departments MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...ncialsAdminBusinessDataWebRequestBean.java | 28 ++-- .../FinancialsBusinessDataWebRequestBean.java | 63 ++++++--- ...cialsBusinessDataWebRequestController.java | 24 ++++ ...ncialsAdminBranchOfficeWebRequestBean.java | 20 +-- .../FinancialsBranchOfficeWebRequestBean.java | 22 +++ ...cialsBranchOfficeWebRequestController.java | 12 ++ ...nancialsAdminDepartmentWebRequestBean.java | 20 +-- .../FinancialsDepartmentWebRequestBean.java | 22 +++ ...ancialsDepartmentWebRequestController.java | 14 ++ ...FinancialsAdminEmployeeWebRequestBean.java | 29 ++-- .../FinancialsEmployeeWebRequestBean.java | 54 +++++--- ...inancialsEmployeeWebRequestController.java | 13 ++ .../FinancialsOpeningTimeWebRequestBean.java | 22 +++ ...ncialsOpeningTimeWebRequestController.java | 14 ++ .../FinancialsContactWebRequestBean.java | 47 +++++-- ...FinancialsContactWebRequestController.java | 23 ++++ ...ncialsAdminContactPhoneWebRequestBean.java | 4 +- .../FinancialsAdminCountryWebRequestBean.java | 18 +-- .../FinancialsCountryWebRequestBean.java | 24 +++- ...FinancialsCountryWebRequestController.java | 13 ++ .../FinancialsWebRequestHelperBean.java | 92 +++++++++++-- .../FinancialsLocalizationSessionBean.java | 20 ++- ...nancialsLocalizationSessionController.java | 9 ++ ...ialsAdminMobileProviderWebRequestBean.java | 2 +- ...inancialsMobileProviderWebRequestBean.java | 22 +++ ...alsMobileProviderWebRequestController.java | 14 ++ .../phone/FinancialsPhoneWebRequestBean.java | 128 +++++++++++++----- .../FinancialsPhoneWebRequestController.java | 34 +++++ .../user/FinancialsUserWebRequestBean.java | 47 ++++++- .../FinancialsUserWebRequestController.java | 25 +++- .../FinancialsBasicCompanyDataConverter.java | 28 ++-- .../FinancialsBranchOfficeConverter.java | 12 +- ...ava => FinancialsDepartmentConverter.java} | 16 +-- .../FinancialsEmployeeConverter.java} | 32 ++--- ...inancialsCompanyHeadquartersConverter.java | 13 +- ...FinancialsCompanyOpeningTimeConverter.java | 104 ++++++++++++++ .../contact/FinancialsContactConverter.java | 12 +- .../country/FinancialsCountryConverter.java | 32 ++--- .../fax/FinancialsFaxNumberConverter.java | 14 +- .../FinancialsLandLineNumberConverter.java | 14 +- .../FinancialsMobileNumberConverter.java | 14 +- .../FinancialsMobileProviderConverter.java | 39 ++---- .../user/FinancialsUserConverter.java | 14 +- .../FinancialsCompanyNameValidator.java | 14 +- .../FinancialsEmailAddressValidator.java | 14 +- .../user/FinancialsUserIdValidator.java | 14 +- .../localization/bundle_de_DE.properties | 4 +- .../localization/bundle_en_US.properties | 4 +- web/WEB-INF/links.jsf.taglib.xml | 2 +- .../admin_form_basic_company_data.tpl | 8 +- .../admin_form_branch_office_data.tpl | 10 +- .../department/admin_form_department_data.tpl | 8 +- .../employee/admin_form_employee_data.tpl | 4 +- .../admin_basic_company_data_list.xhtml | 10 +- .../admin_branch_office_list.xhtml | 6 +- .../department/admin_department_list.xhtml | 6 +- web/admin/employee/admin_employee_list.xhtml | 8 +- 57 files changed, 989 insertions(+), 346 deletions(-) rename src/java/org/mxchange/jfinancials/converter/business/department/{FinancialsCompanyDepartmentConverter.java => FinancialsDepartmentConverter.java} (81%) rename src/java/org/mxchange/jfinancials/converter/business/{company_employee/FinancialsCompanyEmployeeConverter.java => employee/FinancialsEmployeeConverter.java} (70%) create mode 100644 src/java/org/mxchange/jfinancials/converter/business/opening_time/FinancialsCompanyOpeningTimeConverter.java diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBusinessDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBusinessDataWebRequestBean.java index 3407f2c8..1c0760f7 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBusinessDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBusinessDataWebRequestBean.java @@ -25,11 +25,11 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.basicdata.added.AdminAddedBusinessBasicDataEvent; import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataAlreadyAddedException; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataAlreadyAddedException; import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.CompanyBasicData; -import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; @@ -74,7 +74,7 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea /** * An employee as contact person with this company */ - private Employee companyContactEmployee; + private Employable companyContactEmployee; /** * Companies (main) email address (example: info@company.example) @@ -84,7 +84,7 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea /** * Company founder */ - private Employee companyFounder; + private Employable companyFounder; /** * Head quarter data for this company @@ -165,7 +165,7 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea } // Prepare entity - BusinessBasicData basicData = new CompanyBasicData(this.getCompanyName()); + BasicData basicData = new BusinessBasicData(this.getCompanyName()); // Set all opther remaining data basicData.setCompanyComments(this.getCompanyComments()); @@ -228,11 +228,11 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea // Now try to send to EJB and get an updated version back try { // Try it - BusinessBasicData updatedBasicData = this.adminBasicCompanyDataBean.addCompanyBasicData(basicData); + final BasicData updatedBasicData = this.adminBasicCompanyDataBean.addBusinessBasicData(basicData); // Fire event this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData)); - } catch (final BasicCompanyDataAlreadyAddedException e) { + } catch (final BasicDataAlreadyAddedException e) { // Does already exist throw new FacesException(e); } @@ -262,18 +262,18 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea /** * Getter for employee as contact person *

- * @return Employee as contact person + * @return Employable as contact person */ - public Employee getCompanyContactEmployee () { + public Employable getCompanyContactEmployee () { return this.companyContactEmployee; } /** * Setter for employee as contact person *

- * @param companyContactEmployee Employee as contact person + * @param companyContactEmployee Employable as contact person */ - public void setCompanyContactEmployee (final Employee companyContactEmployee) { + public void setCompanyContactEmployee (final Employable companyContactEmployee) { this.companyContactEmployee = companyContactEmployee; } @@ -300,7 +300,7 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea *

* @return Company founder */ - public Employee getCompanyFounder () { + public Employable getCompanyFounder () { return this.companyFounder; } @@ -309,7 +309,7 @@ public class FinancialsAdminBusinessDataWebRequestBean extends BaseFinancialsBea *

* @param companyFounder Company founder */ - public void setCompanyFounder (final Employee companyFounder) { + public void setCompanyFounder (final Employable companyFounder) { this.companyFounder = companyFounder; } diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java index afab9ec8..913a2a39 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestBean.java @@ -30,9 +30,10 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController; @@ -60,14 +61,14 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp /** * List of all basic company data */ - private List allCompanyBasicData; + private List allBasicData; /** * A list of all registered companies (globally) */ @Inject @NamedCache (cacheName = "basicDataCache") - private Cache basicDataCache; + private Cache basicDataCache; /** * EJB for general basic business data purposes @@ -108,7 +109,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp /** * List of filtered basic company data */ - private List filteredBasicCompanyData; + private List filteredBasicCompanyData; /** * Area code for land-line number @@ -139,7 +140,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp super(); // Init list - this.allCompanyBasicData = new LinkedList<>(); + this.allBasicData = new LinkedList<>(); } /** @@ -172,7 +173,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp // Add it to list this.basicDataCache.put(event.getBasicData().getBasicDataId(), event.getBasicData()); - this.allCompanyBasicData.add(event.getBasicData()); + this.allBasicData.add(event.getBasicData()); } /** @@ -181,8 +182,29 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp * @return A list of all business contacts */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allCompanyBasicData () { - return this.allCompanyBasicData; + public List allBasicData () { + return this.allBasicData; + } + + @Override + public BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException { + // Validate parameter + if (null == basicDataId) { + // Throw NPE + throw new NullPointerException("basicDataId is null"); //NOI18N + } else if (basicDataId < 1) { + // Throw IAE + throw new IllegalArgumentException("basicDataId=" + basicDataId + " is invalid"); //NOI18N + } else if (!this.basicDataCache.containsKey(basicDataId)) { + // Not found + throw new BasicDataNotFoundException(basicDataId); + } + + // Get it from cache + final BasicData basicData = this.basicDataCache.get(basicDataId); + + // Return it + return basicData; } /** @@ -299,7 +321,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp * @return Filtered basic company data */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredBasicCompanyData () { + public List getFilteredBasicCompanyData () { return this.filteredBasicCompanyData; } @@ -309,7 +331,7 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp * @param filteredBasicCompanyData Filtered basic company data */ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredBasicCompanyData (final List filteredBasicCompanyData) { + public void setFilteredBasicCompanyData (final List filteredBasicCompanyData) { this.filteredBasicCompanyData = filteredBasicCompanyData; } @@ -375,39 +397,44 @@ public class FinancialsBusinessDataWebRequestBean extends BaseFinancialsBean imp // Is cache there? if (!this.basicDataCache.iterator().hasNext()) { // Get whole list - final List basicDatas = this.businessDataBean.allCompanyBasicData(); + final List basicDatas = this.businessDataBean.allBusinessBasicData(); // Add all - for (final BusinessBasicData basicData : basicDatas) { + for (final BasicData basicData : basicDatas) { // Add it to cache this.basicDataCache.put(basicData.getBasicDataId(), basicData); } } // Is cache there and list is not full? - if ((this.allCompanyBasicData.isEmpty()) && (this.basicDataCache.iterator().hasNext())) { + if ((this.allBasicData.isEmpty()) && (this.basicDataCache.iterator().hasNext())) { // Get iterator - final Iterator> iterator = this.basicDataCache.iterator(); + final Iterator> iterator = this.basicDataCache.iterator(); // Build up list while (iterator.hasNext()) { // GEt next element - final Cache.Entry next = iterator.next(); + final Cache.Entry next = iterator.next(); // Add to list - this.allCompanyBasicData.add(next.getValue()); + this.allBasicData.add(next.getValue()); } // Sort list - this.allCompanyBasicData.sort(new Comparator() { + this.allBasicData.sort(new Comparator() { @Override - public int compare (final BusinessBasicData o1, final BusinessBasicData o2) { + public int compare (final BasicData o1, final BasicData o2) { return o1.getBasicDataId() > o2.getBasicDataId() ? 1 : o1.getBasicDataId() < o2.getBasicDataId() ? -1 : 0; } }); } } + @Override + public Boolean isCompanyNameUsed (String companyName) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + /** * Clears this bean */ diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestController.java index 990aa91f..10492201 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsBusinessDataWebRequestController.java @@ -17,6 +17,8 @@ package org.mxchange.jfinancials.beans.business.basicdata; import java.io.Serializable; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An interface for session-scoped financial controller @@ -25,4 +27,26 @@ import java.io.Serializable; */ public interface FinancialsBusinessDataWebRequestController extends Serializable { + /** + * Retrieves a single business data entity for given id number or throws a + * proper exception if not found. + *

+ * @param basicDataId Company basic data id to lookup + *

+ * @return Business contact instance + *

+ * @throws BasicDataNotFoundException If the id number could not be + * looked up and solved into an entity + */ + BasicData findBasicDataById (final Long basicDataId) throws BasicDataNotFoundException; + + /** + * Checks whether given company name already exists + *

+ * @param companyName Company name to check + *

+ * @return Whether the company name exists + */ + Boolean isCompanyNameUsed (final String companyName); + } diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java index b8019540..b3a069e8 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java @@ -29,12 +29,10 @@ import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.branchoffice.added.BranchOfficeAddedEvent; import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent; import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; -import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; @@ -45,6 +43,8 @@ import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An administrative bean for branch offices @@ -74,12 +74,12 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea /** * Assigned company for this branch office */ - private BusinessBasicData branchCompany; + private BasicData branchCompany; /** * Contact person in branch office */ - private Employee branchContactEmployee; + private Employable branchContactEmployee; /** * Country @@ -308,7 +308,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea *

* @return Basic company data */ - public BusinessBasicData getBranchCompany () { + public BasicData getBranchCompany () { return this.branchCompany; } @@ -317,7 +317,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea *

* @param branchCompany Basic company data */ - public void setBranchCompany (final BusinessBasicData branchCompany) { + public void setBranchCompany (final BasicData branchCompany) { this.branchCompany = branchCompany; } @@ -326,7 +326,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea *

* @return Branch office contact person */ - public Employee getBranchContactEmployee () { + public Employable getBranchContactEmployee () { return this.branchContactEmployee; } @@ -335,7 +335,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea *

* @param branchContactEmployee Branch office contact person */ - public void setBranchContactEmployee (final Employee branchContactEmployee) { + public void setBranchContactEmployee (final Employable branchContactEmployee) { this.branchContactEmployee = branchContactEmployee; } @@ -748,7 +748,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea */ private BranchOffice createBranchOffice () { // Create new branch office instance - final BranchOffice branchOffice = new CompanyBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber()); + final BranchOffice branchOffice = new BusinessBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber()); // Add all other fields, too branchOffice.setBranchContactEmployee(this.getBranchContactEmployee()); diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java index 61210692..08c7a92c 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestBean.java @@ -30,6 +30,7 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; @@ -118,6 +119,27 @@ public class FinancialsBranchOfficeWebRequestBean extends BaseFinancialsBean imp return this.allBranchOffices; } + @Override + public BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException { + // Validate parameter + if (null == branchOfficeId) { + // Throw NPE + throw new NullPointerException("branchOfficeId is null"); //NOI18N + } else if (branchOfficeId < 1) { + // Throw IAE + throw new IllegalArgumentException("branchOfficeId=" + branchOfficeId + " is invalid"); //NOI18N + } else if (!this.branchOfficeCache.containsKey(branchOfficeId)) { + // Not found + throw new BranchOfficeNotFoundException(branchOfficeId); + } + + // Get it from cache + final BranchOffice branchOffice = this.branchOfficeCache.get(branchOfficeId); + + // Return it + return branchOffice; + } + /** * Getter for a list of filtered branch offices *

diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestController.java index b97fb75e..7aae1945 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsBranchOfficeWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.business.branchoffice; import java.io.Serializable; import java.util.List; +import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; /** @@ -34,4 +35,15 @@ public interface FinancialsBranchOfficeWebRequestController extends Serializable */ List allBranchOffices (); + /** + * Tries to find a branch office with given id number + *

+ * @param branchOfficeId Branch office id + *

+ * @return A branch office instance + *

+ * @throws BranchOfficeNotFoundException If the branch office was not found + */ + BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java index 5d248a35..81957206 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java @@ -26,16 +26,16 @@ import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.department.added.DepartmentAddedEvent; import org.mxchange.jcontactsbusiness.events.department.added.ObservableDepartmentAddedEvent; import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.AdminDepartmentSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.department.CompanyDepartment; +import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.department.Departments; -import org.mxchange.jcontactsbusiness.model.employee.Employee; import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; /** * An administrative bean for departments @@ -72,7 +72,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean /** * Assigned company for this department */ - private BusinessBasicData departmentCompany; + private BasicData departmentCompany; /** * A general department controller (backing bean) @@ -88,7 +88,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean /** * Lead person of this department */ - private Employee departmentLead; + private Employable departmentLead; /** * Department name @@ -168,7 +168,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean *

* @return Basic company data */ - public BusinessBasicData getDepartmentCompany () { + public BasicData getDepartmentCompany () { return this.departmentCompany; } @@ -177,7 +177,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean *

* @param departmentCompany Basic company data */ - public void setDepartmentCompany (final BusinessBasicData departmentCompany) { + public void setDepartmentCompany (final BasicData departmentCompany) { this.departmentCompany = departmentCompany; } @@ -204,7 +204,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean *

* @return Department contact person */ - public Employee getDepartmentLead () { + public Employable getDepartmentLead () { return this.departmentLead; } @@ -213,7 +213,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean *

* @param departmentLead Department contact person */ - public void setDepartmentLead (final Employee departmentLead) { + public void setDepartmentLead (final Employable departmentLead) { this.departmentLead = departmentLead; } @@ -262,7 +262,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean */ private Department createDepartment () { // Create new department instance - final Department department = new CompanyDepartment(this.getDepartmentCompany(), this.getDepartmentI18nKey()); + final Department department = new BusinessDepartment(this.getDepartmentCompany(), this.getDepartmentI18nKey()); // Add all optional fields department.setDepartmentHeadquarters(this.getDepartmentHeadquarters()); diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java index da0b7f22..d308404f 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java @@ -30,6 +30,7 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.department.added.ObservableDepartmentAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; @@ -118,6 +119,27 @@ public class FinancialsDepartmentWebRequestBean extends BaseFinancialsBean imple return this.allDepartments; } + @Override + public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException { + // Validate parameter + if (null == departmentId) { + // Throw NPE + throw new NullPointerException("departmentId is null"); //NOI18N + } else if (departmentId < 1) { + // Throw IAE + throw new IllegalArgumentException("departmentId=" + departmentId + " is invalid"); //NOI18N + } else if (!this.departmentCache.containsKey(departmentId)) { + // Not found + throw new DepartmentNotFoundException(departmentId); + } + + // Get it from cache + final Department department = this.departmentCache.get(departmentId); + + // Return it + return department; + } + /** * Getter for a list of filtered departments *

diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestController.java index 8ff2f6ab..0825c3a6 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.business.department; import java.io.Serializable; import java.util.List; +import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException; import org.mxchange.jcontactsbusiness.model.department.Department; /** @@ -34,4 +35,17 @@ public interface FinancialsDepartmentWebRequestController extends Serializable { */ List allDepartments (); + /** + * Retrieves a single company department entity for given id number or + * throws a proper exception if not found. + *

+ * @param departmentId Company department id to lookup + *

+ * @return Company department instance + *

+ * @throws DepartmentNotFoundException If the id number could not be + * looked up and solved into an entity + */ + Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java index 1cb977ad..186da77f 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java @@ -24,17 +24,18 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.events.employee.added.ObservableEmployeeAddedEvent; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.employee.AdminEmployeeSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.model.user.User; /** - * A request-scoped bean for administrative purposes for company employees. + * A request-scoped bean for administrative purposes for administrative employee + * purposes. *

* @author Roland Häder */ @@ -57,18 +58,18 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im /** * EJB for administrative company employee purposes */ - @EJB (lookup = "java:global/jfinancials-ejb/adminEmployee!org.mxchange.jcontactsbusiness.model.employee.AdminCompanyEmployeeSessionBeanRemote") - private AdminCompanyEmployeeSessionBeanRemote adminEmployeeBean; + @EJB (lookup = "java:global/jfinancials-ejb/adminEmployee!org.mxchange.jcontactsbusiness.model.employee.AdminEmployeeSessionBeanRemote") + private AdminEmployeeSessionBeanRemote adminEmployeeBean; /** - * Assigned branch office + * Assigned basic data instance */ - private BranchOffice employeeBranchOffice; + private BasicData employeeBasicData; /** - * Assigned basic data instance + * Assigned branch office */ - private BusinessBasicData employeeCompany; + private BranchOffice employeeBranchOffice; /** * Department where employee works (alternative to headquarters) @@ -146,17 +147,17 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im *

* @return Employee's assigned basic company data */ - public BusinessBasicData getEmployeeCompany () { - return this.employeeCompany; + public BasicData getEmployeeCompany () { + return this.employeeBasicData; } /** * Setter for employee's assigned basic company data *

- * @param employeeCompany Employee's assigned basic company data + * @param employeeBasicData Employee's assigned basic company data */ - public void setEmployeeCompany (final BusinessBasicData employeeCompany) { - this.employeeCompany = employeeCompany; + public void setEmployeeCompany (final BasicData employeeBasicData) { + this.employeeBasicData = employeeBasicData; } /** diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java index 49621af2..0cdbca49 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestBean.java @@ -30,8 +30,9 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.employee.added.ObservableEmployeeAddedEvent; -import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; /** @@ -51,25 +52,25 @@ public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean impleme /** * List of all employees */ - private final List allEmployees; + private final List allEmployees; /** * EJB for general company employee purposes */ - @EJB (lookup = "java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote") - private CompanyEmployeeSessionBeanRemote employeeBean; + @EJB (lookup = "java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote") + private EmployeeSessionBeanRemote employeeBean; /** * List of all company employees */ @Inject @NamedCache (cacheName = "companyEmployeeCache") - private Cache employeeCache; + private Cache employeeCache; /** * A list of filtered employees */ - private List filteredEmployees; + private List filteredEmployees; /** * Default constructor @@ -114,17 +115,38 @@ public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean impleme * @return List of all company employees */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allCompanyEmployees () { + public List allEmployees () { return this.allEmployees; } + @Override + public Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException { + // Validate parameter + if (null == employeeId) { + // Throw NPE + throw new NullPointerException("employeeId is null"); //NOI18N + } else if (employeeId < 1) { + // Throw IAE + throw new IllegalArgumentException("employeeId=" + employeeId + " is invalid"); //NOI18N + } else if (!this.employeeCache.containsKey(employeeId)) { + // Not found + throw new EmployeeNotFoundException(employeeId); + } + + // Get it from cache + final Employable employee = this.employeeCache.get(employeeId); + + // Return it + return employee; + } + /** * Getter for filtered list of employees *

* @return Filtered list of employees */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredEmployees () { //NOI18N + public List getFilteredEmployees () { //NOI18N return this.filteredEmployees; } @@ -134,7 +156,7 @@ public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean impleme * @param filteredEmployees Filtered list of employees */ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredEmployees (final List filteredEmployees) { //NOI18N + public void setFilteredEmployees (final List filteredEmployees) { //NOI18N this.filteredEmployees = filteredEmployees; } @@ -146,10 +168,10 @@ public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean impleme // Is cache there? if (!this.employeeCache.iterator().hasNext()) { // Get whole list - final List employees = this.employeeBean.allCompanyEmployees(); + final List employees = this.employeeBean.allEmployees(); // Add all - for (final Employee employee : employees) { + for (final Employable employee : employees) { // Add it to cache this.employeeCache.put(employee.getEmployeeId(), employee); } @@ -158,21 +180,21 @@ public class FinancialsEmployeeWebRequestBean extends BaseFinancialsBean impleme // Is cache filled and list is empty if ((this.employeeCache.iterator().hasNext()) && (this.allEmployees.isEmpty())) { // Get iterator - final Iterator> iterator = this.employeeCache.iterator(); + final Iterator> iterator = this.employeeCache.iterator(); // Build up list while (iterator.hasNext()) { // GEt next element - final Cache.Entry next = iterator.next(); + final Cache.Entry next = iterator.next(); // Add to list this.allEmployees.add(next.getValue()); } // Sort list - this.allEmployees.sort(new Comparator() { + this.allEmployees.sort(new Comparator() { @Override - public int compare (final Employee o1, final Employee o2) { + public int compare (final Employable o1, final Employable o2) { return o1.getEmployeeId() > o2.getEmployeeId() ? 1 : o1.getEmployeeId() < o2.getEmployeeId() ? -1 : 0; } }); diff --git a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java index e56f6fb5..ba07d24d 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsEmployeeWebRequestController.java @@ -17,6 +17,8 @@ package org.mxchange.jfinancials.beans.business.employee; import java.io.Serializable; +import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; /** * An interface for request-scoped general company employee beans @@ -25,4 +27,15 @@ import java.io.Serializable; */ public interface FinancialsEmployeeWebRequestController extends Serializable { + /** + * Finds a company employee by given employee id + *

+ * @param employeeId Employable id to find company employee instance for + *

+ * @return Company employee instance + *

+ * @throws EmployeeNotFoundException If the company employee was not found + */ + Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestBean.java index c5d8382e..7f0ef7c1 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestBean.java @@ -30,6 +30,7 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.events.opening_time.added.ObservableOpeningTimeAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; @@ -114,6 +115,27 @@ public class FinancialsOpeningTimeWebRequestBean extends BaseFinancialsBean impl return this.allOpeningTimes; } + @Override + public OpeningTime findOpeningTimeById (final Long openingId) throws OpeningTimeNotFoundException { + // Validate parameter + if (null == openingId) { + // Throw NPE + throw new NullPointerException("openingId is null"); //NOI18N + } else if (openingId < 1) { + // Throw IAE + throw new IllegalArgumentException("openingId=" + openingId + " is invalid"); //NOI18N + } else if (!this.openingTimesCache.containsKey(openingId)) { + // Not found + throw new OpeningTimeNotFoundException(openingId); + } + + // Get it from cache + final OpeningTime opening = this.openingTimesCache.get(openingId); + + // Return it + return opening; + } + /** * Getter for a list of filtered opening times *

diff --git a/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestController.java index 442b1532..5a5e060b 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsOpeningTimeWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.business.opening_time; import java.io.Serializable; import java.util.List; +import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; /** @@ -34,4 +35,17 @@ public interface FinancialsOpeningTimeWebRequestController extends Serializable */ List allOpeningTimes (); + /** + * Retrieves a single company department entity for given id number or + * throws a proper exception if not found. + *

+ * @param openingId Company department id to lookup + *

+ * @return Company department instance + *

+ * @throws OpeningTimeNotFoundException If the id number could not be looked + * up and solved into an entity + */ + OpeningTime findOpeningTimeById (final Long openingId) throws OpeningTimeNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java index f91ba1a6..334a4324 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java @@ -33,6 +33,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.model.contact.ContactUtils; @@ -101,8 +102,8 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen * Contact list */ @Inject - @NamedCache (cacheName = "contactsCache") - private Cache contactsCache; + @NamedCache (cacheName = "contactCache") + private Cache contactCache; /** * Country instance @@ -454,7 +455,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen final List list = new LinkedList<>(); // Get iterator - final Iterator> iterator = this.contactsCache.iterator(); + final Iterator> iterator = this.contactCache.iterator(); // Loop over all while (iterator.hasNext()) { @@ -615,6 +616,27 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen return "contact_data_saved"; //NOI18N } + @Override + public Contact findContactById (final Long contactId) throws ContactNotFoundException { + // Validate parameter + if (null == contactId) { + // Throw NPE + throw new NullPointerException("contactId is null"); //NOI18N + } else if (contactId < 1) { + // Throw IAE + throw new IllegalArgumentException("contactId=" + contactId + " is invalid"); //NOI18N + } else if (!this.contactCache.containsKey(contactId)) { + // Not found + throw new ContactNotFoundException(contactId); + } + + // Get it from cache + final Contact contact = this.contactCache.get(contactId); + + // Return it + return contact; + } + /** * Getter for academic title *

@@ -1027,14 +1049,14 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen @PostConstruct public void init () { // Is cache there? - if (!this.contactsCache.iterator().hasNext()) { + if (!this.contactCache.iterator().hasNext()) { // Get whole list final List contacts = this.contactBean.allContacts(); // Add all for (final Contact contact : contacts) { // Add it to cache - this.contactsCache.put(contact.getContactId(), contact); + this.contactCache.put(contact.getContactId(), contact); this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress()); } } else if (this.selectableContactsCache.iterator().hasNext()) { @@ -1046,7 +1068,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen final List allUsers = this.userController.allUsers(); // Get iterator from contacts cache - final Iterator> iterator = this.contactsCache.iterator(); + final Iterator> iterator = this.contactCache.iterator(); // Loop through all contacts while (iterator.hasNext()) { @@ -1092,6 +1114,11 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen return ((this.emailAddressCache instanceof List) && (this.emailAddressCache.containsKey(contact.getContactId()))); } + @Override + public boolean isEmailAddressRegistered (String emailAddress) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public boolean isRequiredChangePersonalDataSet () { return ((this.getPersonalTitle() != null) && @@ -1132,7 +1159,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen final List selectableContacts = new LinkedList<>(); // Get iterator from cache - final Iterator> iterator = this.contactsCache.iterator(); + final Iterator> iterator = this.contactCache.iterator(); // Loop through all contacts while (iterator.hasNext()) { @@ -1291,7 +1318,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen } // Remove from general list - if (!this.contactsCache.remove(contact.getContactId())) { + if (!this.contactCache.remove(contact.getContactId())) { // Did not remove contact throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N } @@ -1320,7 +1347,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen } // Get iterator from list - final Iterator> iterator = this.contactsCache.iterator(); + final Iterator> iterator = this.contactCache.iterator(); // "Walk" through all entries while (iterator.hasNext()) { @@ -1336,7 +1363,7 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen } // Add contact to list - this.contactsCache.put(contact.getContactId(), contact); + this.contactCache.put(contact.getContactId(), contact); } } diff --git a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestController.java index f323378f..2d486bf1 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.contact; import java.io.Serializable; import java.util.List; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; /** @@ -120,4 +121,26 @@ public interface FinancialsContactWebRequestController extends Serializable { */ String doChangePersonalContactData (); + /** + * Returns a contact instance which has the given id number. + *

+ * @param contactId Contact id + *

+ * @return Contact instance + *

+ * @throws ContactNotFoundException If the contact was not found + */ + Contact findContactById (final Long contactId) throws ContactNotFoundException; + + /** + * Checks whether the given email address is already registered. The email + * address should be validated by EmailAddressValidator before calling this + * method. + *

+ * @param emailAddress Email address to check + *

+ * @return Whether the email address is already registered + */ + boolean isEmailAddressRegistered (final String emailAddress); + } diff --git a/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java index 767ed93f..fe61c992 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java @@ -48,8 +48,8 @@ import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestContro import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; -import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException; -import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException; +import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException; +import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; diff --git a/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java index 78d48e96..fcc196b4 100644 --- a/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java @@ -26,12 +26,12 @@ import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcountry.events.AdminAddedCountryEvent; -import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; +import org.mxchange.jcountry.events.added.AdminAddedCountryEvent; +import org.mxchange.jcountry.events.added.ObservableAdminAddedCountryEvent; import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; +import org.mxchange.jcountry.model.data.AdminCountrySessionBeanRemote; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountryData; -import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; /** @@ -56,15 +56,15 @@ public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsBean imp private Event addedCountryEvent; /** - * Abroad dial prefix + * Remote country EJB */ - private String countryAbroadDialPrefix; + @EJB (lookup = "java:global/jfinancials-ejb/adminCountry!org.mxchange.jcountry.model.data.AdminCountrySessionBeanRemote") + private AdminCountrySessionBeanRemote adminCountryBean; /** - * Remote country EJB + * Abroad dial prefix */ - @EJB (lookup = "java:global/jfinancials-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote") - private CountrySingletonBeanRemote countryBean; + private String countryAbroadDialPrefix; /** * 2-letter country code @@ -136,7 +136,7 @@ public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsBean imp try { // Send country to bean - updatedCountry = this.countryBean.addCountry(country); + updatedCountry = this.adminCountryBean.addCountry(country); } catch (final CountryAlreadyAddedException ex) { // Throw again throw new FaceletException(ex); diff --git a/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestBean.java index 62db3b85..9d3d7650 100644 --- a/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestBean.java @@ -28,7 +28,8 @@ import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; +import org.mxchange.jcountry.events.added.ObservableAdminAddedCountryEvent; +import org.mxchange.jcountry.exceptions.CountryNotFoundException; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsBean; @@ -116,6 +117,27 @@ public class FinancialsCountryWebRequestBean extends BaseFinancialsBean implemen return list; } + @Override + public Country findCountryById (final Long countryId) throws CountryNotFoundException { + // Validate parameter + if (null == countryId) { + // Throw NPE + throw new NullPointerException("countryId is null"); //NOI18N + } else if (countryId < 1) { + // Throw IAE + throw new IllegalArgumentException("countryId=" + countryId + " is invalid"); //NOI18N + } else if (!this.countryCache.containsKey(countryId)) { + // Not found + throw new CountryNotFoundException(countryId); + } + + // Get it from cache + final Country country = this.countryCache.get(countryId); + + // Return it + return country; + } + /** * Post-construction method */ diff --git a/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestController.java index f85f0557..de2e8724 100644 --- a/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.country; import java.io.Serializable; import java.util.List; +import org.mxchange.jcountry.exceptions.CountryNotFoundException; import org.mxchange.jcountry.model.data.Country; /** @@ -34,4 +35,16 @@ public interface FinancialsCountryWebRequestController extends Serializable { */ List allCountries (); + /** + * Returns a country instance found by given primary key. If not found, a + * proper exception is thrown. + *

+ * @param countryId Primary key + *

+ * @return Country data instance + *

+ * @throws CountryNotFoundException If the primary key was not found + */ + public Country findCountryById (final Long countryId) throws CountryNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java index 776b24a1..674b63f8 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java @@ -27,10 +27,11 @@ import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEve import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.employee.Employee; import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController; import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController; +import org.mxchange.jfinancials.model.receipt.BillableReceipt; import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent; import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent; @@ -40,9 +41,11 @@ import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEv import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jproduct.model.product.Product; import org.mxchange.jusercore.events.user.created.CreatedUserEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.model.user.User; +import org.mxchange.jcontactsbusiness.model.employee.Employable; /** * A general helper for beans @@ -53,11 +56,6 @@ import org.mxchange.jusercore.model.user.User; @RequestScoped public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implements FinancialsWebRequestHelperController { - /** - * Call-stack instance (5 may show BeanELResolver.getValue as caller) - */ - private static final short THREAD_STACK = 5; - /** * Serial number */ @@ -99,6 +97,12 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement @Inject private Event landLineNumberCreatedEvent; + /** + * Localization controller + */ + @Inject + private FinancialsLocalizationSessionController localizationController; + /** * Mobile number */ @@ -152,8 +156,6 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement * @param contact Contact instance */ public void setContact (final Contact contact) { - // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName()); - // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller)); this.contact = contact; } @@ -524,16 +526,16 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement * Returns the employee's number, personal title, family name and name if * available. If null is provided, an empty string is returned. *

- * @param employee Employee instance - *

+ * @param employee Employable instance +

* @return Contact's full name */ - public String renderEmployee (final Employee employee) { + public String renderEmployee (final Employable employee) { // Default is empty string, so let's get started final StringBuilder sb = new StringBuilder(20); // Is employee set? - if (employee instanceof Employee) { + if (employee instanceof Employable) { // Then create name sb.append(employee.getEmployeeNumber()); @@ -565,12 +567,12 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement } /** - * Returns the headquarters' address. If null is provided, an empty string - * is returned. + * Returns the headquarters address. If null is provided, an empty string is + * returned. *

* @param headquarters Headquarters instance *

- * @return Headquarters' address + * @return Headquarters address */ public String renderHeadquarters (final HeadquartersData headquarters) { // Default is empty string, so let's get started @@ -609,6 +611,66 @@ public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implement return sb.toString(); } + /** + * Returns the product name and price. If null is provided, an empty string + * is returned. + *

+ * @param product Product instance + *

+ * @return Product name + */ + public String renderProduct (final Product product) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(10); + + // Is a product set? + if (product instanceof Product) { + // Add name and price + sb.append(product.getProductTitle()); + sb.append(" ("); //NOI18N + sb.append(this.localizationController.formatCurrency(product.getProductPrice())); + sb.append(")"); //NOI18N + } + + // Return it + return sb.toString(); + } + + /** + * Returns the receipt. If null is provided, an empty string + * is returned. + *

+ * @param receipt Receipt instance + *

+ * @return Product name + */ + public String renderReceipt (final BillableReceipt receipt) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(10); + + // Is receipt set? + if (receipt instanceof BillableReceipt) { + // Add relevant data + sb.append(this.getMessageFromBundle("RECEIPT_ISSUED")).append(" "); //NOI18N + sb.append(this.getMessageFromBundle(receipt.getReceiptPaymentType().getI18nKey())); + + // Is receipt number included? + if (receipt.getReceiptNumber() !=null) { + // Append it + sb.append(", ").append(this.getMessageFromBundle("RECEIPT_NUMBER")).append(" "); //NOI18N + sb.append(receipt.getReceiptNumber()); + } + + // Add company (over branch office) + sb.append(" ("); //NOI18N + sb.append(receipt.getReceiptBranchOffice().getBranchCompany().getCompanyName()); + sb.append(")"); //NOI18N + } + + // Return it + return sb.toString(); + } + /** * Set's all given contact's phone instances: land-line, mobile and * faxNumber diff --git a/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java index 953909bf..5d7c55fe 100644 --- a/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.jfinancials.beans.localization; import java.text.MessageFormat; +import java.text.NumberFormat; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Locale; @@ -48,6 +49,11 @@ import org.mxchange.juserlogincore.events.logout.ObservableUserLogoutEvent; @SessionScoped public class FinancialsLocalizationSessionBean extends BaseFinancialsBean implements FinancialsLocalizationSessionController { + /** + * Number format + */ + private static NumberFormat NUMBER_FORMAT; + /** * Serial number */ @@ -82,7 +88,7 @@ public class FinancialsLocalizationSessionBean extends BaseFinancialsBean implem // Call super constructor super(); - // Init list + // Init locale list this.supportedLocales = new LinkedHashMap<>(2); } @@ -181,6 +187,15 @@ public class FinancialsLocalizationSessionBean extends BaseFinancialsBean implem // Then change it this.changeLocale(newLocale, Boolean.TRUE); + + // Change formatting + NUMBER_FORMAT = NumberFormat.getNumberInstance(newLocale); + } + + @Override + public String formatCurrency (final Float amount) { + // Format amount + return NUMBER_FORMAT.format(amount); } /** @@ -285,6 +300,9 @@ public class FinancialsLocalizationSessionBean extends BaseFinancialsBean implem // Change locale, may set same back in faces context, but triggers event this.changeLocale(requestLocale, Boolean.FALSE); + + // Initial formatting, may change when user chooses other locale + NUMBER_FORMAT = NumberFormat.getNumberInstance(this.locale); } /** diff --git a/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionController.java b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionController.java index 9b84d0d6..a273f888 100644 --- a/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionController.java +++ b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionController.java @@ -25,4 +25,13 @@ import java.io.Serializable; */ public interface FinancialsLocalizationSessionController extends Serializable { + /** + * Formats a float into a currency, depending on current locale + *

+ * @param amount Amount (price) to format + *

+ * @return Formatted string + */ + String formatCurrency (final Float amount); + } diff --git a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java index 1e10d8b2..e48b4b6c 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java @@ -30,7 +30,7 @@ import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent; -import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; +import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderAlreadyAddedException; import org.mxchange.jphone.model.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote; import org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; diff --git a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java index f1b0a41a..40a0b196 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java @@ -31,6 +31,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; +import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote; @@ -116,6 +117,27 @@ public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsBean i return this.allMobileProviders; } + @Override + public MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException { + // Validate parameter + if (null == mobileProviderId) { + // Throw NPE + throw new NullPointerException("mobileProviderId is null"); //NOI18N + } else if (mobileProviderId < 1) { + // Throw IAE + throw new IllegalArgumentException("mobileProviderId=" + mobileProviderId + " is invalid."); //NOI18N + } else if (!this.mobileProviderCache.containsKey(mobileProviderId)) { + // Not found + throw new MobileProviderNotFoundException(mobileProviderId); + } + + // Get it from cache + final MobileProvider mobileProvider = this.mobileProviderCache.get(mobileProviderId); + + // Return it + return mobileProvider; + } + /** * Getter for filtered mobile provider list *

diff --git a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestController.java index b222c50e..778a8bf8 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.mobileprovider; import java.io.Serializable; import java.util.List; +import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; /** @@ -27,6 +28,19 @@ import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; */ public interface FinancialsMobileProviderWebRequestController extends Serializable { + /** + * Returns a mobile provider instance by given primary key. If not found, a + * proper exception is thrown. + *

+ * @param mobileProviderId Primary key + *

+ * @return Mobile provider instance + *

+ * @throws MobileProviderNotFoundException If the primary key could not be + * found + */ + MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException; + /** * Returns a list of all mobile providers *

diff --git a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestBean.java index 30b1c68e..fe8d6359 100644 --- a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestBean.java @@ -42,6 +42,7 @@ import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEve import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent; import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent; import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent; +import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; @@ -254,25 +255,25 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements throw new NullPointerException("event is null"); //NOI18N } else if (event.getContact() == null) { // Throw again ... - throw new NullPointerException("event.contact is null"); + throw new NullPointerException("event.contact is null"); //NOI18N } else if (event.getContact().getContactId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactId is null"); + throw new NullPointerException("event.contact.contactId is null"); //NOI18N } else if (event.getContact().getContactId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); + throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N } else if (event.getContact().getContactFaxNumber() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactFaxNumber is null"); + throw new NullPointerException("event.contact.contactFaxNumber is null"); //NOI18N } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); + throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); //NOI18N } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactFaxNumber.phoneId=" + event.getContact().getContactFaxNumber().getPhoneId() + " is invalid"); + throw new NullPointerException("event.contact.contactFaxNumber.phoneId=" + event.getContact().getContactFaxNumber().getPhoneId() + " is invalid"); //NOI18N } else if (event.getLinkedFaxNumber() == null) { // Throw again ... - throw new NullPointerException("event.linkedFaxNumer is null"); + throw new NullPointerException("event.linkedFaxNumer is null"); //NOI18N } // Is the id number in linked number not set? @@ -295,25 +296,25 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements throw new NullPointerException("event is null"); //NOI18N } else if (event.getContact() == null) { // Throw again ... - throw new NullPointerException("event.contact is null"); + throw new NullPointerException("event.contact is null"); //NOI18N } else if (event.getContact().getContactId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactId is null"); + throw new NullPointerException("event.contact.contactId is null"); //NOI18N } else if (event.getContact().getContactId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); + throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N } else if (event.getContact().getContactLandLineNumber() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactLandLineNumber is null"); + throw new NullPointerException("event.contact.contactLandLineNumber is null"); //NOI18N } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); + throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); //NOI18N } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactLandLineNumber.phoneId=" + event.getContact().getContactLandLineNumber().getPhoneId() + " is invalid"); + throw new NullPointerException("event.contact.contactLandLineNumber.phoneId=" + event.getContact().getContactLandLineNumber().getPhoneId() + " is invalid"); //NOI18N } else if (event.getLinkedLandLineNumber() == null) { // Throw again ... - throw new NullPointerException("event.linkedLandLineNumer is null"); + throw new NullPointerException("event.linkedLandLineNumer is null"); //NOI18N } // Is the id number in linked number not set? @@ -336,25 +337,25 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements throw new NullPointerException("event is null"); //NOI18N } else if (event.getContact() == null) { // Throw again ... - throw new NullPointerException("event.contact is null"); + throw new NullPointerException("event.contact is null"); //NOI18N } else if (event.getContact().getContactId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactId is null"); + throw new NullPointerException("event.contact.contactId is null"); //NOI18N } else if (event.getContact().getContactId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); + throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N } else if (event.getContact().getContactMobileNumber() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactMobileNumber is null"); + throw new NullPointerException("event.contact.contactMobileNumber is null"); //NOI18N } else if (event.getContact().getContactMobileNumber().getPhoneId() == null) { // Throw again ... - throw new NullPointerException("event.contact.contactMobileNumber.phoneId is null"); + throw new NullPointerException("event.contact.contactMobileNumber.phoneId is null"); //NOI18N } else if (event.getContact().getContactMobileNumber().getPhoneId() < 1) { // Throw again ... - throw new NullPointerException("event.contact.contactMobileNumber.phoneId=" + event.getContact().getContactMobileNumber().getPhoneId() + " is invalid"); + throw new NullPointerException("event.contact.contactMobileNumber.phoneId=" + event.getContact().getContactMobileNumber().getPhoneId() + " is invalid"); //NOI18N } else if (event.getLinkedMobileNumber() == null) { // Throw again ... - throw new NullPointerException("event.linkedMobileNumer is null"); + throw new NullPointerException("event.linkedMobileNumer is null"); //NOI18N } // Is the id number in linked number not set? @@ -546,6 +547,69 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements return list; } + @Override + public DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException { + // Validate paramter + if (null == faxNumberId) { + // Throw NPE + throw new NullPointerException("faxNumberId is null"); //NOI18N + } else if (faxNumberId < 1) { + // Throw IAE + throw new IllegalArgumentException("faxNumberId=" + faxNumberId + " is invalid."); //NOI18N + } else if (!this.faxNumberCache.containsKey(faxNumberId)) { + // Not found + throw new PhoneEntityNotFoundException(faxNumberId); + } + + // Get it from cache + final DialableFaxNumber faxNumber = this.faxNumberCache.get(faxNumberId); + + // Return it + return faxNumber; + } + + @Override + public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException { + // Validate paramter + if (null == landLineNumberId) { + // Throw NPE + throw new NullPointerException("landLineNumberId is null"); //NOI18N + } else if (landLineNumberId < 1) { + // Throw IAE + throw new IllegalArgumentException("landLineNumberId=" + landLineNumberId + " is invalid."); //NOI18N + } else if (!this.landLineNumberCache.containsKey(landLineNumberId)) { + // Not found + throw new PhoneEntityNotFoundException(landLineNumberId); + } + + // Get it from cache + final DialableLandLineNumber landLineNumber = this.landLineNumberCache.get(landLineNumberId); + + // Return it + return landLineNumber; + } + + @Override + public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException { + // Validate paramter + if (null == mobileNumberId) { + // Throw NPE + throw new NullPointerException("mobileNumberId is null"); //NOI18N + } else if (mobileNumberId < 1) { + // Throw IAE + throw new IllegalArgumentException("mobileNumberId=" + mobileNumberId + " is invalid."); //NOI18N + } else if (!this.mobileNumberCache.containsKey(mobileNumberId)) { + // Not found + throw new PhoneEntityNotFoundException(mobileNumberId); + } + + // Get it from cache + final DialableMobileNumber mobileNumber = this.mobileNumberCache.get(mobileNumberId); + + // Return it + return mobileNumber; + } + /** * Post-construction method */ @@ -605,13 +669,13 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements // Make sure the parameter is valid if (null == faxNumber) { // Throw NPE - throw new NullPointerException("faxNumber is null"); + throw new NullPointerException("faxNumber is null"); //NOI18N } else if (faxNumber.getPhoneId() == null) { // Throw again ... - throw new NullPointerException("faxNumber.phoneId is null"); + throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N } else if (faxNumber.getPhoneId() < 1) { // Not valid - throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); //NOI18N } // First remove it @@ -641,13 +705,13 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements // Make sure the parameter is valid if (null == landLineNumber) { // Throw NPE - throw new NullPointerException("landLineNumber is null"); + throw new NullPointerException("landLineNumber is null"); //NOI18N } else if (landLineNumber.getPhoneId() == null) { // Throw again ... - throw new NullPointerException("landLineNumber.phoneId is null"); + throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N } else if (landLineNumber.getPhoneId() < 1) { // Not valid - throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); //NOI18N } // First remove it @@ -677,13 +741,13 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements // Make sure the parameter is valid if (null == mobileNumber) { // Throw NPE - throw new NullPointerException("mobileNumber is null"); + throw new NullPointerException("mobileNumber is null"); //NOI18N } else if (mobileNumber.getPhoneId() == null) { // Throw again ... - throw new NullPointerException("mobileNumber.phoneId is null"); + throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N } else if (mobileNumber.getPhoneId() < 1) { // Not valid - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid.", mobileNumber.getPhoneId())); + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid.", mobileNumber.getPhoneId())); //NOI18N } // First remove it by object @@ -712,10 +776,10 @@ public class FinancialsPhoneWebRequestBean extends BaseFinancialsBean implements // Parameter must be valid if (null == contact) { // Throw NPE - throw new NullPointerException("contact is null"); + throw new NullPointerException("contact is null"); //NOI18N } else if (contact.getContactId() == null) { // Throw again - throw new NullPointerException("contact.contactId is null"); + throw new NullPointerException("contact.contactId is null"); //NOI18N } else if (contact.getContactId() < 1) { // Id number is not valid } diff --git a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestController.java index 42ceaa9b..194448c5 100644 --- a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsPhoneWebRequestController.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.beans.phone; import java.io.Serializable; import java.util.List; +import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; @@ -60,4 +61,37 @@ public interface FinancialsPhoneWebRequestController extends Serializable { */ List allLandLineNumbers (); + /** + * Finds a fax entry by given id number + *

+ * @param faxNumberId Fax entry id number + *

+ * @return A valid fax instance + *

+ * @throws PhoneEntityNotFoundException If the entity was not found + */ + DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException; + + /** + * Finds a land-line entry by given id number + *

+ * @param landLineNumberId Land-line entry id number + *

+ * @return A valid land-line instance + *

+ * @throws PhoneEntityNotFoundException If the entity was not found + */ + DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException; + + /** + * Finds a mobile entry by given id number + *

+ * @param mobileNumberId Mobile entry id number + *

+ * @return A valid mobile instance + *

+ * @throws PhoneEntityNotFoundException If the entity was not found + */ + DialableMobileNumber findMobileNumberById (Long mobileNumberId) throws PhoneEntityNotFoundException; + } diff --git a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestBean.java index 27ddc39a..a0a776c0 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestBean.java @@ -383,10 +383,10 @@ public class FinancialsUserWebRequestBean extends BaseFinancialsBean implements // Is the parameter valid? if (null == event) { // Throw NPE - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } else if (event.getLocale() == null) { // Throw NPE again - throw new NullPointerException("event.locale is null"); + throw new NullPointerException("event.locale is null"); //NOI18N } // Set it here @@ -575,7 +575,7 @@ public class FinancialsUserWebRequestBean extends BaseFinancialsBean implements // Is it valid? if (null == event) { // Throw NPE - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } // Clear it @@ -591,7 +591,7 @@ public class FinancialsUserWebRequestBean extends BaseFinancialsBean implements // Is it valid? if (null == event) { // Throw NPE - throw new NullPointerException("event is null"); + throw new NullPointerException("event is null"); //NOI18N } // Clear it @@ -706,6 +706,27 @@ public class FinancialsUserWebRequestBean extends BaseFinancialsBean implements return "user_contact_data_saved"; //NOI18N } + @Override + public User findUserById (final Long userId) throws UserNotFoundException { + // Validate parameter + if (null == userId) { + // Throw NPE + throw new NullPointerException("userId is null"); //NOI18N + } else if (userId < 1) { + // Throw IAE + throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N + } else if (!this.userCache.containsKey(userId)) { + // Not found + throw new UserNotFoundException(userId); + } + + // Get it from cache + final User user = this.userCache.get(userId); + + // Return it + return user; + } + /** * Getter for filtered users list *

@@ -820,6 +841,24 @@ public class FinancialsUserWebRequestBean extends BaseFinancialsBean implements ((this.getUserPasswordRepeat() == null) || (this.getUserPasswordRepeat().isEmpty()))); } + @Override + public boolean ifUserIdExists (final Long userId) { + // Validate parameter + if (null == userId) { + // Throw NPE + throw new NullPointerException("userId is null"); //NOI18N + } else if (userId < 1) { + // Throw IAE + throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N + } + + // Check if key is there + boolean isFound = this.userCache.containsKey(userId); + + // Return flag + return isFound; + } + /** * Post-initialization of this class */ diff --git a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestController.java index ac8561f1..16e49fab 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebRequestController.java @@ -38,6 +38,27 @@ public interface FinancialsUserWebRequestController extends Serializable { @Deprecated public static final Integer MINIMUM_PASSWORD_LENGTH = 5; + /** + * Returns a user instance by given primary key. If not found, a proper + * exception is thrown. + *

+ * @param userId User id + *

+ * @return User instance + *

+ * @throws UserNotFoundException If the user is not found + */ + User findUserById (final Long userId) throws UserNotFoundException; + + /** + * Checks if given user id exists + *

+ * @param userId User id to check + *

+ * @return Whether the user id exists + */ + boolean ifUserIdExists (final Long userId); + /** * Getter for clear-text user password *

@@ -72,9 +93,9 @@ public interface FinancialsUserWebRequestController extends Serializable { boolean isContactFound (final Contact contact); /** - * Checks whether given user instance's name is used + * Checks whether given user instance name is used *

- * @param user User instance's name to check + * @param user User instance name to check *

* @return Whether it is already used */ diff --git a/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java b/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java index 7c8d130e..c88510f8 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/basicdata/FinancialsBasicCompanyDataConverter.java @@ -26,9 +26,9 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicCompanyDataNotFoundException; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; +import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBusinessDataWebRequestController; /** * Converter for basic company data id <-> valid basic company data instance @@ -36,26 +36,26 @@ import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; * @author Roland Häder */ @FacesConverter ("BasicCompanyDataConverter") -public class FinancialsBasicCompanyDataConverter implements Converter { +public class FinancialsBasicCompanyDataConverter implements Converter { /** - * Basic company data EJB + * Basic company data backing bean */ - private static BasicCompanyDataSessionBeanRemote BASIC_DATA_BEAN; + private static FinancialsBusinessDataWebRequestController BASIC_DATA_CONTROLLER; @Override - public BusinessBasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + public BasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (BASIC_DATA_BEAN == null) { + if (BASIC_DATA_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - BASIC_DATA_BEAN = (BasicCompanyDataSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote"); //NOI18N + BASIC_DATA_CONTROLLER = (FinancialsBusinessDataWebRequestController) initial.lookup("java:module/basicCompanyDataController!org.mxchange.jfinancials.beans.business.basicdata.FinancialsBusinessDataWebRequestController"); //NOI18N } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N } } @@ -69,18 +69,18 @@ public class FinancialsBasicCompanyDataConverter implements Converter valid basic company data instance @@ -41,21 +41,21 @@ public class FinancialsBranchOfficeConverter implements Converter /** * Branch office EJB */ - private static BranchOfficeSessionBeanRemote BRANCH_OFFICE_BEAN; + private static FinancialsBranchOfficeWebRequestController BRANCH_OFFICE_CONTROLLER; @Override public BranchOffice getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (BRANCH_OFFICE_BEAN == null) { + if (BRANCH_OFFICE_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - BRANCH_OFFICE_BEAN = (BranchOfficeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/branchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote"); + BRANCH_OFFICE_CONTROLLER = (FinancialsBranchOfficeWebRequestController) initial.lookup("java:module/branchOfficeController!org.mxchange.jfinancials.beans.business.branchoffice.FinancialsBranchOfficeWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -76,7 +76,7 @@ public class FinancialsBranchOfficeConverter implements Converter final Long branchOfficeId = Long.valueOf(submittedValue); // Try to get user instance from it - branchOffice = BRANCH_OFFICE_BEAN.findBranchOfficeById(branchOfficeId); + branchOffice = BRANCH_OFFICE_CONTROLLER.findBranchOfficeById(branchOfficeId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java b/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsDepartmentConverter.java similarity index 81% rename from src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java rename to src/java/org/mxchange/jfinancials/converter/business/department/FinancialsDepartmentConverter.java index 547f9616..a2cb5030 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsCompanyDepartmentConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/department/FinancialsDepartmentConverter.java @@ -28,34 +28,34 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException; import org.mxchange.jcontactsbusiness.model.department.Department; -import org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote; +import org.mxchange.jfinancials.beans.business.department.FinancialsDepartmentWebRequestController; /** * Converter for company department id <-> instance *

* @author Roland Häder */ -@FacesConverter ("CompanyDepartmentConverter") -public class FinancialsCompanyDepartmentConverter implements Converter { +@FacesConverter ("DepartmentConverter") +public class FinancialsDepartmentConverter implements Converter { /** * Company department EJB */ - private static DepartmentSessionBeanRemote DEPARTMENT_BEAN; + private static FinancialsDepartmentWebRequestController DEPARTMENT_CONTROLLER; @Override public Department getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (DEPARTMENT_BEAN == null) { + if (DEPARTMENT_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - DEPARTMENT_BEAN = (DepartmentSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/companyDepartment!org.mxchange.jcontactsbusiness.model.department.CompanyDepartmentSessionBeanRemote"); //NOI18N + DEPARTMENT_CONTROLLER = (FinancialsDepartmentWebRequestController) initial.lookup("java:module/departmentController!org.mxchange.jfinancials.beans.business.department.FinancialsDepartmentWebRequestController"); //NOI18N } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N } } @@ -76,7 +76,7 @@ public class FinancialsCompanyDepartmentConverter implements Converter. */ -package org.mxchange.jfinancials.converter.business.company_employee; +package org.mxchange.jfinancials.converter.business.employee; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; @@ -26,36 +26,36 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcontactsbusiness.exceptions.employee.CompanyEmployeeNotFoundException; -import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jfinancials.beans.business.employee.FinancialsEmployeeWebRequestController; /** * Converter for converting company employee to and from id number *

* @author Roland Häder */ -@FacesConverter ("CompanyEmployeeConverter") -public class FinancialsCompanyEmployeeConverter implements Converter { +@FacesConverter ("EmployeeConverter") +public class FinancialsEmployeeConverter implements Converter { /** - * CompanyEmployee EJB + * Employable EJB */ - private static CompanyEmployeeSessionBeanRemote EMPLOYEE_BEAN; + private static FinancialsEmployeeWebRequestController EMPLOYEE_CONTROLLER; @Override - public Employee getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + public Employable getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (EMPLOYEE_BEAN == null) { + if (EMPLOYEE_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - EMPLOYEE_BEAN = (CompanyEmployeeSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote"); //NOI18N + EMPLOYEE_CONTROLLER = (FinancialsEmployeeWebRequestController) initial.lookup("java:module/!.FinancialsEmployeeWebRequestController"); //NOI18N } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N } } @@ -69,18 +69,18 @@ public class FinancialsCompanyEmployeeConverter implements Converter { } // Init instance - Employee companyEmployee = null; + Employable companyEmployee = null; try { // Try to parse the value as long final Long employeeId = Long.valueOf(submittedValue); // Try to get user instance from it - companyEmployee = EMPLOYEE_BEAN.findCompanyEmployeeById(employeeId); + companyEmployee = EMPLOYEE_CONTROLLER.findEmployeeById(employeeId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); - } catch (final CompanyEmployeeNotFoundException ex) { + } catch (final EmployeeNotFoundException ex) { // Debug message // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N } @@ -90,7 +90,7 @@ public class FinancialsCompanyEmployeeConverter implements Converter { } @Override - public String getAsString (final FacesContext context, final UIComponent component, final Employee value) { + public String getAsString (final FacesContext context, final UIComponent component, final Employable value) { // Is the object null? if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null diff --git a/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java b/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java index c27cba7a..cb273d68 100644 --- a/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/business/headquarters/FinancialsCompanyHeadquartersConverter.java @@ -39,23 +39,24 @@ import org.mxchange.jcontactsbusiness.model.headquarters.HeadquartersData; public class FinancialsCompanyHeadquartersConverter implements Converter { /** - * CompanyEmployee EJB + * Headquarters backing bean + * @TODO Undone */ - private static CompanyHeadquartersSessionBeanRemote COMPANY_HEADQUARTERS_BEAN; + private static CompanyHeadquartersSessionBeanRemote HEADQUARTERS_CONTROLLER; @Override public HeadquartersData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (COMPANY_HEADQUARTERS_BEAN == null) { + if (HEADQUARTERS_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - COMPANY_HEADQUARTERS_BEAN = (CompanyHeadquartersSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/headquarters!org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersSessionBeanRemote"); //NOI18N + HEADQUARTERS_CONTROLLER = (CompanyHeadquartersSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/headquarters!org.mxchange.jcontactsbusiness.model.headquarters.CompanyHeadquartersSessionBeanRemote"); //NOI18N } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); //NOI18N + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N } } @@ -76,7 +77,7 @@ public class FinancialsCompanyHeadquartersConverter implements Converter. + */ +package org.mxchange.jfinancials.converter.business.opening_time; + +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.ConverterException; +import javax.faces.convert.FacesConverter; +import javax.faces.validator.ValidatorException; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jfinancials.beans.business.opening_time.FinancialsOpeningTimeWebRequestController; + +/** + * Converter for opening time id <-> instance + *

+ * @author Roland Häder + */ +@FacesConverter ("OpeningTimeConverter") +public class FinancialsCompanyOpeningTimeConverter implements Converter { + + /** + * Opening time backing bean + */ + private static FinancialsOpeningTimeWebRequestController DEPARTMENT_CONTROLLER; + + @Override + public OpeningTime getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { + // Is the instance there? + if (DEPARTMENT_CONTROLLER == null) { + try { + // Not yet, attempt lookup + final Context initial = new InitialContext(); + + // Lookup EJB + DEPARTMENT_CONTROLLER = (FinancialsOpeningTimeWebRequestController) initial.lookup("java:module/openingTimeController!org.mxchange.jfinancials.beans.business.opening_time.FinancialsOpeningTimeWebRequestController"); //NOI18N + } catch (final NamingException ex) { + // Throw it again + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); //NOI18N + } + } + + // Is the value null or empty? + if ((null == submittedValue) || (submittedValue.trim().isEmpty())) { + // Warning message + // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N + + // Return null + return null; + } + + // Init instance + OpeningTime openingTime = null; + + try { + // Try to parse the value as long + final Long openingId = Long.valueOf(submittedValue); + + // Try to get user instance from it + openingTime = DEPARTMENT_CONTROLLER.findOpeningTimeById(openingId); + } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final OpeningTimeNotFoundException ex) { + // Debug message + // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N + } + + // Return it + return openingTime; + } + + @Override + public String getAsString (final FacesContext context, final UIComponent component, final OpeningTime value) { + // Is the object null? + if ((null == value) || (String.valueOf(value).isEmpty())) { + // Is null + return ""; //NOI18N + } + + // Return id number + return String.valueOf(value.getOpeningId()); + } + +} diff --git a/src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java b/src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java index 259a24c8..6e8adf10 100644 --- a/src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/contact/FinancialsContactConverter.java @@ -28,7 +28,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; +import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController; /** * Converter for contact id <-> valid contact instance @@ -41,21 +41,21 @@ public class FinancialsContactConverter implements Converter { /** * Contact EJB */ - private static ContactSessionBeanRemote CONTACT_BEAN; + private static FinancialsContactWebRequestController CONTACT_CONTROLLER; @Override public Contact getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (CONTACT_BEAN == null) { + if (CONTACT_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - CONTACT_BEAN = (ContactSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote"); + CONTACT_CONTROLLER = (FinancialsContactWebRequestController) initial.lookup("java:module/contactController!org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -76,7 +76,7 @@ public class FinancialsContactConverter implements Converter { final Long contactId = Long.valueOf(submittedValue); // Try to get user instance from it - contact = CONTACT_BEAN.findContactById(contactId); + contact = CONTACT_CONTROLLER.findContactById(contactId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/converter/country/FinancialsCountryConverter.java b/src/java/org/mxchange/jfinancials/converter/country/FinancialsCountryConverter.java index 01e7aaaa..70171e4d 100644 --- a/src/java/org/mxchange/jfinancials/converter/country/FinancialsCountryConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/country/FinancialsCountryConverter.java @@ -16,8 +16,6 @@ */ package org.mxchange.jfinancials.converter.country; -import java.util.List; -import java.util.Objects; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; @@ -28,8 +26,9 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.mxchange.jcountry.exceptions.CountryNotFoundException; import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; +import org.mxchange.jfinancials.beans.country.FinancialsCountryWebRequestController; /** * Converter for country instance @@ -40,23 +39,23 @@ import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; public class FinancialsCountryConverter implements Converter { /** - * Country bean + * Country backing bean */ - private static CountrySingletonBeanRemote COUNTRY_BEAN; + private static FinancialsCountryWebRequestController COUNTRY_CONTROLLER; @Override public Country getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (COUNTRY_BEAN == null) { + if (COUNTRY_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - COUNTRY_BEAN = (CountrySingletonBeanRemote) initial.lookup("java:global/jfinancials-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote"); + COUNTRY_CONTROLLER = (FinancialsCountryWebRequestController) initial.lookup("java:module/countryController!org.mxchange.jfinancials.beans.country.FinancialsCountryWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -69,9 +68,6 @@ public class FinancialsCountryConverter implements Converter { return null; } - // Get full list - final List countryList = COUNTRY_BEAN.allCountries(); - // Init value Country country = null; @@ -80,21 +76,13 @@ public class FinancialsCountryConverter implements Converter { // Convert it to long final Long countryId = Long.parseLong(submittedValue); - // Category id should not be below 1 - assert (countryId > 0) : "countryId is smaller than one: " + countryId; //NOI18N - // Try to find it - for (final Country cntry : countryList) { - // Is the id the same? (null-safe) - if (Objects.equals(cntry.getCountryId(), countryId)) { - // Found it - country = cntry; - break; - } - } + country = COUNTRY_CONTROLLER.findCountryById(countryId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); + } catch (final CountryNotFoundException ex) { + // Not handled } // Return it diff --git a/src/java/org/mxchange/jfinancials/converter/fax/FinancialsFaxNumberConverter.java b/src/java/org/mxchange/jfinancials/converter/fax/FinancialsFaxNumberConverter.java index c1deb9da..ec77d49b 100644 --- a/src/java/org/mxchange/jfinancials/converter/fax/FinancialsFaxNumberConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/fax/FinancialsFaxNumberConverter.java @@ -26,9 +26,9 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException; +import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestController; +import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote; /** * Converter for fax id <-> valid fax number instance @@ -41,21 +41,21 @@ public class FinancialsFaxNumberConverter implements Converter valid land-line number instance @@ -41,21 +41,21 @@ public class FinancialsLandLineNumberConverter implements Converter valid mobile instance @@ -41,21 +41,21 @@ public class FinancialsMobileNumberConverter implements Converter { /** - * Mobile provider bean + * Mobile provider backing bean */ - private static MobileProviderSingletonBeanRemote MOBILE_PROVIDER_BEAN; + private static FinancialsMobileProviderWebRequestController MOBILE_PROVIDER_CONTROLLER; @Override public MobileProvider getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (MOBILE_PROVIDER_BEAN == null) { + if (MOBILE_PROVIDER_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - MOBILE_PROVIDER_BEAN = (MobileProviderSingletonBeanRemote) initial.lookup("java:global/jfinancials-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); + MOBILE_PROVIDER_CONTROLLER = (FinancialsMobileProviderWebRequestController) initial.lookup("java:module/mobileProviderController!org.mxchange.jfinancials.beans.mobileprovider.FinancialsMobileProviderWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -68,36 +67,26 @@ public class FinancialsMobileProviderConverter implements Converter providerList = MOBILE_PROVIDER_BEAN.allMobileProviders(); - // Init value - MobileProvider provider = null; + MobileProvider mobileProvider = null; // Try this better try { // Convert it to long final Long providerId = Long.parseLong(submittedValue); - // Category id should not be below 1 - assert (providerId > 0) : "providerId is smaller than one: " + providerId; //NOI18N - - // Try to find it - for (final MobileProvider prov : providerList) { - // Is the id the same? (null-safe) - if (Objects.equals(prov.getProviderId(), providerId)) { - // Found it - provider = prov; - break; - } - } + // Lookup of mobile provider + mobileProvider = MOBILE_PROVIDER_CONTROLLER.findMobileProviderById(providerId); } catch (final NumberFormatException ex) { + // Throw again + throw new ConverterException(ex); + } catch (final MobileProviderNotFoundException ex) { // Log exception (maybe to much?) // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logException(ex); } // Return it - return provider; + return mobileProvider; } @Override diff --git a/src/java/org/mxchange/jfinancials/converter/user/FinancialsUserConverter.java b/src/java/org/mxchange/jfinancials/converter/user/FinancialsUserConverter.java index 8fc92741..b10d1d82 100644 --- a/src/java/org/mxchange/jfinancials/converter/user/FinancialsUserConverter.java +++ b/src/java/org/mxchange/jfinancials/converter/user/FinancialsUserConverter.java @@ -25,9 +25,9 @@ import javax.faces.convert.FacesConverter; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.model.user.User; -import org.mxchange.jusercore.model.user.UserSessionBeanRemote; /** * Converter for user id <-> valid user instance @@ -38,23 +38,23 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote; public class FinancialsUserConverter implements Converter { /** - * User EJB + * User backing bean */ - private static UserSessionBeanRemote USER_BEAN; + private static FinancialsUserWebRequestController USER_CONTROLLER; @Override public User getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? - if (USER_BEAN == null) { + if (USER_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - USER_BEAN = (UserSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); + USER_CONTROLLER = (FinancialsUserWebRequestController) initial.lookup("java:module/userController!org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -75,7 +75,7 @@ public class FinancialsUserConverter implements Converter { final Long userId = Long.valueOf(submittedValue); // Try to get user instance from it - user = USER_BEAN.findUserById(userId); + user = USER_CONTROLLER.findUserById(userId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java b/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java index f784247d..c10dadae 100644 --- a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java @@ -25,8 +25,8 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jfinancials.beans.business.basicdata.FinancialsBusinessDataWebRequestController; /** * A validator for company names @@ -37,9 +37,9 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator; public class FinancialsCompanyNameValidator extends BaseStringValidator { /** - * Business contact EJB + * Business basic data backing bean */ - private static BasicCompanyDataSessionBeanRemote BASIC_DATA_BEAN; + private static FinancialsBusinessDataWebRequestController BASIC_DATA_CONTROLLER; /** * Serial number @@ -49,16 +49,16 @@ public class FinancialsCompanyNameValidator extends BaseStringValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Is the instance there? - if (BASIC_DATA_BEAN == null) { + if (BASIC_DATA_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - BASIC_DATA_BEAN = (BasicCompanyDataSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote"); + BASIC_DATA_CONTROLLER = (FinancialsBusinessDataWebRequestController) initial.lookup("java:module/basicCompanyDataController!org.mxchange.jfinancials.beans.business.basicdata.FinancialsBusinessDataWebRequestController"); //NOI18N } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -90,7 +90,7 @@ public class FinancialsCompanyNameValidator extends BaseStringValidator { } // Check if name is already used - final Boolean nameExists = BASIC_DATA_BEAN.isCompanyNameUsed(companyName); + final Boolean nameExists = BASIC_DATA_CONTROLLER.isCompanyNameUsed(companyName); // Is the user id valid? if ((!nameExists) && (checkExisting)) { diff --git a/src/java/org/mxchange/jfinancials/validator/emailaddress/FinancialsEmailAddressValidator.java b/src/java/org/mxchange/jfinancials/validator/emailaddress/FinancialsEmailAddressValidator.java index a37c9ec1..36f8cc53 100644 --- a/src/java/org/mxchange/jfinancials/validator/emailaddress/FinancialsEmailAddressValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/emailaddress/FinancialsEmailAddressValidator.java @@ -26,8 +26,8 @@ import javax.faces.validator.ValidatorException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; import org.mxchange.jcoreee.validator.string.BaseStringValidator; +import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController; /** * A validator for email address validation @@ -38,9 +38,9 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator; public class FinancialsEmailAddressValidator extends BaseStringValidator { /** - * Contact session-scoped bean + * Contact backing bean */ - private static ContactSessionBeanRemote CONTACT_BEAN; + private static FinancialsContactWebRequestController CONTACT_CONTROLLER; /** * Email pattern @@ -60,16 +60,16 @@ public class FinancialsEmailAddressValidator extends BaseStringValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Is the instance there? - if (CONTACT_BEAN == null) { + if (CONTACT_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - CONTACT_BEAN = (ContactSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote"); + CONTACT_CONTROLLER = (FinancialsContactWebRequestController) initial.lookup("java:module/contactController!org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -127,7 +127,7 @@ public class FinancialsEmailAddressValidator extends BaseStringValidator { final String clientId = component.getClientId(); // Is it registered? - final Boolean isRegistered = CONTACT_BEAN.isEmailAddressRegistered(emailAddress); + final Boolean isRegistered = CONTACT_CONTROLLER.isEmailAddressRegistered(emailAddress); // Is the email address already registered? if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N diff --git a/src/java/org/mxchange/jfinancials/validator/user/FinancialsUserIdValidator.java b/src/java/org/mxchange/jfinancials/validator/user/FinancialsUserIdValidator.java index 5243aecc..dbac7b31 100644 --- a/src/java/org/mxchange/jfinancials/validator/user/FinancialsUserIdValidator.java +++ b/src/java/org/mxchange/jfinancials/validator/user/FinancialsUserIdValidator.java @@ -26,7 +26,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.validator.number.BaseNumberValidator; -import org.mxchange.jusercore.model.user.UserSessionBeanRemote; +import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController; /** * A validator for user ids @@ -37,9 +37,9 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote; public class FinancialsUserIdValidator extends BaseNumberValidator { /** - * Remote bean + * User backing bean */ - private static UserSessionBeanRemote USER_BEAN; + private static FinancialsUserWebRequestController USER_CONTROLLER; /** * Serial number @@ -49,16 +49,16 @@ public class FinancialsUserIdValidator extends BaseNumberValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Is the instance there? - if (USER_BEAN == null) { + if (USER_CONTROLLER == null) { try { // Not yet, attempt lookup final Context initial = new InitialContext(); // Lookup EJB - USER_BEAN = (UserSessionBeanRemote) initial.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); + USER_CONTROLLER = (FinancialsUserWebRequestController) initial.lookup("java:module/userController!org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController"); } catch (final NamingException ex) { // Throw it again - throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup EJB", ex.getMessage()), ex); + throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot lookup backing bean", ex.getMessage()), ex); } } @@ -72,7 +72,7 @@ public class FinancialsUserIdValidator extends BaseNumberValidator { final Long userId = (Long) value; // Define variable - final Boolean ifUserExists = USER_BEAN.ifUserIdExists(userId); + final Boolean ifUserExists = USER_CONTROLLER.ifUserIdExists(userId); // Is the user id valid? if (!ifUserExists) { diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 8e875648..ac6b5bca 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -862,7 +862,7 @@ ADMIN_ASSIGN_BRANCH_OFFICE_CONTACT_EMPLOYEE=Kontaktperson der Filiale zuweisen: ADMIN_BRANCH_OFFICE_DATA_LEGEND=Grunddaten der Filiale: #@TODO Please fix German umlauts! ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE=Geben Sie hier die Grunddaten der Filiale ein. -ADMIN_ASSIGN_BRANCH_OFFICE_COMPANY=Filiale dem Unternehmen zuweisen: +ADMIN_ASSIGN_BRANCH_OFFICE=Filiale dem Unternehmen zuweisen: PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=Filialen auflisten CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=Auflisten von Filialen: #@TODO Please fix German umlauts! @@ -875,7 +875,7 @@ ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email-Addresse der Filiale: ADMIN_ENTER_BRANCH_OFFICE_PHONE_NUMBER=Telefonnummer eingeben: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Faxnummer eingeben: #@TODO Please fix German umlauts! -ADMIN_BRANCH_OFFICE_COMPANY_REQUIRED=Bitte waehlen das zur Filiale gehoerende Unternehmen aus. +ADMIN_BRANCH_OFFICE_REQUIRED=Bitte waehlen das zur Filiale gehoerende Unternehmen aus. ADMIN_BRANCH_OFFICE_STREET_NAME_REQUIRED=Bitte geben Sie die Strasse der Filiale ein. ADMIN_BRANCH_OFFICE_HOUSE_NUMBER_REQUIRED=Bitte geben Sie die Hausnummer der Filiale ein. #@TODO Please fix German umlauts! diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 23ed5798..22c600b8 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -825,7 +825,7 @@ ADMIN_ASSIGN_BRANCH_OFFICE_USER_OWNER=Assign user to branch office: ADMIN_ASSIGN_BRANCH_OFFICE_CONTACT_EMPLOYEE=Assign contact person to branch office: ADMIN_BRANCH_OFFICE_DATA_LEGEND=Branch office basic data: ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE=Enter branch office basic data here. -ADMIN_ASSIGN_BRANCH_OFFICE_COMPANY=Assign branch office to company: +ADMIN_ASSIGN_BRANCH_OFFICE=Assign branch office to company: PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices: ADMIN_EMPTY_LIST_BRANCH_OFFICES=There are no branch offices found in database. Or your search criteria doesn't match anything. @@ -835,7 +835,7 @@ ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA=Please at least choose assigned company, co ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email address of branch office: ADMIN_ENTER_BRANCH_OFFICE_PHONE_NUMBER=Enter land-line number: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Enter fax number: -ADMIN_BRANCH_OFFICE_COMPANY_REQUIRED=Please choose a company that sohuld be assigned with the branch office. +ADMIN_BRANCH_OFFICE_REQUIRED=Please choose a company that sohuld be assigned with the branch office. ADMIN_BRANCH_OFFICE_STREET_NAME_REQUIRED=Please enter street name of branch office. ADMIN_BRANCH_OFFICE_HOUSE_NUMBER_REQUIRED=Please enter house number of branch office. ENTERED_STORE_INVALID=The entered store is not valid. diff --git a/web/WEB-INF/links.jsf.taglib.xml b/web/WEB-INF/links.jsf.taglib.xml index d07704b7..06af9787 100644 --- a/web/WEB-INF/links.jsf.taglib.xml +++ b/web/WEB-INF/links.jsf.taglib.xml @@ -217,7 +217,7 @@ along with this program. If not, see . - outputCompanyEmployeeAdminMiniLinks + outputEmployeeAdminMiniLinks This tag renders administrative "mini-links" for given employee instance. resources/tags/admin/links/mini/employee/admin_employee_links.tpl diff --git a/web/WEB-INF/templates/admin/basic_company_data/admin_form_basic_company_data.tpl b/web/WEB-INF/templates/admin/basic_company_data/admin_form_basic_company_data.tpl index 9ec478ea..b7ffdec1 100644 --- a/web/WEB-INF/templates/admin/basic_company_data/admin_form_basic_company_data.tpl +++ b/web/WEB-INF/templates/admin/basic_company_data/admin_form_basic_company_data.tpl @@ -56,9 +56,9 @@ filter="true" filterMatchMode="contains" > - + - + @@ -68,9 +68,9 @@ filter="true" filterMatchMode="contains" > - + - + diff --git a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl index 7e2c72b7..dcaefd44 100644 --- a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl +++ b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl @@ -12,18 +12,18 @@ --> - + - + @@ -33,9 +33,9 @@ filter="true" filterMatchMode="contains" > - + - + diff --git a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl index e10b1957..cb76dbc6 100644 --- a/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl +++ b/web/WEB-INF/templates/admin/department/admin_form_department_data.tpl @@ -26,7 +26,7 @@ > - + @@ -48,7 +48,7 @@ filter="true" filterMatchMode="contains" > - + @@ -60,9 +60,9 @@ filter="true" filterMatchMode="contains" > - + - + diff --git a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl index 8a2bf917..5c0747a1 100644 --- a/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl +++ b/web/WEB-INF/templates/admin/employee/admin_form_employee_data.tpl @@ -23,7 +23,7 @@ > - + @@ -88,7 +88,7 @@ filter="true" filterMatchMode="contains" > - + diff --git a/web/admin/basic_company_data/admin_basic_company_data_list.xhtml b/web/admin/basic_company_data/admin_basic_company_data_list.xhtml index 0fb9c237..ac3f5c4f 100644 --- a/web/admin/basic_company_data/admin_basic_company_data_list.xhtml +++ b/web/admin/basic_company_data/admin_basic_company_data_list.xhtml @@ -21,7 +21,7 @@ - + - + @@ -121,9 +121,9 @@ updateLabel="true" title="#{msg.FILTER_BY_MULTIPLE_EMPLOYEES_TITLE}" > - + - + diff --git a/web/admin/branch_office/admin_branch_office_list.xhtml b/web/admin/branch_office/admin_branch_office_list.xhtml index ff665119..670fb3d0 100644 --- a/web/admin/branch_office/admin_branch_office_list.xhtml +++ b/web/admin/branch_office/admin_branch_office_list.xhtml @@ -89,7 +89,7 @@ title="#{msg.FILTER_BY_MULTIPLE_COMPANIES_TITLE}" > - + @@ -120,9 +120,9 @@ updateLabel="true" title="#{msg.FILTER_BY_MULTIPLE_EMPLOYEES_TITLE}" > - + - + diff --git a/web/admin/department/admin_department_list.xhtml b/web/admin/department/admin_department_list.xhtml index 992a6acc..2b5bcc87 100644 --- a/web/admin/department/admin_department_list.xhtml +++ b/web/admin/department/admin_department_list.xhtml @@ -68,7 +68,7 @@ title="#{msg.FILTER_BY_MULTIPLE_COMPANIES_TITLE}" > - + @@ -114,9 +114,9 @@ updateLabel="true" title="#{msg.FILTER_BY_MULTIPLE_EMPLOYEES_TITLE}" > - + - + diff --git a/web/admin/employee/admin_employee_list.xhtml b/web/admin/employee/admin_employee_list.xhtml index 3ac1c784..3f84f684 100644 --- a/web/admin/employee/admin_employee_list.xhtml +++ b/web/admin/employee/admin_employee_list.xhtml @@ -21,7 +21,7 @@ - + @@ -137,7 +137,7 @@ - + @@ -166,7 +166,7 @@ styleClass="submit" type="submit" value="#{msg.BUTTON_ADMIN_ADD_EMPLOYEE}" - action="#{adminEmployeeController.addCompanyEmployee()}" + action="#{adminEmployeeController.addEmployee()}" update=":master:form-list-company-employees:table-list-company-employees" /> -- 2.39.5