From: Roland Häder Date: Fri, 6 Apr 2018 21:22:45 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0de05b59bb67c10eaab1bc5f577a8130304f71ff;p=jjobs-war.git Please cherry-pick: - the helper bean needs to be view-scoped for other "list" view-scoped beans - all action methods must return void to have JSF AJAX requests working properly - sorted some members Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java index db6428ed..6ff360fa 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsAdminBasicDataWebRequestBean.java @@ -152,9 +152,8 @@ public class JobsAdminBasicDataWebRequestBean extends BaseJobsBean implements Jo /** * Adds a basic business data entry, if not yet found. *

- * @return Redirect outcome */ - public String addBusinessBasicData () { + public void addBusinessBasicData () { // First, validate all parameter if (this.getCompanyName() == null) { // Is null @@ -236,9 +235,6 @@ public class JobsAdminBasicDataWebRequestBean extends BaseJobsBean implements Jo // Does already exist throw new FacesException(e); } - - // Continue to list again - return "admin_list_basic_data"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java index 44311693..d7e5a5b3 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java @@ -46,27 +46,6 @@ public class JobsBasicDataWebRequestBean extends BaseJobsBean implements JobsBas private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; /** -<<<<<<< HEAD:src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java - * List of all basic company data - */ - private final List allBasicData; - - /** - * A list of all registered companies (globally) - */ - @Inject - @NamedCache (cacheName = "basicDataCache") - private Cache basicDataCache; - - /** - * EJB for general basic business data purposes - */ - @EJB (lookup = "java:global/jjobs-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") - private BasicCompanyDataSessionBeanRemote businessDataBean; - - /** -======= ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/beans/business/basicdata/JobsBasicDataWebRequestBean.java * Comments for this company */ private String companyComments; diff --git a/src/java/org/mxchange/jjobs/beans/business/basicdata/list/JobsBasicDataListWebViewController.java b/src/java/org/mxchange/jjobs/beans/business/basicdata/list/JobsBasicDataListWebViewController.java index f4424c8c..2ba1db89 100644 --- a/src/java/org/mxchange/jjobs/beans/business/basicdata/list/JobsBasicDataListWebViewController.java +++ b/src/java/org/mxchange/jjobs/beans/business/basicdata/list/JobsBasicDataListWebViewController.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package org.mxchange.jfinancials.beans.business.basicdata.list; +package org.mxchange.jjobs.beans.business.basicdata.list; import java.io.Serializable; import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java index f37c725b..c0539c5d 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java @@ -227,10 +227,8 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements * Adds branch office with all data from this backing bean. First this * action method will validate if the branch office's address is already * registered and if found, it will output a proper faces message. - *

- * @return Redirect outcome */ - public String addBranchOffice () { + public void addBranchOffice () { // Get instance final BranchOffice branchOffice = this.createBranchOffice(); @@ -238,7 +236,7 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) { // Then show proper faces message this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Delcare updated instance @@ -250,7 +248,7 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements } catch (final BranchOfficeAlreadyAddedException ex) { // Output message this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Fire event @@ -258,9 +256,6 @@ public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements // Clear this bean this.clear(); - - // Redirect to list - return "admin_list_branch_office"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java index 1431e179..bfe5f7e9 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/JobsAdminDepartmentWebRequestBean.java @@ -112,10 +112,8 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J * Adds department with all data from this backing bean. First this action * method will validate if the department's address is already registered * and if found, it will output a proper faces message. - *

- * @return Redirect outcome */ - public String addDepartment () { + public void addDepartment () { // Get instance final Department department = this.createDepartment(); @@ -123,7 +121,7 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J if (this.isDepartmentCreatedByRequiredData(department)) { // Then show proper faces message this.showFacesMessage("form-admin-add-department:branchStreet", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Delcare updated instance @@ -135,14 +133,11 @@ public class JobsAdminDepartmentWebRequestBean extends BaseJobsBean implements J } catch (final DepartmentAlreadyAddedException ex) { // Output message this.showFacesMessage("form-admin-add-department:departmentI18nKey", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Fire event this.departmentAddedEvent.fire(new DepartmentAddedEvent(updatedDepartment)); - - // Redirect to list - return "admin_list_department"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java index 38464448..961daf8e 100644 --- a/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/employee/JobsAdminCompanyEmployeeWebRequestBean.java @@ -141,10 +141,8 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job * Adds branch office with all data from this backing bean. First this * action method will validate if the branch office's address is already * registered and if found, it will output a proper faces message. - *

- * @return Redirect outcome */ - public String addEmployee () { + public void addEmployee () { // Get instance final Employable employee = this.createEmployee(); @@ -152,7 +150,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job if (this.isEmployeeCreatedByRequiredData(employee)) { // Then show proper faces message this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Delcare updated instance @@ -164,7 +162,7 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job } catch (final EmployeeAlreadyAddedException ex) { // Output message this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Fire event @@ -172,45 +170,42 @@ public class JobsAdminEmployeeWebRequestBean extends BaseJobsBean implements Job // Clear this bean this.clear(); - - // Redirect to list - return "admin_list_branch_office"; //NOI18N } /** - * Getter for employee's assigned branch office + * Getter for employee's assigned basic company data *

- * @return Employee's assigned branch office + * @return Employee's assigned basic company data */ - public BranchOffice getEmployeeBranchOffice () { - return this.employeeBranchOffice; + public BasicData getEmployeeBasicData () { + return this.employeeBasicData; } /** - * Setter for employee's assigned branch office + * Setter for employee's assigned basic company data *

- * @param employeeBranchOffice Employee's assigned branch office + * @param employeeBasicData Employee's assigned basic company data */ - public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) { - this.employeeBranchOffice = employeeBranchOffice; + public void setEmployeeBasicData (final BasicData employeeBasicData) { + this.employeeBasicData = employeeBasicData; } /** - * Getter for employee's assigned basic company data + * Getter for employee's assigned branch office *

- * @return Employee's assigned basic company data + * @return Employee's assigned branch office */ - public BasicData getEmployeeCompany () { - return this.employeeBasicData; + public BranchOffice getEmployeeBranchOffice () { + return this.employeeBranchOffice; } /** - * Setter for employee's assigned basic company data + * Setter for employee's assigned branch office *

- * @param employeeBasicData Employee's assigned basic company data + * @param employeeBranchOffice Employee's assigned branch office */ - public void setEmployeeCompany (final BasicData employeeBasicData) { - this.employeeBasicData = employeeBasicData; + public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) { + this.employeeBranchOffice = employeeBranchOffice; } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java index 5ccf6e31..063c2b1d 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java @@ -216,10 +216,8 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements * Adds headquarter with all data from this backing bean. First this action * method will validate if the headquarter's address is already registered * and if found, it will output a proper faces message. - *

- * @return Redirect outcome */ - public String addHeadquarter () { + public void addHeadquarter () { // Get instance final Headquarter headquarter = this.createHeadquarter(); @@ -227,7 +225,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements if (this.isHeadquarterCreatedByRequiredData(headquarter)) { // Then show proper faces message this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Delcare updated instance @@ -239,7 +237,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements } catch (final HeadquarterAlreadyAddedException ex) { // Output message this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N - return ""; //NOI18N + return; } // Fire event @@ -247,9 +245,6 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements // Clear this bean this.clear(); - - // Redirect to list - return "admin_list_headquarter"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java index 7e9976c1..8375764c 100644 --- a/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/opening_time/JobsAdminOpeningTimeWebRequestBean.java @@ -90,10 +90,8 @@ public class JobsAdminOpeningTimeWebRequestBean extends BaseJobsBean implements * Adds openingTime with all data from this backing bean. First this action * method will validate if the openingTime's address is already registered * and if found, it will output a proper faces message. - *

- * @return Redirect outcome */ - public String addOpeningTimes () { + public void addOpeningTimes () { // Get instance final OpeningTime openingTime = this.createOpeningTimes(); @@ -102,9 +100,6 @@ public class JobsAdminOpeningTimeWebRequestBean extends BaseJobsBean implements // Fire event this.openingTimeAddedEvent.fire(new OpeningTimeAddedEvent(updatedOpeningTimes)); - - // Redirect to list - return "admin_list_opening_time"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 7ea8c86b..1d81812a 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -247,10 +247,8 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs /** * Adds contact data to database and redirects on success. If the contact is * already found, a proper exception is thrown. - *

- * @return Redirect outcome */ - public String addContact () { + public void addContact () { // Are all minimum fields set? if (this.getPersonalTitle() == null) { // Throw NPE @@ -295,9 +293,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs // Clear this bean this.clear(); - - // Return outcome - return "admin_list_contact"; //NOI18N } /** @@ -486,10 +481,8 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs /** * Edits currently loaded contact's data in database. - *

- * @return Redirect outcome */ - public String editContactData () { + public void editContactData () { // Get contact instance final Contact contact = this.createContactInstance(); @@ -516,9 +509,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs // Clear bean this.clear(); - - // Return to contact list (for now) - return "admin_list_contact"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java index 1f97a968..7db105ee 100644 --- a/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/country/JobsAdminCountryWebRequestBean.java @@ -109,11 +109,9 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements Jobs * Adds country to all relevant beans and sends it to the EJB. A redirect * should happen after successfull creation. *

- * @return Redirect outcome - *

* @todo Add field validation */ - public String addCountry () { + public void addCountry () { // Create new country object final Country country = new CountryData(); @@ -147,9 +145,6 @@ public class JobsAdminCountryWebRequestBean extends BaseJobsBean implements Jobs // Clear this bean this.clear(); - - // Redirect to list - return "admin_list_country"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java deleted file mode 100644 index 5213862d..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperBean.java +++ /dev/null @@ -1,806 +0,0 @@ -/* - * Copyright (C) 2016 - 2018 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.beans.helper; - -import java.text.MessageFormat; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Event; -import javax.enterprise.inject.Any; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent; -import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; -import org.mxchange.jcontacts.model.contact.Contact; -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.Employable; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jjobs.beans.BaseJobsBean; -import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController; -import org.mxchange.jjobs.beans.user.JobsUserWebRequestController; -import org.mxchange.jjobs.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; -import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; -import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent; -import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; -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 - *

- * @author Roland Häder - */ -@Named ("beanHelper") -@RequestScoped -public class JobsWebRequestHelperBean extends BaseJobsBean implements JobsWebRequestHelperController { - - /** - * Serial number - */ - private static final long serialVersionUID = 17_258_793_567_145_701L; - - /** - * Contact instance - */ - private Contact contact; - - /** - * Event for when a contact instance was created - */ - @Any - @Inject - private Event contactCreatedEvent; - - /** - * Fax number - */ - private DialableFaxNumber faxNumber; - - /** - * Event for when a fax number instance was created - */ - @Any - @Inject - private Event faxNumberCreatedEvent; - - /** - * Land-line number - */ - private DialableLandLineNumber landLineNumber; - - /** - * Event for when a land-line number instance was created - */ - @Any - @Inject - private Event landLineNumberCreatedEvent; - - /** - * Localization controller - */ - @Inject - private JobsLocalizationSessionController localizationController; - - /** - * Mobile number - */ - private DialableMobileNumber mobileNumber; - - /** - * Event for when a mobile number instance was created - */ - @Any - @Inject - private Event mobileNumberCreatedEvent; - - /** - * User instance - */ - private User user; - - /** - * Regular user controller - */ - @Inject - private JobsUserWebRequestController userController; - - /** - * Event for when a user instance was created - */ - @Any - @Inject - private Event userCreatedEvent; - - /** - * Default constructor - */ - public JobsWebRequestHelperBean () { - // Call super constructor - super(); - } - - /** - * Getter for contact instance - *

- * @return Contact instance - */ - public Contact getContact () { - return this.contact; - } - - /** - * Setter for contact instance - *

- * @param contact Contact instance - */ - public void setContact (final Contact contact) { - this.contact = contact; - } - - /** - * Returns a message key depending on if this contact is a user and/or a - * contact. If this contact is unused, a default key is returned. - *

- * @param contact Contact instance to check - *

- * @return Message key - */ - public String getContactUsageMessageKey (final Contact contact) { - // The contact must be valid - if (null == contact) { - // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { - // Throw again ... - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N - } - - // Default key is "unused" - String messageKey = "CONTACT_IS_UNUSED"; //NOI18N - - // Check user first - if (this.userController.isContactFound(contact)) { - // Only user - messageKey = "CONTACT_IS_USER"; //NOI18N - } - - // Return message key - return messageKey; - } - - /** - * Getter for dialable fax number - *

- * @return Dialable fax number - */ - public DialableFaxNumber getFaxNumber () { - return this.faxNumber; - } - - /** - * Setter for dialable fax number - *

- * @param faxNumber Dialable fax number - */ - public void setFaxNumber (final DialableFaxNumber faxNumber) { - this.faxNumber = faxNumber; - } - - /** - * Getter for dialable land-line number - *

- * @return Dialable land-line number - */ - public DialableLandLineNumber getLandLineNumber () { - return this.landLineNumber; - } - - /** - * Setter for dialable land-line number - *

- * @param landLineNumber Dialable land-line number - */ - public void setLandLineNumber (final DialableLandLineNumber landLineNumber) { - this.landLineNumber = landLineNumber; - } - - /** - * Getter for dialable mobile number - *

- * @return Dialable mobile number - */ - public DialableMobileNumber getMobileNumber () { - return this.mobileNumber; - } - - /** - * Setter for dialable mobile number - *

- * @param mobileNumber Dialable mobile number - */ - public void setMobileNumber (final DialableMobileNumber mobileNumber) { - this.mobileNumber = mobileNumber; - } - - /** - * Getter for user instance - *

- * @return User instance - */ - public User getUser () { - return this.user; - } - - /** - * Setter for user instance - *

- * @param user User instance - */ - public void setUser (final User user) { - this.user = user; - } - - /** - * Notifies other controllers (backing beans) if a contact id has been - * successfully converted to a Contact instance. - */ - public void notifyControllerContactConverted () { - // Validate contact instance - if (this.getContact() == null) { - // Throw NPE - throw new NullPointerException("this.contact is null"); //NOI18N - } else if (this.getContact().getContactId() == null) { - // Throw NPE again - throw new NullPointerException("this.contact.contactId is null"); //NOI18N - } else if (this.getContact().getContactId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N - } - - // Set all phone instances - this.setPhoneInstances(this.getContact()); - - // Set all fields: user - this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact())); - } - - /** - * Notifies other controllers (backing beans) if a phone id has been - * successfully converted to a DialableFaxNumber instance. - */ - public void notifyControllerFaxNumberConverted () { - // Validate fax instance - if (this.getFaxNumber() == null) { - // Throw NPE - throw new NullPointerException("this.faxNumber is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N - } else if (this.getFaxNumber().getPhoneAreaCode() == null) { - // Throw again - throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N - } else if (this.getFaxNumber().getPhoneCountry() == null) { - // Throw NPE again - throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) { - // ... throw again - throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N - } else if (this.getFaxNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N - } else if (this.getFaxNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N - } - - // Fire event - this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber())); - } - - /** - * Notifies other controllers (backing beans) if a phone id has been - * successfully converted to a DialableLandLineNumber instance. - */ - public void notifyControllerLandLineNumberConverted () { - // Validate land-line instance - if (this.getLandLineNumber() == null) { - // Throw NPE - throw new NullPointerException("this.landLineNumber is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N - } else if (this.getLandLineNumber().getPhoneAreaCode() == null) { - // Throw again - throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N - } else if (this.getLandLineNumber().getPhoneCountry() == null) { - // Throw NPE again - throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) { - // ... throw again - throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N - } else if (this.getLandLineNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N - } else if (this.getLandLineNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N - } - - // Fire event - this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber())); - } - - /** - * Notifies other controllers (backing beans) if a phone id has been - * successfully converted to a DialableMobileNumber instance. - */ - public void notifyControllerMobileNumberConverted () { - // Validate mobile instance - if (this.getMobileNumber() == null) { - // Throw NPE - throw new NullPointerException("this.mobileNumber is null"); //NOI18N - } else if (this.getMobileNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N - } else if (this.getMobileNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N - } else if (this.getMobileNumber().getMobileProvider() == null) { - // Throw NPE again - throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N - } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) { - // ... throw again - throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N - } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N - } else if (this.getMobileNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N - } else if (this.getMobileNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N - } - - // Fire event - this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber())); - } - - /** - * Notifies other controllers (backing beans) if a user id has been - * successfully converted to a User instance. - */ - public void notifyControllerUserConverted () { - // Validate user instance - if (this.getUser() == null) { - // Throw NPE - throw new NullPointerException("this.user is null"); //NOI18N - } else if (this.getUser().getUserId() == null) { - // Throw NPE again - throw new NullPointerException("this.user.userId is null"); //NOI18N - } else if (this.getUser().getUserId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N - } - - // Get contact - final Contact userContact = this.getUser().getUserContact(); - - // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs. - this.setContact(userContact); - - // Set all phone instances - this.setPhoneInstances(userContact); - - // Fire event - this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser())); - } - - /** - * Renders data of basic company data - *

- * @param basicData Basic company data instance - *

- * @return Basic company data as string - */ - public String renderBasicData (final BasicData basicData) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(30); - - // Is basic company data set? - if (basicData instanceof BasicData) { - // Add company name - sb.append(basicData.getCompanyName()); //NOI18N - - // Is email address set? - if (basicData.getCompanyEmailAddress() != null) { - // Add it - sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N - } - - // Is tax number set? - if (basicData.getCompanyTaxNumber() != null) { - // Add it - sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N - } - } - - // Return it - return sb.toString(); - } - - /** - * Returns the branch office's full address. If null is provided, an empty - * string is returned. - *

- * @param branchOffice Branch office instance - *

- * @return Branch office's address - */ - public String renderBranchOffice (final BranchOffice branchOffice) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(30); - - // Is a branch office instance given? - if (branchOffice instanceof BranchOffice) { - // This should not happen: - assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N - - // Yes, then append all data - sb.append(branchOffice.getBranchCompany().getCompanyName()); - sb.append(", "); //NOI18N - sb.append(branchOffice.getBranchStreet()); - sb.append(" "); //NOI18N - sb.append(branchOffice.getBranchHouseNumber()); - sb.append(", "); //NOI18N - sb.append(branchOffice.getBranchCountry().getCountryCode()); - sb.append(" "); //NOI18N - sb.append(branchOffice.getBranchZipCode()); - sb.append(" "); //NOI18N - sb.append(branchOffice.getBranchCity()); - } - - // Return it - return sb.toString(); - } - - /** - * Returns the contact's personal title, family name and name. If null is - * provided, an empty string is returned. - *

- * @param contact Contact instance - *

- * @return Contact's full name - */ - public String renderContact (final Contact contact) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(20); - - // Is contact set? - if (contact instanceof Contact) { - // Then create name - sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey())); - sb.append(" "); //NOI18N - sb.append(contact.getContactFirstName()); - sb.append(" "); //NOI18N - sb.append(contact.getContactFamilyName()); - } - - // Return it - return sb.toString(); - } - - /** - * Returns the department's name and name of assigned company. If null is - * provided, an empty string is returned. - *

- * @param department Department instance - *

- * @return Department's full name - */ - public String renderDepartment (final Department department) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(10); - - // Is a department set? - if (department instanceof Department) { - // Then create name - sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey())); - sb.append(" ("); //NOI18N - sb.append(department.getDepartmentCompany().getCompanyName()); - sb.append(")"); //NOI18N - } - - // Return it - return sb.toString(); - } - - /** - * Returns the employee's number, personal title, family name and name if - * available. If null is provided, an empty string is returned. - *

- * @param employee Employable instance -

- * @return Contact's full name - */ - 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 Employable) { - // Then create name - sb.append(employee.getEmployeeNumber()); - - // Is a department found? - if (employee.getEmployeeDepartment() instanceof Department) { - // Then add it's name to it - sb.append(" ("); //NOI18N - sb.append(this.renderDepartment(employee.getEmployeeDepartment())); - sb.append(")"); //NOI18N - } - - // Is contact data found? - if (employee.getEmployeePersonalData() instanceof Contact) { - // Yes, then render it - final String contactName = this.renderContact(employee.getEmployeePersonalData()); - - // Is it given? - if (contactName != null) { - // Then add it - sb.append(" ("); //NOI18N - sb.append(contactName); - sb.append(")"); //NOI18N - } - } - } - - // Return it - 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 renderGenericProduct (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(this.getMessageFromBundle(product.getProductI18nKey())); - sb.append(" ("); //NOI18N - sb.append(this.localizationController.formatCurrency(product.getProductGrossPrice())); - sb.append(" "); //NOI18N - sb.append(product.getProductCurrencyCode()); - sb.append(")"); //NOI18N - } - - // Return it - return sb.toString(); - } - - /** - * Returns the headquarter address. If null is provided, an empty string is - * returned. - *

- * @param headquarter Headquarter instance - *

- * @return Headquarter address - */ - public String renderHeadquarter (final Headquarter headquarter) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(10); - - // Is a headquarter set? - if (headquarter instanceof Headquarter) { - // Then create name - sb.append(headquarter.getHeadquarterStreet()); - sb.append(" "); //NOI18N - sb.append(headquarter.getHeadquarterHouseNumber()); - - // Is store/suite number set? - if (headquarter.getHeadquarterStore() instanceof Short) { - sb.append(" ("); //NOI18N - sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N - sb.append(" "); //NOI18N - sb.append(headquarter.getHeadquarterStore()); - sb.append(", "); //NOI18N - sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N - sb.append(" "); //NOI18N - sb.append(headquarter.getHeadquarterSuiteNumber()); - sb.append(")"); //NOI18N - } - - // Continue with country, ZIP code and city - sb.append(", "); //NOI18N - sb.append(headquarter.getHeadquarterCountry().getCountryCode()); - sb.append(" "); //NOI18N - sb.append(headquarter.getHeadquarterZipCode()); - sb.append(" "); //NOI18N - sb.append(headquarter.getHeadquarterCity()); - } - - // Return it - 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(); - } - - /** - * Returns the user's personal title, family name and name. If null is - * provided, an empty string is returned. - *

- * @param user User instance - *

- * @return User's full name - */ - public String renderUser (final User user) { - // Default is empty string, so let's get started - final StringBuilder sb = new StringBuilder(20); - - // Is user given? - if (user instanceof User) { - // Add user name first - sb.append(user.getUserName()); - sb.append(" ("); //NOI18N - - // Add contact data - sb.append(this.renderContact(user.getUserContact())); - - // Close brace - sb.append(")"); //NOI18N - } - - // Return it - return sb.toString(); - } - - /** - * Set's all given contact's phone instances: land-line, mobile and - * faxNumber - *

- * @param contact Contact to set phone instances for - */ - private void setPhoneInstances (final Contact contact) { - // The contact must be valid - if (null == contact) { - // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { - // Throw again ... - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N - } - - // Is mobile set? - if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { - // Yes, then set it in admin controller - this.setMobileNumber(contact.getContactMobileNumber()); - } - - // Is land-line set? - if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { - // Yes, then set it in admin controller - this.setLandLineNumber(contact.getContactLandLineNumber()); - } - - // Is faxNumber set? - if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { - // Yes, then set it in admin controller - this.setFaxNumber(contact.getContactFaxNumber()); - } - } - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java deleted file mode 100644 index 48ecaf37..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebRequestHelperController.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2016 - 2018 Free Software Foundation - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jjobs.beans.helper; - -import java.io.Serializable; - -/** - * An interface for general bean helper - *

- * @author Roland Häder - */ -public interface JobsWebRequestHelperController extends Serializable { - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java new file mode 100644 index 00000000..4ab1d734 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java @@ -0,0 +1,754 @@ +/* + * Copyright (C) 2016 - 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.helper; + +import java.text.DateFormat; +import java.text.MessageFormat; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent; +import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; +import org.mxchange.jcontacts.model.contact.Contact; +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.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController; +import org.mxchange.jjobs.beans.user.JobsUserWebRequestController; +import org.mxchange.jjobs.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; +import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; +import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent; +import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; +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.jusercore.events.user.created.CreatedUserEvent; +import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; +import org.mxchange.jusercore.model.user.User; + +/** + * A general helper for beans + *

+ * @author Roland Häder + */ +@Named ("beanHelper") +@ViewScoped +public class JobsWebViewHelperBean extends BaseJobsBean implements JobsWebViewHelperController { + + /** + * Serial number + */ + private static final long serialVersionUID = 17_258_793_567_145_701L; + + /** + * Contact instance + */ + private Contact contact; + + /** + * Event for when a contact instance was created + */ + @Any + @Inject + private Event contactCreatedEvent; + + /** + * Fax number + */ + private DialableFaxNumber faxNumber; + + /** + * Event for when a fax number instance was created + */ + @Any + @Inject + private Event faxNumberCreatedEvent; + + /** + * Land-line number + */ + private DialableLandLineNumber landLineNumber; + + /** + * Event for when a land-line number instance was created + */ + @Any + @Inject + private Event landLineNumberCreatedEvent; + + /** + * Localization controller + */ + @Inject + private JobsLocalizationSessionController localizationController; + + /** + * Mobile number + */ + private DialableMobileNumber mobileNumber; + + /** + * Event for when a mobile number instance was created + */ + @Any + @Inject + private Event mobileNumberCreatedEvent; + + /** + * User instance + */ + private User user; + + /** + * Regular user controller + */ + @Inject + private JobsUserWebRequestController userController; + + /** + * Event for when a user instance was created + */ + @Any + @Inject + private Event userCreatedEvent; + + /** + * Default constructor + */ + public JobsWebViewHelperBean () { + // Call super constructor + super(); + } + + /** + * Getter for contact instance + *

+ * @return Contact instance + */ + public Contact getContact () { + return this.contact; + } + + /** + * Setter for contact instance + *

+ * @param contact Contact instance + */ + public void setContact (final Contact contact) { + this.contact = contact; + } + + /** + * Returns a message key depending on if this contact is a user and/or a + * contact. If this contact is unused, a default key is returned. + *

+ * @param contact Contact instance to check + *

+ * @return Message key + */ + public String getContactUsageMessageKey (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Default key is "unused" + String messageKey = "CONTACT_IS_UNUSED"; //NOI18N + + // Check user first + if (this.userController.isContactFound(contact)) { + // Only user + messageKey = "CONTACT_IS_USER"; //NOI18N + } + + // Return message key + return messageKey; + } + + /** + * Getter for dialable fax number + *

+ * @return Dialable fax number + */ + public DialableFaxNumber getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for dialable fax number + *

+ * @param faxNumber Dialable fax number + */ + public void setFaxNumber (final DialableFaxNumber faxNumber) { + this.faxNumber = faxNumber; + } + + /** + * Getter for dialable land-line number + *

+ * @return Dialable land-line number + */ + public DialableLandLineNumber getLandLineNumber () { + return this.landLineNumber; + } + + /** + * Setter for dialable land-line number + *

+ * @param landLineNumber Dialable land-line number + */ + public void setLandLineNumber (final DialableLandLineNumber landLineNumber) { + this.landLineNumber = landLineNumber; + } + + /** + * Getter for dialable mobile number + *

+ * @return Dialable mobile number + */ + public DialableMobileNumber getMobileNumber () { + return this.mobileNumber; + } + + /** + * Setter for dialable mobile number + *

+ * @param mobileNumber Dialable mobile number + */ + public void setMobileNumber (final DialableMobileNumber mobileNumber) { + this.mobileNumber = mobileNumber; + } + + /** + * Getter for user instance + *

+ * @return User instance + */ + public User getUser () { + return this.user; + } + + /** + * Setter for user instance + *

+ * @param user User instance + */ + public void setUser (final User user) { + this.user = user; + } + + /** + * Notifies other controllers (backing beans) if a contact id has been + * successfully converted to a Contact instance. + */ + public void notifyControllerContactConverted () { + // Validate contact instance + if (this.getContact() == null) { + // Throw NPE + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { + // Throw NPE again + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N + } + + // Set all phone instances + this.setPhoneInstances(this.getContact()); + + // Set all fields: user + this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact())); + } + + /** + * Notifies other controllers (backing beans) if a phone id has been + * successfully converted to a DialableFaxNumber instance. + */ + public void notifyControllerFaxNumberConverted () { + // Validate fax instance + if (this.getFaxNumber() == null) { + // Throw NPE + throw new NullPointerException("this.faxNumber is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N + } else if (this.getFaxNumber().getPhoneAreaCode() == null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N + } else if (this.getFaxNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N + } else if (this.getFaxNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N + } else if (this.getFaxNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N + } + + // Fire event + this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber())); + } + + /** + * Notifies other controllers (backing beans) if a phone id has been + * successfully converted to a DialableLandLineNumber instance. + */ + public void notifyControllerLandLineNumberConverted () { + // Validate land-line instance + if (this.getLandLineNumber() == null) { + // Throw NPE + throw new NullPointerException("this.landLineNumber is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N + } else if (this.getLandLineNumber().getPhoneAreaCode() == null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N + } else if (this.getLandLineNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N + } else if (this.getLandLineNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N + } else if (this.getLandLineNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N + } + + // Fire event + this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber())); + } + + /** + * Notifies other controllers (backing beans) if a phone id has been + * successfully converted to a DialableMobileNumber instance. + */ + public void notifyControllerMobileNumberConverted () { + // Validate mobile instance + if (this.getMobileNumber() == null) { + // Throw NPE + throw new NullPointerException("this.mobileNumber is null"); //NOI18N + } else if (this.getMobileNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N + } else if (this.getMobileNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N + } else if (this.getMobileNumber().getMobileProvider() == null) { + // Throw NPE again + throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N + } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N + } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N + } else if (this.getMobileNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N + } else if (this.getMobileNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N + } + + // Fire event + this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber())); + } + + /** + * Notifies other controllers (backing beans) if a user id has been + * successfully converted to a User instance. + */ + public void notifyControllerUserConverted () { + // Validate user instance + if (this.getUser() == null) { + // Throw NPE + throw new NullPointerException("this.user is null"); //NOI18N + } else if (this.getUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("this.user.userId is null"); //NOI18N + } else if (this.getUser().getUserId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N + } + + // Get contact + final Contact userContact = this.getUser().getUserContact(); + + // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs. + this.setContact(userContact); + + // Set all phone instances + this.setPhoneInstances(userContact); + + // Fire event + this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser())); + } + + /** + * Renders data of basic company data + *

+ * @param basicData Basic company data instance + *

+ * @return Basic company data as string + */ + public String renderBasicData (final BasicData basicData) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(30); + + // Is basic company data set? + if (basicData instanceof BasicData) { + // Add company name + sb.append(basicData.getCompanyName()); //NOI18N + + // Is email address set? + if (basicData.getCompanyEmailAddress() != null) { + // Add it + sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N + } + + // Is tax number set? + if (basicData.getCompanyTaxNumber() != null) { + // Add it + sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N + } + } + + // Return it + return sb.toString(); + } + + /** + * Returns the branch office's full address. If null is provided, an empty + * string is returned. + *

+ * @param branchOffice Branch office instance + *

+ * @return Branch office's address + */ + public String renderBranchOffice (final BranchOffice branchOffice) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(30); + + // Is a branch office instance given? + if (branchOffice instanceof BranchOffice) { + // This should not happen: + assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N + + // Yes, then append all data + sb.append(branchOffice.getBranchCompany().getCompanyName()); + sb.append(", "); //NOI18N + sb.append(branchOffice.getBranchStreet()); + sb.append(" "); //NOI18N + sb.append(branchOffice.getBranchHouseNumber()); + sb.append(", "); //NOI18N + sb.append(branchOffice.getBranchCountry().getCountryCode()); + sb.append(" "); //NOI18N + sb.append(branchOffice.getBranchZipCode()); + sb.append(" "); //NOI18N + sb.append(branchOffice.getBranchCity()); + } + + // Return it + return sb.toString(); + } + + /** + * Returns the contact's personal title, family name and name. If null is + * provided, an empty string is returned. + *

+ * @param contact Contact instance + *

+ * @return Contact's full name + */ + public String renderContact (final Contact contact) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(20); + + // Is contact set? + if (contact instanceof Contact) { + // Then create name + sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey())); + sb.append(" "); //NOI18N + sb.append(contact.getContactFirstName()); + sb.append(" "); //NOI18N + sb.append(contact.getContactFamilyName()); + } + + // Return it + return sb.toString(); + } + + /** + * Returns the department's name and name of assigned company. If null is + * provided, an empty string is returned. + *

+ * @param department Department instance + *

+ * @return Department's full name + */ + public String renderDepartment (final Department department) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(10); + + // Is a department set? + if (department instanceof Department) { + // Then create name + sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey())); + sb.append(" ("); //NOI18N + sb.append(department.getDepartmentCompany().getCompanyName()); + sb.append(")"); //NOI18N + } + + // Return it + return sb.toString(); + } + + /** + * Returns the employee's number, personal title, family name and name if + * available. If null is provided, an empty string is returned. + *

+ * @param employee Employable instance + *

+ * @return Contact's full name + */ + 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 Employable) { + // Then create name + sb.append(employee.getEmployeeNumber()); + + // Is a department found? + if (employee.getEmployeeDepartment() instanceof Department) { + // Then add it's name to it + sb.append(" ("); //NOI18N + sb.append(this.renderDepartment(employee.getEmployeeDepartment())); + sb.append(")"); //NOI18N + } + + // Is contact data found? + if (employee.getEmployeePersonalData() instanceof Contact) { + // Yes, then render it + final String contactName = this.renderContact(employee.getEmployeePersonalData()); + + // Is it given? + if (contactName != null) { + // Then add it + sb.append(" ("); //NOI18N + sb.append(contactName); + sb.append(")"); //NOI18N + } + } + } + + // Return it + return sb.toString(); + } + + /** + * Returns the headquarter address. If null is provided, an empty string is + * returned. + *

+ * @param headquarter Headquarter instance + *

+ * @return Headquarter address + */ + public String renderHeadquarter (final Headquarter headquarter) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(10); + + // Is a headquarter set? + if (headquarter instanceof Headquarter) { + // Then create name + sb.append(headquarter.getHeadquarterStreet()); + sb.append(" "); //NOI18N + sb.append(headquarter.getHeadquarterHouseNumber()); + + // Is store/suite number set? + if (headquarter.getHeadquarterStore() instanceof Short) { + sb.append(" ("); //NOI18N + sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N + sb.append(" "); //NOI18N + sb.append(headquarter.getHeadquarterStore()); + sb.append(", "); //NOI18N + sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N + sb.append(" "); //NOI18N + sb.append(headquarter.getHeadquarterSuiteNumber()); + sb.append(")"); //NOI18N + } + + // Continue with country, ZIP code and city + sb.append(", "); //NOI18N + sb.append(headquarter.getHeadquarterCountry().getCountryCode()); + sb.append(" "); //NOI18N + sb.append(headquarter.getHeadquarterZipCode()); + sb.append(" "); //NOI18N + sb.append(headquarter.getHeadquarterCity()); + } + + // 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(50); + + // Is receipt set? + if (receipt instanceof BillableReceipt) { + // Add relevant data + sb.append(this.getMessageFromBundle("RECEIPT_ISSUED")).append(" "); //NOI18N + sb.append(DateFormat.getInstance().format(receipt.getReceiptIssued())).append(", "); //NOI18N + sb.append(this.getMessageFromBundle("PAYMENT_TYPE")).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(); + } + + /** + * Returns the user's personal title, family name and name. If null is + * provided, an empty string is returned. + *

+ * @param user User instance + *

+ * @return User's full name + */ + public String renderUser (final User user) { + // Default is empty string, so let's get started + final StringBuilder sb = new StringBuilder(20); + + // Is user given? + if (user instanceof User) { + // Add user name first + sb.append(user.getUserName()); + sb.append(" ("); //NOI18N + + // Add contact data + sb.append(this.renderContact(user.getUserContact())); + + // Close brace + sb.append(")"); //NOI18N + } + + // Return it + return sb.toString(); + } + + /** + * Set's all given contact's phone instances: land-line, mobile and + * faxNumber + *

+ * @param contact Contact to set phone instances for + */ + private void setPhoneInstances (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Is mobile set? + if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { + // Yes, then set it in admin controller + this.setMobileNumber(contact.getContactMobileNumber()); + } + + // Is land-line set? + if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { + // Yes, then set it in admin controller + this.setLandLineNumber(contact.getContactLandLineNumber()); + } + + // Is faxNumber set? + if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { + // Yes, then set it in admin controller + this.setFaxNumber(contact.getContactFaxNumber()); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java new file mode 100644 index 00000000..b4cd8650 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2016 - 2018 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.helper; + +import java.io.Serializable; + +/** + * An interface for general bean helper + *

+ * @author Roland Häder + */ +public interface JobsWebViewHelperController extends Serializable { + +} diff --git a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java index 578b05b3..a675cbee 100644 --- a/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/mobileprovider/JobsAdminMobileProviderWebRequestBean.java @@ -101,19 +101,17 @@ public class JobsAdminMobileProviderWebRequestBean extends BaseJobsBean implemen * dial-prefix and country combination is done, if found, an exception is * thrown. A redirect should take place after successfull creation. *

- * @return Redirect outcome - *

* @todo Add field validation */ - public String addMobileProvider () { + public void addMobileProvider () { // Create mobile provider instance final MobileProvider mobileProvider = new CellphoneProvider(this.getProviderDialPrefix(), this.getProviderName(), this.getProviderCountry(), this.getProviderMailPattern()); // Is the provider already created? if (this.isMobileProviderCreated(mobileProvider)) { // Then throw exception - this.showFacesMessage("form_add_mobile_provider:providerDialPrefix", "ERROR_ADMIN_MOBILE_PROVIDER_ALREADY_ADDED"); //NOI18N - return ""; //NOI18N + this.showFacesMessage("form_add_mobile_provider:providerDialPrefix", new MobileProviderAlreadyAddedException(mobileProvider)); //NOI18N + return; //NOI18N } // Init variable @@ -129,9 +127,6 @@ public class JobsAdminMobileProviderWebRequestBean extends BaseJobsBean implemen // Fire event this.providerAddedEvent.fire(new AdminMobileProviderAddedEvent(updatedProvider)); - - // Redirect to list - return "admin_list_mobile_provider"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index b83666a3..a63a5713 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -360,9 +360,8 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsBean implements JobsAd /** * Deletes given fax entry data *

- * @return Redirect outcome */ - public String deleteFaxData () { + public void deleteFaxData () { // Get fax number from bean helper DialableFaxNumber number = this.createFaxNumber(); @@ -404,17 +403,12 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsBean implements JobsAd // Fire event this.faxNumberDeletedEvent.fire(new AdminFaxNumberDeletedEvent(number)); - - // All fine, redirect - return "admin_list_fax"; //NOI18N } /** * Deletes given land-line entry data - *

- * @return Redirect outcome */ - public String deleteLandLineData () { + public void deleteLandLineData () { // Get land-line number from helper DialableLandLineNumber number = this.createLandLineNumber(); @@ -456,17 +450,12 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsBean implements JobsAd // Fire event this.landLineNumberDeletedEvent.fire(new AdminLandLineNumberDeletedEvent(number)); - - // All fine, redirect - return "admin_list_landline"; //NOI18N } /** * Deletes given mobile entry data - *

- * @return Redirect outcome */ - public String deleteMobileData () { + public void deleteMobileData () { // Get mobile number from helper DialableMobileNumber number = this.createMobileNumber(); @@ -502,9 +491,6 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsBean implements JobsAd // Fire event this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number)); - - // All fine, redirect - return "admin_list_mobile"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index faeba8ee..31f79a87 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -216,9 +216,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm * sending it to the EJB. The data set in the controller is being verified, * e.g. if the user name or email address is not used yet. *

- * @return Redirect outcome */ - public String addUser () { + public void addUser () { // As the form cannot validate the data (required="true"), check it here if (this.getUserName() == null) { // Throw NPE @@ -248,7 +247,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm this.setUserPasswordRepeat(null); // Skip it - return ""; //NOI18N + return; } try { @@ -276,9 +275,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Clear this bean this.clear(); - - // Return to user list (for now) - return "admin_list_user"; //NOI18N } /** @@ -339,10 +335,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm /** * Deletes given user account - *

- * @return Redirect outcome */ - public String deleteUserData () { + public void deleteUserData () { // Is the user instance valid and CONFIRMED? if (this.getUser() == null) { // Throw NPE @@ -365,17 +359,12 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Fire event this.deleteUserEvent.fire(new AdminDeletedUserEvent(this.getUser(), this.getUserDeleteReason())); - - // Redirect - return "admin_list_user"; //NOI18N } /** * Edits currently loaded user's data in database. - *

- * @return Redirect outcome */ - public String editUserData () { + public void editUserData () { // Null password means not setting it String encryptedPassword = null; @@ -402,14 +391,14 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Not same password entered this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_PASSWORD_REPEAT_DIFFERENT"); //NOI18N - return ""; //NOI18N + return; } else if ((!Objects.equals(this.getUser().getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) { // Clear all fields this.clear(); // User name already exists this.showFacesMessage("form_edit_user:userName", "ADMIN_USER_NAME_ALREADY_EXISTS"); //NOI18N - return ""; //NOI18N + return; } else if (this.isSamePasswordEntered()) { // Same password entered, create container if ((Objects.equals(this.getUser().getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserLoginUtils.ifPasswordMatches(new UserLoginContainer(this.getUser(), this.getUserPassword())))) { @@ -419,7 +408,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Same password entered this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD"); //NOI18N - return ""; //NOI18N + return; } // Encrypt password @@ -441,9 +430,6 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm // Fire event this.updatedUserDataEvent.fire(new AdminUpdatedUserDataEvent(updatedUser)); - - // Return to user list (for now) - return "admin_list_user"; //NOI18N } /** diff --git a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java index 2feff0fa..3dc4c726 100644 --- a/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java @@ -24,13 +24,8 @@ import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; import org.mxchange.jcontactsbusiness.exceptions.basicdata.BasicDataNotFoundException; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -<<<<<<< HEAD:src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; -======= import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewBean; import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewController; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java /** * Converter for basic company data id <-> valid basic company data instance @@ -43,22 +38,14 @@ public class JobsBasicCompanyDataConverter implements Converter { /** * Basic company data backing bean */ -<<<<<<< HEAD:src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java - private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; -======= private static JobsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java @Override public BasicData getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { // Is the instance there? if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly -<<<<<<< HEAD:src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBusinessContactConverter.java - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); -======= BASIC_DATA_LIST_CONTROLLER = CDI.current().select(JobsBasicDataListWebViewBean.class).get(); ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/converter/business/basicdata/JobsBasicCompanyDataConverter.java } // Is the value null or empty? diff --git a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java index a7e4eebf..022e9c4b 100644 --- a/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java +++ b/src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java @@ -24,13 +24,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; -======= import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewBean; import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewController; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java /** * A validator for basic data company names @@ -43,11 +38,7 @@ public class JobsBasicDataCompanyNameValidator extends BaseStringValidator { /** * Business basic data backing bean */ -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java - private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; -======= private static JobsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java /** * Serial number @@ -59,11 +50,7 @@ public class JobsBasicDataCompanyNameValidator extends BaseStringValidator { // Is the instance there? if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); -======= BASIC_DATA_LIST_CONTROLLER = CDI.current().select(JobsBasicDataListWebViewBean.class).get(); ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/business/basicdata/JobsBasicDataCompanyNameValidator.java } // All accepted, required fields diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java index ce6693fd..c2d923f4 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java @@ -25,13 +25,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestBean; -import org.mxchange.jjobs.beans.business.basicdata.JobsBasicDataWebRequestController; -======= import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewBean; import org.mxchange.jjobs.beans.business.basicdata.list.JobsBasicDataListWebViewController; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java /** * A validator for basic company data email address validation @@ -44,11 +39,7 @@ public class JobsBasicDataEmailAddressValidator extends BaseStringValidator { /** * Branch office backing bean */ -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java - private static JobsBasicDataWebRequestController BASIC_DATA_CONTROLLER; -======= private static JobsBasicDataListWebViewController BASIC_DATA_LIST_CONTROLLER; ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java /** * Email pattern @@ -126,11 +117,7 @@ public class JobsBasicDataEmailAddressValidator extends BaseStringValidator { // Is the instance there? if (null == BASIC_DATA_LIST_CONTROLLER) { // Get bean from CDI directly -<<<<<<< HEAD:src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java - BASIC_DATA_CONTROLLER = CDI.current().select(JobsBasicDataWebRequestBean.class).get(); -======= BASIC_DATA_LIST_CONTROLLER = CDI.current().select(JobsBasicDataListWebViewBean.class).get(); ->>>>>>> 11ccdf2a4... Please cherry-pick::src/java/org/mxchange/jjobs/validator/emailaddress/basicdata/JobsBasicDataEmailAddressValidator.java } // Is it registered?