From: Roland Häder Date: Thu, 2 Apr 2020 16:29:54 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5846335593436ab8813782a8970a654d21d6aa60;p=jjobs-war.git Please cherry-pick: - rewrote admin-headquarters-list to have filters and sorting (newer approach) - added p:panelGrid around reset/submit buttons, still administrative contact list is not being updated on record insert - used beanHelper.renderEmployee() to render department leader (employee instance again) - fixed some wrong references due to last rewrite for departments - added missing i18n key Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java index 813d2cf5..af5b9e15 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsAdminHeadquarterWebRequestBean.java @@ -33,12 +33,12 @@ import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.AdminHeadquarterSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; 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.jjobs.beans.BaseJobsBean; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; @@ -107,12 +107,6 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements */ private Employable headquarterContactEmployee; - /** - * A general headquarter controller (backing bean) - */ - @Inject - private JobsHeadquarterWebRequestController headquarterController; - /** * Country */ @@ -138,6 +132,12 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements */ private Short headquarterLastHouseNumber; + /** + * A general headquarter controller (backing bean) + */ + @Inject + private JobsHeadquarterListWebViewController headquarterListController; + /** * Store */ @@ -222,7 +222,7 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements final Headquarter headquarter = this.createHeadquarter(); // Is the headquarter not created yet? - if (this.isHeadquarterCreatedByRequiredData(headquarter)) { + if (this.headquarterListController.isHeadquarterCreatedByRequiredData(headquarter)) { // Then show proper faces message this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N return; @@ -847,36 +847,6 @@ public class JobsAdminHeadquarterWebRequestBean extends BaseJobsBean implements return openingTime; } - /** - * Checks whether the given headquarter' address is already found in local - * cache. Please note that this method fully relies on the cache, so you - * must always fire proper events that add/update/delete entries in cache. - *

- * @param headquarter Headquarter to check it's address - *

- * @return Whether the address has been found - */ - private boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter) { - // Get full list from other bean - final List allHeadquarter = this.headquarterController.allHeadquarter(); - - // Default is not found - boolean isFound = false; - - // Now check each entry - for (final Headquarter hq : allHeadquarter) { - // Is same address? - if (Headquarters.isSameAddress(hq, headquarter)) { - // Found one - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - /** * Checks if given opening time is already added *

diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java index dc43b6d5..98a61350 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestBean.java @@ -16,22 +16,9 @@ */ package org.mxchange.jjobs.beans.business.headquarter; -import fish.payara.cdi.jsr107.impl.NamedCache; -import java.text.MessageFormat; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import javax.annotation.PostConstruct; -import javax.cache.Cache; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; -import javax.enterprise.event.Observes; -import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; -import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; import org.mxchange.jjobs.beans.BaseJobsBean; @@ -49,206 +36,18 @@ public class JobsHeadquarterWebRequestBean extends BaseJobsBean implements JobsH */ private static final long serialVersionUID = 5_028_697_360_465L; - /** - * A list of all headquarter - */ - private final List allHeadquarter; - - /** - * A list of filtered headquarter - */ - private List filteredHeadquarter; - /** * EJB for administrative purposes */ @EJB (lookup = "java:global/jjobs-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") private HeadquarterSessionBeanRemote headquarterBean; - /** - * A list of all headquarter (globally) - */ - @Inject - @NamedCache (cacheName = "headquarterCache") - private Cache headquarterCache; - /** * Default constructor */ public JobsHeadquarterWebRequestBean () { // Call super constructor super(); - - // Init list - this.allHeadquarter = new LinkedList<>(); - } - - /** - * Observes events being fired when a branch office has been added. - *

- * @param event Event being fired - *

- * @throws NullPointerException If the parameter or it's carried instance is - * null - * @throws IllegalArgumentException If the branchId is zero or lower - */ - public void afterHeadquarterAddedEvent (@Observes final ObservableHeadquarterAddedEvent event) { - // Validate parameter - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getHeadquarter() == null) { - // Throw NPE again - throw new NullPointerException("event.headquarter is null"); //NOI18N - } else if (event.getHeadquarter().getHeadquarterId() == null) { - // Throw it again - throw new NullPointerException("event.headquarter.branchId is null"); //NOI18N - } else if (event.getHeadquarter().getHeadquarterId() < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("event.headquarter.branchId={0} is not valid", event.getHeadquarter().getHeadquarterId())); //NOI18N - } - - // Add instance to cache - this.headquarterCache.put(event.getHeadquarter().getHeadquarterId(), event.getHeadquarter()); - this.allHeadquarter.add(event.getHeadquarter()); - } - - @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allHeadquarter () { - return this.allHeadquarter; - } - - @Override - public Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException { - // Validate parameter - if (null == headquarterId) { - // Throw NPE - throw new NullPointerException("headquarterId is null"); //NOI18N - } else if (headquarterId < 1) { - // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("headquarterId={0} is invalid", headquarterId)); //NOI18N - } else if (!this.headquarterCache.containsKey(headquarterId)) { - // Not found - throw new HeadquarterNotFoundException(headquarterId); - } - - // Get it from cache - final Headquarter headquarter = this.headquarterCache.get(headquarterId); - - // Return it - return headquarter; - } - - /** - * Getter for a list of filtered headquarter - *

- * @return Filtered headquarter - */ - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List getFilteredHeadquarter () { - return this.filteredHeadquarter; - } - - /** - * Setter for a list of filtered headquarter - *

- * @param filteredHeadquarter Filtered headquarter - */ - @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") - public void setFilteredHeadquarter (final List filteredHeadquarter) { - this.filteredHeadquarter = filteredHeadquarter; - } - - /** - * Initializer method - */ - @PostConstruct - public void initializeList () { - // Is cache there? - if (!this.headquarterCache.iterator().hasNext()) { - // Get whole list from EJB - final List Headquarter = this.headquarterBean.allHeadquarters(); - - // Add all - for (final Headquarter headquarter : Headquarter) { - // Add it to cache - this.headquarterCache.put(headquarter.getHeadquarterId(), headquarter); - } - } - - // Is the list empty, but filled cache? - if (this.allHeadquarter.isEmpty() && this.headquarterCache.iterator().hasNext()) { - // Build up list - for (final Cache.Entry currentEntry : this.headquarterCache) { - // Add to list - this.allHeadquarter.add(currentEntry.getValue()); - } - - // Sort list - this.allHeadquarter.sort(new Comparator() { - @Override - public int compare (final Headquarter headquarter1, final Headquarter headquarter2) { - return headquarter1.getHeadquarterId() > headquarter2.getHeadquarterId() ? 1 : headquarter1.getHeadquarterId() < headquarter2.getHeadquarterId() ? -1 : 0; - } - }); - } - } - - @Override - public Boolean isCompanyNameUsed (final String companyName) { - // Validate parameter - if (null == companyName) { - // Throw NPE - throw new NullPointerException("companyName is null"); //NOI18N - } else if (companyName.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("companyName is empty"); //NOI18N - } - - // Default is not found - boolean isFound = false; - - // Check all entries - for (final Headquarter headquarter : this.allHeadquarter()) { - // Is same company name? - if (Objects.equals(headquarter.getHeadquarterCompanyName(), companyName)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; - } - - @Override - public Boolean isEmailAddressRegistered (final String emailAddress) { - // Validate parameter - if (null == emailAddress) { - // Throw NPE - throw new NullPointerException("emailAddress is null"); //NOI18N - } else if (emailAddress.isEmpty()) { - // Throw IAE - throw new IllegalArgumentException("emailAddress is empty"); //NOI18N - } - - // Default is not found - boolean isFound = false; - - // Check all entries - for (final Headquarter headquarter : this.allHeadquarter()) { - // Is email address used? - if (Objects.equals(headquarter.getHeadquarterEmailAddress(), emailAddress)) { - // Found it - isFound = true; - break; - } - } - - // Return flag - return isFound; } } diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java index 6446d924..f6048446 100644 --- a/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/JobsHeadquarterWebRequestController.java @@ -17,9 +17,6 @@ package org.mxchange.jjobs.beans.business.headquarter; import java.io.Serializable; -import java.util.List; -import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; /** * An interface for general Headquarter controller @@ -28,41 +25,4 @@ import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; */ public interface JobsHeadquarterWebRequestController extends Serializable { - /** - * Checks whether given company name already exists - *

- * @param companyName Company name to check - *

- * @return Whether the company name exists - */ - Boolean isCompanyNameUsed (final String companyName); - - /** - * Checks if given email address is already registered by an other - * headquarter - *

- * @param emailAddress Email address - *

- * @return Whether the email address has been already registered - */ - Boolean isEmailAddressRegistered (final String emailAddress); - - /** - * Returns a list of all headquarter - *

- * @return A list of all headquarter - */ - List allHeadquarter (); - - /** - * Tries to find a headquarter with given id number - *

- * @param headquarterId Headquarter id - *

- * @return A headquarter instance - *

- * @throws HeadquarterNotFoundException If the headquarter was not found - */ - Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException; - } diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewBean.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewBean.java new file mode 100644 index 00000000..8d79b441 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewBean.java @@ -0,0 +1,306 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.business.headquarter.list; + +import fish.payara.cdi.jsr107.impl.NamedCache; +import java.text.MessageFormat; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import javax.annotation.PostConstruct; +import javax.cache.Cache; +import javax.ejb.EJB; +import javax.enterprise.event.Observes; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontactsbusiness.events.headquarter.added.ObservableHeadquarterAddedEvent; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; +import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; +import org.mxchange.jjobs.beans.BaseJobsBean; + +/** + * A list bean for headquarter + *

+ * @author Roland Häder + */ +@Named ("headquarterListController") +@ViewScoped +public class JobsHeadquarterListWebViewBean extends BaseJobsBean implements JobsHeadquarterListWebViewController { + + /** + * Serial number + */ + private static final long serialVersionUID = 5_028_697_360_466L; + + /** + * A list of all headquarter + */ + private final List allHeadquarters; + + /** + * A list of filtered headquarter + */ + private List filteredHeadquarters; + + /** + * EJB for administrative purposes + */ + @EJB (lookup = "java:global/jjobs-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote") + private HeadquarterSessionBeanRemote headquarterBean; + + /** + * A list of all headquarter (globally) + */ + @Inject + @NamedCache (cacheName = "headquarterCache") + private transient Cache headquarterCache; + + /** + * Currently selected headquarter + */ + private Headquarter selectedHeadquarter; + + /** + * Default constructor + */ + public JobsHeadquarterListWebViewBean () { + // Call super constructor + super(); + + // Init list + this.allHeadquarters = new LinkedList<>(); + } + + /** + * Observes events being fired when a branch office has been added. + *

+ * @param event Event being fired + *

+ * @throws NullPointerException If the parameter or it's carried instance is + * null + * @throws IllegalArgumentException If the branchId is zero or lower + */ + public void afterHeadquarterAddedEvent (@Observes final ObservableHeadquarterAddedEvent event) { + // Validate parameter + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getHeadquarter() == null) { + // Throw NPE again + throw new NullPointerException("event.headquarter is null"); //NOI18N + } else if (event.getHeadquarter().getHeadquarterId() == null) { + // Throw it again + throw new NullPointerException("event.headquarter.branchId is null"); //NOI18N + } else if (event.getHeadquarter().getHeadquarterId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("event.headquarter.branchId={0} is not valid", event.getHeadquarter().getHeadquarterId())); //NOI18N + } + + // Add instance to cache + this.headquarterCache.put(event.getHeadquarter().getHeadquarterId(), event.getHeadquarter()); + this.getAllHeadquarters().add(event.getHeadquarter()); + } + + @Override + public Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException { + // Validate parameter + if (null == headquarterId) { + // Throw NPE + throw new NullPointerException("headquarterId is null"); //NOI18N + } else if (headquarterId < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("headquarterId={0} is invalid", headquarterId)); //NOI18N + } else if (!this.headquarterCache.containsKey(headquarterId)) { + // Not found + throw new HeadquarterNotFoundException(headquarterId); + } + + // Get it from cache + final Headquarter headquarter = this.headquarterCache.get(headquarterId); + + // Return it + return headquarter; + } + + @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getAllHeadquarters () { + return this.allHeadquarters; + } + + /** + * Getter for a list of filtered headquarter + *

+ * @return Filtered headquarter + */ + @SuppressWarnings ("ReturnOfCollectionOrArrayField") + public List getFilteredHeadquarters () { + return this.filteredHeadquarters; + } + + /** + * Setter for a list of filtered headquarter + *

+ * @param filteredHeadquarters Filtered headquarter + */ + @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter") + public void setFilteredHeadquarters (final List filteredHeadquarters) { + this.filteredHeadquarters = filteredHeadquarters; + } + + /** + * Getter for selected headquarter + *

+ * @return Selected headquarter + */ + public Headquarter getSelectedHeadquarter () { + return this.selectedHeadquarter; + } + + /** + * Setter for selected headquarter + *

+ * @param selectedHeadquarter Selected headquarter + */ + public void setSelectedHeadquarter (final Headquarter selectedHeadquarter) { + this.selectedHeadquarter = selectedHeadquarter; + } + + /** + * Initializer method + */ + @PostConstruct + public void initializeList () { + // Is cache there? + if (!this.headquarterCache.iterator().hasNext()) { + // Get whole list from EJB + final List Headquarter = this.headquarterBean.allHeadquarters(); + + // Add all + for (final Headquarter headquarter : Headquarter) { + // Add it to cache + this.headquarterCache.put(headquarter.getHeadquarterId(), headquarter); + } + } + + // Is the list empty, but filled cache? + if (this.getAllHeadquarters().isEmpty() && this.headquarterCache.iterator().hasNext()) { + // Build up list + for (final Cache.Entry currentEntry : this.headquarterCache) { + // Add to list + this.getAllHeadquarters().add(currentEntry.getValue()); + } + + // Sort list + this.getAllHeadquarters().sort(new Comparator() { + @Override + public int compare (final Headquarter headquarter1, final Headquarter headquarter2) { + return headquarter1.getHeadquarterId() > headquarter2.getHeadquarterId() ? 1 : headquarter1.getHeadquarterId() < headquarter2.getHeadquarterId() ? -1 : 0; + } + }); + } + } + + @Override + public Boolean isCompanyNameUsed (final String companyName) { + // Validate parameter + if (null == companyName) { + // Throw NPE + throw new NullPointerException("companyName is null"); //NOI18N + } else if (companyName.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("companyName is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final Headquarter headquarter : this.getAllHeadquarters()) { + // Is same company name? + if (Objects.equals(headquarter.getHeadquarterCompanyName(), companyName)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + @Override + public Boolean isEmailAddressRegistered (final String emailAddress) { + // Validate parameter + if (null == emailAddress) { + // Throw NPE + throw new NullPointerException("emailAddress is null"); //NOI18N + } else if (emailAddress.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("emailAddress is empty"); //NOI18N + } + + // Default is not found + boolean isFound = false; + + // Check all entries + for (final Headquarter headquarter : this.getAllHeadquarters()) { + // Is email address used? + if (Objects.equals(headquarter.getHeadquarterEmailAddress(), emailAddress)) { + // Found it + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + + /** + * Checks whether the given headquarter' address is already found in local + * cache. Please note that this method fully relies on the cache, so you + * must always fire proper events that add/update/delete entries in cache. + *

+ * @param headquarter Headquarter to check it's address + *

+ * @return Whether the address has been found + */ + @Override + public boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter) { + // Default is not found + boolean isFound = false; + + // Now check each entry + for (final Headquarter hq : this.getAllHeadquarters()) { + // Is same address? + if (Headquarters.isSameAddress(hq, headquarter)) { + // Found one + isFound = true; + break; + } + } + + // Return flag + return isFound; + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewController.java b/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewController.java new file mode 100644 index 00000000..e593d64f --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/business/headquarter/list/JobsHeadquarterListWebViewController.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jjobs.beans.business.headquarter.list; + +import java.io.Serializable; +import java.util.List; +import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; +import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; + +/** + * An interface for general Headquarter controller + *

+ * @author Roland Häder + */ +public interface JobsHeadquarterListWebViewController extends Serializable { + + /** + * Checks whether given company name already exists + *

+ * @param companyName Company name to check + *

+ * @return Whether the company name exists + */ + Boolean isCompanyNameUsed (final String companyName); + + /** + * Checks if given email address is already registered by an other + * headquarter + *

+ * @param emailAddress Email address + *

+ * @return Whether the email address has been already registered + */ + Boolean isEmailAddressRegistered (final String emailAddress); + + /** + * Returns a list of all headquarter + *

+ * @return A list of all headquarter + */ + List getAllHeadquarters (); + + /** + * Tries to find a headquarter with given id number + *

+ * @param headquarterId Headquarter id + *

+ * @return A headquarter instance + *

+ * @throws HeadquarterNotFoundException If the headquarter was not found + */ + Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException; + + /** + * Checks whether the given headquarter' address is already found in local + * cache. Please note that this method fully relies on the cache, so you + * must always fire proper events that add/update/delete entries in cache. + *

+ * @param headquarter Headquarter to check it's address + *

+ * @return Whether the address has been found + */ + boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter); + +} diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java index 3901d358..569b6471 100644 --- a/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java @@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewBean; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController; /** * Converter for converting company headquarter to and from id number @@ -38,15 +38,10 @@ public class JobsHeadquarterConverter implements Converter { /** * Headquarter backing bean */ - private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + private static JobsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER; @Override public Headquarter getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Is the instance there? - if (null == HEADQUARTER_CONTROLLER) { - HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); - } - // Init instance Headquarter headquarter = null; @@ -54,8 +49,14 @@ public class JobsHeadquarterConverter implements Converter { // Try to parse the value as long final Long headquarterId = Long.valueOf(submittedValue); + // Is the instance there? + if (null == HEADQUARTER_LIST_CONTROLLER) { + // Set it now + HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get(); + } + // Try to get user instance from it - headquarter = HEADQUARTER_CONTROLLER.findHeadquarterById(headquarterId); + headquarter = HEADQUARTER_LIST_CONTROLLER.findHeadquarterById(headquarterId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java b/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java index 9044fe99..6a99e742 100644 --- a/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java +++ b/src/java/org/mxchange/jjobs/converter/business/headquarters/JobsHeadquarterConverter.java @@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException; import javax.faces.convert.FacesConverter; import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewBean; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController; /** * Converter for converting company headquarters to and from id number @@ -38,15 +38,10 @@ public class JobsHeadquarterConverter implements Converter { /** * Headquarter backing bean */ - private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + private static JobsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER; @Override public Headquarter getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) { - // Is the instance there? - if (null == HEADQUARTER_CONTROLLER) { - HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); - } - // Init instance Headquarter headquarter = null; @@ -54,8 +49,14 @@ public class JobsHeadquarterConverter implements Converter { // Try to parse the value as long final Long headquarterId = Long.valueOf(submittedValue); + // Is the instance there? + if (null == HEADQUARTER_LIST_CONTROLLER) { + // Then set controller + HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get(); + } + // Try to get user instance from it - headquarter = HEADQUARTER_CONTROLLER.findHeadquarterById(headquarterId); + headquarter = HEADQUARTER_LIST_CONTROLLER.findHeadquarterById(headquarterId); } catch (final NumberFormatException ex) { // Throw again throw new ConverterException(ex); diff --git a/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java index e662bac6..6c8bb379 100644 --- a/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java +++ b/src/java/org/mxchange/jjobs/validator/business/headquarter/JobsHeadquarterCompanyNameValidator.java @@ -24,8 +24,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewBean; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController; /** * A validator for headquarter company names @@ -38,7 +38,7 @@ public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { /** * Headquarter backing bean */ - private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + private static JobsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER; /** * Serial number @@ -47,12 +47,6 @@ public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { - // Is the instance there? - if (null == HEADQUARTER_CONTROLLER) { - // Get bean from CDI directly - HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); - } - // All accepted, required fields final String[] requiredFields = {"companyName"}; //NOI18N @@ -80,8 +74,14 @@ public class JobsHeadquarterCompanyNameValidator extends BaseStringValidator { checkExisting = Boolean.parseBoolean((String) attribute); } + // Is the instance there? + if (null == HEADQUARTER_LIST_CONTROLLER) { + // Get bean from CDI directly + HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get(); + } + // Check if name is already used - final Boolean nameExists = HEADQUARTER_CONTROLLER.isCompanyNameUsed(companyName); + final Boolean nameExists = HEADQUARTER_LIST_CONTROLLER.isCompanyNameUsed(companyName); // Is the user id valid? if ((!nameExists) && (checkExisting)) { diff --git a/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java index a7deaf3e..bca2a332 100644 --- a/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java +++ b/src/java/org/mxchange/jjobs/validator/emailaddress/headquarter/JobsHeadquarterEmailAddressValidator.java @@ -25,8 +25,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean; -import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewBean; +import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController; /** * A validator for headquarter's email address validation @@ -44,7 +44,7 @@ public class JobsHeadquarterEmailAddressValidator extends BaseStringValidator { /** * Headquarter backing bean */ - private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER; + private static JobsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER; /** * Pattern matcher @@ -65,6 +65,7 @@ public class JobsHeadquarterEmailAddressValidator extends BaseStringValidator { * Default constructor */ public JobsHeadquarterEmailAddressValidator () { + // Default is not allowed this.allowEmptyRequiredData = Boolean.FALSE; } @@ -115,13 +116,13 @@ public class JobsHeadquarterEmailAddressValidator extends BaseStringValidator { final String clientId = component.getClientId(); // Is the instance there? - if (null == HEADQUARTER_CONTROLLER) { + if (null == HEADQUARTER_LIST_CONTROLLER) { // Get bean from CDI directly - HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get(); + HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get(); } // Is it registered? - final Boolean isRegistered = HEADQUARTER_CONTROLLER.isEmailAddressRegistered(emailAddress); + final Boolean isRegistered = HEADQUARTER_LIST_CONTROLLER.isEmailAddressRegistered(emailAddress); // Is the email address already registered? if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N diff --git a/src/java/org/mxchange/localization/generic_de_DE.properties b/src/java/org/mxchange/localization/generic_de_DE.properties index cffa4945..a53e0cf4 100644 --- a/src/java/org/mxchange/localization/generic_de_DE.properties +++ b/src/java/org/mxchange/localization/generic_de_DE.properties @@ -1229,3 +1229,4 @@ ADMIN_ASSIGNED_MANUFACTURER_LABEL=Zugewiesener Hersteller: BARCODE=Barcode: ADMIN_CONTACT_DETAILS_HEADER=Kontaktdaten zu {0} {1} {2}: ADMIN_DEPARTMENT_DETAILS_HEADER=Daten der Abteilung {0} (Id {1}): +ADMIN_HEADQUARTER_DETAILS_HEADER=Haupstelle von {0} (Id {1})): diff --git a/src/java/org/mxchange/localization/generic_en_US.properties b/src/java/org/mxchange/localization/generic_en_US.properties index 2af80878..b7faeb42 100644 --- a/src/java/org/mxchange/localization/generic_en_US.properties +++ b/src/java/org/mxchange/localization/generic_en_US.properties @@ -1136,3 +1136,4 @@ ADMIN_ASSIGNED_MANUFACTURER_LABEL=Assigned manufacturer: BARCODE=Barcode: ADMIN_CONTACT_DETAILS_HEADER=Contact data of {0} {1} {2}: ADMIN_DEPARTMENT_DETAILS_HEADER=Data of department {0} (Id {1}): +ADMIN_HEADQUARTER_DETAILS_HEADER=Headquarter of {0} (Id {1})): diff --git a/web/WEB-INF/templates/admin/basic_data/admin_form_basic_data.tpl b/web/WEB-INF/templates/admin/basic_data/admin_form_basic_data.tpl index fb72b672..6e0e18cf 100644 --- a/web/WEB-INF/templates/admin/basic_data/admin_form_basic_data.tpl +++ b/web/WEB-INF/templates/admin/basic_data/admin_form_basic_data.tpl @@ -132,7 +132,7 @@ - - + + + + diff --git a/web/admin/department/admin_department_list.xhtml b/web/admin/department/admin_department_list.xhtml index 4f724549..d3a51bee 100644 --- a/web/admin/department/admin_department_list.xhtml +++ b/web/admin/department/admin_department_list.xhtml @@ -210,7 +210,7 @@ @@ -307,7 +307,7 @@ - + diff --git a/web/admin/headquarter/admin_headquarter_list.xhtml b/web/admin/headquarter/admin_headquarter_list.xhtml index bc94fcd9..089a71f1 100644 --- a/web/admin/headquarter/admin_headquarter_list.xhtml +++ b/web/admin/headquarter/admin_headquarter_list.xhtml @@ -18,29 +18,49 @@ - + - - + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + @@ -228,7 +281,7 @@ type="submit" value="#{msg.BUTTON_ADMIN_ADD_HEADQUARTER}" action="#{adminHeadquarterController.addHeadquarter()}" - update=":master:form-list-Headquarter:headquarterList" + update=":master:form-list-headquarters:headquarterList" />