From ec9657313addf6dbde140e1c5743e870ae1b607d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 13 Oct 2017 01:51:26 +0200 Subject: [PATCH] Please cherry-pick: - added template for adding branch office opening times - added all required fields in adminBranchOfficeController bean - opening times for branch offices are now set, if provided, in new branchOffice instance - double opening times won't be accepted - added clear() method, seem not to affect formular in PrimeFaces - added missing navigation cases MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...ncialsAdminBranchOfficeWebRequestBean.java | 256 +++++++++++++++++- .../localization/bundle_de_DE.properties | 24 +- .../localization/bundle_en_US.properties | 10 + web/WEB-INF/faces-config.xml | 15 + .../branch_office/admin_form_opening_time.tpl | 67 +++++ .../admin_branch_office_list.xhtml | 73 +++++ .../admin_opening_time_list.xhtml | 10 +- 7 files changed, 447 insertions(+), 8 deletions(-) create mode 100644 web/WEB-INF/templates/admin/branch_office/admin_form_opening_time.tpl diff --git a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java index 77e85ff2..b8019540 100644 --- a/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java @@ -16,9 +16,12 @@ */ 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.context.SessionScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.inject.Inject; @@ -32,6 +35,9 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice; import org.mxchange.jcontactsbusiness.model.employee.Employee; +import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -46,7 +52,7 @@ import org.mxchange.jusercore.model.user.User; * @author Roland Häder */ @Named ("adminBranchOfficeController") -@RequestScoped +@SessionScoped public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminBranchOfficeWebRequestController { /** @@ -108,6 +114,11 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea @Inject private FinancialsBranchOfficeWebRequestController branchOfficeController; + /** + * Opening times of this branch office + */ + private static List branchOpeningTimes; + /** * Store */ @@ -163,12 +174,38 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea */ 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); + } } /** @@ -204,10 +241,50 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea // Fire event this.branchOfficeAddedEvent.fire(new BranchOfficeAddedEvent(updatedOffice)); + // Clear this bean + this.clear(); + // Redirect to list return "admin_list_branch_office"; //NOI18N } + /** + * 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"); //NOI18N + return; + } + + // Add to temporary list + branchOpeningTimes.add(openingTime); + + // Clear opening time fields + this.clearOpeningTime(); + } + /** * Getter for city *

@@ -334,6 +411,26 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea this.branchNumber = branchNumber; } + /** + * Getter for opening times of this branch office + *

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

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

@@ -532,6 +629,116 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea this.landLineNumber = landLineNumber; } + /** + * Getter for ending week day + *

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

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

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

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

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

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

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

+ * @param openingStartTime Starting time + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setOpeningStartTime (final Date openingStartTime) { + this.openingStartTime = openingStartTime; + } + + /** + * Clears this bean data + */ + private void clear () { + // Clear all branch office data + this.setBranchCity(null); + this.setBranchCompany(null); + this.setBranchContactEmployee(null); + this.setBranchCountry(null); + this.setBranchEmailAddress(null); + this.setBranchHouseNumber(null); + this.setBranchNumber(null); + this.setBranchStore(null); + this.setBranchStreet(null); + this.setBranchSuiteNumber(null); + this.setBranchUserOwner(null); + this.setBranchZipCode(null); + this.setBranchOpeningTimes(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 @@ -596,11 +803,31 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea // Set fax number branchOffice.setBranchFaxNumber(fax); } + // Is the opening times list filled? + if (!this.getBranchOpeningTimes().isEmpty()) { + // Yes, then set in branch office, too + branchOffice.setBranchOpeningTimes(this.getBranchOpeningTimes()); + } // Return fully prepared instance return branchOffice; } + /** + * Prepares an instance of a OpeningTimes object (entity) with all data from + * this bean. If a complete fax number or land-line number was provided, it + * will be set in the instance as well. + *

+ * @return An instance of a OpeningTimes class (entity) + */ + private OpeningTime createOpeningTimes () { + // Create new openingTime instance + final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime()); + + // Return fully prepared instance + return openingTime; + } + /** * Checks whether the given branch office's address is already found in * local cache. Please note that this method fully relies on the cache, so @@ -632,4 +859,29 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea return isFound; } + /** + * Checks if given opening time is already added + *

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

+ * @return Whether it has been added already + */ + private boolean isSameOpeningTimeFound (final OpeningTime openingTime) { + // Default is not found + boolean isFound = false; + + // Loop through list + for (final OpeningTime ot : this.getBranchOpeningTimes()) { + // Check it + if (Objects.equals(ot, openingTime)) { + // Found same match + isFound = true; + break; + } + } + + // Return it + return isFound; + } + } diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 32313a5c..8e875648 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -526,7 +526,7 @@ BUTTON_ADMIN_EXPORT_USERS_XLS=Benutzerdaten als Excel-Datei ADMIN_LINK_EXPORT_CONTACT=Daten exportieren ADMIN_LINK_EXPORT_CONTACT_TITLE=Kontaktdaten exportieren #@TODO Please fix German umlauts! -ADMIN_EMPTY_LIST_CONTACT=Keine Kontaktdaten in Datenbank gefunden. Oder Ihre Suche ergab keine Uebereinstimmungen. +ADMIN_EMPTY_LIST_CONTACT=Es befinden sich leine Kontaktdaten in der Datenbank. Oder Ihre Suche ergab keine Uebereinstimmungen. #@TODO Please fix German umlauts! ADMIN_EMPTY_LIST_USER=Keine Benutzerdaten in Datenbank gefunden. Oder Ihre Suche ergab keine Uebereinstimmungen. ADMIN_PERSONAL_DATA_COMMENT=Kommentar: (optional) @@ -810,7 +810,7 @@ ADMIN_BASIC_COMPANY_DATA_COMPANY_COMMENTS=Anmerkungen: ADMIN_BASIC_COMPANY_DATA_PHONE_NUMBER=Haupttelefonnummer: ADMIN_BASIC_COMPANY_DATA_FAX_NUMBER=Hauptfaxnummer: #@TODO Please fix German umlauts! -ADMIN_ADD_BASIC_COMPANY_DATA_TITLE=Neuen geschaeftlichen Kontakt hinzufuegen +ADMIN_ADD_BASIC_COMPANY_DATA_TITLE=Geschaeftlichen Kontakt hinzufuegen ADMIN_ADD_BASIC_COMPANY_DATA_MINIMUM_DATA=Bitte mindestens Firmennamen inklusive Rechtsform ein. #@TODO Please fix German umlauts! ENTERED_EMAIL_ADDRESS_IS_INVALID=Die eingegebene Email-Addresse entspricht nicht dem gueltigen Format. @@ -866,7 +866,7 @@ ADMIN_ASSIGN_BRANCH_OFFICE_COMPANY=Filiale dem Unternehmen zuweisen: PAGE_TITLE_ADMIN_LIST_BRANCH_OFFICES=Filialen auflisten CONTENT_TITLE_ADMIN_LIST_BRANCH_OFFICES=Auflisten von Filialen: #@TODO Please fix German umlauts! -ADMIN_EMPTY_LIST_BRANCH_OFFICES=Es wurden keine Filialen in der Datenbank gefunden. Oder Ihre Suche ergab keine Uebereinstimmungen. +ADMIN_EMPTY_LIST_BRANCH_OFFICES=Es befinden sich keine Filialen in der Datenbank gefunden. Oder Ihre Suche ergab keine Uebereinstimmungen. #@TODO Please fix German umlauts! ADMIN_ADD_BRANCH_OFFICE_TITLE=Filiale hinzufuegen #@TODO Please fix German umlauts! @@ -1071,6 +1071,7 @@ ADMIN_OPENING_TIME_LEGEND_TITLE=Geben Sie die Daten einer einzelnen Oeffnungszei ADMIN_ADD_OPENING_TIME_TITLE=Oeffnungszeit hinzufuegen: #@TODO Please fix German umlauts! ADMIN_ADD_OPENING_TIME_MINIMUM_DATA=Bitte geben Sie zum Hinzufuegen einer Oeffnungszeit alle Angaben an. Diese sollten nicht konfliktieren. +#@TODO Please fix German umlauts! BUTTON_ADMIN_ADD_OPENING_TIME=Oeffnungszeit hinzufuegen ADMIN_LINK_ASSIGN_DEPARTMENT_BRANCH_OFFICE_TITLE=Dieser Abteilung eine Filiale zuweisen. ADMIN_LINK_ASSIGN_DEPARTMENTS_LEAD_EMPLOYEE_TITLE=Dieser Abteilung einen leitenden Mitarbeiter zuweisen. @@ -1078,3 +1079,20 @@ ADMIN_LINK_ASSIGN_DEPARTMENTS_OWNER_USER_TITLE=Dieser Abteilung einen besitzende #@TODO Please fix German umlauts! FIELD_PAYMENT_TYPE_REQUIRED=Bitte waehlen Sie eine Zahlungsmethode aus. ADMIN_LIST_USERS_HEADER=Liste aller Benutzer +#@TODO Please fix German umlauts! +ADMIN_BRANCH_OFFICE_OPENING_TIMES_LEGEND=Oeffnungszeiten der Filiale: +#@TODO Please fix German umlauts! +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=Diese Tabelle listet Oeffnungszeiten der Filiale auf. +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICES=Diese Tabelle listet Filialen auf. +#@TODO Please fix German umlauts! +ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=Es befinden sich keine Oeffnungszeiten dieser Filiale in der Datenbank. +#@TODO Please fix German umlauts! +ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=Alle Oeffnungszeiten der Filiale auflisten +#@TODO Please fix German umlauts! +ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME_TITLE=Oeffnungszeit zur Filiale hinzufuegen +#@TODO Please fix German umlauts! +BUTTON_ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME=Oeffnungszeit zur Filiale hinzufuegen +ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND=Einzelne Oeffnungzeit der Filiale: +ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND_TITLE=Geben Sie hier eine einzelne Oeffnungszeit der Filiale ein. +#@TODO Please fix German umlauts! +ADMIN_OPENING_TIME_ALREADY_CREATED=Die Oeffnungzeit wurde bereits hinzugefuegt. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index b46c2c18..23ed5798 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -996,3 +996,13 @@ ADMIN_LINK_ASSIGN_DEPARTMENTS_LEAD_EMPLOYEE_TITLE=Assign this department a leadi ADMIN_LINK_ASSIGN_DEPARTMENTS_OWNER_USER_TITLE=Assign this department an owning user. FIELD_PAYMENT_TYPE_REQUIRED=Please choose a payment method. ADMIN_LIST_USERS_HEADER=List of all users +ADMIN_BRANCH_OFFICE_OPENING_TIMES_LEGEND=Opening times of branch office: +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES=This table lists opening times of this branch office. +TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICES=This table lists branch offices. +ADMIN_EMPTY_LIST_BRANCH_OFFICE_OPENING_TIMES=There are no opening times of this branch office in database. +ADMIN_LIST_BRANCH_OFFICE_OPENING_TIMES_HEADER=List all opening times of branch office +ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME_TITLE=Add opening time to branch office +BUTTON_ADMIN_ADD_BRANCH_OFFICE_OPENING_TIME=Add opening time to branch office +ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND=Single opening time of branch office: +ADMIN_BRANCH_OFFICE_OPENING_TIME_LEGEND_TITLE=Enter single opening time of branch office. +ADMIN_OPENING_TIME_ALREADY_CREATED=The opening time has already been added. diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index c1f66e43..30de4b7c 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -854,6 +854,21 @@ /admin/employee/admin_employee_delete.xhtml + + /admin/opening_time/admin_opening_time_list.xhtml + + admin_show_opening_time + /admin/opening_time/admin_opening_time_show.xhtml + + + admin_edit_opening_time + /admin/opening_time/admin_opening_time_edit.xhtml + + + admin_delete_opening_time + /admin/opening_time/admin_opening_time_delete.xhtml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/admin/branch_office/admin_branch_office_list.xhtml b/web/admin/branch_office/admin_branch_office_list.xhtml index 26bd0c68..ff665119 100644 --- a/web/admin/branch_office/admin_branch_office_list.xhtml +++ b/web/admin/branch_office/admin_branch_office_list.xhtml @@ -178,5 +178,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/admin/opening_time/admin_opening_time_list.xhtml b/web/admin/opening_time/admin_opening_time_list.xhtml index a91a699e..66d2630e 100644 --- a/web/admin/opening_time/admin_opening_time_list.xhtml +++ b/web/admin/opening_time/admin_opening_time_list.xhtml @@ -48,7 +48,7 @@ - + @@ -88,11 +88,15 @@ - + + + - + + + -- 2.39.5