*/
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
@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;
}
}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 {
+
+}
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;
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;
/**
* 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
}
/**
- * 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;
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.
/**
* 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;
}
/**
* 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
/**
* 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
// 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));
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;
*/
private FinancialsContactListWebViewController contactListController;
+ /**
+ * Event being fired when a user has updated his contact data
+ */
+ @Any
+ @Inject
+ private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
+
/**
* Country instance
*/
// 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
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;
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>
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;
/**
* 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
@Any
private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
- /**
- * Administrative phone controller
- */
- @Inject
- private FinancialsAdminPhoneWebRequestController adminPhoneController;
-
/**
* Contact instance
*/
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>
// 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
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
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;
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>
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;
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;
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>
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
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
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
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
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;
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>
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;
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
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;
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
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);
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
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:
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}:
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:
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:
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}):
<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>
<?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"
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"
<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"
<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"
>
<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>
<p:selectOneMenu
id="openingStartDay"
- value="#{adminBranchOfficeController.openingStartDay}"
+ value="#{adminBranchOfficeActionController.openingStartDay}"
filter="true"
filterMatchMode="contains"
required="true"
<p:selectOneMenu
id="openingEndDay"
- value="#{adminBranchOfficeController.openingEndDay}"
+ value="#{adminBranchOfficeActionController.openingEndDay}"
filter="true"
filterMatchMode="contains"
required="true"
<p:calendar
id="openingStartTime"
- value="#{adminBranchOfficeController.openingStartTime}"
+ value="#{adminBranchOfficeActionController.openingStartTime}"
pattern="HH:mm"
timeOnly="true"
stepMinute="5"
<p:calendar
id="openingEndTime"
- value="#{adminBranchOfficeController.openingEndTime}"
+ value="#{adminBranchOfficeActionController.openingEndTime}"
pattern="HH:mm"
timeOnly="true"
stepMinute="5"
--- /dev/null
+<?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>
</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=""
/>