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.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
*/
private Employable headquarterContactEmployee;
- /**
- * A general headquarter controller (backing bean)
- */
- @Inject
- private FinancialsHeadquarterWebRequestController headquarterController;
-
/**
* Country
*/
*/
private Short headquarterLastHouseNumber;
+ /**
+ * A general headquarter controller (backing bean)
+ */
+ @Inject
+ private FinancialsHeadquarterListWebViewController headquarterListController;
+
/**
* Store
*/
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;
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.
- * <p>
- * @param headquarter Headquarter to check it's address
- * <p>
- * @return Whether the address has been found
- */
- private boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter) {
- // Get full list from other bean
- final List<Headquarter> 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
* <p>
*/
package org.mxchange.jfinancials.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.jfinancials.beans.BaseFinancialsBean;
*/
private static final long serialVersionUID = 5_028_697_360_465L;
- /**
- * A list of all headquarter
- */
- private final List<Headquarter> allHeadquarter;
-
- /**
- * A list of filtered headquarter
- */
- private List<Headquarter> filteredHeadquarter;
-
/**
* EJB for administrative purposes
*/
@EJB (lookup = "java:global/jfinancials-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote")
private HeadquarterSessionBeanRemote headquarterBean;
- /**
- * A list of all headquarter (globally)
- */
- @Inject
- @NamedCache (cacheName = "headquarterCache")
- private Cache<Long, Headquarter> headquarterCache;
-
/**
* Default constructor
*/
public FinancialsHeadquarterWebRequestBean () {
// Call super constructor
super();
-
- // Init list
- this.allHeadquarter = new LinkedList<>();
- }
-
- /**
- * Observes events being fired when a branch office has been added.
- * <p>
- * @param event Event being fired
- * <p>
- * @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<Headquarter> 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
- * <p>
- * @return Filtered headquarter
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Headquarter> getFilteredHeadquarter () {
- return this.filteredHeadquarter;
- }
-
- /**
- * Setter for a list of filtered headquarter
- * <p>
- * @param filteredHeadquarter Filtered headquarter
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredHeadquarter (final List<Headquarter> 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> 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<Long, Headquarter> currentEntry : this.headquarterCache) {
- // Add to list
- this.allHeadquarter.add(currentEntry.getValue());
- }
-
- // Sort list
- this.allHeadquarter.sort(new Comparator<Headquarter>() {
- @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;
}
}
package org.mxchange.jfinancials.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
*/
public interface FinancialsHeadquarterWebRequestController extends Serializable {
- /**
- * Checks whether given company name already exists
- * <p>
- * @param companyName Company name to check
- * <p>
- * @return Whether the company name exists
- */
- Boolean isCompanyNameUsed (final String companyName);
-
- /**
- * Checks if given email address is already registered by an other
- * headquarter
- * <p>
- * @param emailAddress Email address
- * <p>
- * @return Whether the email address has been already registered
- */
- Boolean isEmailAddressRegistered (final String emailAddress);
-
- /**
- * Returns a list of all headquarter
- * <p>
- * @return A list of all headquarter
- */
- List<Headquarter> allHeadquarter ();
-
- /**
- * Tries to find a headquarter with given id number
- * <p>
- * @param headquarterId Headquarter id
- * <p>
- * @return A headquarter instance
- * <p>
- * @throws HeadquarterNotFoundException If the headquarter was not found
- */
- Headquarter findHeadquarterById (final Long headquarterId) throws HeadquarterNotFoundException;
-
}
--- /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.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.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * A list bean for headquarter
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("headquarterListController")
+@ViewScoped
+public class FinancialsHeadquarterListWebViewBean extends BaseFinancialsBean implements FinancialsHeadquarterListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 5_028_697_360_466L;
+
+ /**
+ * A list of all headquarter
+ */
+ private final List<Headquarter> allHeadquarters;
+
+ /**
+ * A list of filtered headquarter
+ */
+ private List<Headquarter> filteredHeadquarters;
+
+ /**
+ * EJB for administrative purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/headquarter!org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote")
+ private HeadquarterSessionBeanRemote headquarterBean;
+
+ /**
+ * A list of all headquarter (globally)
+ */
+ @Inject
+ @NamedCache (cacheName = "headquarterCache")
+ private transient Cache<Long, Headquarter> headquarterCache;
+
+ /**
+ * Currently selected headquarter
+ */
+ private Headquarter selectedHeadquarter;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsHeadquarterListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allHeadquarters = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when a branch office has been added.
+ * <p>
+ * @param event Event being fired
+ * <p>
+ * @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<Headquarter> getAllHeadquarters () {
+ return this.allHeadquarters;
+ }
+
+ /**
+ * Getter for a list of filtered headquarter
+ * <p>
+ * @return Filtered headquarter
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Headquarter> getFilteredHeadquarters () {
+ return this.filteredHeadquarters;
+ }
+
+ /**
+ * Setter for a list of filtered headquarter
+ * <p>
+ * @param filteredHeadquarters Filtered headquarter
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredHeadquarters (final List<Headquarter> filteredHeadquarters) {
+ this.filteredHeadquarters = filteredHeadquarters;
+ }
+
+ /**
+ * Getter for selected headquarter
+ * <p>
+ * @return Selected headquarter
+ */
+ public Headquarter getSelectedHeadquarter () {
+ return this.selectedHeadquarter;
+ }
+
+ /**
+ * Setter for selected headquarter
+ * <p>
+ * @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> 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<Long, Headquarter> currentEntry : this.headquarterCache) {
+ // Add to list
+ this.getAllHeadquarters().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllHeadquarters().sort(new Comparator<Headquarter>() {
+ @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.
+ * <p>
+ * @param headquarter Headquarter to check it's address
+ * <p>
+ * @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;
+ }
+
+}
--- /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.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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsHeadquarterListWebViewController extends Serializable {
+
+ /**
+ * Checks whether given company name already exists
+ * <p>
+ * @param companyName Company name to check
+ * <p>
+ * @return Whether the company name exists
+ */
+ Boolean isCompanyNameUsed (final String companyName);
+
+ /**
+ * Checks if given email address is already registered by an other
+ * headquarter
+ * <p>
+ * @param emailAddress Email address
+ * <p>
+ * @return Whether the email address has been already registered
+ */
+ Boolean isEmailAddressRegistered (final String emailAddress);
+
+ /**
+ * Returns a list of all headquarter
+ * <p>
+ * @return A list of all headquarter
+ */
+ List<Headquarter> getAllHeadquarters ();
+
+ /**
+ * Tries to find a headquarter with given id number
+ * <p>
+ * @param headquarterId Headquarter id
+ * <p>
+ * @return A headquarter instance
+ * <p>
+ * @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.
+ * <p>
+ * @param headquarter Headquarter to check it's address
+ * <p>
+ * @return Whether the address has been found
+ */
+ boolean isHeadquarterCreatedByRequiredData (final Headquarter headquarter);
+
+}
import javax.faces.convert.FacesConverter;
import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestBean;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestController;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewBean;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController;
/**
* Converter for converting company headquarter to and from id number
/**
* Headquarter backing bean
*/
- private static FinancialsHeadquarterWebRequestController HEADQUARTER_CONTROLLER;
+ private static FinancialsHeadquarterListWebViewController 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(FinancialsHeadquarterWebRequestBean.class).get();
- }
-
// Init instance
Headquarter headquarter = null;
// 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(FinancialsHeadquarterListWebViewBean.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);
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestBean;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestController;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewBean;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController;
/**
* A validator for headquarter company names
/**
* Headquarter backing bean
*/
- private static FinancialsHeadquarterWebRequestController HEADQUARTER_CONTROLLER;
+ private static FinancialsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER;
/**
* Serial number
@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(FinancialsHeadquarterWebRequestBean.class).get();
- }
-
// All accepted, required fields
final String[] requiredFields = {"companyName"}; //NOI18N
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(FinancialsHeadquarterListWebViewBean.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)) {
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestBean;
-import org.mxchange.jfinancials.beans.business.headquarter.FinancialsHeadquarterWebRequestController;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewBean;
+import org.mxchange.jfinancials.beans.business.headquarter.list.FinancialsHeadquarterListWebViewController;
/**
* A validator for headquarter's email address validation
/**
* Headquarter backing bean
*/
- private static FinancialsHeadquarterWebRequestController HEADQUARTER_CONTROLLER;
+ private static FinancialsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER;
/**
* Pattern matcher
* Default constructor
*/
public FinancialsHeadquarterEmailAddressValidator () {
+ // Default is not allowed
this.allowEmptyRequiredData = Boolean.FALSE;
}
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(FinancialsHeadquarterWebRequestBean.class).get();
+ HEADQUARTER_LIST_CONTROLLER = CDI.current().select(FinancialsHeadquarterListWebViewBean.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
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})):
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})):
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{headquarterController.allHeadquarter()}"
+ value="#{headquarterListController.allHeadquarters}"
var="headquarter"
itemValue="#{headquarter}"
itemLabel="#{beanHelper.renderHeadquarter(headquarter)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{headquarterController.allHeadquarter()}"
+ value="#{headquarterListController.allHeadquarters}"
var="headquarter"
itemValue="#{headquarter}"
itemLabel="#{beanHelper.renderHeadquarter(headquarter)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{departmentController.allDepartments()}"
+ value="#{departmentListController.allDepartments}"
var="department"
itemValue="#{department}"
itemLabel="#{beanHelper.renderDepartment(department)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{headquarterController.allHeadquarter()}"
+ value="#{headquarterListController.allHeadquarters}"
var="headquarter"
itemValue="#{headquarter}"
itemLabel="#{beanHelper.renderHeadquarter(headquarter)}"
<core:outputAdminContactDataFormFields allowEmptyRequiredData="true" />
<f:facet name="footer">
- <p:commandButton
- styleClass="reset"
- type="reset"
- value="#{msg.BUTTON_RESET_FORM}"
- />
- <p:commandButton
- type="submit"
- value="#{msg.BUTTON_ADMIN_ADD_CONTACT}"
- action="#{adminContactController.addContact()}"
- update=":master:form-list-contacts:contactList"
- />
+ <p:panelGrid columns="2" layout="grid">
+ <p:commandButton
+ styleClass="reset"
+ type="reset"
+ value="#{msg.BUTTON_RESET_FORM}"
+ />
+ <p:commandButton
+ type="submit"
+ value="#{msg.BUTTON_ADMIN_ADD_CONTACT}"
+ action="#{adminContactController.addContact()}"
+ update=":master:form-list-contacts:contactList"
+ />
+ </p:panelGrid>
</f:facet>
</p:panelGrid>
</h:form>
<p:link
outcome="admin_show_employee"
- value="#{department.departmentLead.employeeId}"
+ value="#{beanHelper.renderEmployee(department.departmentLead)}"
title="#{msg.ADMIN_LINK_SHOW_DEPARTMENT_LEAD_EMPLOYEE_TITLE}"
rendered="#{not empty department.departmentLead}"
>
<p:panelGrid columns="2" rendered="#{not empty departmentListController.selectedDepartment}">
<f:facet name="header">
<h:outputFormat value="#{msg.ADMIN_DEPARTMENT_DETAILS_HEADER}">
- <f:param value="#{msg[departmentListController.selectedDepartment.departmentI18nKey]}" />
+ <f:param value="#{local[departmentListController.selectedDepartment.departmentI18nKey]}" />
<f:param value="#{departmentListController.selectedDepartment.departmentId}" />
</h:outputFormat>
</f:facet>
</ui:define>
<ui:define name="content">
- <h:form id="form-list-Headquarter">
+ <h:form id="form-list-headquarters">
<p:dataTable
id="headquarterList"
var="headquarter"
- value="#{headquarterController.allHeadquarter()}"
+ value="#{headquarterListController.allHeadquarters}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
- filteredValue="#{headquarterController.filteredHeadquarter}"
+ filteredValue="#{headquarterListController.filteredHeadquarters}"
rows="10"
+ rowKey="#{headquarter.headquarterId}"
reflow="true"
resizableColumns="true"
rowsPerPageTemplate="5,10,20,50,100"
sortMode="multiple"
- summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_HEADQUARTER}"
- emptyMessage="#{msg.ADMIN_EMPTY_LIST_HEADQUARTER}"
+ summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_BRANCH_OFFICES}"
+ emptyMessage="#{msg.ADMIN_EMPTY_LIST_BRANCH_OFFICES}"
widgetVar="headquarterList"
+ selectionMode="single"
+ selection="#{headquarterListController.selectedHeadquarter}"
+ skipChildren="true"
>
<f:facet name="header">
- <p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
- <h:outputText value="#{msg.ADMIN_LIST_HEADQUARTER_HEADER}" />
+ <p:panelGrid
+ columns="3"
+ layout="grid"
+ columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2"
+ >
+ <p:spacer />
+
+ <p:panelGrid
+ columns="2"
+ columnClasses="ui-grid-4,ui-grid-8"
+ layout="grid"
+ styleClass="ui-noborder"
+ >
+ <p:outputLabel for="globalFilter" value="#{msg.SEARCH_ALL_FIELDS}" style="float: right" />
+ <p:inputText id="globalFilter" onkeyup="PF('headquarterList').filter()" placeholder="#{msg.ENTER_KEYWORD}"/>
+ </p:panelGrid>
+
+ <p:outputPanel>
+ <p:spacer height="4" />
- <h:panelGroup>
<p:commandButton
id="toggler"
type="button"
/>
<p:columnToggler datasource="headquarterList" trigger="toggler" />
- </h:panelGroup>
+ </p:outputPanel>
</p:panelGrid>
</f:facet>
+ <p:ajax
+ event="rowSelect"
+ update=":master:form-list-headquarters:headquarter-details"
+ oncomplete="PF('headquarterDialog').show()"
+ />
+
<p:column
headerText="#{msg.ID_HEADER}"
sortBy="#{headquarter.headquarterId}"
<links:outputHeadquarterAdminDropdownMenu headquarter="#{headquarter}" />
</p:column>
</p:dataTable>
+
+ <p:dialog
+ dynamic="true"
+ modal="true"
+ resizable="false"
+ header="#{msg.ADMIN_SINGLE_HEADQUARTER_DETAILS_HEADER}"
+ hideEffect="fade"
+ showEffect="fade"
+ widgetVar="headquarterDialog"
+ position="top"
+ responsive="true"
+ closeOnEscape="true"
+ >
+ <p:outputPanel id="headquarter-details">
+ <p:panelGrid columns="2" rendered="#{not empty headquarterListController.selectedHeadquarter}">
+ <f:facet name="header">
+ <h:outputFormat value="#{msg.ADMIN_HEADQUARTER_DETAILS_HEADER}">
+ <f:param value="#{headquarterListController.selectedHeadquarter.headquarterCompanyName}" />
+ <f:param value="#{headquarterListController.selectedHeadquarter.headquarterId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.HEADQUARTER_ID_NUMBER_TITLE}" />
+ <h:outputText value="#{headquarterListController.selectedHeadquarter.headquarterId}" />
+ </p:panelGrid>
+ </p:outputPanel>
+ </p:dialog>
</h:form>
<h:form>
type="submit"
value="#{msg.BUTTON_ADMIN_ADD_HEADQUARTER}"
action="#{adminHeadquarterController.addHeadquarter()}"
- update=":master:form-list-Headquarter:headquarterList"
+ update=":master:form-list-headquarters:headquarterList"
/>
</p:panelGrid>
</f:facet>