From aa4ae5d46784ebecf3aeb959f9a0f98017434d7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 24 Apr 2020 05:05:31 +0200 Subject: [PATCH] Please cherry-pick: - added view admin-edit-branch-office view including backing bean action method - added navigation rule from admin-edit-branch-office to admin-list-branch-offices view, including redirect - added event observer for when an administrator has updated a branch office - renamed adminBranchOfficeController to adminBranchOfficeActionController - added many missing i18n strings - renamed i18n string MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsAdminBranchOfficeWebRequestBean.java | 924 -------------- .../list/JobsBranchOfficeListWebViewBean.java | 100 +- ...JobsBranchOfficeListWebViewController.java | 4 +- ...AdminBranchOfficeActionWebRequestBean.java | 1132 +++++++++++++++++ ...ranchOfficeActionWebRequestController.java | 28 + .../list/JobsDepartmentListWebViewBean.java | 2 +- .../JobsAdminHeadquarterWebRequestBean.java | 2 +- .../JobsAdminContactWebRequestBean.java | 12 +- .../contact/JobsContactWebRequestBean.java | 27 +- .../list/JobsContactListWebViewBean.java | 26 + .../JobsAdminContactMobileWebRequestBean.java | 47 +- .../JobsContactMobileWebRequestBean.java | 26 + .../JobsAdminContactPhoneWebRequestBean.java | 35 +- .../phone/JobsContactPhoneWebRequestBean.java | 26 + .../list/JobsMobileListWebViewBean.java | 29 + .../phone/list/JobsPhoneListWebViewBean.java | 29 + .../JobsBranchOfficeConverter.java | 4 +- .../localization/generic_de_DE.properties | 13 +- .../localization/generic_en_US.properties | 9 +- web/WEB-INF/faces-config.xml | 8 + .../admin_form_branch_office_data.tpl | 56 +- .../admin_form_branch_opening_time.tpl | 8 +- .../admin_branch_office_edit.xhtml | 89 ++ .../admin_branch_office_list.xhtml | 8 +- 24 files changed, 1637 insertions(+), 1007 deletions(-) create mode 100644 src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestBean.java create mode 100644 src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestController.java create mode 100644 web/admin/branch_office/admin_branch_office_edit.xhtml 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 62a018db..a3ed888b 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/JobsAdminBranchOfficeWebRequestBean.java @@ -16,37 +16,9 @@ */ package org.mxchange.jjobs.beans.business.branchoffice; -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.branchoffice.added.BranchOfficeAddedEvent; -import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent; -import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; -import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; -import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; -import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.Employable; -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.jjobs.beans.BaseJobsBean; -import org.mxchange.jjobs.beans.business.branchoffice.list.JobsBranchOfficeListWebViewController; -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 branch offices @@ -57,913 +29,17 @@ import org.mxchange.jusercore.model.user.User; @RequestScoped public class JobsAdminBranchOfficeWebRequestBean extends BaseJobsBean implements JobsAdminBranchOfficeWebRequestController { - /** - * Opening times of this branch office - */ - private static List branchOpeningTimes; - /** * Serial number */ private static final long serialVersionUID = 5_028_697_360_461L; - /** - * EJB for administrative purposes - */ - @EJB (lookup = "java:global/jjobs-ejb/adminBranchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote") - private AdminBranchOfficeSessionBeanRemote adminBranchOfficeBean; - - /** - * City - */ - private String branchCity; - - /** - * Assigned company for this branch office - */ - private BasicData branchCompany; - - /** - * Contact person in branch office - */ - private Employable branchContactEmployee; - - /** - * Country - */ - private Country branchCountry; - - /** - * Email address - */ - private String branchEmailAddress; - - /** - * House number - */ - private Short branchHouseNumber; - - /** - * House number's extension (a,b,c,...) - */ - private String branchHouseNumberExtension; - - /** - * Last house number - */ - private Short branchLastHouseNumber; - - /** - * Number of branch office - */ - private Long branchNumber; - - /** - * An event being fired when a branch office has been successfully added - */ - @Inject - @Any - private Event branchOfficeAddedEvent; - - /** - * A list branch office controller (backing bean) - */ - @Inject - private JobsBranchOfficeListWebViewController branchOfficeListController; - - /** - * Owner/leader of branch office - */ - private Employable branchOwner; - - /** - * Store - */ - private Short branchStore; - - /** - * Branch office street name - */ - private String branchStreet; - - /** - * Suite number - */ - private Short branchSuiteNumber; - - /** - * Owning user instance (which this branch office is assigned to) - */ - private User branchUserOwner; - - /** - * ZIP code - */ - private Integer branchZipCode; - - /** - * Area code for fax number - */ - private Integer faxAreaCode; - - /** - * Country for fax number - */ - private Country faxCountry; - - /** - * Dial number for fax number - */ - private Long faxNumber; - - /** - * 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 JobsAdminBranchOfficeWebRequestBean () { // Call super constructor super(); - - // Is the opening times list there? - if (null == branchOpeningTimes) { - // Init list - branchOpeningTimes = new ArrayList<>(1); - } - } - - /** - * 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. - */ - public void addBranchOffice () { - // Get instance - final BranchOffice branchOffice = this.createBranchOffice(); - - // Is the branch office not created yet? - if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) { - // Then show proper faces message - this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N - return; - } - - // Delcare updated instance - final BranchOffice updatedOffice; - - try { - // Try to call EJB - updatedOffice = this.adminBranchOfficeBean.addBranchOffice(branchOffice); - } catch (final BranchOfficeAlreadyAddedException ex) { - // Output message - this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED", FacesMessage.SEVERITY_ERROR); //NOI18N - return; - } - - // Fire event - this.branchOfficeAddedEvent.fire(new BranchOfficeAddedEvent(updatedOffice)); - - // Clear this bean - this.clear(); - } - - /** - * Adds opening time to temporary list which will be sent along with the - * branch office 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-branch-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N - return; - } - - // Add to temporary list - branchOpeningTimes.add(openingTime); - - // Clear opening time fields - this.clearOpeningTime(); - } - - /** - * Getter for city - *

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

- * @param branchCity City - */ - public void setBranchCity (final String branchCity) { - this.branchCity = branchCity; - } - - /** - * Getter for basic company data - *

- * @return Basic company data - */ - public BasicData getBranchCompany () { - return this.branchCompany; - } - - /** - * Setter for basic company data - *

- * @param branchCompany Basic company data - */ - public void setBranchCompany (final BasicData branchCompany) { - this.branchCompany = branchCompany; - } - - /** - * Getter for branch office contact person - *

- * @return Branch office contact person - */ - public Employable getBranchContactEmployee () { - return this.branchContactEmployee; - } - - /** - * Setter for branch office contact person - *

- * @param branchContactEmployee Branch office contact person - */ - public void setBranchContactEmployee (final Employable branchContactEmployee) { - this.branchContactEmployee = branchContactEmployee; - } - - /** - * Getter for country - *

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

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

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

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

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

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

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

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

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

- * @param branchLastHouseNumber Last house number - */ - public void setBranchLastHouseNumber (final Short branchLastHouseNumber) { - this.branchLastHouseNumber = branchLastHouseNumber; - } - - /** - * Getter for branch office number - *

- * @return Branch office number - */ - public Long getBranchNumber () { - return this.branchNumber; - } - - /** - * Setter for branch office number - *

- * @param branchNumber Branch office number - */ - public void setBranchNumber (final Long branchNumber) { - this.branchNumber = branchNumber; - } - - /** - * Getter for opening times of this branch office - *

- * @return Opening times - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getBranchOpeningTimes () { - return branchOpeningTimes; - } - - /** - * Setter for opening times of this branch office - *

- * @param branchOpeningTimes Opening times - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setBranchOpeningTimes (final List branchOpeningTimes) { - JobsAdminBranchOfficeWebRequestBean.branchOpeningTimes = branchOpeningTimes; - } - - /** - * Getter for branch office contact person - *

- * @return Branch office contact person - */ - public Employable getBranchOwner () { - return this.branchOwner; - } - - /** - * Setter for branch office contact person - *

- * @param branchOwner Branch office contact person - */ - public void setBranchOwner (final Employable branchOwner) { - this.branchOwner = branchOwner; - } - - /** - * Getter for store - *

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

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

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

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

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

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

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

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

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

- * @param branchZipCode ZIP code - */ - public void setBranchZipCode (final Integer branchZipCode) { - this.branchZipCode = branchZipCode; - } - - /** - * 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 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 branch office data - this.setBranchCity(null); - this.setBranchCompany(null); - this.setBranchContactEmployee(null); - this.setBranchCountry(null); - this.setBranchEmailAddress(null); - this.setBranchHouseNumber(null); - this.setBranchHouseNumberExtension(null); - this.setBranchLastHouseNumber(null); - this.setBranchNumber(null); - this.setBranchOwner(null); - this.setBranchStore(null); - this.setBranchStreet(null); - this.setBranchSuiteNumber(null); - this.setBranchUserOwner(null); - this.setBranchZipCode(null); - - // Opening times list - this.setBranchOpeningTimes(new ArrayList(1)); - - // Fax and land-line number - this.setFaxAreaCode(null); - this.setFaxCountry(null); - this.setFaxNumber(null); - this.setLandLineAreaCode(null); - this.setLandLineCountry(null); - this.setLandLineNumber(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 BranchOffice 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 BranchOffice class (entity) - */ - private BranchOffice createBranchOffice () { - // Create new branch office instance - final BranchOffice branchOffice = new BusinessBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber()); - - // Add all other fields, too - branchOffice.setBranchContactEmployee(this.getBranchContactEmployee()); - branchOffice.setBranchEmailAddress(this.getBranchEmailAddress()); - branchOffice.setBranchHouseNumberExtension(this.getBranchHouseNumberExtension()); - branchOffice.setBranchLastHouseNumber(this.getBranchLastHouseNumber()); - branchOffice.setBranchNumber(this.getBranchNumber()); - branchOffice.setBranchOwnerEmployee(this.getBranchOwner()); - branchOffice.setBranchStore(this.getBranchStore()); - branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber()); - branchOffice.setBranchUserOwner(this.getBranchUserOwner()); - - // 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 - branchOffice.setBranchLandLineNumber(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 - branchOffice.setBranchFaxNumber(fax); - } - // Is the opening times list filled? - if (!this.getBranchOpeningTimes().isEmpty()) { - // Yes, then set in branch office, too - branchOffice.setBranchOpeningTimes(this.getBranchOpeningTimes()); - } - - // Return fully prepared instance - return branchOffice; - } - - /** - * 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 whether the given branch office's address is already found in - * local cache. Please note that this method fully relies on the cache, so - * you must always fire proper events that add/update/delete entries in - * cache. - *

- * @param branchOffice Branch office to check it's address - *

- * @return Whether the address has been found - */ - private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) { - // Get full list from other bean - final List branchOffices = this.branchOfficeListController.getAllBranchOffices(); - - // Default is not found - boolean isFound = false; - - // Now check each entry - for (final BranchOffice bo : branchOffices) { - // Is same address? - if (BranchOffices.isSameAddress(bo, branchOffice)) { - // Found one - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - - /** - * 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.getBranchOpeningTimes()) { - // Check it - if (Objects.equals(ot, openingTime)) { - // Found same match - isFound = true; - break; - } - } - - // Return it - return isFound; } } diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewBean.java index 0a23589e..543474ce 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewBean.java @@ -19,6 +19,7 @@ package org.mxchange.jjobs.beans.business.branchoffice.list; import fish.payara.cdi.jsr107.impl.NamedCache; import java.text.MessageFormat; import java.util.Comparator; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -29,7 +30,8 @@ import javax.enterprise.event.Observes; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent; +import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableAdminBranchOfficeAddedEvent; +import org.mxchange.jcontactsbusiness.events.branchoffice.updated.ObservableAdminBranchOfficeUpdatedEvent; import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote; @@ -47,7 +49,7 @@ public class JobsBranchOfficeListWebViewBean extends BaseJobsBean implements Job /** * Serial number */ - private static final long serialVersionUID = 5_028_697_360_462L; + private static final long serialVersionUID = 5_028_697_360_468L; /** * A list of all branch offices @@ -89,51 +91,75 @@ public class JobsBranchOfficeListWebViewBean extends BaseJobsBean implements Job } /** - * Observes events being fired when a branch office has been added. + * Observes events being fired when a branch office has been added by an + * administrator. *

* @param event Event being fired + */ + public void afterAdminBranchOfficeAddedEvent (@Observes final ObservableAdminBranchOfficeAddedEvent event) { + // Validate parameter + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getAddedBranchOffice() == null) { + // Throw NPE again + throw new NullPointerException("event.addedBranchOffice is null"); //NOI18N + } else if (event.getAddedBranchOffice().getBranchId() == null) { + // Throw it again + throw new NullPointerException("event.addedBranchOffice .branchId is null"); //NOI18N + } else if (event.getAddedBranchOffice().getBranchId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.addedBranchOffice .branchId={0} is not valid", event.getAddedBranchOffice().getBranchId())); //NOI18N + } + + // Add instance to cache + this.branchOfficeCache.put(event.getAddedBranchOffice().getBranchId(), event.getAddedBranchOffice()); + this.uniqueAddBranchOffice(event.getAddedBranchOffice()); + } + + /** + * Observes events being fired when a branch office has been updated by an + * administrator. *

- * @throws NullPointerException If the parameter or it's carried instance is - * null - * @throws IllegalArgumentException If the branchId is zero or lower + * @param event Event being fired */ - public void afterBranchOfficeAddedEvent (@Observes final ObservableBranchOfficeAddedEvent event) { + public void afterAdminBranchOfficeUpdatedEvent (@Observes final ObservableAdminBranchOfficeUpdatedEvent event) { // Validate parameter if (null == event) { // Throw NPE throw new NullPointerException("event is null"); //NOI18N - } else if (event.getBranchOffice() == null) { + } else if (event.getUpdatedBranchOffice() == null) { // Throw NPE again - throw new NullPointerException("event.branchOffice is null"); //NOI18N - } else if (event.getBranchOffice().getBranchId() == null) { + throw new NullPointerException("event.updatedBranchOffice is null"); //NOI18N + } else if (event.getUpdatedBranchOffice().getBranchId() == null) { // Throw it again - throw new NullPointerException("event.branchOffice.branchId is null"); //NOI18N - } else if (event.getBranchOffice().getBranchId() < 1) { + throw new NullPointerException("event.updatedBranchOffice .branchId is null"); //NOI18N + } else if (event.getUpdatedBranchOffice().getBranchId() < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("event.branchOffice.branchId={0} is not valid", event.getBranchOffice().getBranchId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("event.updatedBranchOffice .branchId={0} is not valid", event.getUpdatedBranchOffice().getBranchId())); //NOI18N } // Add instance to cache - this.branchOfficeCache.put(event.getBranchOffice().getBranchId(), event.getBranchOffice()); - this.getAllBranchOffices().add(event.getBranchOffice()); + this.branchOfficeCache.put(event.getUpdatedBranchOffice().getBranchId(), event.getUpdatedBranchOffice()); + this.uniqueAddBranchOffice(event.getUpdatedBranchOffice()); } @Override - public BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException { + public BranchOffice findBranchOfficeById (final Long branchId) throws BranchOfficeNotFoundException { // Validate parameter - if (null == branchOfficeId) { + if (null == branchId) { // Throw NPE - throw new NullPointerException("branchOfficeId is null"); //NOI18N - } else if (branchOfficeId < 1) { + throw new NullPointerException("branchId is null"); //NOI18N + } else if (branchId < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("branchOfficeId={0} is invalid", branchOfficeId)); //NOI18N - } else if (!this.branchOfficeCache.containsKey(branchOfficeId)) { + throw new IllegalArgumentException(MessageFormat.format("branchId={0} is invalid", branchId)); //NOI18N + } else if (!this.branchOfficeCache.containsKey(branchId)) { // Not found - throw new BranchOfficeNotFoundException(branchOfficeId); + throw new BranchOfficeNotFoundException(branchId); } // Get it from cache - final BranchOffice branchOffice = this.branchOfficeCache.get(branchOfficeId); + final BranchOffice branchOffice = this.branchOfficeCache.get(branchId); // Return it return branchOffice; @@ -243,6 +269,34 @@ public class JobsBranchOfficeListWebViewBean extends BaseJobsBean implements Job return isFound; } + /** + * Uniquely add branch office instance to allBranchOffices property + *

+ * @param branchOffice Branch office being added + */ + private void uniqueAddBranchOffice (final BranchOffice branchOffice) { + // Get iterator + final Iterator iterator = this.getAllBranchOffices().iterator(); + + // Iterate over all + while (iterator.hasNext()) { + // Get current element + final BranchOffice currentBranchOffice = iterator.next(); + + // Does primary key match? + if (Objects.equals(branchOffice.getBranchId(), currentBranchOffice.getBranchId())) { + // Yes then remove this one + iterator.remove(); + + // Re-add maybe updated version + this.getAllBranchOffices().add(branchOffice); + + // Stop iteration + break; + } + } + } + @Override protected Object clone () throws CloneNotSupportedException { return super.clone(); //To change body of generated methods, choose Tools | Templates. diff --git a/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewController.java b/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewController.java index f11accab..89945ab0 100644 --- a/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewController.java +++ b/src/java/org/mxchange/jjobs/beans/business/branchoffice/list/JobsBranchOfficeListWebViewController.java @@ -48,12 +48,12 @@ public interface JobsBranchOfficeListWebViewController extends Serializable { /** * Tries to find a branch office with given id number *

- * @param branchOfficeId Branch office id + * @param branchId Branch office id *

* @return A branch office instance *

* @throws BranchOfficeNotFoundException If the branch office was not found */ - BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException; + BranchOffice findBranchOfficeById (final Long branchId) throws BranchOfficeNotFoundException; } diff --git a/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestBean.java new file mode 100644 index 00000000..cd9a57f9 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestBean.java @@ -0,0 +1,1132 @@ +/* + * 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.jjobs.beans.business.branchoffice.action; + +import java.text.MessageFormat; +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.FacesException; +import javax.faces.application.FacesMessage; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.branchoffice.added.AdminBranchOfficeAddedEvent; +import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableAdminBranchOfficeAddedEvent; +import org.mxchange.jcontactsbusiness.events.branchoffice.updated.AdminBranchOfficeUpdatedEvent; +import org.mxchange.jcontactsbusiness.events.branchoffice.updated.ObservableAdminBranchOfficeUpdatedEvent; +import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException; +import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; +import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; +import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; +import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; +import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; +import org.mxchange.jcontactsbusiness.model.employee.Employable; +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.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.beans.business.branchoffice.list.JobsBranchOfficeListWebViewController; +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 branch offices + *

+ * @author Roland Häder + */ +@Named ("adminBranchOfficeActionController") +@RequestScoped +public class JobsAdminBranchOfficeActionWebRequestBean extends BaseJobsBean implements JobsAdminBranchOfficeActionWebRequestController { + + /** + * Opening times of this branch office + */ + private static List branchOpeningTimes; + + /** + * Serial number + */ + private static final long serialVersionUID = 5_028_697_360_471L; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/adminBranchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote") + private AdminBranchOfficeSessionBeanRemote adminBranchOfficeBean; + + /** + * City + */ + private String branchCity; + + /** + * Assigned company for this branch office + */ + private BasicData branchCompany; + + /** + * Contact person in branch office + */ + private Employable branchContactEmployee; + + /** + * Country + */ + private Country branchCountry; + + /** + * Email address + */ + private String branchEmailAddress; + + /** + * House number + */ + private Short branchHouseNumber; + + /** + * House number's extension (a,b,c,...) + */ + private String branchHouseNumberExtension; + + /** + * Branch office's id number + */ + private Long branchId; + + /** + * Last house number + */ + private Short branchLastHouseNumber; + + /** + * Number of branch office + */ + private Long branchNumber; + + /** + * An event being fired when a branch office has been successfully added + */ + @Inject + @Any + private Event branchOfficeAddedEvent; + + /** + * A list branch office controller (backing bean) + */ + @Inject + private JobsBranchOfficeListWebViewController branchOfficeListController; + + /** + * Owner/leader of branch office + */ + private Employable branchOwnerEmployee; + + /** + * Store + */ + private Short branchStore; + + /** + * Branch office street name + */ + private String branchStreet; + + /** + * Suite number + */ + private Short branchSuiteNumber; + + /** + * Owning user instance (which this branch office is assigned to) + */ + private User branchUserOwner; + + /** + * ZIP code + */ + private Integer branchZipCode; + + /** + * Currently worked on branch office + */ + private BranchOffice currentBranchOffice; + + /** + * Area code for fax number + */ + private Integer faxAreaCode; + + /** + * Country for fax number + */ + private Country faxCountry; + + /** + * Dial number for fax number + */ + private Long faxNumber; + + /** + * 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; + + /** + * Event being fired when an administrator has updated a branch office + */ + @Any + @Inject + private Event updatedBranchOfficeEvent; + + /** + * Default constructor + */ + public JobsAdminBranchOfficeActionWebRequestBean () { + // Call super constructor + super(); + + // Is the opening times list there? + if (null == branchOpeningTimes) { + // Init list + branchOpeningTimes = new ArrayList<>(1); + } + } + + /** + * 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. + */ + public void addBranchOffice () { + // Get instance + final BranchOffice branchOffice = this.createBranchOffice(); + + // Is the branch office not created yet? + if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) { + // Then show proper faces message + this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N + return; + } + + // Delcare updated instance + final BranchOffice updatedOffice; + + try { + // Try to call EJB + updatedOffice = this.adminBranchOfficeBean.addBranchOffice(branchOffice); + } catch (final BranchOfficeAlreadyAddedException ex) { + // Output message + this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED", FacesMessage.SEVERITY_ERROR); //NOI18N + return; + } + + // Fire event + this.branchOfficeAddedEvent.fire(new AdminBranchOfficeAddedEvent(updatedOffice)); + + // Clear this bean + this.clear(); + } + + /** + * Adds opening time to temporary list which will be sent along with the + * branch office 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-branch-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED", FacesMessage.SEVERITY_WARN); //NOI18N + return; + } + + // Add to temporary list + branchOpeningTimes.add(openingTime); + + // Clear opening time fields + this.clearOpeningTime(); + } + + /** + * Copies all current branch office's properties back to this bean. + */ + public void copyAllBranchOfficeProperties () { + // Validate current product instance + if (this.getCurrentBranchOffice() == null) { + // Throw NPE + throw new NullPointerException("this.product is null"); //NOI18N + } else if (this.getCurrentBranchOffice().getBranchId() == null) { + // Throw NPE again + throw new NullPointerException("this.product.branchId is null"); //NOI18N + } else if (this.getCurrentBranchOffice().getBranchId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.product.branchId={0} is not valid.", this.getCurrentBranchOffice().getBranchId())); //NOI18N + } + + // Now copy all fields + this.setBranchCity(this.getCurrentBranchOffice().getBranchCity()); + this.setBranchCompany(this.getCurrentBranchOffice().getBranchCompany()); + this.setBranchContactEmployee(this.getCurrentBranchOffice().getBranchContactEmployee()); + this.setBranchCountry(this.getCurrentBranchOffice().getBranchCountry()); + this.setBranchEmailAddress(this.getCurrentBranchOffice().getBranchEmailAddress()); + this.setBranchHouseNumber(this.getCurrentBranchOffice().getBranchHouseNumber()); + this.setBranchHouseNumberExtension(this.getCurrentBranchOffice().getBranchHouseNumberExtension()); + this.setBranchId(this.getCurrentBranchOffice().getBranchId()); + this.setBranchLastHouseNumber(this.getCurrentBranchOffice().getBranchLastHouseNumber()); + this.setBranchNumber(this.getCurrentBranchOffice().getBranchNumber()); + this.setBranchOpeningTimes(this.getCurrentBranchOffice().getBranchOpeningTimes()); + this.setBranchOwnerEmployee(this.getCurrentBranchOffice().getBranchOwnerEmployee()); + this.setBranchStore(this.getCurrentBranchOffice().getBranchStore()); + this.setBranchStreet(this.getCurrentBranchOffice().getBranchStreet()); + this.setBranchSuiteNumber(this.getCurrentBranchOffice().getBranchSuiteNumber()); + this.setBranchUserOwner(this.getCurrentBranchOffice().getBranchUserOwner()); + this.setBranchZipCode(this.getCurrentBranchOffice().getBranchZipCode()); + } + + /** + * Getter for city + *

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

+ * @param branchCity City + */ + public void setBranchCity (final String branchCity) { + this.branchCity = branchCity; + } + + /** + * Getter for basic company data + *

+ * @return Basic company data + */ + public BasicData getBranchCompany () { + return this.branchCompany; + } + + /** + * Setter for basic company data + *

+ * @param branchCompany Basic company data + */ + public void setBranchCompany (final BasicData branchCompany) { + this.branchCompany = branchCompany; + } + + /** + * Getter for branch office contact person + *

+ * @return Branch office contact person + */ + public Employable getBranchContactEmployee () { + return this.branchContactEmployee; + } + + /** + * Setter for branch office contact person + *

+ * @param branchContactEmployee Branch office contact person + */ + public void setBranchContactEmployee (final Employable branchContactEmployee) { + this.branchContactEmployee = branchContactEmployee; + } + + /** + * Getter for country + *

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

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

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

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

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

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

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

+ * @param branchHouseNumberExtension House number's extension + */ + public void setBranchHouseNumberExtension (final String branchHouseNumberExtension) { + this.branchHouseNumberExtension = branchHouseNumberExtension; + } + + /** + * Getter for branch office's id number + *

+ * @return Branch office's id number + */ + public Long getBranchId () { + return this.branchId; + } + + /** + * Setter for branch office's id number + *

+ * @param branchId Branch office's id number + */ + public void setBranchId (final Long branchId) { + this.branchId = branchId; + } + + /** + * Getter for last house number + *

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

+ * @param branchLastHouseNumber Last house number + */ + public void setBranchLastHouseNumber (final Short branchLastHouseNumber) { + this.branchLastHouseNumber = branchLastHouseNumber; + } + + /** + * Getter for branch office number + *

+ * @return Branch office number + */ + public Long getBranchNumber () { + return this.branchNumber; + } + + /** + * Setter for branch office number + *

+ * @param branchNumber Branch office number + */ + public void setBranchNumber (final Long branchNumber) { + this.branchNumber = branchNumber; + } + + /** + * Getter for opening times of this branch office + *

+ * @return Opening times + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getBranchOpeningTimes () { + return branchOpeningTimes; + } + + /** + * Setter for opening times of this branch office + *

+ * @param branchOpeningTimes Opening times + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setBranchOpeningTimes (final List branchOpeningTimes) { + JobsAdminBranchOfficeActionWebRequestBean.branchOpeningTimes = branchOpeningTimes; + } + + /** + * Getter for branch office contact person + *

+ * @return Branch office contact person + */ + public Employable getBranchOwnerEmployee () { + return this.branchOwnerEmployee; + } + + /** + * Setter for branch office contact person + *

+ * @param branchOwnerEmployee Branch office contact person + */ + public void setBranchOwnerEmployee (final Employable branchOwnerEmployee) { + this.branchOwnerEmployee = branchOwnerEmployee; + } + + /** + * Getter for store + *

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

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

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

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

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

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

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

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

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

+ * @param branchZipCode ZIP code + */ + public void setBranchZipCode (final Integer branchZipCode) { + this.branchZipCode = branchZipCode; + } + + /** + * Getter for current branch office + *

+ * @return Current branch office + */ + public BranchOffice getCurrentBranchOffice () { + return this.currentBranchOffice; + } + + /** + * Setter for current branch office + *

+ * @param currentBranchOffice Current branch office + */ + public void setCurrentBranchOffice (final BranchOffice currentBranchOffice) { + this.currentBranchOffice = currentBranchOffice; + } + + /** + * 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 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; + } + + /** + * Updates currently worked on branch office data + *

+ * @return Redirection outcome + */ + public String updateBranchOffice () { + // Id should be set + if (this.getBranchId() == null) { + // Throw NPE + throw new NullPointerException("this.branchId is null"); //NOI18N + } else if (this.getBranchId() < 1) { + // Throw ISE + throw new IllegalStateException(MessageFormat.format("this.branchId={0} is not valid.", this.getBranchId())); //NOI18N + } + + // Init instance with fresh data + final BranchOffice branchOffice = this.createBranchOffice(); + + // Does current (not updated) and just created (maybe updated) match? + if (Objects.equals(this.getCurrentBranchOffice(), branchOffice)) { + // Yes, then output message + this.showFacesMessage("form-admin-edit-branch-office:branchCompany", "ADMIN_BRANCH_OFFICE_NOT_UPDATED", FacesMessage.SEVERITY_WARN); //NOI18N + + // Skip below code + return ""; //NOI18N + } + + // Copy all fields + BranchOffices.copyBranchOfficeData(this.getCurrentBranchOffice(), branchOffice); + + // Initialize updated instance + final BranchOffice updatedBranchOffice; + + // Try it + try { + // Invoke EJB + updatedBranchOffice = this.adminBranchOfficeBean.updateBranchOffice(branchOffice); + } catch (final BranchOfficeNotFoundException ex) { + // Throw as a cause + throw new FacesException(ex); + } + + // Fire event + this.updatedBranchOfficeEvent.fire(new AdminBranchOfficeUpdatedEvent(updatedBranchOffice)); + + // Redirect to list view + return "admin_list_branch_office"; //NOI18N + } + + /** + * Clears this bean data + */ + private void clear () { + // Clear all branch office data + this.setBranchCity(null); + this.setBranchCompany(null); + this.setBranchContactEmployee(null); + this.setBranchCountry(null); + this.setBranchEmailAddress(null); + this.setBranchHouseNumber(null); + this.setBranchHouseNumberExtension(null); + this.setBranchLastHouseNumber(null); + this.setBranchNumber(null); + this.setBranchOwnerEmployee(null); + this.setBranchStore(null); + this.setBranchStreet(null); + this.setBranchSuiteNumber(null); + this.setBranchUserOwner(null); + this.setBranchZipCode(null); + + // Opening times list + this.setBranchOpeningTimes(new ArrayList(1)); + + // Fax and land-line number + this.setFaxAreaCode(null); + this.setFaxCountry(null); + this.setFaxNumber(null); + this.setLandLineAreaCode(null); + this.setLandLineCountry(null); + this.setLandLineNumber(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 BranchOffice 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 BranchOffice class (entity) + */ + private BranchOffice createBranchOffice () { + // Create new branch office instance + final BranchOffice branchOffice = new BusinessBranchOffice( + this.getBranchCity(), + this.getBranchCompany(), + this.getBranchCountry(), + this.getBranchStreet(), + this.getBranchZipCode(), + this.getBranchHouseNumber() + ); + + // Add all other fields, too + branchOffice.setBranchId(this.getBranchId()); + branchOffice.setBranchContactEmployee(this.getBranchContactEmployee()); + branchOffice.setBranchEmailAddress(this.getBranchEmailAddress()); + branchOffice.setBranchHouseNumberExtension(this.getBranchHouseNumberExtension()); + branchOffice.setBranchLastHouseNumber(this.getBranchLastHouseNumber()); + branchOffice.setBranchNumber(this.getBranchNumber()); + branchOffice.setBranchOwnerEmployee(this.getBranchOwnerEmployee()); + branchOffice.setBranchStore(this.getBranchStore()); + branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber()); + branchOffice.setBranchUserOwner(this.getBranchUserOwner()); + + // Init variables + DialableLandLineNumber landLine = null; + DialableFaxNumber fax = null; + + // Are all required fields set? + if (this.getLandLineAreaCode() != null && this.getLandLineCountry() != null && 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) { + // Initialize fax 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 + branchOffice.setBranchLandLineNumber(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 + branchOffice.setBranchFaxNumber(fax); + } + // Is the opening times list filled? + if (!this.getBranchOpeningTimes().isEmpty()) { + // Yes, then set in branch office, too + branchOffice.setBranchOpeningTimes(this.getBranchOpeningTimes()); + } + + // Return fully prepared instance + return branchOffice; + } + + /** + * 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 whether the given branch office's address is already found in + * local cache. Please note that this method fully relies on the cache, so + * you must always fire proper events that add/update/delete entries in + * cache. + *

+ * @param branchOffice Branch office to check it's address + *

+ * @return Whether the address has been found + */ + private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) { + // Get full list from other bean + final List branchOffices = this.branchOfficeListController.getAllBranchOffices(); + + // Default is not found + boolean isFound = false; + + // Now check each entry + for (final BranchOffice bo : branchOffices) { + // Is same address? + if (BranchOffices.isSameAddress(bo, branchOffice)) { + // Found one + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + /** + * 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.getBranchOpeningTimes()) { + // Check it + if (Objects.equals(ot, openingTime)) { + // Found same match + isFound = true; + break; + } + } + + // Return it + return isFound; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestController.java new file mode 100644 index 00000000..c9b38969 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/department/action/JobsAdminBranchOfficeActionWebRequestController.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.jjobs.beans.business.branchoffice.action; + +import java.io.Serializable; + +/** + * An interface for administrative branch office controller + *

+ * @author Roland Häder + */ +public interface JobsAdminBranchOfficeActionWebRequestController extends Serializable { + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/department/list/JobsDepartmentListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/business/department/list/JobsDepartmentListWebViewBean.java index 05294fe0..3d2d155d 100644 --- a/src/java/org/mxchange/jjobs/beans/business/department/list/JobsDepartmentListWebViewBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/department/list/JobsDepartmentListWebViewBean.java @@ -47,7 +47,7 @@ public class JobsDepartmentListWebViewBean extends BaseJobsBean implements JobsD /** * Serial number */ - private static final long serialVersionUID = 5_028_697_360_462L; + private static final long serialVersionUID = 5_028_697_360_469L; /** * A list of all departments 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 79fd3c9a..abc53b35 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java @@ -63,7 +63,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements /** * Serial number */ - private static final long serialVersionUID = 5_028_697_360_462L; + private static final long serialVersionUID = 5_028_697_360_470L; /** * EJB for administrative purposes diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 728edaf4..173c97f7 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -553,8 +553,16 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs // Update all data in contact this.updateContactData(createdContact); - // Call EJB for updating contact data - final Contact updatedContact = this.contactBean.updateContactData(createdContact, this.isMobileNumberUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); + // Init updated contact instance + final Contact updatedContact; + + try { + // Call EJB for updating contact data + updatedContact = this.contactBean.updateContactData(createdContact, this.isMobileNumberUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); + } catch (final ContactNotFoundException ex) { + // Throw as a cause + throw new FacesException(ex); + } // Fire event this.updatedContactEvent.fire(new AdminUpdatedContactEvent(updatedContact)); diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index d9e62b76..03197352 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java @@ -21,11 +21,16 @@ import java.util.Date; import java.util.Objects; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; +import javax.enterprise.event.Event; import javax.enterprise.event.Observes; +import javax.enterprise.inject.Any; import javax.faces.FacesException; import javax.faces.application.FacesMessage; import javax.inject.Inject; import javax.inject.Named; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.model.contact.Contacts; @@ -93,6 +98,13 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta */ private JobsContactListWebViewController contactListController; + /** + * Event being fired when a user has updated his contact data + */ + @Any + @Inject + private Event contactUpdatedEvent; + /** * Country instance */ @@ -368,8 +380,19 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta // Update contact's fax number final boolean isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); - // Send it to the EJB - this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked); + // Init updated contact instance + final Contact updatedContact; + + try { + // Send it to the EJB + updatedContact = this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked); + } catch (final ContactNotFoundException ex) { + // Throw as cause + throw new FacesException(ex); + } + + // Fire event + this.contactUpdatedEvent.fire(new UpdatedContactEvent(updatedContact)); // All fine return "contact_data_saved"; //NOI18N diff --git a/src/java/org/mxchange/jjobs/beans/contact/list/JobsContactListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/contact/list/JobsContactListWebViewBean.java index 5c8b19a1..c4de0434 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/list/JobsContactListWebViewBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/list/JobsContactListWebViewBean.java @@ -32,6 +32,7 @@ import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.deleted.ObservableAdminDeletedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent; import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent; import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent; @@ -277,6 +278,31 @@ public class JobsContactListWebViewBean extends BaseJobsBean implements JobsCont this.uniqueAddContact(event.getUpdatedContact()); } + /** + * Event observer for updated contact data by the user + *

+ * @param event Updated contact data event + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Add contact instance only once + this.uniqueAddContact(event.getUpdatedContact()); + } + /** * Event observer when user confirmed account. *

diff --git a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsAdminContactMobileWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsAdminContactMobileWebRequestBean.java index 5d5a4801..a0c26bb3 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsAdminContactMobileWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsAdminContactMobileWebRequestBean.java @@ -29,16 +29,18 @@ import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent; import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent; import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent; import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote; +import org.mxchange.jcontacts.model.mobile.AdminContactsMobileSessionBeanRemote; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; -import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException; -import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException; +import org.mxchange.jphone.exceptions.mobile.MobileNumberAlreadyLinkedException; +import org.mxchange.jphone.exceptions.mobile.MobileNumberNotLinkedException; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; @@ -59,10 +61,10 @@ public class JobsAdminContactMobileWebRequestBean extends BaseJobsBean implement private static final long serialVersionUID = 542_145_347_919L; /** - * Administrative EJB for phone number + * Administrative EJB for mobile number */ - @EJB (lookup = "java:global/jjobs-ejb/adminContactPhone!org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote") - private AdminContactsPhoneSessionBeanRemote adminContactPhoneBean; + @EJB (lookup = "java:global/jjobs-ejb/adminContactMobile!org.mxchange.jcontacts.model.mobile.AdminContactsMobileSessionBeanRemote") + private AdminContactsMobileSessionBeanRemote adminContactMobileBean; /** * Event being fired when a mobile number has been linked @@ -257,6 +259,31 @@ public class JobsAdminContactMobileWebRequestBean extends BaseJobsBean implement this.setMobileEntryUpdated(number.getMobileEntryUpdated()); } + /** + * Event observer for updated contact data by the user + *

+ * @param event Updated contact data event + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Clear all data + this.clear(); + } + /** * Links mobile number to contact from bean helper as "main mobile number". *

@@ -300,8 +327,8 @@ public class JobsAdminContactMobileWebRequestBean extends BaseJobsBean implement // Try it again try { // Link it, too - updatedContact = this.adminContactPhoneBean.linkNewMobileNumberWithContact(targetContact, number); - } catch (final PhoneNumberAlreadyLinkedException ex) { + updatedContact = this.adminContactMobileBean.linkNewMobileNumberWithContact(targetContact, number); + } catch (final MobileNumberAlreadyLinkedException | ContactNotFoundException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N @@ -436,8 +463,8 @@ public class JobsAdminContactMobileWebRequestBean extends BaseJobsBean implement try { // Unlink it and return contact without mobile instance - updatedContact = this.adminContactPhoneBean.unlinkMobileDataFromContact(this.getContact(), number); - } catch (final PhoneNumberNotLinkedException ex) { + updatedContact = this.adminContactMobileBean.unlinkMobileDataFromContact(this.getContact(), number); + } catch (final MobileNumberNotLinkedException | ContactNotFoundException ex) { // Did not work this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N diff --git a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java index 25c0af4e..75df73db 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/mobile/JobsContactMobileWebRequestBean.java @@ -26,6 +26,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController; @@ -168,6 +169,31 @@ public class JobsContactMobileWebRequestBean extends BaseJobsBean implements Job this.setMobileNumber(event.getMobileNumber()); } + /** + * Event observer for updated contact data by the user + *

+ * @param event Updated contact data event + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Clear all data + this.clear(); + } + /** * Getter for all contacts having current mobile number linked *

diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java index 5d1f90be..eb8a01fe 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java @@ -29,6 +29,7 @@ import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent; import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent; import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent; @@ -37,6 +38,7 @@ import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEv import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent; import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent; import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote; import org.mxchange.jcountry.model.data.Country; @@ -345,6 +347,31 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements this.setPhoneEntryUpdated(number.getPhoneEntryUpdated()); } + /** + * Event observer for updated contact data by the user + *

+ * @param event Updated contact data event + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Clear all data + this.clear(); + } + /** * Links fax number to contact from bean helper as "main fax number". *

@@ -395,7 +422,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements try { // Link it, too updatedContact = this.adminContactPhoneBean.linkNewFaxNumberWithContact(targetContact, number); - } catch (final PhoneNumberAlreadyLinkedException ex) { + } catch (final PhoneNumberAlreadyLinkedException | ContactNotFoundException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_fax:faxNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N @@ -459,7 +486,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements try { // Link it, too updatedContact = this.adminContactPhoneBean.linkNewLandLineNumberWithContact(targetContact, number); - } catch (final PhoneNumberAlreadyLinkedException ex) { + } catch (final PhoneNumberAlreadyLinkedException | ContactNotFoundException ex) { // Throw again as cause this.showFacesMessage("form_add_contact_landLine:landLineNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N @@ -658,7 +685,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements try { // Unlink it and return contact without fax instance updatedContact = this.adminContactPhoneBean.unlinkFaxDataFromContact(this.getContact(), number); - } catch (final PhoneNumberNotLinkedException ex) { + } catch (final PhoneNumberNotLinkedException | ContactNotFoundException ex) { // Did not work this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N @@ -713,7 +740,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsBean implements try { // Unlink it and return contact without landLine instance updatedContact = this.adminContactPhoneBean.unlinkLandLineDataFromContact(this.getContact(), number); - } catch (final PhoneNumberNotLinkedException ex) { + } catch (final PhoneNumberNotLinkedException | ContactNotFoundException ex) { // Did not work this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N return ""; //NOI18N diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java index ed939622..cc2ace7c 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebRequestBean.java @@ -26,6 +26,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController; @@ -201,6 +202,31 @@ public class JobsContactPhoneWebRequestBean extends BaseJobsBean implements Jobs this.setLandLineNumber(event.getLandLineNumber()); } + /** + * Event observer for updated contact data by the user + *

+ * @param event Updated contact data event + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Clear all data + this.clear(); + } + /** * Getter for all contacts having current fax number linked *

diff --git a/src/java/org/mxchange/jjobs/beans/mobile/list/JobsMobileListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/mobile/list/JobsMobileListWebViewBean.java index 3fe9c493..6bd46bb6 100644 --- a/src/java/org/mxchange/jjobs/beans/mobile/list/JobsMobileListWebViewBean.java +++ b/src/java/org/mxchange/jjobs/beans/mobile/list/JobsMobileListWebViewBean.java @@ -31,6 +31,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jjobs.beans.BaseJobsBean; @@ -274,6 +275,34 @@ public class JobsMobileListWebViewBean extends BaseJobsBean implements JobsMobil this.clear(); } + /** + * Observes events being fired when an user has updated contact data. + *

+ * @param event Event being fired + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // userId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Update contact's mobile, land-line and mobile number + this.updateContactMobileNumbers(event.getUpdatedContact()); + + // Clear all data + this.clear(); + } + @Override public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws MobileEntityNotFoundException { // Validate paramter diff --git a/src/java/org/mxchange/jjobs/beans/phone/list/JobsPhoneListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/phone/list/JobsPhoneListWebViewBean.java index 398fbdb5..0f72401e 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/list/JobsPhoneListWebViewBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/list/JobsPhoneListWebViewBean.java @@ -31,6 +31,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent; import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent; import org.mxchange.jcontacts.model.contact.Contact; @@ -366,6 +367,34 @@ public class JobsPhoneListWebViewBean extends BaseJobsBean implements JobsPhoneL this.clear(); } + /** + * Observes events being fired when an user has updated contact data. + *

+ * @param event Event being fired + */ + public void afterUpdatedContactDataEvent (@Observes final ObservableUpdatedContactEvent event) { + // Event and contained entity instance should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUpdatedContact() == null) { + // Throw NPE again + throw new NullPointerException("event.updatedContact is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() == null) { + // phoneId is null + throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N + } else if (event.getUpdatedContact().getContactId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N + } + + // Update contact's mobile, land-line and fax number + this.updateContactPhoneNumbers(event.getUpdatedContact()); + + // Clear all data + this.clear(); + } + @Override public DialableFaxNumber findFaxNumberById (final Long phoneId) throws PhoneEntityNotFoundException { // Validate paramter diff --git a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java index f05fe543..6aa69961 100644 --- a/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/branchoffice/JobsBranchOfficeConverter.java @@ -59,10 +59,10 @@ public class JobsBranchOfficeConverter implements Converter { try { // Try to parse the value as long - final Long branchOfficeId = Long.valueOf(submittedValue); + final Long branchId = Long.valueOf(submittedValue); // Try to get user instance from it - branchOffice = BRANCH_OFFICE_LIST_CONTROLLER.findBranchOfficeById(branchOfficeId); + branchOffice = BRANCH_OFFICE_LIST_CONTROLLER.findBranchOfficeById(branchId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/localization/generic_de_DE.properties b/src/java/org/mxchange/localization/generic_de_DE.properties index 70932c5a..210d89e2 100644 --- a/src/java/org/mxchange/localization/generic_de_DE.properties +++ b/src/java/org/mxchange/localization/generic_de_DE.properties @@ -158,7 +158,7 @@ USER_CREATED_TITLE=Wann der Benutzer dieser Community beigetreten ist. PAGE_TITLE_INDEX_USER_PROFILE=Benutzerprofil CONTENT_TITLE_INDEX_USER_PROFILE=\u00d6ffentliches Profil des Benutzers: PARAMETER_USER_ID_MISSING=Benutzernummer nicht angegeben. -PARAMETER_USER_ID_INVALID=Der angeklickte Link ist nicht mehr g\u00fcltig: Den Benutzer mit der Id-Nummer existiert nicht (mehr). +PARAMETER_USER_ID_INVALID=Der angeklickte Link ist nicht mehr g\u00fcltig: Der Benutzer mit der Id-Nummer existiert nicht (mehr). PARAMETER_USER_ID_NOT_FOUND=Benutzeraccount mit der Id-Nummer nicht gefunden. TABLE_HEADER_ERROR_HANDLING_USER_ID=Fehler beim Verarbeiten der Benutzernummer: TABLE_HEADER_SHOW_ADDRESSBOOK=Adressbuchdaten: @@ -873,7 +873,7 @@ CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=Auflisten von Filialen: ADMIN_EMPTY_LIST_BRANCH_OFFICES=Es befinden sich keine Filialen in der Datenbank gefunden. Oder Ihre Suche ergab keine Uebereinstimmungen. ADMIN_ADD_BRANCH_OFFICE_TITLE=Filiale hinzuf\u00fcgen #@TODO Please fix German umlauts! -ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA=Bitte waehlen Sie mindestens das zugehoerige Unternehmen und das Land aus und geben Sie Strasse, Hausnummer, Postleitzahl und Stadt ein. +ADMIN_BRANCH_OFFICE_MINIMUM_DATA=Bitte waehlen Sie mindestens das zugehoerige Unternehmen und das Land aus und geben Sie Strasse, Hausnummer, Postleitzahl und Stadt ein. ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email-Addresse der Filiale: ADMIN_ENTER_BRANCH_OFFICE_LAND_LINE_NUMBER=Telefonnummer eingeben: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Faxnummer eingeben: @@ -1221,7 +1221,7 @@ OPTIONS=Optionen ADMIN_BASIC_DATA_COMPANY_SHORT_NAME=Kurzer Firmenname: ADMIN_BASIC_DATA_COMPANY_SHORT_NAME_HEADER=Kurzer Name: AVAILABLE_HEADER=Verf\u00fcgbar: -ADMIN_MANUFACTURER_HEADER=Hersteller: +ADMIN_MANUFACTURER_HEADER=Hersteller:branchId ADMIN_ASSIGNED_MANUFACTURER_LABEL=Zugewiesener Hersteller: BARCODE=Barcode: ADMIN_CONTACT_DETAILS_HEADER=Kontaktdaten zu {0} {1} {2}: @@ -1231,3 +1231,10 @@ ERROR_PARAMETER_CONFIRM_KEY_IS_NOT_SET=Fehler: Parameter "confirmationKey" ist n ROAD_NUMBER_HEADER=Betriebsnummer: ADMIN_BASIC_DATA_COMPANY_ROAD_NUMBER=Betriebsnummer: BASIC_DATA_COMPANY_ROAD_NUMBER_MISMATCHES_PATTERN=Die Betriebsnummer stimmt nicht mit dem regul\u00e4ren Ausruck AA BB 12345 \u00fcberein. +ERROR_PARAMETER_BRANCH_OFFICE_ID_NOT_SET=Fehler: Parameter "branchId" ist nicht gesetzt. +PARAMETER_BRANCH_OFFICE_ID_INVALID=Der angeklickte Link ist nicht mehr g\u00fcltig: Die Filiale mit der Id-Nummer existiert nicht (mehr). +ADMIN_BRANCH_OFFICE_NOT_UPDATED=Sie haben keine Daten der Filiale aktualisiert. +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: diff --git a/src/java/org/mxchange/localization/generic_en_US.properties b/src/java/org/mxchange/localization/generic_en_US.properties index 8a828f4c..748ed6a3 100644 --- a/src/java/org/mxchange/localization/generic_en_US.properties +++ b/src/java/org/mxchange/localization/generic_en_US.properties @@ -840,7 +840,7 @@ PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=List branch offices: ADMIN_EMPTY_LIST_BRANCH_OFFICES=There are no branch offices found in database. Or your search criteria doesn't match anything. ADMIN_ADD_BRANCH_OFFICE_TITLE=Add branch office -ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA=Please at least choose assigned company, country and enter at least street name, house number, ZIP code and city. +ADMIN_BRANCH_OFFICE_MINIMUM_DATA=Please at least choose assigned company, country and enter at least street name, house number, ZIP code and city. ADMIN_ENTER_BRANCH_OFFICE_EMAIL_ADDRESS=Email address of branch office: ADMIN_ENTER_BRANCH_OFFICE_LAND_LINE_NUMBER=Enter land-line number: ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER=Enter fax number: @@ -1137,3 +1137,10 @@ ERROR_PARAMETER_CONFIRM_KEY_IS_NOT_SET=Error: Parameter "confirmKey" is required ROAD_NUMBER_HEADER=Road number: ADMIN_BASIC_DATA_COMPANY_ROAD_NUMBER=Road number: BASIC_DATA_COMPANY_ROAD_NUMBER_MISMATCHES_PATTERN=Company's road number does not match pattern AA BB 12345. +ERROR_PARAMETER_BRANCH_OFFICE_ID_NOT_SET=Error: Parameter "branchId" is not set. +PARAMETER_BRANCH_OFFICE_ID_INVALID=The clicked link is no longer valid: The branch office with provided id number does not exist. +ADMIN_BRANCH_OFFICE_NOT_UPDATED=You have not updated any data of the branch office. +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}): diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index ba45efc4..1529c0ee 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -839,6 +839,14 @@ /admin/landline/admin_landline_show.xhtml + + /admin/branch_office/admin_branch_office_edit.xhtml + + admin_list_branch_office + /admin/branch_office/admin_branch_office_list.xhtml + + + /admin/department/admin_department_list.xhtml diff --git a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl index 00b6545d..8cc47ec8 100644 --- a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl +++ b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl @@ -1,7 +1,4 @@ - - + @@ -60,10 +60,10 @@ /> - + @@ -83,7 +83,7 @@ @@ -105,24 +105,32 @@ id="branchEmailAddress" size="40" maxlength="255" - value="#{adminBranchOfficeController.branchEmailAddress}" + value="#{adminBranchOfficeActionController.branchEmailAddress}" validatorMessage="#{msg.ENTERED_EMAIL_ADDRESS_IS_INVALID}" > - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_opening_time.tpl b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_opening_time.tpl index 6c54ce6c..4af4b866 100644 --- a/web/WEB-INF/templates/admin/branch_office/admin_form_branch_opening_time.tpl +++ b/web/WEB-INF/templates/admin/branch_office/admin_form_branch_opening_time.tpl @@ -22,7 +22,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/admin/branch_office/admin_branch_office_list.xhtml b/web/admin/branch_office/admin_branch_office_list.xhtml index 0a55aa17..f491f4d0 100644 --- a/web/admin/branch_office/admin_branch_office_list.xhtml +++ b/web/admin/branch_office/admin_branch_office_list.xhtml @@ -485,7 +485,7 @@ - + @@ -500,7 +500,7 @@ @@ -513,7 +513,7 @@ -- 2.39.5