From: Roland Häder Date: Sat, 25 Apr 2020 16:41:39 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6bf698f3d45184c87df7e13ba6ce1d9967020602;p=jfinancials-war.git Please cherry-pick: - introduced new administrative action backing bean (add/update/delete being done here) - land-line, fax and mobile instances must be intialized with null first, then check all respective backing bean properties if they all exist. This fixes the NPEs coming from updated constructors - check Country instance against the interface Country and not not being null - added missing i18n string Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java index dbfb419c..387e1b14 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java @@ -198,13 +198,13 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i DialableFaxNumber fax = null; // Are all 3 fields set? - if (this.getLandLineAreaCode() != null && this.getLandLineCountry() != null && this.getLandLineNumber() != null) { + if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) { // Initialize land number number instance landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); } // Are all 3 fields set? - if (this.getFaxAreaCode() != null && this.getFaxCountry() != null && this.getFaxNumber() != null) { + if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) { // Initialzie fax number instance fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); } diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java index d84e53ab..e2ea689f 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java @@ -996,13 +996,13 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci DialableFaxNumber fax = null; // Are all required fields set? - if (this.getLandLineAreaCode() != null && this.getLandLineCountry() != null && this.getLandLineNumber() != null) { + if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) { // Initialize land-line instance landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); } // Are all required fields set? - if (this.getFaxAreaCode() != null && this.getFaxCountry() != null && this.getFaxNumber() != null) { + if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) { // Initialize fax instance fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); } diff --git a/src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java index 61b9c5bf..6d973896 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java @@ -16,35 +16,9 @@ */ package org.mxchange.jfinancials.beans.business.headquarter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Event; -import javax.enterprise.inject.Any; -import javax.faces.application.FacesMessage; -import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontactsbusiness.events.headquarter.added.HeadquarterAddedEvent; -import org.mxchange.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; -import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -import org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; -import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; -import org.mxchange.jcoreee.dates.DayOfTheWeek; -import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; -import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController; -import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -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; /** * An administrative bean for headquarter @@ -55,822 +29,17 @@ import org.mxchange.jusercore.model.user.User; @RequestScoped public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean implements FinancialsAdminHeadquarterWebRequestController { - /** - * Opening times of this headquarter - */ - private static List headquarterOpeningTimes; - /** * Serial number */ private static final long serialVersionUID = 5_028_697_360_470L; - /** - * EJB for administrative purposes - */ - @EJB (lookup = "java:global/jfinancials-ejb/adminHeadquarter!org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote") - private AdminHeadquarterSessionBeanRemote adminHeadquarterBean; - - /** - * Area code for fax number - */ - private Integer faxAreaCode; - - /** - * Country for fax number - */ - private Country faxCountry; - - /** - * Dial number for fax number - */ - private Long faxNumber; - - /** - * An event being fired when a headquarter has been successfully added - */ - @Inject - @Any - private Event headquarterAddedEvent; - - /** - * City - */ - private String headquarterCity; - - /** - * Headquarter's company name - */ - private String headquarterCompanyName; - - /** - * Contact person in headquarter - */ - private Employable headquarterContactEmployee; - - /** - * Country - */ - private Country headquarterCountry; - - /** - * Email address - */ - private String headquarterEmailAddress; - - /** - * House number - */ - private Short headquarterHouseNumber; - - /** - * House number's extension - */ - private String headquarterHouseNumberExtension; - - /** - * Last house number - */ - private Short headquarterLastHouseNumber; - - /** - * A general headquarter controller (backing bean) - */ - @Inject - private FinancialsHeadquarterListWebViewController headquarterListController; - - /** - * Store - */ - private Short headquarterStore; - - /** - * Headquarter street name - */ - private String headquarterStreet; - - /** - * Suite number - */ - private Short headquarterSuiteNumber; - - /** - * Owning user instance (which this headquarter is assigned to) - */ - private User headquarterUserOwner; - - /** - * ZIP code - */ - private Integer headquarterZipCode; - - /** - * Area code for land-line number - */ - private Integer landLineAreaCode; - - /** - * Country for land-line number - */ - private Country landLineCountry; - - /** - * Dial number for land-line number - */ - private Long landLineNumber; - - /** - * Ending week day - */ - private DayOfTheWeek openingEndDay; - - /** - * Ending time - */ - private Date openingEndTime; - - /** - * Starting week day - */ - private DayOfTheWeek openingStartDay; - - /** - * Starting time - */ - private Date openingStartTime; - /** * Default constructor */ public FinancialsAdminHeadquarterWebRequestBean () { // Call super constructor super(); - - // Is the opening times list there? - if (null == headquarterOpeningTimes) { - // Init list - headquarterOpeningTimes = new ArrayList<>(1); - } - } - - /** - * 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. - */ - public void addHeadquarter () { - // Get instance - final Headquarter headquarter = this.createHeadquarter(); - - // Is the headquarter not created yet? - if (this.headquarterListController.isHeadquarterCreatedByRequiredData(headquarter)) { - // Then show proper faces message - this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N - return; - } - - // Delcare updated instance - final Headquarter updatedHeadquarter; - - try { - // Try to call EJB - updatedHeadquarter = this.adminHeadquarterBean.addHeadquarter(headquarter); - } catch (final HeadquarterAlreadyAddedException ex) { - // Output message - this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED", FacesMessage.SEVERITY_ERROR); //NOI18N - return; - } - - // Fire event - this.headquarterAddedEvent.fire(new HeadquarterAddedEvent(updatedHeadquarter)); - - // Clear this bean - this.clear(); - } - - /** - * Adds opening time to temporary list which will be sent along with the - * headquarter data to the EJB. - */ - public void addOpeningTime () { - // Validate all required fields - if (this.getOpeningEndDay() == null) { - // Throw NPE - throw new NullPointerException("this.openingEndDay is null"); //NOI18N - } else if (this.getOpeningEndTime() == null) { - // Throw NPE - throw new NullPointerException("this.openingEndTime is null"); //NOI18N - } else if (this.getOpeningStartDay() == null) { - // Throw NPE - throw new NullPointerException("this.openingStartDay is null"); //NOI18N - } else if (this.getOpeningStartTime() == null) { - // Throw NPE - throw new NullPointerException("this.openingStartTime is null"); //NOI18N - } - - // Get opening time instance - final OpeningTime openingTime = this.createOpeningTimes(); - - // Is same found? - if (this.isSameOpeningTimeFound(openingTime)) { - // Yes then abort here - this.showFacesMessage("form-admin-add-headquarter-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N - return; - } - - // Add to temporary list - headquarterOpeningTimes.add(openingTime); - - // Clear opening time fields - this.clearOpeningTime(); - } - - /** - * Getter for fax number's area code - *

- * @return Fax number's area code - */ - public Integer getFaxAreaCode () { - return this.faxAreaCode; - } - - /** - * Setter for fax number's area code - *

- * @param faxAreaCode Fax number's area code - */ - public void setFaxAreaCode (final Integer faxAreaCode) { - this.faxAreaCode = faxAreaCode; - } - - /** - * Getter for fax's country instance - *

- * @return Fax' country instance - */ - public Country getFaxCountry () { - return this.faxCountry; - } - - /** - * Setter for fax's country instance - *

- * @param faxCountry Fax' country instance - */ - public void setFaxCountry (final Country faxCountry) { - this.faxCountry = faxCountry; - } - - /** - * Getter for fax number - *

- * @return Fax number - */ - public Long getFaxNumber () { - return this.faxNumber; - } - - /** - * Setter for fax number - *

- * @param faxNumber Fax number - */ - public void setFaxNumber (final Long faxNumber) { - this.faxNumber = faxNumber; - } - - /** - * Getter for city - *

- * @return City - */ - public String getHeadquarterCity () { - return this.headquarterCity; - } - - /** - * Setter for city - *

- * @param headquarterCity City - */ - public void setHeadquarterCity (final String headquarterCity) { - this.headquarterCity = headquarterCity; - } - - /** - * Getter for headquarter's company name - *

- * @return Headquarter's company name - */ - public String getHeadquarterCompanyName () { - return this.headquarterCompanyName; - } - - /** - * Setter for headquarter's company name - *

- * @param headquarterCompanyName Headquarter's company name - */ - public void setHeadquarterCompanyName (final String headquarterCompanyName) { - this.headquarterCompanyName = headquarterCompanyName; - } - - /** - * Getter for headquarter contact person - *

- * @return Headquarter contact person - */ - public Employable getHeadquarterContactEmployee () { - return this.headquarterContactEmployee; - } - - /** - * Setter for headquarter contact person - *

- * @param headquarterContactEmployee Headquarter contact person - */ - public void setHeadquarterContactEmployee (final Employable headquarterContactEmployee) { - this.headquarterContactEmployee = headquarterContactEmployee; - } - - /** - * Getter for country - *

- * @return Country - */ - public Country getHeadquarterCountry () { - return this.headquarterCountry; - } - - /** - * Setter for country - *

- * @param headquarterCountry Country - */ - public void setHeadquarterCountry (final Country headquarterCountry) { - this.headquarterCountry = headquarterCountry; - } - - /** - * Getter for email address - *

- * @return Email address - */ - public String getHeadquarterEmailAddress () { - return this.headquarterEmailAddress; - } - - /** - * Getter for email address - *

- * @param headquarterEmailAddress Email address - */ - public void setHeadquarterEmailAddress (final String headquarterEmailAddress) { - this.headquarterEmailAddress = headquarterEmailAddress; - } - - /** - * Getter for house number - *

- * @return House number - */ - public Short getHeadquarterHouseNumber () { - return this.headquarterHouseNumber; - } - - /** - * Setter for house number - *

- * @param headquarterHouseNumber House number - */ - public void setHeadquarterHouseNumber (final Short headquarterHouseNumber) { - this.headquarterHouseNumber = headquarterHouseNumber; - } - - /** - * Getter for house number's extension - *

- * @return House number's extension - */ - public String getHeadquarterHouseNumberExtension () { - return this.headquarterHouseNumberExtension; - } - - /** - * Setter for house number's extension - *

- * @param headquarterHouseNumberExtension House number's extension - */ - public void setHeadquarterHouseNumberExtension (final String headquarterHouseNumberExtension) { - this.headquarterHouseNumberExtension = headquarterHouseNumberExtension; - } - - /** - * Getter for last house number - *

- * @return Last house number - */ - public Short getHeadquarterLastHouseNumber () { - return this.headquarterLastHouseNumber; - } - - /** - * Setter for last house number - *

- * @param headquarterLastHouseNumber Last house number - */ - public void setHeadquarterLastHouseNumber (final Short headquarterLastHouseNumber) { - this.headquarterLastHouseNumber = headquarterLastHouseNumber; - } - - /** - * Getter for opening times of this headquarter - *

- * @return Opening times - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getHeadquarterOpeningTimes () { - return headquarterOpeningTimes; - } - - /** - * Setter for opening times of this headquarter - *

- * @param headquarterOpeningTimes Opening times - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setHeadquarterOpeningTimes (final List headquarterOpeningTimes) { - FinancialsAdminHeadquarterWebRequestBean.headquarterOpeningTimes = headquarterOpeningTimes; - } - - /** - * Getter for store - *

- * @return Store - */ - public Short getHeadquarterStore () { - return this.headquarterStore; - } - - /** - * Setter for store - *

- * @param headquarterStore Store - */ - public void setHeadquarterStore (final Short headquarterStore) { - this.headquarterStore = headquarterStore; - } - - /** - * Getter for street name - *

- * @return Street name - */ - public String getHeadquarterStreet () { - return this.headquarterStreet; - } - - /** - * Setter for street name - *

- * @param headquarterStreet Street name - */ - public void setHeadquarterStreet (final String headquarterStreet) { - this.headquarterStreet = headquarterStreet; - } - - /** - * Getter for suite number - *

- * @return Suite number - */ - public Short getHeadquarterSuiteNumber () { - return this.headquarterSuiteNumber; - } - - /** - * Setter for suite number - *

- * @param headquarterSuiteNumber Suite number - */ - public void setHeadquarterSuiteNumber (final Short headquarterSuiteNumber) { - this.headquarterSuiteNumber = headquarterSuiteNumber; - } - - /** - * Getter for owning user instance - *

- * @return Owning user instance - */ - public User getHeadquarterUserOwner () { - return this.headquarterUserOwner; - } - - /** - * Setter for owning user instance - *

- * @param headquarterUserOwner Owning user instance - */ - public void setHeadquarterUserOwner (final User headquarterUserOwner) { - this.headquarterUserOwner = headquarterUserOwner; - } - - /** - * Getter for ZIP code\ - *

- * @return ZIP code - */ - public Integer getHeadquarterZipCode () { - return this.headquarterZipCode; - } - - /** - * Setter for ZIP code\ - *

- * @param headquarterZipCode ZIP code - */ - public void setHeadquarterZipCode (final Integer headquarterZipCode) { - this.headquarterZipCode = headquarterZipCode; - } - - /** - * Getter for land-line number's area code - *

- * @return Land-line number's area code - */ - public Integer getLandLineAreaCode () { - return this.landLineAreaCode; - } - - /** - * Setter for land-line number's area code - *

- * @param landLineAreaCode Land-line number's area code - */ - public void setLandLineAreaCode (final Integer landLineAreaCode) { - this.landLineAreaCode = landLineAreaCode; - } - - /** - * Getter for land-line number's country instance - *

- * @return Land-line number's country instance - */ - public Country getLandLineCountry () { - return this.landLineCountry; - } - - /** - * Setter for land-line number's country instance - *

- * @param landLineCountry Land-line number's country instance - */ - public void setLandLineCountry (final Country landLineCountry) { - this.landLineCountry = landLineCountry; - } - - /** - * Getter for land-line number - *

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

- * @param landLineNumber Land-line number - */ - public void setLandLineNumber (final Long landLineNumber) { - this.landLineNumber = landLineNumber; - } - - /** - * Getter for ending week day - *

- * @return Ending week day - */ - public DayOfTheWeek getOpeningEndDay () { - return this.openingEndDay; - } - - /** - * Setter for ending week day - *

- * @param openingEndDay Ending week day - */ - public void setOpeningEndDay (final DayOfTheWeek openingEndDay) { - this.openingEndDay = openingEndDay; - } - - /** - * Getter for ending time - *

- * @return Ending time - */ - @SuppressWarnings ("ReturnOfDateField") - public Date getOpeningEndTime () { - return this.openingEndTime; - } - - /** - * Getter for ending time - *

- * @param openingEndTime Ending time - */ - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setOpeningEndTime (final Date openingEndTime) { - this.openingEndTime = openingEndTime; - } - - /** - * Getter for starting week day - *

- * @return Starting week day - */ - public DayOfTheWeek getOpeningStartDay () { - return this.openingStartDay; - } - - /** - * Getter for starting week day - *

- * @param openingStartDay Starting week day - */ - public void setOpeningStartDay (final DayOfTheWeek openingStartDay) { - this.openingStartDay = openingStartDay; - } - - /** - * Getter for starting time - *

- * @return Starting time - */ - @SuppressWarnings ("ReturnOfDateField") - public Date getOpeningStartTime () { - return this.openingStartTime; - } - - /** - * Getter for starting time - *

- * @param openingStartTime Starting time - */ - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setOpeningStartTime (final Date openingStartTime) { - this.openingStartTime = openingStartTime; - } - - /** - * Clears this bean data - */ - private void clear () { - // Clear all headquarter data - this.setHeadquarterCity(null); - this.setHeadquarterCompanyName(null); - this.setHeadquarterContactEmployee(null); - this.setHeadquarterCountry(null); - this.setHeadquarterEmailAddress(null); - this.setHeadquarterHouseNumber(null); - this.setHeadquarterHouseNumberExtension(null); - this.setHeadquarterLastHouseNumber(null); - this.setHeadquarterStore(null); - this.setHeadquarterStreet(null); - this.setHeadquarterSuiteNumber(null); - this.setHeadquarterUserOwner(null); - this.setHeadquarterZipCode(null); - this.setHeadquarterOpeningTimes(null); - - // Extra-clear opening time - this.clearOpeningTime(); - } - - /** - * Clears all opening time fields - */ - private void clearOpeningTime () { - // Clear all opening time fields - this.setOpeningEndDay(null); - this.setOpeningEndTime(null); - this.setOpeningStartDay(null); - this.setOpeningStartTime(null); - } - - /** - * Prepares an instance of a Headquarter object (entity) with all data from - * this bean. If a complete fax number or land-line number was provided, it - * will be set in the instance as well. - *

- * @return An instance of a Headquarter class (entity) - */ - private Headquarter createHeadquarter () { - // Create new headquarter instance - final Headquarter headquarter = new BusinessHeadquarter(this.getHeadquarterCompanyName(), this.getHeadquarterCity(), this.getHeadquarterCountry(), this.getHeadquarterStreet(), this.getHeadquarterZipCode(), this.getHeadquarterHouseNumber()); - - // Add all other fields, too - headquarter.setHeadquarterContactEmployee(this.getHeadquarterContactEmployee()); - headquarter.setHeadquarterEmailAddress(this.getHeadquarterEmailAddress()); - headquarter.setHeadquarterHouseNumberExtension(this.getHeadquarterHouseNumberExtension()); - headquarter.setHeadquarterLastHouseNumber(this.getHeadquarterLastHouseNumber()); - headquarter.setHeadquarterStore(this.getHeadquarterStore()); - headquarter.setHeadquarterSuiteNumber(this.getHeadquarterSuiteNumber()); - headquarter.setHeadquarterUserOwner(this.getHeadquarterUserOwner()); - - // Generate phone number - final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); - final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); - - // Don't set null or wrong references - if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { - // Now the number must be given - if (landLine.getPhoneAreaCode() == null) { - // Is null - throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (landLine.getPhoneAreaCode() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (landLine.getPhoneNumber() == null) { - // Is null - throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (landLine.getPhoneNumber() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N - } - - // Set phone number - headquarter.setHeadquarterLandLineNumber(landLine); - } - - // Don't set null or wrong references - if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { - // Now the number must be given - if (fax.getPhoneAreaCode() == null) { - // Is null - throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N - } else if (fax.getPhoneAreaCode() < 1) { - // Abort here - throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N - } else if (fax.getPhoneNumber() == null) { - // Is null - throw new NullPointerException("fax.phoneNumber is null"); //NOI18N - } else if (fax.getPhoneNumber() < 1) { - // Abort here - throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N - } - - // Set fax number - headquarter.setHeadquarterFaxNumber(fax); - } - // Is the opening times list filled? - if (!this.getHeadquarterOpeningTimes().isEmpty()) { - // Yes, then set in headquarter, too - headquarter.setHeadquarterOpeningTimes(this.getHeadquarterOpeningTimes()); - } - - // Return fully prepared instance - return headquarter; - } - - /** - * Prepares an instance of a OpeningTimes object (entity) with all data from - * this bean. If a complete fax number or land-line number was provided, it - * will be set in the instance as well. - *

- * @return An instance of a OpeningTimes class (entity) - */ - private OpeningTime createOpeningTimes () { - // Create new openingTime instance - final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime()); - - // Return fully prepared instance - return openingTime; - } - - /** - * Checks if given opening time is already added - *

- * @param openingTime Opening time to be checked - *

- * @return Whether it has been added already - */ - private boolean isSameOpeningTimeFound (final OpeningTime openingTime) { - // Default is not found - boolean isFound = false; - - // Loop through list - for (final OpeningTime ot : this.getHeadquarterOpeningTimes()) { - // Check it - if (Objects.equals(ot, openingTime)) { - // Found same match - isFound = true; - break; - } - } - - // Return it - return isFound; } } diff --git a/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestBean.java new file mode 100644 index 00000000..6e2faccc --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestBean.java @@ -0,0 +1,895 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * 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.jfinancials.beans.business.headquarter.action; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; +import javax.ejb.EJB; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; +import javax.enterprise.inject.Any; +import javax.faces.application.FacesMessage; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.headquarter.added.HeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +import org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcoreee.dates.DayOfTheWeek; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jfinancials.beans.BaseFinancialsBean; +import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController; +import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; +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; + +/** + * An administrative action bean for headquarter + *

+ * @author Roland Häder + */ +@Named ("adminHeadquarterActionController") +@RequestScoped +public class FinancialsAdminHeadquarterActionWebRequestBean extends BaseFinancialsBean implements FinancialsAdminHeadquarterActionWebRequestController { + + /** + * Opening times of this headquarter + */ + private static List headquarterOpeningTimes; + + /** + * Serial number + */ + private static final long serialVersionUID = 5_028_697_360_472L; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jfinancials-ejb/adminHeadquarter!org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote") + private AdminHeadquarterSessionBeanRemote adminHeadquarterBean; + + /** + * Area code for fax number + */ + private Integer faxAreaCode; + + /** + * Country for fax number + */ + private Country faxCountry; + + /** + * Dial number for fax number + */ + private Long faxNumber; + + /** + * An event being fired when a headquarter has been successfully added + */ + @Inject + @Any + private Event headquarterAddedEvent; + + /** + * City + */ + private String headquarterCity; + + /** + * Headquarter's company name + */ + private String headquarterCompanyName; + + /** + * Contact person in headquarter + */ + private Employable headquarterContactEmployee; + + /** + * Country + */ + private Country headquarterCountry; + + /** + * Email address + */ + private String headquarterEmailAddress; + + /** + * House number + */ + private Short headquarterHouseNumber; + + /** + * House number's extension + */ + private String headquarterHouseNumberExtension; + + /** + * Last house number + */ + private Short headquarterLastHouseNumber; + + /** + * A general headquarter controller (backing bean) + */ + @Inject + private FinancialsHeadquarterListWebViewController headquarterListController; + + /** + * Store + */ + private Short headquarterStore; + + /** + * Headquarter street name + */ + private String headquarterStreet; + + /** + * Suite number + */ + private Short headquarterSuiteNumber; + + /** + * Owning user instance (which this headquarter is assigned to) + */ + private User headquarterUserOwner; + + /** + * ZIP code + */ + private Integer headquarterZipCode; + + /** + * Area code for land-line number + */ + private Integer landLineAreaCode; + + /** + * Country for land-line number + */ + private Country landLineCountry; + + /** + * Dial number for land-line number + */ + private Long landLineNumber; + + /** + * Ending week day + */ + private DayOfTheWeek openingEndDay; + + /** + * Ending time + */ + private Date openingEndTime; + + /** + * Starting week day + */ + private DayOfTheWeek openingStartDay; + + /** + * Starting time + */ + private Date openingStartTime; + + /** + * Default constructor + */ + public FinancialsAdminHeadquarterActionWebRequestBean () { + // Call super constructor + super(); + + // Is the opening times list there? + if (null == headquarterOpeningTimes) { + // Init list + headquarterOpeningTimes = new ArrayList<>(1); + } + } + + /** + * 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. + */ + public void addHeadquarter () { + // Get instance + final Headquarter headquarter = this.createHeadquarter(); + + // Is the headquarter not created yet? + if (this.headquarterListController.isHeadquarterCreatedByRequiredData(headquarter)) { + // Then show proper faces message + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N + return; + } + + // Delcare updated instance + final Headquarter updatedHeadquarter; + + try { + // Try to call EJB + updatedHeadquarter = this.adminHeadquarterBean.addHeadquarter(headquarter); + } catch (final HeadquarterAlreadyAddedException ex) { + // Output message + this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED", FacesMessage.SEVERITY_ERROR); //NOI18N + return; + } + + // Fire event + this.headquarterAddedEvent.fire(new HeadquarterAddedEvent(updatedHeadquarter)); + + // Clear this bean + this.clear(); + } + + /** + * Adds opening time to temporary list which will be sent along with the + * headquarter data to the EJB. + */ + public void addOpeningTime () { + // Validate all required fields + if (this.getOpeningEndDay() == null) { + // Throw NPE + throw new NullPointerException("this.openingEndDay is null"); //NOI18N + } else if (this.getOpeningEndTime() == null) { + // Throw NPE + throw new NullPointerException("this.openingEndTime is null"); //NOI18N + } else if (this.getOpeningStartDay() == null) { + // Throw NPE + throw new NullPointerException("this.openingStartDay is null"); //NOI18N + } else if (this.getOpeningStartTime() == null) { + // Throw NPE + throw new NullPointerException("this.openingStartTime is null"); //NOI18N + } + + // Get opening time instance + final OpeningTime openingTime = this.createOpeningTimes(); + + // Is same found? + if (this.isSameOpeningTimeFound(openingTime)) { + // Yes then abort here + this.showFacesMessage("form-admin-add-headquarter-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N + return; + } + + // Add to temporary list + headquarterOpeningTimes.add(openingTime); + + // Clear opening time fields + this.clearOpeningTime(); + } + + /** + * Getter for fax number's area code + *

+ * @return Fax number's area code + */ + public Integer getFaxAreaCode () { + return this.faxAreaCode; + } + + /** + * Setter for fax number's area code + *

+ * @param faxAreaCode Fax number's area code + */ + public void setFaxAreaCode (final Integer faxAreaCode) { + this.faxAreaCode = faxAreaCode; + } + + /** + * Getter for fax's country instance + *

+ * @return Fax' country instance + */ + public Country getFaxCountry () { + return this.faxCountry; + } + + /** + * Setter for fax's country instance + *

+ * @param faxCountry Fax' country instance + */ + public void setFaxCountry (final Country faxCountry) { + this.faxCountry = faxCountry; + } + + /** + * Getter for fax number + *

+ * @return Fax number + */ + public Long getFaxNumber () { + return this.faxNumber; + } + + /** + * Setter for fax number + *

+ * @param faxNumber Fax number + */ + public void setFaxNumber (final Long faxNumber) { + this.faxNumber = faxNumber; + } + + /** + * Getter for city + *

+ * @return City + */ + public String getHeadquarterCity () { + return this.headquarterCity; + } + + /** + * Setter for city + *

+ * @param headquarterCity City + */ + public void setHeadquarterCity (final String headquarterCity) { + this.headquarterCity = headquarterCity; + } + + /** + * Getter for headquarter's company name + *

+ * @return Headquarter's company name + */ + public String getHeadquarterCompanyName () { + return this.headquarterCompanyName; + } + + /** + * Setter for headquarter's company name + *

+ * @param headquarterCompanyName Headquarter's company name + */ + public void setHeadquarterCompanyName (final String headquarterCompanyName) { + this.headquarterCompanyName = headquarterCompanyName; + } + + /** + * Getter for headquarter contact person + *

+ * @return Headquarter contact person + */ + public Employable getHeadquarterContactEmployee () { + return this.headquarterContactEmployee; + } + + /** + * Setter for headquarter contact person + *

+ * @param headquarterContactEmployee Headquarter contact person + */ + public void setHeadquarterContactEmployee (final Employable headquarterContactEmployee) { + this.headquarterContactEmployee = headquarterContactEmployee; + } + + /** + * Getter for country + *

+ * @return Country + */ + public Country getHeadquarterCountry () { + return this.headquarterCountry; + } + + /** + * Setter for country + *

+ * @param headquarterCountry Country + */ + public void setHeadquarterCountry (final Country headquarterCountry) { + this.headquarterCountry = headquarterCountry; + } + + /** + * Getter for email address + *

+ * @return Email address + */ + public String getHeadquarterEmailAddress () { + return this.headquarterEmailAddress; + } + + /** + * Getter for email address + *

+ * @param headquarterEmailAddress Email address + */ + public void setHeadquarterEmailAddress (final String headquarterEmailAddress) { + this.headquarterEmailAddress = headquarterEmailAddress; + } + + /** + * Getter for house number + *

+ * @return House number + */ + public Short getHeadquarterHouseNumber () { + return this.headquarterHouseNumber; + } + + /** + * Setter for house number + *

+ * @param headquarterHouseNumber House number + */ + public void setHeadquarterHouseNumber (final Short headquarterHouseNumber) { + this.headquarterHouseNumber = headquarterHouseNumber; + } + + /** + * Getter for house number's extension + *

+ * @return House number's extension + */ + public String getHeadquarterHouseNumberExtension () { + return this.headquarterHouseNumberExtension; + } + + /** + * Setter for house number's extension + *

+ * @param headquarterHouseNumberExtension House number's extension + */ + public void setHeadquarterHouseNumberExtension (final String headquarterHouseNumberExtension) { + this.headquarterHouseNumberExtension = headquarterHouseNumberExtension; + } + + /** + * Getter for last house number + *

+ * @return Last house number + */ + public Short getHeadquarterLastHouseNumber () { + return this.headquarterLastHouseNumber; + } + + /** + * Setter for last house number + *

+ * @param headquarterLastHouseNumber Last house number + */ + public void setHeadquarterLastHouseNumber (final Short headquarterLastHouseNumber) { + this.headquarterLastHouseNumber = headquarterLastHouseNumber; + } + + /** + * Getter for opening times of this headquarter + *

+ * @return Opening times + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getHeadquarterOpeningTimes () { + return headquarterOpeningTimes; + } + + /** + * Setter for opening times of this headquarter + *

+ * @param headquarterOpeningTimes Opening times + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setHeadquarterOpeningTimes (final List headquarterOpeningTimes) { + FinancialsAdminHeadquarterActionWebRequestBean.headquarterOpeningTimes = headquarterOpeningTimes; + } + + /** + * Getter for store + *

+ * @return Store + */ + public Short getHeadquarterStore () { + return this.headquarterStore; + } + + /** + * Setter for store + *

+ * @param headquarterStore Store + */ + public void setHeadquarterStore (final Short headquarterStore) { + this.headquarterStore = headquarterStore; + } + + /** + * Getter for street name + *

+ * @return Street name + */ + public String getHeadquarterStreet () { + return this.headquarterStreet; + } + + /** + * Setter for street name + *

+ * @param headquarterStreet Street name + */ + public void setHeadquarterStreet (final String headquarterStreet) { + this.headquarterStreet = headquarterStreet; + } + + /** + * Getter for suite number + *

+ * @return Suite number + */ + public Short getHeadquarterSuiteNumber () { + return this.headquarterSuiteNumber; + } + + /** + * Setter for suite number + *

+ * @param headquarterSuiteNumber Suite number + */ + public void setHeadquarterSuiteNumber (final Short headquarterSuiteNumber) { + this.headquarterSuiteNumber = headquarterSuiteNumber; + } + + /** + * Getter for owning user instance + *

+ * @return Owning user instance + */ + public User getHeadquarterUserOwner () { + return this.headquarterUserOwner; + } + + /** + * Setter for owning user instance + *

+ * @param headquarterUserOwner Owning user instance + */ + public void setHeadquarterUserOwner (final User headquarterUserOwner) { + this.headquarterUserOwner = headquarterUserOwner; + } + + /** + * Getter for ZIP code\ + *

+ * @return ZIP code + */ + public Integer getHeadquarterZipCode () { + return this.headquarterZipCode; + } + + /** + * Setter for ZIP code\ + *

+ * @param headquarterZipCode ZIP code + */ + public void setHeadquarterZipCode (final Integer headquarterZipCode) { + this.headquarterZipCode = headquarterZipCode; + } + + /** + * Getter for land-line number's area code + *

+ * @return Land-line number's area code + */ + public Integer getLandLineAreaCode () { + return this.landLineAreaCode; + } + + /** + * Setter for land-line number's area code + *

+ * @param landLineAreaCode Land-line number's area code + */ + public void setLandLineAreaCode (final Integer landLineAreaCode) { + this.landLineAreaCode = landLineAreaCode; + } + + /** + * Getter for land-line number's country instance + *

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; + } + + /** + * Setter for land-line number's country instance + *

+ * @param landLineCountry Land-line number's country instance + */ + public void setLandLineCountry (final Country landLineCountry) { + this.landLineCountry = landLineCountry; + } + + /** + * Getter for land-line number + *

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

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; + } + + /** + * Getter for ending week day + *

+ * @return Ending week day + */ + public DayOfTheWeek getOpeningEndDay () { + return this.openingEndDay; + } + + /** + * Setter for ending week day + *

+ * @param openingEndDay Ending week day + */ + public void setOpeningEndDay (final DayOfTheWeek openingEndDay) { + this.openingEndDay = openingEndDay; + } + + /** + * Getter for ending time + *

+ * @return Ending time + */ + @SuppressWarnings ("ReturnOfDateField") + public Date getOpeningEndTime () { + return this.openingEndTime; + } + + /** + * Getter for ending time + *

+ * @param openingEndTime Ending time + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setOpeningEndTime (final Date openingEndTime) { + this.openingEndTime = openingEndTime; + } + + /** + * Getter for starting week day + *

+ * @return Starting week day + */ + public DayOfTheWeek getOpeningStartDay () { + return this.openingStartDay; + } + + /** + * Getter for starting week day + *

+ * @param openingStartDay Starting week day + */ + public void setOpeningStartDay (final DayOfTheWeek openingStartDay) { + this.openingStartDay = openingStartDay; + } + + /** + * Getter for starting time + *

+ * @return Starting time + */ + @SuppressWarnings ("ReturnOfDateField") + public Date getOpeningStartTime () { + return this.openingStartTime; + } + + /** + * Getter for starting time + *

+ * @param openingStartTime Starting time + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setOpeningStartTime (final Date openingStartTime) { + this.openingStartTime = openingStartTime; + } + + /** + * Clears this bean data + */ + private void clear () { + // Clear all headquarter data + this.setHeadquarterCity(null); + this.setHeadquarterCompanyName(null); + this.setHeadquarterContactEmployee(null); + this.setHeadquarterCountry(null); + this.setHeadquarterEmailAddress(null); + this.setHeadquarterHouseNumber(null); + this.setHeadquarterHouseNumberExtension(null); + this.setHeadquarterLastHouseNumber(null); + this.setHeadquarterStore(null); + this.setHeadquarterStreet(null); + this.setHeadquarterSuiteNumber(null); + this.setHeadquarterUserOwner(null); + this.setHeadquarterZipCode(null); + this.setHeadquarterOpeningTimes(null); + + // Extra-clear opening time + this.clearOpeningTime(); + } + + /** + * Clears all opening time fields + */ + private void clearOpeningTime () { + // Clear all opening time fields + this.setOpeningEndDay(null); + this.setOpeningEndTime(null); + this.setOpeningStartDay(null); + this.setOpeningStartTime(null); + } + + /** + * Prepares an instance of a Headquarter object (entity) with all data from + * this bean. If a complete fax number or land-line number was provided, it + * will be set in the instance as well. + *

+ * @return An instance of a Headquarter class (entity) + */ + private Headquarter createHeadquarter () { + // Create new headquarter instance + final Headquarter headquarter = new BusinessHeadquarter( + this.getHeadquarterCompanyName(), + this.getHeadquarterCity(), + this.getHeadquarterCountry(), + this.getHeadquarterStreet(), + this.getHeadquarterZipCode(), + this.getHeadquarterHouseNumber() + ); + + // Add all other fields, too + headquarter.setHeadquarterContactEmployee(this.getHeadquarterContactEmployee()); + headquarter.setHeadquarterEmailAddress(this.getHeadquarterEmailAddress()); + headquarter.setHeadquarterHouseNumberExtension(this.getHeadquarterHouseNumberExtension()); + headquarter.setHeadquarterLastHouseNumber(this.getHeadquarterLastHouseNumber()); + headquarter.setHeadquarterStore(this.getHeadquarterStore()); + headquarter.setHeadquarterSuiteNumber(this.getHeadquarterSuiteNumber()); + headquarter.setHeadquarterUserOwner(this.getHeadquarterUserOwner()); + + // Initialize variables + DialableLandLineNumber landLine = null; + DialableFaxNumber fax = null; + + // Are all fields set? + if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) { + // Initialize instance + landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + } + + // Are all fields set? + if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) { + // Initialize instance + fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + } + + // Don't set null or wrong references + if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { + // Now the number must be given + if (landLine.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N + } else if (landLine.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N + } else if (landLine.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("phone.phoneNumber is null"); //NOI18N + } else if (landLine.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N + } + + // Set phone number + headquarter.setHeadquarterLandLineNumber(landLine); + } + + // Don't set null or wrong references + if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { + // Now the number must be given + if (fax.getPhoneAreaCode() == null) { + // Is null + throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N + } else if (fax.getPhoneAreaCode() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N + } else if (fax.getPhoneNumber() == null) { + // Is null + throw new NullPointerException("fax.phoneNumber is null"); //NOI18N + } else if (fax.getPhoneNumber() < 1) { + // Abort here + throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N + } + + // Set fax number + headquarter.setHeadquarterFaxNumber(fax); + } + // Is the opening times list filled? + if (!this.getHeadquarterOpeningTimes().isEmpty()) { + // Yes, then set in headquarter, too + headquarter.setHeadquarterOpeningTimes(this.getHeadquarterOpeningTimes()); + } + + // Return fully prepared instance + return headquarter; + } + + /** + * Prepares an instance of a OpeningTimes object (entity) with all data from + * this bean. If a complete fax number or land-line number was provided, it + * will be set in the instance as well. + *

+ * @return An instance of a OpeningTimes class (entity) + */ + private OpeningTime createOpeningTimes () { + // Create new openingTime instance + final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime()); + + // Return fully prepared instance + return openingTime; + } + + /** + * Checks if given opening time is already added + *

+ * @param openingTime Opening time to be checked + *

+ * @return Whether it has been added already + */ + private boolean isSameOpeningTimeFound (final OpeningTime openingTime) { + // Default is not found + boolean isFound = false; + + // Loop through list + for (final OpeningTime ot : this.getHeadquarterOpeningTimes()) { + // Check it + if (Objects.equals(ot, openingTime)) { + // Found same match + isFound = true; + break; + } + } + + // Return it + return isFound; + } + +} diff --git a/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestController.java new file mode 100644 index 00000000..ec84498b --- /dev/null +++ b/src/java/org/mxchange/jfinancials/beans/business/headquarter/action/FinancialsAdminHeadquarterActionWebRequestController.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * 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.jfinancials.beans.business.headquarter.action; + +import java.io.Serializable; + +/** + * An interface for administrative headquarter action controller + *

+ * @author Roland Häder + */ +public interface FinancialsAdminHeadquarterActionWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java index 9af9e3a8..820c1d0c 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java @@ -408,25 +408,46 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp } // Generate phone number - final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); - final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber()); - final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + DialableLandLineNumber landLine = null; + DialableMobileNumber mobile = null; + DialableFaxNumber fax = null; + + // Are all fields set? + if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) { + // Init instance + landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber()); + } + + // Are all fields set? + if (this.getMobileProvider() instanceof MobileProvider && this.getMobileNumber() != null) { + // Initialize instance + mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber()); + } + + // Are all fields set? + if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) { + // Initialize instance + fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); + } // Create new instance - final Contact localContact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName()); + final Contact localContact = new UserContact( + this.getPersonalTitle(), + this.getFirstName(), + this.getFamilyName() + ); // Add all others - localContact.setContactId(this.getContactId()); - localContact.setContactTitle(this.getAcademicTitle()); localContact.setContactBirthday(this.getBirthday()); - localContact.setContactStreet(this.getStreet()); - localContact.setContactHouseNumber(this.getHouseNumber()); - localContact.setContactZipCode(this.getZipCode()); localContact.setContactCity(this.getCity()); + localContact.setContactComment(this.getComment()); localContact.setContactCountry(this.getContactCountry()); localContact.setContactEmailAddress(this.getEmailAddress()); - localContact.setContactBirthday(this.getBirthday()); - localContact.setContactComment(this.getComment()); + localContact.setContactHouseNumber(this.getHouseNumber()); + localContact.setContactId(this.getContactId()); + localContact.setContactStreet(this.getStreet()); + localContact.setContactTitle(this.getAcademicTitle()); + localContact.setContactZipCode(this.getZipCode()); // Set ownContact localContact.setContactOwnContact(Boolean.TRUE); diff --git a/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java index 548eea32..f8cbb418 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java @@ -759,7 +759,14 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem } // Create new instance - final User newUser = new LoginUser(this.getUserName(), this.getUserProfileMode(), this.getUserMustChangePassword(), UserLoginUtils.encryptPassword(password), UserAccountStatus.CONFIRMED, userContact); + final User newUser = new LoginUser( + this.getUserName(), + this.getUserProfileMode(), + this.getUserMustChangePassword(), + UserLoginUtils.encryptPassword(password), + UserAccountStatus.CONFIRMED, + userContact + ); // Get locale from view-root final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale(); diff --git a/src/java/org/mxchange/localization/generic_de_DE.properties b/src/java/org/mxchange/localization/generic_de_DE.properties index 186e35b6..3a7b35d4 100644 --- a/src/java/org/mxchange/localization/generic_de_DE.properties +++ b/src/java/org/mxchange/localization/generic_de_DE.properties @@ -1222,3 +1222,4 @@ PAGE_TITLE_ADMIN_EDIT_BRANCH_OFFICE=Filiale editieren CONTENT_TITLE_ADMIN_EDIT_BRANCH_OFFICE=Filiale editieren: ADMIN_EDIT_BRANCH_OFFICE_TITLE=Filiale mit Id-Nummer {0} editieren: ADMIN_EDIT_BRANCH_OFFICE_NUMBER_TITLE=Filiale Nummer {1} (Id {0}) editieren: +BUTTON_ADMIN_EDIT_BRANCH_OFFICE=Filiale \u00e4ndern diff --git a/src/java/org/mxchange/localization/generic_en_US.properties b/src/java/org/mxchange/localization/generic_en_US.properties index cbb4adcc..05ef418a 100644 --- a/src/java/org/mxchange/localization/generic_en_US.properties +++ b/src/java/org/mxchange/localization/generic_en_US.properties @@ -1132,3 +1132,4 @@ PAGE_TITLE_ADMIN_EDIT_BRANCH_OFFICE=Edit branch office CONTENT_TITLE_ADMIN_EDIT_BRANCH_OFFICE=Edit branch office: ADMIN_EDIT_BRANCH_OFFICE_TITLE=Edit branch office with id {0}: ADMIN_EDIT_BRANCH_OFFICE_NUMBER_TITLE=Edit branch office number {1} (Id {0}): +BUTTON_ADMIN_EDIT_BRANCH_OFFICE=Change branch office diff --git a/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter.tpl b/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter.tpl index 9f0e8845..5035f119 100644 --- a/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter.tpl +++ b/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter.tpl @@ -21,7 +21,7 @@ @@ -54,7 +54,7 @@ @@ -76,17 +76,17 @@ id="headquarterEmailAddress" size="40" maxlength="255" - value="#{adminHeadquarterController.headquarterEmailAddress}" + value="#{adminHeadquarterActionController.headquarterEmailAddress}" validatorMessage="#{msg.ENTERED_EMAIL_ADDRESS_IS_INVALID}" > - + - + @@ -98,41 +98,41 @@ styleClass="ui-noborder" > - + - + - + - + - + - + - + - + - + diff --git a/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter_opening_time.tpl b/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter_opening_time.tpl index 20479554..4256ad25 100644 --- a/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter_opening_time.tpl +++ b/web/WEB-INF/templates/admin/headquarter/admin_form_headquarter_opening_time.tpl @@ -23,7 +23,7 @@ @@ -327,7 +327,7 @@