]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Fri, 24 Apr 2020 03:05:31 +0000 (05:05 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 24 Apr 2020 03:05:31 +0000 (05:05 +0200)
- 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

Signed-off-by: Roland Häder <roland@mxchange.org>
24 files changed:
src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/business/branchoffice/list/FinancialsBranchOfficeListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/business/branchoffice/list/FinancialsBranchOfficeListWebViewController.java
src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/list/FinancialsContactListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/contact/mobile/FinancialsAdminContactMobileWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/mobile/FinancialsContactMobileWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsAdminContactPhoneWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsContactPhoneWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/mobile/list/FinancialsMobileListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/phone/list/FinancialsPhoneListWebViewBean.java
src/java/org/mxchange/jfinancials/converter/business/branchoffice/FinancialsBranchOfficeConverter.java
src/java/org/mxchange/localization/generic_de_DE.properties
src/java/org/mxchange/localization/generic_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl
web/WEB-INF/templates/admin/branch_office/admin_form_branch_opening_time.tpl
web/admin/branch_office/admin_branch_office_edit.xhtml [new file with mode: 0644]
web/admin/branch_office/admin_branch_office_list.xhtml

index c5d603e48d1e3a190936d1653acc03de3e45f69b..8af3b1146b70388e3484c49cc917023e419ff50f 100644 (file)
  */
 package org.mxchange.jfinancials.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.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.business.branchoffice.list.FinancialsBranchOfficeListWebViewController;
-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 FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminBranchOfficeWebRequestController {
 
-       /**
-        * Opening times of this branch office
-        */
-       private static List<OpeningTime> branchOpeningTimes;
-
        /**
         * Serial number
         */
        private static final long serialVersionUID = 5_028_697_360_461L;
 
-       /**
-        * EJB for administrative purposes
-        */
-       @EJB (lookup = "java:global/jfinancials-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<ObservableBranchOfficeAddedEvent> branchOfficeAddedEvent;
-
-       /**
-        * A list branch office controller (backing bean)
-        */
-       @Inject
-       private FinancialsBranchOfficeListWebViewController 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 FinancialsAdminBranchOfficeWebRequestBean () {
                // 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
-        * <p>
-        * @return City
-        */
-       public String getBranchCity () {
-               return this.branchCity;
-       }
-
-       /**
-        * Setter for city
-        * <p>
-        * @param branchCity City
-        */
-       public void setBranchCity (final String branchCity) {
-               this.branchCity = branchCity;
-       }
-
-       /**
-        * Getter for basic company data
-        * <p>
-        * @return Basic company data
-        */
-       public BasicData getBranchCompany () {
-               return this.branchCompany;
-       }
-
-       /**
-        * Setter for basic company data
-        * <p>
-        * @param branchCompany Basic company data
-        */
-       public void setBranchCompany (final BasicData branchCompany) {
-               this.branchCompany = branchCompany;
-       }
-
-       /**
-        * Getter for branch office contact person
-        * <p>
-        * @return Branch office contact person
-        */
-       public Employable getBranchContactEmployee () {
-               return this.branchContactEmployee;
-       }
-
-       /**
-        * Setter for branch office contact person
-        * <p>
-        * @param branchContactEmployee Branch office contact person
-        */
-       public void setBranchContactEmployee (final Employable branchContactEmployee) {
-               this.branchContactEmployee = branchContactEmployee;
-       }
-
-       /**
-        * Getter for country
-        * <p>
-        * @return Country
-        */
-       public Country getBranchCountry () {
-               return this.branchCountry;
-       }
-
-       /**
-        * Setter for country
-        * <p>
-        * @param branchCountry Country
-        */
-       public void setBranchCountry (final Country branchCountry) {
-               this.branchCountry = branchCountry;
-       }
-
-       /**
-        * Getter for email address
-        * <p>
-        * @return Email address
-        */
-       public String getBranchEmailAddress () {
-               return this.branchEmailAddress;
-       }
-
-       /**
-        * Getter for email address
-        * <p>
-        * @param branchEmailAddress Email address
-        */
-       public void setBranchEmailAddress (final String branchEmailAddress) {
-               this.branchEmailAddress = branchEmailAddress;
-       }
-
-       /**
-        * Getter for house number
-        * <p>
-        * @return House number
-        */
-       public Short getBranchHouseNumber () {
-               return this.branchHouseNumber;
-       }
-
-       /**
-        * Setter for house number
-        * <p>
-        * @param branchHouseNumber House number
-        */
-       public void setBranchHouseNumber (final Short branchHouseNumber) {
-               this.branchHouseNumber = branchHouseNumber;
-       }
-
-       /**
-        * Getter for house number's extension
-        * <p>
-        * @return House number's extension
-        */
-       public String getBranchHouseNumberExtension () {
-               return this.branchHouseNumberExtension;
-       }
-
-       /**
-        * Setter for house number's extension
-        * <p>
-        * @param branchHouseNumberExtension House number's extension
-        */
-       public void setBranchHouseNumberExtension (final String branchHouseNumberExtension) {
-               this.branchHouseNumberExtension = branchHouseNumberExtension;
-       }
-
-       /**
-        * Getter for last house number
-        * <p>
-        * @return Last house number
-        */
-       public Short getBranchLastHouseNumber () {
-               return this.branchLastHouseNumber;
-       }
-
-       /**
-        * Setter for last house number
-        * <p>
-        * @param branchLastHouseNumber Last house number
-        */
-       public void setBranchLastHouseNumber (final Short branchLastHouseNumber) {
-               this.branchLastHouseNumber = branchLastHouseNumber;
-       }
-
-       /**
-        * Getter for branch office number
-        * <p>
-        * @return Branch office number
-        */
-       public Long getBranchNumber () {
-               return this.branchNumber;
-       }
-
-       /**
-        * Setter for branch office number
-        * <p>
-        * @param branchNumber Branch office number
-        */
-       public void setBranchNumber (final Long branchNumber) {
-               this.branchNumber = branchNumber;
-       }
-
-       /**
-        * Getter for opening times of this branch office
-        * <p>
-        * @return Opening times
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<OpeningTime> getBranchOpeningTimes () {
-               return branchOpeningTimes;
-       }
-
-       /**
-        * Setter for opening times of this branch office
-        * <p>
-        * @param branchOpeningTimes Opening times
-        */
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setBranchOpeningTimes (final List<OpeningTime> branchOpeningTimes) {
-               FinancialsAdminBranchOfficeWebRequestBean.branchOpeningTimes = branchOpeningTimes;
-       }
-
-       /**
-        * Getter for branch office contact person
-        * <p>
-        * @return Branch office contact person
-        */
-       public Employable getBranchOwner () {
-               return this.branchOwner;
-       }
-
-       /**
-        * Setter for branch office contact person
-        * <p>
-        * @param branchOwner Branch office contact person
-        */
-       public void setBranchOwner (final Employable branchOwner) {
-               this.branchOwner = branchOwner;
-       }
-
-       /**
-        * Getter for store
-        * <p>
-        * @return Store
-        */
-       public Short getBranchStore () {
-               return this.branchStore;
-       }
-
-       /**
-        * Setter for store
-        * <p>
-        * @param branchStore Store
-        */
-       public void setBranchStore (final Short branchStore) {
-               this.branchStore = branchStore;
-       }
-
-       /**
-        * Getter for street name
-        * <p>
-        * @return Street name
-        */
-       public String getBranchStreet () {
-               return this.branchStreet;
-       }
-
-       /**
-        * Setter for street name
-        * <p>
-        * @param branchStreet Street name
-        */
-       public void setBranchStreet (final String branchStreet) {
-               this.branchStreet = branchStreet;
-       }
-
-       /**
-        * Getter for suite number
-        * <p>
-        * @return Suite number
-        */
-       public Short getBranchSuiteNumber () {
-               return this.branchSuiteNumber;
-       }
-
-       /**
-        * Setter for suite number
-        * <p>
-        * @param branchSuiteNumber Suite number
-        */
-       public void setBranchSuiteNumber (final Short branchSuiteNumber) {
-               this.branchSuiteNumber = branchSuiteNumber;
-       }
-
-       /**
-        * Getter for owning user instance
-        * <p>
-        * @return Owning user instance
-        */
-       public User getBranchUserOwner () {
-               return this.branchUserOwner;
-       }
-
-       /**
-        * Setter for owning user instance
-        * <p>
-        * @param branchUserOwner Owning user instance
-        */
-       public void setBranchUserOwner (final User branchUserOwner) {
-               this.branchUserOwner = branchUserOwner;
-       }
-
-       /**
-        * Getter for ZIP code\
-        * <p>
-        * @return ZIP code
-        */
-       public Integer getBranchZipCode () {
-               return this.branchZipCode;
-       }
-
-       /**
-        * Setter for ZIP code\
-        * <p>
-        * @param branchZipCode ZIP code
-        */
-       public void setBranchZipCode (final Integer branchZipCode) {
-               this.branchZipCode = branchZipCode;
-       }
-
-       /**
-        * Getter for fax number's area code
-        * <p>
-        * @return Fax number's area code
-        */
-       public Integer getFaxAreaCode () {
-               return this.faxAreaCode;
-       }
-
-       /**
-        * Setter for fax number's area code
-        * <p>
-        * @param faxAreaCode Fax number's area code
-        */
-       public void setFaxAreaCode (final Integer faxAreaCode) {
-               this.faxAreaCode = faxAreaCode;
-       }
-
-       /**
-        * Getter for fax's country instance
-        * <p>
-        * @return Fax' country instance
-        */
-       public Country getFaxCountry () {
-               return this.faxCountry;
-       }
-
-       /**
-        * Setter for fax's country instance
-        * <p>
-        * @param faxCountry Fax' country instance
-        */
-       public void setFaxCountry (final Country faxCountry) {
-               this.faxCountry = faxCountry;
-       }
-
-       /**
-        * Getter for fax number
-        * <p>
-        * @return Fax number
-        */
-       public Long getFaxNumber () {
-               return this.faxNumber;
-       }
-
-       /**
-        * Setter for fax number
-        * <p>
-        * @param faxNumber Fax number
-        */
-       public void setFaxNumber (final Long faxNumber) {
-               this.faxNumber = faxNumber;
-       }
-
-       /**
-        * Getter for land-line number's area code
-        * <p>
-        * @return Land-line number's area code
-        */
-       public Integer getLandLineAreaCode () {
-               return this.landLineAreaCode;
-       }
-
-       /**
-        * Setter for land-line number's area code
-        * <p>
-        * @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
-        * <p>
-        * @return Land-line number's country instance
-        */
-       public Country getLandLineCountry () {
-               return this.landLineCountry;
-       }
-
-       /**
-        * Setter for land-line number's country instance
-        * <p>
-        * @param landLineCountry Land-line number's country instance
-        */
-       public void setLandLineCountry (final Country landLineCountry) {
-               this.landLineCountry = landLineCountry;
-       }
-
-       /**
-        * Getter for land-line number
-        * <p>
-        * @return Land-line number
-        */
-       public Long getLandLineNumber () {
-               return this.landLineNumber;
-       }
-
-       /**
-        * Setter for land-line number
-        * <p>
-        * @param landLineNumber Land-line number
-        */
-       public void setLandLineNumber (final Long landLineNumber) {
-               this.landLineNumber = landLineNumber;
-       }
-
-       /**
-        * Getter for ending week day
-        * <p>
-        * @return Ending week day
-        */
-       public DayOfTheWeek getOpeningEndDay () {
-               return this.openingEndDay;
-       }
-
-       /**
-        * Setter for ending week day
-        * <p>
-        * @param openingEndDay Ending week day
-        */
-       public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
-               this.openingEndDay = openingEndDay;
-       }
-
-       /**
-        * Getter for ending time
-        * <p>
-        * @return Ending time
-        */
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getOpeningEndTime () {
-               return this.openingEndTime;
-       }
-
-       /**
-        * Getter for ending time
-        * <p>
-        * @param openingEndTime Ending time
-        */
-       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
-       public void setOpeningEndTime (final Date openingEndTime) {
-               this.openingEndTime = openingEndTime;
-       }
-
-       /**
-        * Getter for starting week day
-        * <p>
-        * @return Starting week day
-        */
-       public DayOfTheWeek getOpeningStartDay () {
-               return this.openingStartDay;
-       }
-
-       /**
-        * Getter for starting week day
-        * <p>
-        * @param openingStartDay Starting week day
-        */
-       public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
-               this.openingStartDay = openingStartDay;
-       }
-
-       /**
-        * Getter for starting time
-        * <p>
-        * @return Starting time
-        */
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getOpeningStartTime () {
-               return this.openingStartTime;
-       }
-
-       /**
-        * Getter for starting time
-        * <p>
-        * @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<OpeningTime>(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.
-        * <p>
-        * @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.
-        * <p>
-        * @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.
-        * <p>
-        * @param branchOffice Branch office to check it's address
-        * <p>
-        * @return Whether the address has been found
-        */
-       private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
-               // Get full list from other bean
-               final List<BranchOffice> 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
-        * <p>
-        * @param openingTime Opening time to be checked
-        * <p>
-        * @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/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java
new file mode 100644 (file)
index 0000000..d84e53a
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.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.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.business.branchoffice.list.FinancialsBranchOfficeListWebViewController;
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminBranchOfficeActionController")
+@RequestScoped
+public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinancialsBean implements FinancialsAdminBranchOfficeActionWebRequestController {
+
+       /**
+        * Opening times of this branch office
+        */
+       private static List<OpeningTime> branchOpeningTimes;
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_028_697_360_471L;
+
+       /**
+        * EJB for administrative purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-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<ObservableAdminBranchOfficeAddedEvent> branchOfficeAddedEvent;
+
+       /**
+        * A list branch office controller (backing bean)
+        */
+       @Inject
+       private FinancialsBranchOfficeListWebViewController 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<ObservableAdminBranchOfficeUpdatedEvent> updatedBranchOfficeEvent;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsAdminBranchOfficeActionWebRequestBean () {
+               // 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
+        * <p>
+        * @return City
+        */
+       public String getBranchCity () {
+               return this.branchCity;
+       }
+
+       /**
+        * Setter for city
+        * <p>
+        * @param branchCity City
+        */
+       public void setBranchCity (final String branchCity) {
+               this.branchCity = branchCity;
+       }
+
+       /**
+        * Getter for basic company data
+        * <p>
+        * @return Basic company data
+        */
+       public BasicData getBranchCompany () {
+               return this.branchCompany;
+       }
+
+       /**
+        * Setter for basic company data
+        * <p>
+        * @param branchCompany Basic company data
+        */
+       public void setBranchCompany (final BasicData branchCompany) {
+               this.branchCompany = branchCompany;
+       }
+
+       /**
+        * Getter for branch office contact person
+        * <p>
+        * @return Branch office contact person
+        */
+       public Employable getBranchContactEmployee () {
+               return this.branchContactEmployee;
+       }
+
+       /**
+        * Setter for branch office contact person
+        * <p>
+        * @param branchContactEmployee Branch office contact person
+        */
+       public void setBranchContactEmployee (final Employable branchContactEmployee) {
+               this.branchContactEmployee = branchContactEmployee;
+       }
+
+       /**
+        * Getter for country
+        * <p>
+        * @return Country
+        */
+       public Country getBranchCountry () {
+               return this.branchCountry;
+       }
+
+       /**
+        * Setter for country
+        * <p>
+        * @param branchCountry Country
+        */
+       public void setBranchCountry (final Country branchCountry) {
+               this.branchCountry = branchCountry;
+       }
+
+       /**
+        * Getter for email address
+        * <p>
+        * @return Email address
+        */
+       public String getBranchEmailAddress () {
+               return this.branchEmailAddress;
+       }
+
+       /**
+        * Getter for email address
+        * <p>
+        * @param branchEmailAddress Email address
+        */
+       public void setBranchEmailAddress (final String branchEmailAddress) {
+               this.branchEmailAddress = branchEmailAddress;
+       }
+
+       /**
+        * Getter for house number
+        * <p>
+        * @return House number
+        */
+       public Short getBranchHouseNumber () {
+               return this.branchHouseNumber;
+       }
+
+       /**
+        * Setter for house number
+        * <p>
+        * @param branchHouseNumber House number
+        */
+       public void setBranchHouseNumber (final Short branchHouseNumber) {
+               this.branchHouseNumber = branchHouseNumber;
+       }
+
+       /**
+        * Getter for house number's extension
+        * <p>
+        * @return House number's extension
+        */
+       public String getBranchHouseNumberExtension () {
+               return this.branchHouseNumberExtension;
+       }
+
+       /**
+        * Setter for house number's extension
+        * <p>
+        * @param branchHouseNumberExtension House number's extension
+        */
+       public void setBranchHouseNumberExtension (final String branchHouseNumberExtension) {
+               this.branchHouseNumberExtension = branchHouseNumberExtension;
+       }
+
+       /**
+        * Getter for branch office's id number
+        * <p>
+        * @return Branch office's id number
+        */
+       public Long getBranchId () {
+               return this.branchId;
+       }
+
+       /**
+        * Setter for branch office's id number
+        * <p>
+        * @param branchId Branch office's id number
+        */
+       public void setBranchId (final Long branchId) {
+               this.branchId = branchId;
+       }
+
+       /**
+        * Getter for last house number
+        * <p>
+        * @return Last house number
+        */
+       public Short getBranchLastHouseNumber () {
+               return this.branchLastHouseNumber;
+       }
+
+       /**
+        * Setter for last house number
+        * <p>
+        * @param branchLastHouseNumber Last house number
+        */
+       public void setBranchLastHouseNumber (final Short branchLastHouseNumber) {
+               this.branchLastHouseNumber = branchLastHouseNumber;
+       }
+
+       /**
+        * Getter for branch office number
+        * <p>
+        * @return Branch office number
+        */
+       public Long getBranchNumber () {
+               return this.branchNumber;
+       }
+
+       /**
+        * Setter for branch office number
+        * <p>
+        * @param branchNumber Branch office number
+        */
+       public void setBranchNumber (final Long branchNumber) {
+               this.branchNumber = branchNumber;
+       }
+
+       /**
+        * Getter for opening times of this branch office
+        * <p>
+        * @return Opening times
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<OpeningTime> getBranchOpeningTimes () {
+               return branchOpeningTimes;
+       }
+
+       /**
+        * Setter for opening times of this branch office
+        * <p>
+        * @param branchOpeningTimes Opening times
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setBranchOpeningTimes (final List<OpeningTime> branchOpeningTimes) {
+               FinancialsAdminBranchOfficeActionWebRequestBean.branchOpeningTimes = branchOpeningTimes;
+       }
+
+       /**
+        * Getter for branch office contact person
+        * <p>
+        * @return Branch office contact person
+        */
+       public Employable getBranchOwnerEmployee () {
+               return this.branchOwnerEmployee;
+       }
+
+       /**
+        * Setter for branch office contact person
+        * <p>
+        * @param branchOwnerEmployee Branch office contact person
+        */
+       public void setBranchOwnerEmployee (final Employable branchOwnerEmployee) {
+               this.branchOwnerEmployee = branchOwnerEmployee;
+       }
+
+       /**
+        * Getter for store
+        * <p>
+        * @return Store
+        */
+       public Short getBranchStore () {
+               return this.branchStore;
+       }
+
+       /**
+        * Setter for store
+        * <p>
+        * @param branchStore Store
+        */
+       public void setBranchStore (final Short branchStore) {
+               this.branchStore = branchStore;
+       }
+
+       /**
+        * Getter for street name
+        * <p>
+        * @return Street name
+        */
+       public String getBranchStreet () {
+               return this.branchStreet;
+       }
+
+       /**
+        * Setter for street name
+        * <p>
+        * @param branchStreet Street name
+        */
+       public void setBranchStreet (final String branchStreet) {
+               this.branchStreet = branchStreet;
+       }
+
+       /**
+        * Getter for suite number
+        * <p>
+        * @return Suite number
+        */
+       public Short getBranchSuiteNumber () {
+               return this.branchSuiteNumber;
+       }
+
+       /**
+        * Setter for suite number
+        * <p>
+        * @param branchSuiteNumber Suite number
+        */
+       public void setBranchSuiteNumber (final Short branchSuiteNumber) {
+               this.branchSuiteNumber = branchSuiteNumber;
+       }
+
+       /**
+        * Getter for owning user instance
+        * <p>
+        * @return Owning user instance
+        */
+       public User getBranchUserOwner () {
+               return this.branchUserOwner;
+       }
+
+       /**
+        * Setter for owning user instance
+        * <p>
+        * @param branchUserOwner Owning user instance
+        */
+       public void setBranchUserOwner (final User branchUserOwner) {
+               this.branchUserOwner = branchUserOwner;
+       }
+
+       /**
+        * Getter for ZIP code\
+        * <p>
+        * @return ZIP code
+        */
+       public Integer getBranchZipCode () {
+               return this.branchZipCode;
+       }
+
+       /**
+        * Setter for ZIP code\
+        * <p>
+        * @param branchZipCode ZIP code
+        */
+       public void setBranchZipCode (final Integer branchZipCode) {
+               this.branchZipCode = branchZipCode;
+       }
+
+       /**
+        * Getter for current branch office
+        * <p>
+        * @return Current branch office
+        */
+       public BranchOffice getCurrentBranchOffice () {
+               return this.currentBranchOffice;
+       }
+
+       /**
+        * Setter for current branch office
+        * <p>
+        * @param currentBranchOffice Current branch office
+        */
+       public void setCurrentBranchOffice (final BranchOffice currentBranchOffice) {
+               this.currentBranchOffice = currentBranchOffice;
+       }
+
+       /**
+        * Getter for fax number's area code
+        * <p>
+        * @return Fax number's area code
+        */
+       public Integer getFaxAreaCode () {
+               return this.faxAreaCode;
+       }
+
+       /**
+        * Setter for fax number's area code
+        * <p>
+        * @param faxAreaCode Fax number's area code
+        */
+       public void setFaxAreaCode (final Integer faxAreaCode) {
+               this.faxAreaCode = faxAreaCode;
+       }
+
+       /**
+        * Getter for fax's country instance
+        * <p>
+        * @return Fax' country instance
+        */
+       public Country getFaxCountry () {
+               return this.faxCountry;
+       }
+
+       /**
+        * Setter for fax's country instance
+        * <p>
+        * @param faxCountry Fax' country instance
+        */
+       public void setFaxCountry (final Country faxCountry) {
+               this.faxCountry = faxCountry;
+       }
+
+       /**
+        * Getter for fax number
+        * <p>
+        * @return Fax number
+        */
+       public Long getFaxNumber () {
+               return this.faxNumber;
+       }
+
+       /**
+        * Setter for fax number
+        * <p>
+        * @param faxNumber Fax number
+        */
+       public void setFaxNumber (final Long faxNumber) {
+               this.faxNumber = faxNumber;
+       }
+
+       /**
+        * Getter for land-line number's area code
+        * <p>
+        * @return Land-line number's area code
+        */
+       public Integer getLandLineAreaCode () {
+               return this.landLineAreaCode;
+       }
+
+       /**
+        * Setter for land-line number's area code
+        * <p>
+        * @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
+        * <p>
+        * @return Land-line number's country instance
+        */
+       public Country getLandLineCountry () {
+               return this.landLineCountry;
+       }
+
+       /**
+        * Setter for land-line number's country instance
+        * <p>
+        * @param landLineCountry Land-line number's country instance
+        */
+       public void setLandLineCountry (final Country landLineCountry) {
+               this.landLineCountry = landLineCountry;
+       }
+
+       /**
+        * Getter for land-line number
+        * <p>
+        * @return Land-line number
+        */
+       public Long getLandLineNumber () {
+               return this.landLineNumber;
+       }
+
+       /**
+        * Setter for land-line number
+        * <p>
+        * @param landLineNumber Land-line number
+        */
+       public void setLandLineNumber (final Long landLineNumber) {
+               this.landLineNumber = landLineNumber;
+       }
+
+       /**
+        * Getter for ending week day
+        * <p>
+        * @return Ending week day
+        */
+       public DayOfTheWeek getOpeningEndDay () {
+               return this.openingEndDay;
+       }
+
+       /**
+        * Setter for ending week day
+        * <p>
+        * @param openingEndDay Ending week day
+        */
+       public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
+               this.openingEndDay = openingEndDay;
+       }
+
+       /**
+        * Getter for ending time
+        * <p>
+        * @return Ending time
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getOpeningEndTime () {
+               return this.openingEndTime;
+       }
+
+       /**
+        * Getter for ending time
+        * <p>
+        * @param openingEndTime Ending time
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setOpeningEndTime (final Date openingEndTime) {
+               this.openingEndTime = openingEndTime;
+       }
+
+       /**
+        * Getter for starting week day
+        * <p>
+        * @return Starting week day
+        */
+       public DayOfTheWeek getOpeningStartDay () {
+               return this.openingStartDay;
+       }
+
+       /**
+        * Getter for starting week day
+        * <p>
+        * @param openingStartDay Starting week day
+        */
+       public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
+               this.openingStartDay = openingStartDay;
+       }
+
+       /**
+        * Getter for starting time
+        * <p>
+        * @return Starting time
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getOpeningStartTime () {
+               return this.openingStartTime;
+       }
+
+       /**
+        * Getter for starting time
+        * <p>
+        * @param openingStartTime Starting time
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setOpeningStartTime (final Date openingStartTime) {
+               this.openingStartTime = openingStartTime;
+       }
+
+       /**
+        * Updates currently worked on branch office data
+        * <p>
+        * @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<OpeningTime>(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.
+        * <p>
+        * @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.
+        * <p>
+        * @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.
+        * <p>
+        * @param branchOffice Branch office to check it's address
+        * <p>
+        * @return Whether the address has been found
+        */
+       private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
+               // Get full list from other bean
+               final List<BranchOffice> 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
+        * <p>
+        * @param openingTime Opening time to be checked
+        * <p>
+        * @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/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestController.java
new file mode 100644 (file)
index 0000000..a6de792
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.business.branchoffice.action;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative branch office controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminBranchOfficeActionWebRequestController extends Serializable {
+
+}
index 6e8f32a4afd633a4b7391d5ef069e5fb5bddfc74..f525430897cb315c87ec38c82b404d7bf87062f0 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jfinancials.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 FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
        /**
         * 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 FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
        }
 
        /**
-        * 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.
         * <p>
         * @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.
         * <p>
-        * @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 FinancialsBranchOfficeListWebViewBean extends BaseFinancialsBean im
                return isFound;
        }
 
+       /**
+        * Uniquely add branch office instance to allBranchOffices property
+        * <p>
+        * @param branchOffice Branch office being added
+        */
+       private void uniqueAddBranchOffice (final BranchOffice branchOffice) {
+               // Get iterator
+               final Iterator<BranchOffice> 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.
index 6401b27ef600bda9cd53f81da8e4dd6f71e44223..e08066e203b60e857bd8a20aea37eaa0ee1c8e02 100644 (file)
@@ -48,12 +48,12 @@ public interface FinancialsBranchOfficeListWebViewController extends Serializabl
        /**
         * Tries to find a branch office with given id number
         * <p>
-        * @param branchOfficeId Branch office id
+        * @param branchId Branch office id
         * <p>
         * @return A branch office instance
         * <p>
         * @throws BranchOfficeNotFoundException If the branch office was not found
         */
-       BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException;
+       BranchOffice findBranchOfficeById (final Long branchId) throws BranchOfficeNotFoundException;
 
 }
index dd4a6e535df9cfaa1851fc46a01978966c8efefd..c39af5c4bc20be3c7659ce327757acbc5d0e4dd3 100644 (file)
@@ -47,7 +47,7 @@ public class FinancialsDepartmentListWebViewBean extends BaseFinancialsBean impl
        /**
         * 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
index 5b68f1a81b1cc0d6f3e8d21c3c5f3af1655781f0..61b9c5bf2bd472bd7c26cac045efcc09b34e4587 100644 (file)
@@ -63,7 +63,7 @@ public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean
        /**
         * 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
index 00b50e5b87cd274ee7f3e7ee6bf935eaabe08090..9af9e3a8bd8847e27b44e83d75f21165cb6ab248 100644 (file)
@@ -547,8 +547,16 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
                // 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));
index 19c41c8e8466816db4c4b33f33e84f6fb30b0d58..16e1407cf771030f8d611fa97f38d3ea809857eb 100644 (file)
@@ -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 FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
         */
        private FinancialsContactListWebViewController contactListController;
 
+       /**
+        * Event being fired when a user has updated his contact data
+        */
+       @Any
+       @Inject
+       private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
+
        /**
         * Country instance
         */
@@ -368,8 +380,19 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                // 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
index 51765a3631d2299fc12e249ee6011be6766a04fa..65c5a6f7691be365650e828426f57c195a68a230 100644 (file)
@@ -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 FinancialsContactListWebViewBean extends BaseFinancialsBean impleme
                this.uniqueAddContact(event.getUpdatedContact());
        }
 
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @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.
         * <p>
index bde080e6130105eb9439291a2b7f5f07a524cb0b..466febe6c6deb568ff3183bf8cad516533a7fb1d 100644 (file)
@@ -29,17 +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.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
 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;
@@ -62,8 +63,8 @@ public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBe
        /**
         * Administrative EJB for phone number
         */
-       @EJB (lookup = "java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote")
-       private AdminContactsPhoneSessionBeanRemote adminContactPhoneBean;
+       @EJB (lookup = "java:global/jfinancials-ejb/adminContactMobile!org.mxchange.jcontacts.model.mobile.AdminContactsMobileSessionBeanRemote")
+       private AdminContactsMobileSessionBeanRemote adminContactMobileBean;
 
        /**
         * Event being fired when a mobile number has been linked
@@ -72,12 +73,6 @@ public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBe
        @Any
        private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
 
-       /**
-        * Administrative phone controller
-        */
-       @Inject
-       private FinancialsAdminPhoneWebRequestController adminPhoneController;
-
        /**
         * Contact instance
         */
@@ -264,6 +259,31 @@ public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBe
                this.setMobileEntryUpdated(number.getMobileEntryUpdated());
        }
 
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @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".
         * <p>
@@ -307,8 +327,8 @@ public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBe
                // 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
@@ -443,8 +463,8 @@ public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBe
 
                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
index a3ef2762b311132a8c99f6ea017ccec3c6301571..24b25abfc5128fd63dcd941668d862b45cb3686e 100644 (file)
@@ -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.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
@@ -168,6 +169,31 @@ public class FinancialsContactMobileWebRequestBean extends BaseFinancialsBean im
                this.setMobileNumber(event.getMobileNumber());
        }
 
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @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
         * <p>
index 549b7e5a84cc913877f45675015a17ea62971921..59df8b152341511d0014ff916a8cc8e4795aa48e 100644 (file)
@@ -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 FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBea
                this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
        }
 
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @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".
         * <p>
@@ -395,7 +422,7 @@ public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBea
                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 FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBea
                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 FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBea
                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 FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsBea
                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
index ec2780985a13cfdc1b33a47a2f637473535bcf22..fe465b4584e03c5e56941adc091110df1e5e3f40 100644 (file)
@@ -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.jfinancials.beans.BaseFinancialsBean;
 import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
@@ -201,6 +202,31 @@ public class FinancialsContactPhoneWebRequestBean extends BaseFinancialsBean imp
                this.setLandLineNumber(event.getLandLineNumber());
        }
 
+       /**
+        * Event observer for updated contact data by the user
+        * <p>
+        * @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
         * <p>
index 5c6a03f033e387511fb93521e1fbc96fa53ad15c..9b331fff8d0eb8e83a45cd4804e4101c9e1a01df 100644 (file)
@@ -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.jfinancials.beans.BaseFinancialsBean;
@@ -274,6 +275,34 @@ public class FinancialsMobileListWebViewBean extends BaseFinancialsBean implemen
                this.clear();
        }
 
+       /**
+        * Observes events being fired when an user has updated contact data.
+        * <p>
+        * @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
index 58642aed5f5e3a81d05cf1b8d79379d3db5e3785..137bb810f604d422214531811fc8c0dc8b25a65d 100644 (file)
@@ -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 FinancialsPhoneListWebViewBean extends BaseFinancialsBean implement
                this.clear();
        }
 
+       /**
+        * Observes events being fired when an user has updated contact data.
+        * <p>
+        * @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
index 555146ad92fcd7097ef6080514aeb9bbb0f2df95..4b57b97953f3ec3bb16955d4555ce4064679e351 100644 (file)
@@ -59,10 +59,10 @@ public class FinancialsBranchOfficeConverter implements Converter<BranchOffice>
 
                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);
index 5c16d007660d8144dc4196774bae02eeedcc94c1..186e35b64e17245e5ab83e08d515a6653f35d66a 100644 (file)
@@ -157,7 +157,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:
 LINK_USER_PROFILE=Zum Benutzerprofil
@@ -857,7 +857,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:
@@ -1205,7 +1205,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}:
@@ -1215,3 +1215,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:
index 293d341c7699e2d2c9d3ccd2c57c1e591ce8dd80..cbb4adcccb72994c49891915b9caef0633443c91 100644 (file)
@@ -828,7 +828,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:
@@ -1125,3 +1125,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}):
index 1c5973eab536009e3830f520f3232d92d50e2718..de114e1a5dd820f657784eb8adb851d27737c634 100644 (file)
                        <to-view-id>/admin/landline/admin_landline_show.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/admin/branch_office/admin_branch_office_edit.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>admin_list_branch_office</from-outcome>
+                       <to-view-id>/admin/branch_office/admin_branch_office_list.xhtml</to-view-id>
+                       <redirect></redirect>
+               </navigation-case>
+       </navigation-rule>
        <navigation-rule>
                <from-view-id>/admin/department/admin_department_list.xhtml</from-view-id>
                <navigation-case>
index 00b6545d79c964ce40c2723a5f7d43a057bb52ae..8cc47ec8496e266936fa03cbc6bb1430a54d74a7 100644 (file)
@@ -1,7 +1,4 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!--
-@TODO: title="#{msg.ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE}"
--->
 <ui:composition
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:core="http://mxchange.org/jsf/core/widgets"
@@ -11,7 +8,10 @@
        xmlns:p="http://primefaces.org/ui"
        >
 
-       <p:fieldset legend="#{msg.ADMIN_BRANCH_OFFICE_DATA_LEGEND}">
+       <p:fieldset
+               legend="#{msg.ADMIN_BRANCH_OFFICE_DATA_LEGEND}"
+               title="#{msg.ADMIN_BRANCH_OFFICE_DATA_LEGEND_TITLE}"
+               >
                <p:panelGrid
                        layout="grid"
                        columns="2"
@@ -21,7 +21,7 @@
                        <p:outputLabel for="branchCompany" value="#{msg.ADMIN_ASSIGN_BASIC_DATA_BRANCH_OFFICE}" />
                        <p:selectOneMenu
                                id="branchCompany"
-                               value="#{adminBranchOfficeController.branchCompany}"
+                               value="#{adminBranchOfficeActionController.branchCompany}"
                                filter="true"
                                filterMatchMode="contains"
                                required="true"
@@ -43,7 +43,7 @@
                        <p:outputLabel for="branchContactEmployee" value="#{msg.ADMIN_ASSIGN_BRANCH_OFFICE_CONTACT_EMPLOYEE}" />
                        <p:selectOneMenu
                                id="branchContactEmployee"
-                               value="#{adminBranchOfficeController.branchContactEmployee}"
+                               value="#{adminBranchOfficeActionController.branchContactEmployee}"
                                filter="true"
                                filterMatchMode="contains"
                                >
                                        />
                        </p:selectOneMenu>
 
-                       <p:outputLabel for="branchOwner" value="#{msg.ADMIN_ASSIGN_BRANCH_OFFICE_OWNER}" />
+                       <p:outputLabel for="branchOwnerEmployee" value="#{msg.ADMIN_ASSIGN_BRANCH_OFFICE_OWNER}" />
                        <p:selectOneMenu
-                               id="branchOwner"
-                               value="#{adminBranchOfficeController.branchOwner}"
+                               id="branchOwnerEmployee"
+                               value="#{adminBranchOfficeActionController.branchOwnerEmployee}"
                                filter="true"
                                filterMatchMode="contains"
                                >
@@ -83,7 +83,7 @@
                        <p:outputLabel for="branchUserOwner" value="#{msg.ADMIN_ASSIGN_BRANCH_OFFICE_USER_OWNER}" />
                        <p:selectOneMenu
                                id="branchUserOwner"
-                               value="#{adminBranchOfficeController.branchUserOwner}"
+                               value="#{adminBranchOfficeActionController.branchUserOwner}"
                                filter="true"
                                filterMatchMode="contains"
                                >
                                id="branchEmailAddress"
                                size="40"
                                maxlength="255"
-                               value="#{adminBranchOfficeController.branchEmailAddress}"
+                               value="#{adminBranchOfficeActionController.branchEmailAddress}"
                                validatorMessage="#{msg.ENTERED_EMAIL_ADDRESS_IS_INVALID}"
                                >
                                <validator:branchOfficeEmailAddressValidator allowEmptyRequiredData="true" />
                        </p:inputText>
 
                        <p:outputLabel for="landLineCountry" value="#{msg.ADMIN_ENTER_BRANCH_OFFICE_LAND_LINE_NUMBER}" />
-                       <core:inputLandLineNumberPanelGrid targetController="#{adminBranchOfficeController}" />
+                       <core:inputLandLineNumberPanelGrid targetController="#{adminBranchOfficeActionController}" />
 
                        <p:outputLabel for="faxCountry" value="#{msg.ADMIN_ENTER_BRANCH_OFFICE_FAX_NUMBER}" />
-                       <core:inputFaxNumberPanelGrid targetController="#{adminBranchOfficeController}" />
+                       <core:inputFaxNumberPanelGrid targetController="#{adminBranchOfficeActionController}" />
 
                        <p:outputLabel for="branchNumber" value="#{msg.ADMIN_ENTER_BRANCH_OFFICE_NUMBER}" />
-                       <p:inputText id="branchNumber" size="2" maxlength="10" value="#{adminBranchOfficeController.branchNumber}" />
+                       <p:inputText
+                               id="branchNumber"
+                               size="5"
+                               maxlength="10"
+                               value="#{adminBranchOfficeActionController.branchNumber}"
+                               />
                </p:panelGrid>
        </p:fieldset>
 
-       <p:fieldset legend="#{msg.ADMIN_BRANCH_OFFICE_ADDRESS_LEGEND}">
+       <p:fieldset
+               legend="#{msg.ADMIN_BRANCH_OFFICE_ADDRESS_LEGEND}"
+               title="#{msg.ADMIN_BRANCH_OFFICE_ADDRESS_LEGEND_TITLE}"
+               >
                <p:panelGrid
                        layout="grid"
                        columns="2"
                        styleClass="ui-noborder"
                        >
                        <p:outputLabel for="branchStreet" value="#{msg.ADMIN_DATA_STREET_NAME}" />
-                       <p:inputText id="branchStreet" size="20" maxlength="255" value="#{adminBranchOfficeController.branchStreet}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_STREET_NAME_REQUIRED}" />
+                       <p:inputText id="branchStreet" size="20" maxlength="255" value="#{adminBranchOfficeActionController.branchStreet}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_STREET_NAME_REQUIRED}" />
 
                        <p:outputLabel for="branchHouseNumber" value="#{msg.ADMIN_DATA_HOUSE_NUMBER}" />
-                       <p:inputText id="branchHouseNumber" size="3" maxlength="5" value="#{adminBranchOfficeController.branchHouseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_HOUSE_NUMBER_REQUIRED}">
+                       <p:inputText id="branchHouseNumber" size="3" maxlength="5" value="#{adminBranchOfficeActionController.branchHouseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_HOUSE_NUMBER_REQUIRED}">
                                <f:validateLongRange minimum="1" maximum="500" />
                        </p:inputText>
 
                        <p:outputLabel for="branchLastHouseNumber" value="#{msg.ADMIN_DATA_LAST_HOUSE_NUMBER}" />
-                       <p:inputText id="branchLastHouseNumber" size="3" maxlength="5" value="#{adminBranchOfficeController.branchLastHouseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
+                       <p:inputText id="branchLastHouseNumber" size="3" maxlength="5" value="#{adminBranchOfficeActionController.branchLastHouseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
                                <f:validateLongRange minimum="1" maximum="500" />
                        </p:inputText>
 
                        <p:outputLabel for="branchHouseNumberExtension" value="#{msg.ADMIN_DATA_HOUSE_NUMBER_EXTENSION}" />
-                       <p:inputText id="branchHouseNumberExtension" size="1" maxlength="255" value="#{adminBranchOfficeController.branchHouseNumberExtension}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}" />
+                       <p:inputText id="branchHouseNumberExtension" size="1" maxlength="255" value="#{adminBranchOfficeActionController.branchHouseNumberExtension}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}" />
 
                        <p:outputLabel for="branchStore" value="#{msg.ADMIN_ENTER_DATA_STORE}" />
-                       <p:inputText id="branchStore" size="3" maxlength="5" value="#{adminBranchOfficeController.branchStore}" validatorMessage="#{msg.ENTERED_STORE_INVALID}">
+                       <p:inputText id="branchStore" size="3" maxlength="5" value="#{adminBranchOfficeActionController.branchStore}" validatorMessage="#{msg.ENTERED_STORE_INVALID}">
                                <f:validateLongRange minimum="-5" maximum="200" />
                        </p:inputText>
 
                        <p:outputLabel for="branchSuiteNumber" value="#{msg.ADMIN_ENTER_DATA_SUITE_NUMBER}" />
-                       <p:inputText id="branchSuiteNumber" size="3" maxlength="5" value="#{adminBranchOfficeController.branchSuiteNumber}" validatorMessage="#{msg.ENTERED_SUITE_NUMBER_INVALID}">
+                       <p:inputText id="branchSuiteNumber" size="3" maxlength="5" value="#{adminBranchOfficeActionController.branchSuiteNumber}" validatorMessage="#{msg.ENTERED_SUITE_NUMBER_INVALID}">
                                <f:validateLongRange minimum="1" maximum="500" />
                        </p:inputText>
 
                        <p:outputLabel for="branchZipCode" value="#{msg.DATA_ZIP_CODE}" />
-                       <p:inputText id="branchZipCode" size="5" maxlength="6" value="#{adminBranchOfficeController.branchZipCode}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_ZIP_CODE_REQUIRED}">
+                       <p:inputText id="branchZipCode" size="5" maxlength="6" value="#{adminBranchOfficeActionController.branchZipCode}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_ZIP_CODE_REQUIRED}">
                                <f:validateLongRange minimum="1" maximum="99999" />
                        </p:inputText>
 
                        <p:outputLabel for="branchCity" value="#{msg.ADMIN_DATA_CITY}" />
-                       <p:inputText id="branchCity" size="20" maxlength="255" value="#{adminBranchOfficeController.branchCity}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_CITY_REQUIRED}" />
+                       <p:inputText id="branchCity" size="20" maxlength="255" value="#{adminBranchOfficeActionController.branchCity}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_CITY_REQUIRED}" />
 
                        <p:outputLabel for="branchCountry" value="#{msg.ADMIN_SELECT_COUNTRY}" />
-                       <core:outputCountrySelector id="branchCountry" value="#{adminBranchOfficeController.branchCountry}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_COUNTRY_REQUIRED}" />
+                       <core:outputCountrySelector id="branchCountry" value="#{adminBranchOfficeActionController.branchCountry}" required="true" requiredMessage="#{msg.ADMIN_BRANCH_OFFICE_COUNTRY_REQUIRED}" />
                </p:panelGrid>
        </p:fieldset>
 </ui:composition>
index 6c54ce6cc0714bfb43521c024f3291582f69ae50..4af4b8665bfb8c3f6f308e0674c600c7887ea1c2 100644 (file)
@@ -22,7 +22,7 @@
 
                        <p:selectOneMenu
                                id="openingStartDay"
-                               value="#{adminBranchOfficeController.openingStartDay}"
+                               value="#{adminBranchOfficeActionController.openingStartDay}"
                                filter="true"
                                filterMatchMode="contains"
                                required="true"
@@ -43,7 +43,7 @@
 
                        <p:selectOneMenu
                                id="openingEndDay"
-                               value="#{adminBranchOfficeController.openingEndDay}"
+                               value="#{adminBranchOfficeActionController.openingEndDay}"
                                filter="true"
                                filterMatchMode="contains"
                                required="true"
@@ -64,7 +64,7 @@
 
                        <p:calendar
                                id="openingStartTime"
-                               value="#{adminBranchOfficeController.openingStartTime}"
+                               value="#{adminBranchOfficeActionController.openingStartTime}"
                                pattern="HH:mm"
                                timeOnly="true"
                                stepMinute="5"
@@ -75,7 +75,7 @@
 
                        <p:calendar
                                id="openingEndTime"
-                               value="#{adminBranchOfficeController.openingEndTime}"
+                               value="#{adminBranchOfficeActionController.openingEndTime}"
                                pattern="HH:mm"
                                timeOnly="true"
                                stepMinute="5"
diff --git a/web/admin/branch_office/admin_branch_office_edit.xhtml b/web/admin/branch_office/admin_branch_office_edit.xhtml
new file mode 100644 (file)
index 0000000..12fdd25
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       template="/WEB-INF/templates/admin/admin_base.tpl"
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:h="http://xmlns.jcp.org/jsf/html"
+       xmlns:f="http://xmlns.jcp.org/jsf/core"
+       xmlns:p="http://primefaces.org/ui"
+       >
+
+       <ui:define name="metadata">
+               <f:metadata>
+                       <f:viewParam
+                               name="branchId"
+                               value="#{adminBranchOfficeActionController.currentBranchOffice}"
+                               converter="BranchOfficeConverter"
+                               required="true"
+                               requiredMessage="#{msg.ERROR_PARAMETER_BRANCH_OFFICE_ID_NOT_SET}"
+                               converterMessage="#{msg.PARAMETER_BRANCH_OFFICE_ID_INVALID}"
+                               />
+
+                       <f:viewAction
+                               action="#{adminBranchOfficeActionController.copyAllBranchOfficeProperties()}"
+                               />
+               </f:metadata>
+       </ui:define>
+
+       <ui:define name="document_admin_title">
+               <h:outputText value="#{msg.PAGE_TITLE_ADMIN_EDIT_BRANCH_OFFICE}" />
+       </ui:define>
+
+       <ui:define name="content_header">
+               <h:outputText value="#{msg.CONTENT_TITLE_ADMIN_EDIT_BRANCH_OFFICE}" />
+       </ui:define>
+
+       <ui:define name="content">
+               <h:form
+                       id="form-admin-edit-branch-office"
+                       rendered="#{not empty adminBranchOfficeActionController.currentBranchOffice}"
+                       >
+                       <h:inputHidden value="#{adminBranchOfficeActionController.branchId}" />
+
+                       <p:panelGrid
+                               columns="1"
+                               layout="grid"
+                               >
+                               <f:facet name="header">
+                                       <h:outputFormat
+                                               value="#{msg.ADMIN_EDIT_BRANCH_OFFICE_TITLE}"
+                                               title="#{beanHelper.renderBranchOffice(adminBranchOfficeActionController.currentBranchOffice, false)}"
+                                               rendered="#{empty adminBranchOfficeActionController.branchNumber}"
+                                               >
+                                               <f:param value="#{adminBranchOfficeActionController.branchId}" />
+                                       </h:outputFormat>
+
+                                       <h:outputFormat
+                                               value="#{msg.ADMIN_EDIT_BRANCH_OFFICE_NUMBER_TITLE}"
+                                               title="#{beanHelper.renderBranchOffice(adminBranchOfficeActionController.currentBranchOffice, false)}"
+                                               rendered="#{not empty adminBranchOfficeActionController.branchNumber}"
+                                               >
+                                               <f:param value="#{adminBranchOfficeActionController.branchId}" />
+                                               <f:param value="#{adminBranchOfficeActionController.branchNumber}" />
+                                       </h:outputFormat>
+                               </f:facet>
+
+                               <h:panelGroup styleClass="para" layout="block">
+                                       <h:outputText value="#{msg.ADMIN_BRANCH_OFFICE_MINIMUM_DATA}" />
+                               </h:panelGroup>
+
+                               <ui:include src="/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl" />
+
+                               <f:facet name="footer">
+                                       <p:panelGrid columns="2" layout="grid">
+                                               <p:commandButton
+                                                       type="reset"
+                                                       value="#{msg.BUTTON_RESET_FORM}"
+                                                       />
+
+                                               <p:commandButton
+                                                       type="submit"
+                                                       value="#{msg.BUTTON_ADMIN_EDIT_BRANCH_OFFICE}"
+                                                       action="#{adminBranchOfficeActionController.updateBranchOffice()}"
+                                                       />
+                                       </p:panelGrid>
+                               </f:facet>
+                       </p:panelGrid>
+               </h:form>
+       </ui:define>
+</ui:composition>
index 0a55aa17e6b06a2037dab4c34b53c844726159c7..f491f4d0e4726525330fa536ac1965db345f8e64 100644 (file)
                                </f:facet>
 
                                <h:panelGroup styleClass="para" layout="block">
-                                       <h:outputText value="#{msg.ADMIN_ADD_BRANCH_OFFICE_MINIMUM_DATA}" />
+                                       <h:outputText value="#{msg.ADMIN_BRANCH_OFFICE_MINIMUM_DATA}" />
                                </h:panelGroup>
 
                                <ui:include src="/WEB-INF/templates/admin/branch_office/admin_form_branch_office_data.tpl" />
                                                <p:commandButton
                                                        type="submit"
                                                        value="#{msg.BUTTON_ADMIN_ADD_BASIC_DATA}"
-                                                       action="#{adminBranchOfficeController.addBranchOffice()}"
+                                                       action="#{adminBranchOfficeActionController.addBranchOffice()}"
                                                        update="form-list-branch-offices:branchOfficeList"
                                                        oncomplete="PF('branchOfficeList').filter()"
                                                        />
                        <p:fieldset legend="#{msg.ADMIN_BRANCH_OFFICE_OPENING_TIMES_LEGEND}">
                                <core:outputOpeningTimesDataTable
                                        id="branchOpeningTimeList"
-                                       value="#{adminBranchOfficeController.branchOpeningTimes}"
+                                       value="#{adminBranchOfficeActionController.branchOpeningTimes}"
                                        rows="10"
                                        summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES}"
                                        emptyMessage="#{msg.ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES}"
                                                <p:commandButton
                                                        type="submit"
                                                        value="#{msg.BUTTON_ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME}"
-                                                       action="#{adminBranchOfficeController.addOpeningTime()}"
+                                                       action="#{adminBranchOfficeActionController.addOpeningTime()}"
                                                        update="form-list-branch-opening-time:branchOpeningTimeList"
                                                        oncomplete=""
                                                        />