// Is cache there?
if (!this.basicDataCache.iterator().hasNext()) {
// Add all
- for (final BasicData basicData : this.basicDataBean.allBusinessBasicData()) {
+ for (final BasicData basicData : this.basicDataBean.fetchAllBusinessBasicData()) {
// Add it to cache
this.basicDataCache.put(basicData.getBasicDataId(), basicData);
}
*/
private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
// Get full list from other bean
- final List<BranchOffice> branchOffices = this.branchOfficeListController.allBranchOffices();
+ final List<BranchOffice> branchOffices = this.branchOfficeListController.getAllBranchOffices();
// Default is not found
boolean isFound = false;
// Add instance to cache
this.branchOfficeCache.put(event.getBranchOffice().getBranchId(), event.getBranchOffice());
- this.allBranchOffices.add(event.getBranchOffice());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<BranchOffice> allBranchOffices () {
- return this.allBranchOffices;
+ this.getAllBranchOffices().add(event.getBranchOffice());
}
@Override
return branchOffice;
}
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<BranchOffice> getAllBranchOffices () {
+ return this.allBranchOffices;
+ }
+
/**
* Getter for a list of filtered branch offices
* <p>
// Is cache there?
if (!this.branchOfficeCache.iterator().hasNext()) {
// Add all
- for (final BranchOffice branchOffice : this.branchOfficeBean.allBranchOffices()) {
+ for (final BranchOffice branchOffice : this.branchOfficeBean.fetchAllBranchOffices()) {
// Add it to cache
this.branchOfficeCache.put(branchOffice.getBranchId(), branchOffice);
}
}
// Is the list empty, but filled cache?
- if (this.allBranchOffices.isEmpty() && this.branchOfficeCache.iterator().hasNext()) {
+ if (this.getAllBranchOffices().isEmpty() && this.branchOfficeCache.iterator().hasNext()) {
// Build up list
for (final Cache.Entry<Long, BranchOffice> currentEntry : this.branchOfficeCache) {
// Add to list
- this.allBranchOffices.add(currentEntry.getValue());
+ this.getAllBranchOffices().add(currentEntry.getValue());
}
// Sort list
- this.allBranchOffices.sort(new Comparator<BranchOffice>() {
+ this.getAllBranchOffices().sort(new Comparator<BranchOffice>() {
@Override
public int compare (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
return branchOffice1.getBranchId() > branchOffice2.getBranchId() ? 1 : branchOffice1.getBranchId() < branchOffice2.getBranchId() ? -1 : 0;
boolean isFound = false;
// Check all entries
- for (final BranchOffice branchOffice : this.allBranchOffices()) {
+ for (final BranchOffice branchOffice : this.getAllBranchOffices()) {
// Is email address used?
if (Objects.equals(branchOffice.getBranchEmailAddress(), emailAddress)) {
// Found it
* <p>
* @return A list of all branch offices
*/
- List<BranchOffice> allBranchOffices ();
+ List<BranchOffice> getAllBranchOffices ();
/**
* Tries to find a branch office with given id number
// Is cache there?
if (!this.departmentCache.iterator().hasNext()) {
// Add all
- for (final Department department : this.departmentBean.allDepartments()) {
+ for (final Department department : this.departmentBean.fetchAllDepartments()) {
// Add it to cache
this.departmentCache.put(department.getDepartmentId(), department);
}
import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jfinancials.beans.business.employee.list.FinancialsEmployeeListWebViewController;
/**
* A request-scoped bean for administrative purposes for administrative employee
@EJB (lookup = "java:global/jfinancials-ejb/adminEmployee!org.mxchange.jcontactsbusiness.model.employee.AdminEmployeeSessionBeanRemote")
private AdminEmployeeSessionBeanRemote adminEmployeeBean;
+ /**
+ * Administrative list-all-employees controller
+ */
+ @Inject
+ private FinancialsEmployeeListWebViewController adminEmployeeListController;
+
/**
* Assigned basic data instance
*/
boolean isFound = false;
// Check all employees
- for (final Employable otherEmployee : this.employeeController.allEmployees()) {
+ for (final Employable otherEmployee : this.adminEmployeeListController.getAllEmployees()) {
// Is same found?
if (Employees.isSameEmployeeFound(employee, otherEmployee)) {
// Okay, found it
*/
package org.mxchange.jfinancials.beans.business.employee;
-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.employee.added.ObservableEmployeeAddedEvent;
-import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
-import org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
/**
*/
private static final long serialVersionUID = 12_886_968_547_361L;
- /**
- * List of all employees
- */
- private final List<Employable> allEmployees;
-
- /**
- * EJB for general company employee purposes
- */
- @EJB (lookup = "java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote")
- private EmployeeSessionBeanRemote employeeBean;
-
- /**
- * List of all company employees
- */
- @Inject
- @NamedCache (cacheName = "companyEmployeeCache")
- private Cache<Long, Employable> employeeCache;
-
- /**
- * A list of filtered employees
- */
- private List<Employable> filteredEmployees;
-
/**
* Default constructor
*/
public FinancialsEmployeeWebRequestBean () {
// Call super constructor
super();
-
- // Init list
- this.allEmployees = new LinkedList<>();
- }
-
- /**
- * Observes events being fired when an employee has been added
- * <p>
- * @param event Event being fired
- */
- public void afterEmployeeAddedEvent (@Observes final ObservableEmployeeAddedEvent event) {
- // Validate parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getEmployee() == null) {
- // Throw it again
- throw new NullPointerException("event.employee is null"); //NOI18N
- } else if (event.getEmployee().getEmployeeId() == null) {
- // Throw it again
- throw new NullPointerException("event.employee.employeeId is null"); //NOI18N
- } else if (event.getEmployee().getEmployeeId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("event.employee.employeeId={0} is invalid", event.getEmployee().getEmployeeId())); //NOI18N
- }
-
- // Add employee to cache and list
- this.employeeCache.put(event.getEmployee().getEmployeeId(), event.getEmployee());
- this.allEmployees.add(event.getEmployee());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Employable> allEmployees () {
- return this.allEmployees;
- }
-
- @Override
- public Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException {
- // Validate parameter
- if (null == employeeId) {
- // Throw NPE
- throw new NullPointerException("employeeId is null"); //NOI18N
- } else if (employeeId < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is invalid", employeeId)); //NOI18N
- } else if (!this.employeeCache.containsKey(employeeId)) {
- // Not found
- throw new EmployeeNotFoundException(employeeId);
- }
-
- // Get it from cache
- final Employable employee = this.employeeCache.get(employeeId);
-
- // Return it
- return employee;
- }
-
- /**
- * Getter for filtered list of employees
- * <p>
- * @return Filtered list of employees
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Employable> getFilteredEmployees () {
- return this.filteredEmployees;
- }
-
- /**
- * Getter for filtered list of employees
- * <p>
- * @param filteredEmployees Filtered list of employees
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredEmployees (final List<Employable> filteredEmployees) {
- this.filteredEmployees = filteredEmployees;
- }
-
- /**
- * Initialization method
- */
- @PostConstruct
- public void init () {
- // Is cache there?
- if (!this.employeeCache.iterator().hasNext()) {
- // Add all
- for (final Employable employee : this.employeeBean.allEmployees()) {
- // Add it to cache
- this.employeeCache.put(employee.getEmployeeId(), employee);
- }
- }
-
- // Is cache filled and list is empty
- if ((this.employeeCache.iterator().hasNext()) && (this.allEmployees.isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, Employable> currentEntry : this.employeeCache) {
- // Add to list
- this.allEmployees.add(currentEntry.getValue());
- }
-
- // Sort list
- this.allEmployees.sort(new Comparator<Employable>() {
- @Override
- public int compare (final Employable employee1, final Employable employee2) {
- return employee1.getEmployeeId() > employee2.getEmployeeId() ? 1 : employee1.getEmployeeId() < employee2.getEmployeeId() ? -1 : 0;
- }
- });
- }
- }
-
- @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 Employable basicData : this.allEmployees()) {
- // Is email address used?
- if (Objects.equals(basicData.getEmployeeEmailAddress(), emailAddress)) {
- // Found it
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
}
}
package org.mxchange.jfinancials.beans.business.employee;
import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
/**
* An interface for request-scoped general company employee beans
*/
public interface FinancialsEmployeeWebRequestController extends Serializable {
- /**
- * Validates if given email address is already in use by an employee
- * <p>
- * @param emailAddress Email address to be validated
- * <p>
- * @return Whether the email address is already used
- */
- Boolean isEmailAddressRegistered (final String emailAddress);
-
- /**
- * Returns a list of all company employees
- * <p>
- * @return List of all company employees
- */
- List<Employable> allEmployees ();
-
- /**
- * Finds a company employee by given employee id
- * <p>
- * @param employeeId Employable id to find company employee instance for
- * <p>
- * @return Company employee instance
- * <p>
- * @throws EmployeeNotFoundException If the company employee was not found
- */
- Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException;
-
}
--- /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.employee.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.employee.added.ObservableEmployeeAddedEvent;
+import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+import org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * A view-scoped bean for listing purposes for e.g. administrative employee
+ * purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("employeeListController")
+@ViewScoped
+public class FinancialsEmployeeListWebViewBean extends BaseFinancialsBean implements FinancialsEmployeeListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 12_886_968_547_362L;
+
+ /**
+ * List of all employees
+ */
+ private final List<Employable> allEmployees;
+
+ /**
+ * EJB for general company employee purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/employee!org.mxchange.jcontactsbusiness.model.employee.EmployeeSessionBeanRemote")
+ private EmployeeSessionBeanRemote employeeBean;
+
+ /**
+ * List of all company employees
+ */
+ @Inject
+ @NamedCache (cacheName = "companyEmployeeCache")
+ private transient Cache<Long, Employable> employeeCache;
+
+ /**
+ * A list of filtered employees
+ */
+ private List<Employable> filteredEmployees;
+
+ /**
+ * Currently selected employee
+ */
+ private Employable selectedEmployee;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsEmployeeListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allEmployees = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when an employee has been added
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterEmployeeAddedEvent (@Observes final ObservableEmployeeAddedEvent event) {
+ // Validate parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getEmployee() == null) {
+ // Throw it again
+ throw new NullPointerException("event.employee is null"); //NOI18N
+ } else if (event.getEmployee().getEmployeeId() == null) {
+ // Throw it again
+ throw new NullPointerException("event.employee.employeeId is null"); //NOI18N
+ } else if (event.getEmployee().getEmployeeId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("event.employee.employeeId={0} is invalid", event.getEmployee().getEmployeeId())); //NOI18N
+ }
+
+ // Add employee to cache and list
+ this.employeeCache.put(event.getEmployee().getEmployeeId(), event.getEmployee());
+ this.getAllEmployees().add(event.getEmployee());
+ }
+
+ @Override
+ public Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException {
+ // Validate parameter
+ if (null == employeeId) {
+ // Throw NPE
+ throw new NullPointerException("employeeId is null"); //NOI18N
+ } else if (employeeId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employeeId={0} is invalid", employeeId)); //NOI18N
+ } else if (!this.employeeCache.containsKey(employeeId)) {
+ // Not found
+ throw new EmployeeNotFoundException(employeeId);
+ }
+
+ // Get it from cache
+ final Employable employee = this.employeeCache.get(employeeId);
+
+ // Return it
+ return employee;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Employable> getAllEmployees () {
+ return this.allEmployees;
+ }
+
+ /**
+ * Getter for filtered list of employees
+ * <p>
+ * @return Filtered list of employees
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Employable> getFilteredEmployees () {
+ return this.filteredEmployees;
+ }
+
+ /**
+ * Getter for filtered list of employees
+ * <p>
+ * @param filteredEmployees Filtered list of employees
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredEmployees (final List<Employable> filteredEmployees) {
+ this.filteredEmployees = filteredEmployees;
+ }
+
+ /**
+ * Getter for currently selected employee
+ * <p>
+ * @return Currently selected employee
+ */
+ public Employable getSelectedEmployee () {
+ return this.selectedEmployee;
+ }
+
+ /**
+ * Setter for currently selected employee
+ * <p>
+ * @param selectedEmployee Currently selected employee
+ */
+ public void setSelectedEmployee (final Employable selectedEmployee) {
+ this.selectedEmployee = selectedEmployee;
+ }
+
+ /**
+ * Initialization method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.employeeCache.iterator().hasNext()) {
+ // Add all
+ for (final Employable employee : this.employeeBean.fetchAllEmployees()) {
+ // Add it to cache
+ this.employeeCache.put(employee.getEmployeeId(), employee);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.employeeCache.iterator().hasNext()) && (this.getAllEmployees().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, Employable> currentEntry : this.employeeCache) {
+ // Add to list
+ this.getAllEmployees().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllEmployees().sort(new Comparator<Employable>() {
+ @Override
+ public int compare (final Employable employee1, final Employable employee2) {
+ return employee1.getEmployeeId() > employee2.getEmployeeId() ? 1 : employee1.getEmployeeId() < employee2.getEmployeeId() ? -1 : 0;
+ }
+ });
+ }
+ }
+
+ @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 Employable basicData : this.getAllEmployees()) {
+ // Is email address used?
+ if (Objects.equals(basicData.getEmployeeEmailAddress(), emailAddress)) {
+ // Found it
+ 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.employee.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+
+/**
+ * An interface for request-scoped administrative company employee beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsEmployeeListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all company employees
+ * <p>
+ * @return List of all company employees
+ */
+ List<Employable> getAllEmployees ();
+
+ /**
+ * Validates if given email address is already in use by an employee
+ * <p>
+ * @param emailAddress Email address to be validated
+ * <p>
+ * @return Whether the email address is already used
+ */
+ Boolean isEmailAddressRegistered (final String emailAddress);
+
+ /**
+ * Finds a company employee by given employee id
+ * <p>
+ * @param employeeId Employable id to find company employee instance for
+ * <p>
+ * @return Company employee instance
+ * <p>
+ * @throws EmployeeNotFoundException If the company employee was not found
+ */
+ Employable findEmployeeById (final Long employeeId) throws EmployeeNotFoundException;
+
+}
// Is cache there?
if (!this.headquarterCache.iterator().hasNext()) {
// Add all
- for (final Headquarter headquarter : this.headquarterBean.allHeadquarters()) {
+ for (final Headquarter headquarter : this.headquarterBean.fetchAllHeadquarters()) {
// Add it to cache
this.headquarterCache.put(headquarter.getHeadquarterId(), headquarter);
}
* method will validate if the openingTime's address is already registered
* and if found, it will output a proper faces message.
*/
- public void addOpeningTimes () {
+ public void addOpeningTime () {
// Get instance
final OpeningTime openingTime = this.createOpeningTimes();
*/
package org.mxchange.jfinancials.beans.business.opening_time;
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-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.opening_time.added.ObservableOpeningTimeAddedEvent;
-import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
-import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
*/
private static final long serialVersionUID = 5_028_697_360_462L;
- /**
- * A list of all opening times
- */
- private final List<OpeningTime> allOpeningTimes;
-
- /**
- * A list of filtered opening times
- */
- private List<OpeningTime> filteredOpeningTimes;
-
/**
* EJB for administrative purposes
*/
@EJB (lookup = "java:global/jfinancials-ejb/openingTimes!org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote")
private OpeningTimeSessionBeanRemote openingTimesBean;
- /**
- * A list of all opening times (globally)
- */
- @Inject
- @NamedCache (cacheName = "openingTimesCache")
- private Cache<Long, OpeningTime> openingTimesCache;
-
/**
* Default constructor
*/
public FinancialsOpeningTimeWebRequestBean () {
// Call super constructor
super();
-
- // Init list
- this.allOpeningTimes = new LinkedList<>();
- }
-
- /**
- * Observes events being thrown when a new opening time has been added
- * <p>
- * @param event Event being fired
- */
- public void afterOpeningTimeAddedEvent (@Observes final ObservableOpeningTimeAddedEvent event) {
- // Validate parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null");
- } else if (event.getOpeningTime() == null) {
- // Throw it again
- throw new NullPointerException("event.openingTime is null");
- } else if (event.getOpeningTime().getOpeningId() == null) {
- // Throw it again
- throw new NullPointerException("event.openingTime.openingId is null");
- } else if (event.getOpeningTime().getOpeningId() < 1) {
- // Throw it again
- throw new NullPointerException(MessageFormat.format("event.openingTime.openingId={0} is invalid", event.getOpeningTime().getOpeningId()));
- }
-
- // Add to cache and list
- this.openingTimesCache.put(event.getOpeningTime().getOpeningId(), event.getOpeningTime());
- this.allOpeningTimes.add(event.getOpeningTime());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<OpeningTime> allOpeningTimes () {
- return this.allOpeningTimes;
- }
-
- @Override
- public OpeningTime findOpeningTimeById (final Long openingId) throws OpeningTimeNotFoundException {
- // Validate parameter
- if (null == openingId) {
- // Throw NPE
- throw new NullPointerException("openingId is null"); //NOI18N
- } else if (openingId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("openingId=" + openingId + " is invalid"); //NOI18N
- } else if (!this.openingTimesCache.containsKey(openingId)) {
- // Not found
- throw new OpeningTimeNotFoundException(openingId);
- }
-
- // Get it from cache
- final OpeningTime opening = this.openingTimesCache.get(openingId);
-
- // Return it
- return opening;
- }
-
- /**
- * Getter for a list of filtered opening times
- * <p>
- * @return Filtered opening times
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<OpeningTime> getFilteredOpeningTimes () {
- return this.filteredOpeningTimes;
- }
-
- /**
- * Setter for a list of filtered opening times
- * <p>
- * @param filteredOpeningTimes Filtered opening times
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredOpeningTimes (final List<OpeningTime> filteredOpeningTimes) {
- this.filteredOpeningTimes = filteredOpeningTimes;
- }
-
- /**
- * Initializer method
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.openingTimesCache.iterator().hasNext()) {
- // Add all
- for (final OpeningTime openingTime : this.openingTimesBean.allOpeningTimes()) {
- // Add it to cache
- this.openingTimesCache.put(openingTime.getOpeningId(), openingTime);
- }
- }
-
- // Is the list empty, but filled cache?
- if (this.allOpeningTimes.isEmpty() && this.openingTimesCache.iterator().hasNext()) {
- // Build up list
- for (final Cache.Entry<Long, OpeningTime> currentEntry : this.openingTimesCache) {
- // Add to list
- this.allOpeningTimes.add(currentEntry.getValue());
- }
-
- // Sort list
- this.allOpeningTimes.sort(new Comparator<OpeningTime>() {
- @Override
- public int compare (final OpeningTime openingTime1, final OpeningTime openingTime2) {
- return openingTime1.getOpeningId() > openingTime2.getOpeningId() ? 1 : openingTime1.getOpeningId() < openingTime2.getOpeningId() ? -1 : 0;
- }
- }
- );
- }
}
}
package org.mxchange.jfinancials.beans.business.opening_time;
import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
-import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
/**
* An interface for general opening times controller
*/
public interface FinancialsOpeningTimeWebRequestController extends Serializable {
- /**
- * Returns a list of all opening times
- * <p>
- * @return A list of all opening times
- */
- List<OpeningTime> allOpeningTimes ();
-
- /**
- * Retrieves a single company department entity for given id number or
- * throws a proper exception if not found.
- * <p>
- * @param openingId Company department id to lookup
- * <p>
- * @return Company department instance
- * <p>
- * @throws OpeningTimeNotFoundException If the id number could not be looked
- * up and solved into an entity
- */
- OpeningTime findOpeningTimeById (final Long openingId) throws OpeningTimeNotFoundException;
-
}
--- /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.opening_time.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 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.opening_time.added.ObservableOpeningTimeAddedEvent;
+import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * A general bean for opening times
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("openingTimeListController")
+@ViewScoped
+public class FinancialsOpeningTimeListWebViewBean extends BaseFinancialsBean implements FinancialsOpeningTimeListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 5_028_697_360_467L;
+
+ /**
+ * A list of all opening times
+ */
+ private final List<OpeningTime> allOpeningTimes;
+
+ /**
+ * A list of filtered opening times
+ */
+ private List<OpeningTime> filteredOpeningTimes;
+
+ /**
+ * EJB for administrative purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/openingTimes!org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimeSessionBeanRemote")
+ private OpeningTimeSessionBeanRemote openingTimesBean;
+
+ /**
+ * A list of all opening times (globally)
+ */
+ @Inject
+ @NamedCache (cacheName = "openingTimesCache")
+ private transient Cache<Long, OpeningTime> openingTimesCache;
+
+ /**
+ * Selected opening-time instance
+ */
+ private OpeningTime selectedOpeningTime;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsOpeningTimeListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allOpeningTimes = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being thrown when a new opening time has been added
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterOpeningTimeAddedEvent (@Observes final ObservableOpeningTimeAddedEvent event) {
+ // Validate parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null");
+ } else if (event.getOpeningTime() == null) {
+ // Throw it again
+ throw new NullPointerException("event.openingTime is null");
+ } else if (event.getOpeningTime().getOpeningTimeId() == null) {
+ // Throw it again
+ throw new NullPointerException("event.openingTime.openingTimeId is null");
+ } else if (event.getOpeningTime().getOpeningTimeId() < 1) {
+ // Throw it again
+ throw new NullPointerException(MessageFormat.format("event.openingTime.openingTimeId={0} is invalid", event.getOpeningTime().getOpeningTimeId()));
+ }
+
+ // Add to cache and list
+ this.openingTimesCache.put(event.getOpeningTime().getOpeningTimeId(), event.getOpeningTime());
+ this.getAllOpeningTimes().add(event.getOpeningTime());
+ }
+
+ @Override
+ public OpeningTime findOpeningTimeById (final Long openingTimeId) throws OpeningTimeNotFoundException {
+ // Validate parameter
+ if (null == openingTimeId) {
+ // Throw NPE
+ throw new NullPointerException("openingTimeId is null"); //NOI18N
+ } else if (openingTimeId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("openingTimeId=" + openingTimeId + " is invalid"); //NOI18N
+ } else if (!this.openingTimesCache.containsKey(openingTimeId)) {
+ // Not found
+ throw new OpeningTimeNotFoundException(openingTimeId);
+ }
+
+ // Get it from cache
+ final OpeningTime opening = this.openingTimesCache.get(openingTimeId);
+
+ // Return it
+ return opening;
+ }
+
+ /**
+ * Returns a list of all opening times
+ * <p>
+ * @return A list of all opening times
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<OpeningTime> getAllOpeningTimes () {
+ return this.allOpeningTimes;
+ }
+
+ /**
+ * Getter for a list of filtered opening times
+ * <p>
+ * @return Filtered opening times
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<OpeningTime> getFilteredOpeningTimes () {
+ return this.filteredOpeningTimes;
+ }
+
+ /**
+ * Setter for a list of filtered opening times
+ * <p>
+ * @param filteredOpeningTimes Filtered opening times
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredOpeningTimes (final List<OpeningTime> filteredOpeningTimes) {
+ this.filteredOpeningTimes = filteredOpeningTimes;
+ }
+
+ /**
+ * Getter for selected open-time instance
+ * <p>
+ * @return Selected open-time instance
+ */
+ public OpeningTime getSelectedOpeningTime () {
+ return this.selectedOpeningTime;
+ }
+
+ /**
+ * Setter for selected open-time instance
+ * <p>
+ * @param selectedOpeningTime Selected open-time instance
+ */
+ public void setSelectedOpeningTime (final OpeningTime selectedOpeningTime) {
+ this.selectedOpeningTime = selectedOpeningTime;
+ }
+
+ /**
+ * Initializer method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.openingTimesCache.iterator().hasNext()) {
+ // Add all
+ for (final OpeningTime openingTime : this.openingTimesBean.fetchAllOpeningTimes()) {
+ // Add it to cache
+ this.openingTimesCache.put(openingTime.getOpeningTimeId(), openingTime);
+ }
+ }
+
+ // Is the list empty, but filled cache?
+ if (this.getAllOpeningTimes().isEmpty() && this.openingTimesCache.iterator().hasNext()) {
+ // Build up list
+ for (final Cache.Entry<Long, OpeningTime> currentEntry : this.openingTimesCache) {
+ // Add to list
+ this.getAllOpeningTimes().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllOpeningTimes().sort(new Comparator<OpeningTime>() {
+ @Override
+ public int compare (final OpeningTime openingTime1, final OpeningTime openingTime2) {
+ return openingTime1.getOpeningTimeId() > openingTime2.getOpeningTimeId() ? 1 : openingTime1.getOpeningTimeId() < openingTime2.getOpeningTimeId() ? -1 : 0;
+ }
+ }
+ );
+ }
+ }
+
+}
--- /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.opening_time.list;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
+import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+
+/**
+ * An interface for general opening times controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsOpeningTimeListWebViewController extends Serializable {
+
+ /**
+ * Retrieves a single opening-time entity for given id number or throws a
+ * proper exception if not found.
+ * <p>
+ * @param openingTimeId Opening time id to lookup
+ * <p>
+ * @return Company department instance
+ * <p>
+ * @throws OpeningTimeNotFoundException If the id number could not be looked
+ * up and solved into an entity
+ */
+ OpeningTime findOpeningTimeById (final Long openingTimeId) throws OpeningTimeNotFoundException;
+
+}
// Is the cell phone set?
if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
// ... cmobile data
- this.setMobileId(contact.getContactMobileNumber().getPhoneId());
+ this.setMobileId(contact.getContactMobileNumber().getMobileId());
this.setMobileProvider(contact.getContactMobileNumber().getMobileProvider());
- this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber());
+ this.setMobileNumber(contact.getContactMobileNumber().getMobileNumber());
}
// Is the fax set?
// Create new instance
final Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName());
- // Is contact id set?
- if (this.getContactId() instanceof Long) {
- // Set it, too
- contact.setContactId(this.getContactId());
- }
-
// Add all others
+ contact.setContactId(this.getContactId());
contact.setContactTitle(this.getAcademicTitle());
contact.setContactBirthday(this.getBirthday());
contact.setContactStreet(this.getStreet());
// Is the provider set?
if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
// Is the number set?
- if (mobile.getPhoneNumber() == null) {
+ if (mobile.getMobileNumber() == null) {
// Is null
throw new NullPointerException("cmobile.phoneNumber is null"); //NOI18N
- } else if (mobile.getPhoneNumber() < 1) {
+ } else if (mobile.getMobileNumber() < 1) {
// Abort here
throw new IllegalArgumentException("cmobile.phoneNumber is zero or below."); //NOI18N
}
"%s%d%d", //NOI18N
mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
mobileNumber.getMobileProvider().getProviderDialPrefix(),
- mobileNumber.getPhoneNumber()
+ mobileNumber.getMobileNumber()
);
// Return it
return "admin"; //NOI18N
}
- @Override
- @Deprecated
- public void setControllerType (final String controllerType) {
- throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
- }
-
/**
* Getter for email address
* <p>
*/
String getControllerType ();
- /**
- * Setter for controller type
- * <p>
- * @param controllerType Controller type
- * <p>
- * @deprecated Don't use this method
- */
- @Deprecated
- void setControllerType (final String controllerType);
-
}
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
+import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent;
import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
*/
private String houseNumberExtension;
- /**
- * Whether a fax entry has been unlinked
- */
- private boolean isFaxUnlinked;
-
- /**
- * Whether a land-line number has been unlinked
- */
- private boolean isLandLineUnlinked;
-
- /**
- * Whether a mobile entry has been unlinked
- */
- private boolean isMobileUnlinked;
-
/**
* Phone number area code
*/
}
// Copy all data to this bean
- this.copyContact(event.getLoggedInUser().getUserContact());
+ this.copyFromContact(event.getLoggedInUser().getUserContact());
+ }
+
+ /**
+ * Observes events being fired before an updated of personal data done by a
+ * user has started.
+ * <p>
+ * @param event Event being observed
+ */
+ public void beforeUserUpdatedPersonalDataEvent (@Observes final ObservablePreUserPersonalDataUpdatedEvent event) {
+ // Is the instance valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedUser() == null) {
+ // Throw NPE
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
+ }
+
+ // Set all
+ this.copyToContact(event.getUpdatedUser().getUserContact());
}
@Override
// Required personal data must be set
assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
- // Generate phone number
- DialableLandLineNumber phone = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
- DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
- DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
// Create new contact
- Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName());
- contact.setContactStreet(this.getStreet());
- contact.setContactHouseNumber(this.getHouseNumber());
- contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
- contact.setContactZipCode(this.getZipCode());
- contact.setContactCity(this.getCity());
- contact.setContactCountry(this.getCountry());
- contact.setContactEmailAddress(this.getEmailAddress());
- contact.setContactBirthday(this.getBirthday());
- contact.setContactComment(this.getComment());
-
- // Don't set null or wrong references
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
- // Now the number must be given
- if (phone.getPhoneAreaCode() == null) {
- // Is null
- throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
- } else if (phone.getPhoneAreaCode() < 1) {
- // Abort here
- throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
- } else if (phone.getPhoneNumber() == null) {
- // Is null
- throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
- } else if (phone.getPhoneNumber() < 1) {
- // Abort here
- throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
- }
-
- // Set phone number
- contact.setContactLandLineNumber(phone);
- }
-
- // 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
- contact.setContactFaxNumber(fax);
- }
+ final Contact contact = new UserContact(
+ this.getPersonalTitle(),
+ this.getFirstName(),
+ this.getFamilyName()
+ );
- // Is the provider set?
- if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
- // Is the number set?
- if (mobile.getPhoneNumber() == null) {
- // Is null
- throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
- } else if (mobile.getPhoneNumber() < 1) {
- // Abort here
- throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
- }
-
- // Set mobile number
- contact.setContactMobileNumber(mobile);
- }
-
- // Return it
+ // Return instance
return contact;
}
}
// Get contact instance
- Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
+ final Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
// It should be there, so run some tests on it
assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
contact.setContactCountry(this.getCountry());
// Update contact's mobile number
- this.isMobileUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
+ final boolean isMobileUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
// Update contact's land-line number
- this.isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+ final boolean isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
// Update contact's fax number
- this.isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+ final boolean isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
// Send it to the EJB
- this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
+ this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
// All fine
return "contact_data_saved"; //NOI18N
return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
}
- @Override
- public void updateContactDataFromController (final Contact contact) {
- // Is the instance valid?
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Set all
- this.copyContact(contact);
- }
-
/**
* Clears this bean
*/
}
/**
- * Copies given contact into the controller
+ * Copies given contact data into the controller
* <p>
* @param contact Contact instance
*/
- private void copyContact (final Contact contact) {
+ private void copyFromContact (final Contact contact) {
// Copy all fields:
// - base data
this.setPersonalTitle(contact.getContactPersonalTitle());
this.setComment(contact.getContactComment());
// Get mobile, phone and fax instance
- DialableMobileNumber mobile = contact.getContactMobileNumber();
- DialableFaxNumber fax = contact.getContactFaxNumber();
- DialableLandLineNumber phone = contact.getContactLandLineNumber();
+ final DialableFaxNumber fax = contact.getContactFaxNumber();
+ final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
+ final DialableMobileNumber mobile = contact.getContactMobileNumber();
- // - contact data
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
- this.setLandLineCountry(phone.getPhoneCountry());
- this.setLandLineAreaCode(phone.getPhoneAreaCode());
- this.setLandLineNumber(phone.getPhoneNumber());
+ // Is a fax number set?
+ if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
+ // Copy elements
+ this.setFaxCountry(fax.getPhoneCountry());
+ this.setFaxAreaCode(fax.getPhoneAreaCode());
+ this.setFaxNumber(fax.getPhoneNumber());
+ }
+
+ // Is a land-line number set?
+ if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
+ // Copy elements
+ this.setLandLineCountry(landLine.getPhoneCountry());
+ this.setLandLineAreaCode(landLine.getPhoneAreaCode());
+ this.setLandLineNumber(landLine.getPhoneNumber());
}
+ // Is a mobile number set?
if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
+ // Copy elements
this.setMobileProvider(mobile.getMobileProvider());
- this.setMobileNumber(mobile.getPhoneNumber());
+ this.setMobileNumber(mobile.getMobileNumber());
}
+ }
- if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
- this.setFaxCountry(fax.getPhoneCountry());
- this.setFaxAreaCode(fax.getPhoneAreaCode());
- this.setFaxNumber(fax.getPhoneNumber());
+ /**
+ * Copies all fields from this backing bean into given instance.
+ * <p>
+ * @param contact An instance of a Contact class
+ */
+ private void copyToContact (final Contact contact) {
+ // Set other elements
+ contact.setContactStreet(this.getStreet());
+ contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
+ contact.setContactZipCode(this.getZipCode());
+ contact.setContactCity(this.getCity());
+ contact.setContactCountry(this.getCountry());
+ contact.setContactEmailAddress(this.getEmailAddress());
+ contact.setContactBirthday(this.getBirthday());
+ contact.setContactComment(this.getComment());
+
+ // Generate phone number
+ final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+ final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+ 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
+ contact.setContactLandLineNumber(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
+ contact.setContactFaxNumber(fax);
+ }
+
+ // Is the provider set?
+ if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
+ // Is the number set?
+ if (mobile.getMobileNumber() == null) {
+ // Is null
+ throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
+ } else if (mobile.getMobileNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set mobile number
+ contact.setContactMobileNumber(mobile);
}
}
*/
void clearEmailAddresses ();
- /**
- * Updates all data from bean in given contact instance
- * <p>
- * @param userContact Contact instance to update
- */
- void updateContactDataFromController (final Contact userContact);
-
/**
* Creates an instance from all properties
* <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.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent;
+import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
+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.contact.ContactSessionBeanRemote;
this.uniqueAddContact(event.getAddedContact());
}
+ /**
+ * Event observer for unlinked fax contact by administrators
+ * <p>
+ * @param event Unlinked fax contact event
+ */
+ public void afterAdminUnlinkedFaxContactDataEvent (@Observes final ObservableAdminUnlinkedFaxNumberEvent 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.getUnlinkedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedFaxNumber is null"); //NOI18N
+ } else if (event.getUnlinkedFaxNumber().getPhoneId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedFaxNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedFaxNumber(), event.getUnlinkedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Remove it from any entry
+ for (final Cache.Entry<Long, Contact> entry : this.contactCache) {
+ // Get contact instance from it
+ final Contact contact = entry.getValue();
+
+ // Is the number matching?
+ if (Objects.equals(event.getUnlinkedFaxNumber(), contact.getContactFaxNumber())) {
+ // Yes, then unset it
+ contact.setContactFaxNumber(null);
+ }
+ }
+ }
+
+ /**
+ * Event observer for unlinked land-line contact by administrators
+ * <p>
+ * @param event Unlinked land-line contact event
+ */
+ public void afterAdminUnlinkedLandLineContactDataEvent (@Observes final ObservableAdminUnlinkedLandLineNumberEvent 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.getUnlinkedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedLandLineNumber is null"); //NOI18N
+ } else if (event.getUnlinkedLandLineNumber().getPhoneId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedLandLineNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedLandLineNumber(), event.getUnlinkedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Remove it from any entry
+ for (final Cache.Entry<Long, Contact> entry : this.contactCache) {
+ // Get contact instance from it
+ final Contact contact = entry.getValue();
+
+ // Is the number matching?
+ if (Objects.equals(event.getUnlinkedLandLineNumber(), contact.getContactLandLineNumber())) {
+ // Yes, then unset it
+ contact.setContactLandLineNumber(null);
+ }
+ }
+ }
+
+ /**
+ * Event observer for unlinked mobile contact by administrators
+ * <p>
+ * @param event Unlinked mobile contact event
+ */
+ public void afterAdminUnlinkedMobileContactDataEvent (@Observes final ObservableAdminUnlinkedMobileNumberEvent 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.getUnlinkedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedMobileNumber is null"); //NOI18N
+ } else if (event.getUnlinkedMobileNumber().getMobileId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedMobileNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedMobileNumber().getMobileId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedMobileNumber(), event.getUnlinkedMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Remove it from any entry
+ for (final Cache.Entry<Long, Contact> entry : this.contactCache) {
+ // Get contact instance from it
+ final Contact contact = entry.getValue();
+
+ // Is the number matching?
+ if (Objects.equals(event.getUnlinkedMobileNumber(), contact.getContactMobileNumber())) {
+ // Yes, then unset it
+ contact.setContactMobileNumber(null);
+ }
+ }
+ }
+
/**
* Event observer for updated contact data by administrators
* <p>
"%s%d%d", //NOI18N
mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
mobileNumber.getMobileProvider().getProviderDialPrefix(),
- mobileNumber.getPhoneNumber()
+ mobileNumber.getMobileNumber()
);
// Return it
// Is cache there?
if (!this.contactCache.iterator().hasNext()) {
// Add all
- for (final Contact contact : this.contactBean.allContacts()) {
+ for (final Contact contact : this.contactBean.fetchAllContacts()) {
// Add it to cache
this.contactCache.put(contact.getContactId(), contact);
}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.contact.mobile;
+
+import java.text.MessageFormat;
+import java.util.Date;
+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.application.FacesMessage;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.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.model.contact.Contact;
+import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote;
+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.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+
+/**
+ * An administrative contact mobile controller (bean)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminContactMobileController")
+@RequestScoped
+public class FinancialsAdminContactMobileWebRequestBean extends BaseFinancialsBean implements FinancialsAdminContactMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_919L;
+
+ /**
+ * Administrative EJB for phone number
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote")
+ private AdminContactsPhoneSessionBeanRemote adminContactPhoneBean;
+
+ /**
+ * Event being fired when a mobile number has been linked
+ */
+ @Inject
+ @Any
+ private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
+
+ /**
+ * Administrative phone controller
+ */
+ @Inject
+ private FinancialsAdminPhoneWebRequestController adminPhoneController;
+
+ /**
+ * Contact instance
+ */
+ private Contact contact;
+
+ /**
+ * When mobile number has been created
+ */
+ private Date mobileEntryCreated;
+
+ /**
+ * When mobile number has been updated
+ */
+ private Date mobileEntryUpdated;
+
+ /**
+ * Phone id (primary key)
+ */
+ private Long mobileId;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * Event being fired when administrator unlinks mobile from contact
+ */
+ @Inject
+ @Any
+ private Event<ObservableAdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
+
+ /**
+ * Mobile provider
+ */
+ private MobileProvider mobileProvider;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminContactMobileWebRequestBean () {
+ // Call super constructor
+ super();
+
+ // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
+ // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Event observer for updated contact data by administrators
+ * <p>
+ * @param event Updated contact data event
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent 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();
+ }
+
+ /**
+ * Observer for events being fired when a bean helper has successfully
+ * created a contact instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedContactEvent (@Observes final ObservableCreatedContactEvent event) {
+ // Log message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N
+
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE again
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getCreatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.createdContact is null"); //NOI18N //NOI18N
+ } else if (event.getCreatedContact().getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.createdContact.contactId is null"); //NOI18N //NOI18N
+ } else if (event.getCreatedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("event.createdContact.contactId={0} is not valid.", event.getCreatedContact().getContactId())); //NOI18N
+ }
+
+ // Set it here
+ this.setContact(event.getCreatedContact());
+ }
+
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * mobile number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.mobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.mobileNumber.mobileId={0} is invalid", event.getMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Get fax number from event
+ final DialableMobileNumber number = event.getMobileNumber();
+
+ // Copy all data to this bean
+ this.setMobileId(number.getMobileId());
+ this.setMobileProvider(number.getMobileProvider());
+ this.setMobileNumber(number.getMobileNumber());
+ this.setMobileEntryCreated(number.getMobileEntryCreated());
+ this.setMobileEntryUpdated(number.getMobileEntryUpdated());
+ }
+
+ /**
+ * Links mobile number to contact from bean helper as "main mobile number".
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doLinkMainMobileNumber () {
+ // Get contact from helper
+ final Contact targetContact = this.getContact();
+
+ // Is all data properly set?
+ if (null == targetContact) {
+ // Throw NPE
+ throw new NullPointerException("targetContact is null"); //NOI18N
+ } else if (targetContact.getContactId() == null) {
+ // Throw it again
+ throw new NullPointerException("targetContact.contactId is null"); //NOI18N
+ } else if (targetContact.getContactId() < 1) {
+ // Is not valid
+ throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N
+ } else if (this.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.mobileProvider is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() < 1) {
+ // Throw NPE
+ throw new NullPointerException(MessageFormat.format("this.mobileProvider.providerId={0} is invalid", this.getMobileProvider().getProviderId())); //NOI18N
+ } else if (this.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.mobileNumber is null"); //NOI18N
+ } else if (this.getMobileNumber() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber={0} is invalid", this.getMobileNumber())); //NOI18N
+ }
+
+ // Init instance
+ final Contact updatedContact;
+ final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+
+ // Try it again
+ try {
+ // Link it, too
+ updatedContact = this.adminContactPhoneBean.linkNewMobileNumberWithContact(targetContact, number);
+ } catch (final PhoneNumberAlreadyLinkedException ex) {
+ // Throw again as cause
+ this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Fire event
+ this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, number));
+
+ // Return to contact profile
+ return "admin_show_contact"; //NOI18N
+ }
+
+ /**
+ * Getter for contact instance
+ * <p>
+ * @return Contact instance
+ */
+ public Contact getContact () {
+ return this.contact;
+ }
+
+ /**
+ * Setter for contact instance
+ * <p>
+ * @param contact Contact instance
+ */
+ public void setContact (final Contact contact) {
+ this.contact = contact;
+ }
+
+ /**
+ * Setter for phone id
+ * <p>
+ * @return Phone id
+ */
+ public Long getMobileId () {
+ return this.mobileId;
+ }
+
+ /**
+ * Getter for phone id
+ * <p>
+ * @param mobileId Phone id
+ */
+ public void setMobileId (final Long mobileId) {
+ this.mobileId = mobileId;
+ }
+
+ /**
+ * Getter for mobile number
+ * <p>
+ * @return Mobile number
+ */
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ /**
+ * Setter for mobile number
+ * <p>
+ * @param mobileNumber Mobile number
+ */
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ /**
+ * Getter for mobile provider
+ * <p>
+ * @return Mobile provider
+ */
+ public MobileProvider getMobileProvider () {
+ return this.mobileProvider;
+ }
+
+ /**
+ * Setter for mobile provider
+ * <p>
+ * @param mobileProvider Mobile provider
+ */
+ public void setMobileProvider (final MobileProvider mobileProvider) {
+ this.mobileProvider = mobileProvider;
+ }
+
+ /**
+ * Unlinks mobile data with current contact
+ * <p>
+ * @return Redirect outcome
+ */
+ public String unlinkMobileContactData () {
+ // Create fax number instance
+ final DialableMobileNumber number = this.createMobileNumber();
+
+ // Is all data set
+ if (number == null) {
+ // Not set, throw NPE
+ throw new NullPointerException("number is null"); //NOI18N
+ } else if (number.getMobileId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("number.phoneId is null"); //NOI18N
+ } else if (number.getMobileId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getMobileId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("number.mobileProvider is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() == null) {
+ // ... throw again
+ throw new NullPointerException("number.mobileProvider.providerId is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("number.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("number.phoneNumber is null"); //NOI18N
+ } else if (number.getMobileNumber() < 1) {
+ // Throw it again ...
+ throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
+ } else if (this.getContact() == null) {
+ // ... and throw again
+ throw new NullPointerException("this.contact is null"); //NOI18N
+ } else if (this.getContact().getContactId() == null) {
+ // ... and again ...
+ throw new NullPointerException("this.contact.contactId is null"); //NOI18N
+ } else if (this.getContact().getContactId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N
+ }
+
+ // Init contact instance
+ final Contact updatedContact;
+
+ try {
+ // Unlink it and return contact without mobile instance
+ updatedContact = this.adminContactPhoneBean.unlinkMobileDataFromContact(this.getContact(), number);
+ } catch (final PhoneNumberNotLinkedException ex) {
+ // Did not work
+ this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Fire event
+ this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, number));
+
+ // All fine here
+ return "admin_show_contact"; //NOI18N
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Returns an instance of a DialableMobileNumber from all fields stored in
+ * this bean.
+ * <p>
+ * @return An instance of a DialableMobileNumber class
+ */
+ private DialableMobileNumber createMobileNumber () {
+ // Initialize it
+ final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+
+ // Add all other data
+ number.setMobileEntryCreated(this.getMobileEntryCreated());
+ number.setMobileEntryUpdated(this.getMobileEntryUpdated());
+
+ // Is id number set?
+ if (this.getMobileId() instanceof Long) {
+ // Set it
+ number.setMobileId(this.getMobileId());
+ }
+
+ // Return it
+ return number;
+ }
+
+ /**
+ * Getter for mobile entry created
+ * <p>
+ * @return Mobile entry created
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ private Date getMobileEntryCreated () {
+ return this.mobileEntryCreated;
+ }
+
+ /**
+ * Setter for mobile entry created
+ * <p>
+ * @param mobileEntryCreated Mobile entry created
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ private void setMobileEntryCreated (final Date mobileEntryCreated) {
+ this.mobileEntryCreated = mobileEntryCreated;
+ }
+
+ /**
+ * Getter for mobile entry updated
+ * <p>
+ * @return Mobile entry updated
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ private Date getMobileEntryUpdated () {
+ return this.mobileEntryUpdated;
+ }
+
+ /**
+ * Setter for mobile entry updated
+ * <p>
+ * @param mobileEntryUpdated Mobile entry updated
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ private void setMobileEntryUpdated (final Date mobileEntryUpdated) {
+ this.mobileEntryUpdated = mobileEntryUpdated;
+ }
+
+}
--- /dev/null
+
+/*
+ * Copyright (C) 2016 - 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.contact.mobile;
+
+import org.mxchange.jfinancials.beans.contact.phone.*;
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminContactMobileWebRequestController extends Serializable {
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.contact.mobile;
+
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+
+/**
+ * A general contact bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("contactMobileController")
+@RequestScoped
+public class FinancialsContactMobileWebRequestBean extends BaseFinancialsBean implements FinancialsContactMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * An instance of a contact-list controller
+ */
+ @Inject
+ private FinancialsContactListWebViewController contactListController;
+
+ /**
+ * Chosen mobile number
+ */
+ private DialableMobileNumber mobileNumber;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsContactMobileWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Event observer for updated contact data by administrators
+ * <p>
+ * @param event Updated contact data event
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent 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();
+ }
+
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * mobile number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.mobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.mobileNumber.mobileId={0} is invalid", event.getMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Set it here
+ this.setMobileNumber(event.getMobileNumber());
+ }
+
+ /**
+ * Getter for all contacts having current mobile number linked
+ * <p>
+ * @return List of all linked contacts
+ */
+ public List<Contact> allCurrentMobileNumberContacts () {
+ // Get id
+ final DialableMobileNumber dialableMobileNumber = this.getMobileNumber();
+
+ // Init list
+ final List<Contact> contacts = new LinkedList<>();
+
+ // "Walk" through all contacts
+ for (final Contact contact : this.contactListController.getAllContacts()) {
+ // Is mobile instance the same?
+ if (Objects.equals(contact.getContactMobileNumber(), dialableMobileNumber)) {
+ // Found one
+ contacts.add(contact);
+ }
+ }
+
+ // Return now-cached list
+ return contacts;
+ }
+
+ /**
+ * Getter for chosen mobile number
+ * <p>
+ * @return mobile number
+ */
+ public DialableMobileNumber getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ /**
+ * Setter for chosen mobile number
+ * <p>
+ * @param mobileNumber mobile number
+ */
+ public void setMobileNumber (final DialableMobileNumber mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.contact.mobile;
+
+import org.mxchange.jfinancials.beans.contact.phone.*;
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsContactMobileWebRequestController extends Serializable {
+
+}
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.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.model.contact.Contact;
import org.mxchange.jcontacts.model.phone.AdminContactsPhoneSessionBeanRemote;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
-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.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.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
/**
@Any
private Event<ObservableAdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
- /**
- * Event being fired when a mobile number has been linked
- */
- @Inject
- @Any
- private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
-
/**
* Administrative phone controller
*/
private Event<ObservableAdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
/**
- * Mobile number
- */
- private Long mobileNumber;
-
- /**
- * Event being fired when administrator unlinks mobile from contact
- */
- @Inject
- @Any
- private Event<ObservableAdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
-
- /**
- * Mobile provider
- */
- private MobileProvider mobileProvider;
-
- /**
- * When fax number has been created
+ * When phone number has been created
*/
private Date phoneEntryCreated;
/**
- * When fax number has been updated
+ * When phone number has been updated
*/
private Date phoneEntryUpdated;
this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
}
- /**
- * Observes events being fired when a bean helper has successfully created a
- * mobile number instance.
- * <p>
- * @param event Event being fired
- */
- public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
- // The event instance must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.mobileNumber is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() == null) {
- // Throw NPE yet again
- throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() < 1) {
- // Throw NPE yet again
- throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Get fax number from event
- final DialableMobileNumber number = event.getMobileNumber();
-
- // Copy all data to this bean
- this.setPhoneId(number.getPhoneId());
- this.setMobileProvider(number.getMobileProvider());
- this.setMobileNumber(number.getPhoneNumber());
- this.setPhoneEntryCreated(number.getPhoneEntryCreated());
- this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
- }
-
/**
* Links fax number to contact from bean helper as "main fax number".
* <p>
return "admin_show_contact"; //NOI18N
}
- /**
- * Links mobile number to contact from bean helper as "main mobile number".
- * <p>
- * @return Redirect outcome
- */
- public String doLinkMainMobileNumber () {
- // Get contact from helper
- final Contact targetContact = this.getContact();
-
- // Is all data properly set?
- if (null == targetContact) {
- // Throw NPE
- throw new NullPointerException("targetContact is null"); //NOI18N
- } else if (targetContact.getContactId() == null) {
- // Throw it again
- throw new NullPointerException("targetContact.contactId is null"); //NOI18N
- } else if (targetContact.getContactId() < 1) {
- // Is not valid
- throw new IllegalArgumentException(MessageFormat.format("targetContact.contactId={0} is not valid", targetContact.getContactId())); //NOI18N
- } else if (this.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("this.mobileProvider is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() == null) {
- // Throw NPE
- throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() < 1) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("this.mobileProvider.providerId={0} is invalid", this.getMobileProvider().getProviderId())); //NOI18N
- } else if (this.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("this.mobileNumber is null"); //NOI18N
- } else if (this.getMobileNumber() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber={0} is invalid", this.getMobileNumber())); //NOI18N
- }
-
- // Init instance
- final Contact updatedContact;
- final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
-
- // Try it again
- try {
- // Link it, too
- updatedContact = this.adminContactPhoneBean.linkNewMobileNumberWithContact(targetContact, number);
- } catch (final PhoneNumberAlreadyLinkedException ex) {
- // Throw again as cause
- this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
- return ""; //NOI18N
- }
-
- // Fire event
- this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, number));
-
- // Return to contact profile
- return "admin_show_contact"; //NOI18N
- }
-
/**
* Getter for contact instance
* <p>
this.landLineNumber = landLineNumber;
}
- /**
- * Getter for mobile number
- * <p>
- * @return Mobile number
- */
- public Long getMobileNumber () {
- return this.mobileNumber;
- }
-
- /**
- * Setter for mobile number
- * <p>
- * @param mobileNumber Mobile number
- */
- public void setMobileNumber (final Long mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
- /**
- * Getter for mobile provider
- * <p>
- * @return Mobile provider
- */
- public MobileProvider getMobileProvider () {
- return this.mobileProvider;
- }
-
- /**
- * Setter for mobile provider
- * <p>
- * @param mobileProvider Mobile provider
- */
- public void setMobileProvider (final MobileProvider mobileProvider) {
- this.mobileProvider = mobileProvider;
- }
-
/**
* Setter for phone id
* <p>
return "admin_show_contact"; //NOI18N
}
- /**
- * Unlinks mobile data with current contact
- * <p>
- * @return Redirect outcome
- */
- public String unlinkMobileContactData () {
- // Create fax number instance
- final DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("number is null"); //NOI18N
- } else if (number.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("number.phoneId is null"); //NOI18N
- } else if (number.getPhoneId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("number.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("number.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("number.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getPhoneNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("number.phoneNumber is null"); //NOI18N
- } else if (number.getPhoneNumber() < 1) {
- // Throw it again ...
- throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
- } else if (this.getContact() == null) {
- // ... and throw again
- throw new NullPointerException("this.contact is null"); //NOI18N
- } else if (this.getContact().getContactId() == null) {
- // ... and again ...
- throw new NullPointerException("this.contact.contactId is null"); //NOI18N
- } else if (this.getContact().getContactId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N
- }
-
- // Init contact instance
- final Contact updatedContact;
-
- try {
- // Unlink it and return contact without mobile instance
- updatedContact = this.adminContactPhoneBean.unlinkMobileDataFromContact(this.getContact(), number);
- } catch (final PhoneNumberNotLinkedException ex) {
- // Did not work
- this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
- return ""; //NOI18N
- }
-
- // Fire event
- this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, number));
-
- // All fine here
- return "admin_show_contact"; //NOI18N
- }
-
/**
* Clears this bean
*/
// Set all other fields
number.setPhoneEntryCreated(this.getPhoneEntryCreated());
number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
-
- // Is id number there?
- if (this.getPhoneId() instanceof Long) {
- // Set it
- number.setPhoneId(this.getPhoneId());
- }
+ number.setPhoneId(this.getPhoneId());
// Return it
return number;
// Add all other data
number.setPhoneEntryCreated(this.getPhoneEntryCreated());
number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
-
- // Is id number set?
- if (this.getPhoneId() instanceof Long) {
- // Set it
- number.setPhoneId(this.getPhoneId());
- }
-
- // Return it
- return number;
- }
-
- /**
- * Returns an instance of a DialableMobileNumber from all fields stored in
- * this bean.
- * <p>
- * @return An instance of a DialableMobileNumber class
- */
- private DialableMobileNumber createMobileNumber () {
- // Initialize it
- final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
-
- // Add all other data
- number.setPhoneEntryCreated(this.getPhoneEntryCreated());
- number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
-
- // Is id number set?
- if (this.getPhoneId() instanceof Long) {
- // Set it
- number.setPhoneId(this.getPhoneId());
- }
+ number.setPhoneId(this.getPhoneId());
// Return it
return number;
/**
* Getter for phone entry created
* <p>
- * @param faxNumberEntryCreated Phone entry created
+ * @return Phone entry created
*/
@SuppressWarnings ("ReturnOfDateField")
private Date getPhoneEntryCreated () {
*/
package org.mxchange.jfinancials.beans.contact.phone;
-import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
-import javax.cache.Cache;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent;
-import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
-import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
-import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
-import org.mxchange.jphone.model.phonenumbers.DialableNumber;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
/**
@Inject
private FinancialsContactListWebViewController contactListController;
- /**
- * "Cache" for contact's mobile, land-line and fax numbers. Currently one
- * per each type is supported. Maybe later this will change into a OneToMany
- * relationship (one contact, many numbers).
- */
- @Inject
- @NamedCache (cacheName = "contactsPhoneCache")
- private Cache<DialableNumber, List<Contact>> contactsPhoneCache;
-
/**
* fax number
*/
*/
private DialableLandLineNumber landLineNumber;
- /**
- * Chosen mobile number
- */
- private DialableMobileNumber mobileNumber;
-
/**
* Default constructor
*/
this.clear();
}
- /**
- * Event observer for unlinked fax contact by administrators
- * <p>
- * @param event Unlinked fax contact event
- */
- public void afterAdminUnlinkedFaxContactDataEvent (@Observes final ObservableAdminUnlinkedFaxNumberEvent 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.getUnlinkedFaxNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlinkedFaxNumber is null"); //NOI18N
- } else if (event.getUnlinkedFaxNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.unlinkedFaxNumber.contactId is null"); //NOI18N
- } else if (event.getUnlinkedFaxNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedFaxNumber(), event.getUnlinkedFaxNumber().getPhoneId())); //NOI18N
- }
-
- // Remove it from list
- this.contactsPhoneCache.remove(event.getUnlinkedFaxNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Event observer for unlinked land-line contact by administrators
- * <p>
- * @param event Unlinked land-line contact event
- */
- public void afterAdminUnlinkedLandLineContactDataEvent (@Observes final ObservableAdminUnlinkedLandLineNumberEvent 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.getUnlinkedLandLineNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlinkedLandLineNumber is null"); //NOI18N
- } else if (event.getUnlinkedLandLineNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.unlinkedLandLineNumber.contactId is null"); //NOI18N
- } else if (event.getUnlinkedLandLineNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedLandLineNumber(), event.getUnlinkedLandLineNumber().getPhoneId())); //NOI18N
- }
-
- // Remove it from list
- this.contactsPhoneCache.remove(event.getUnlinkedLandLineNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Event observer for unlinked mobile contact by administrators
- * <p>
- * @param event Unlinked mobile contact event
- */
- public void afterAdminUnlinkedMobileContactDataEvent (@Observes final ObservableAdminUnlinkedMobileNumberEvent 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.getUnlinkedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlinkedMobileNumber is null"); //NOI18N
- } else if (event.getUnlinkedMobileNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.unlinkedMobileNumber.contactId is null"); //NOI18N
- } else if (event.getUnlinkedMobileNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedMobileNumber(), event.getUnlinkedMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Remove it from list
- this.contactsPhoneCache.remove(event.getUnlinkedMobileNumber());
-
- // Clear all data
- this.clear();
- }
-
/**
* Event observer for updated contact data by administrators
* <p>
this.setLandLineNumber(event.getLandLineNumber());
}
- /**
- * Observes events being fired when a bean helper has successfully created a
- * mobile number instance.
- * <p>
- * @param event Event being fired
- */
- public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
- // The event instance must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.mobileNumber is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() == null) {
- // Throw NPE yet again
- throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() < 1) {
- // Throw NPE yet again
- throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Set it here
- this.setMobileNumber(event.getMobileNumber());
- }
-
/**
* Getter for all contacts having current fax number linked
* <p>
* @return List of all linked contacts
*/
- public List<Contact> getAllCurrentFaxNumberContacts () {
+ public List<Contact> allCurrentFaxNumberContacts () {
// Get id
final DialableFaxNumber number = this.getFaxNumber();
- // Is cache there?
- if (this.contactsPhoneCache.containsKey(number)) {
- // Return cached version
- return this.contactsPhoneCache.get(number);
- } else {
- // Ask bean
- final List<Contact> list = new LinkedList<>();
+ // Init list
+ final List<Contact> contacts = new LinkedList<>();
- // "Walk" through all contacts
- for (final Contact contact : this.contactListController.getAllContacts()) {
- // Is mobile instance the same?
- if (Objects.equals(contact.getContactFaxNumber(), number)) {
- // Found one
- list.add(contact);
- }
+ // "Walk" through all contacts
+ for (final Contact contact : this.contactListController.getAllContacts()) {
+ // Is mobile instance the same?
+ if (Objects.equals(contact.getContactFaxNumber(), number)) {
+ // Found one
+ contacts.add(contact);
}
-
- // Store result in cache
- this.contactsPhoneCache.put(number, list);
-
- // Return now-cached list
- return list;
}
+
+ // Return now-cached list
+ return contacts;
}
/**
* @return List of all linked contacts
*/
public List<Contact> allCurrentLandLineNumberContacts () {
- // Get id
+ // Get it locally
final DialableLandLineNumber number = this.getLandLineNumber();
- // Is cache there?
- if (this.contactsPhoneCache.containsKey(number)) {
- // Return cached version
- return this.contactsPhoneCache.get(number);
- } else {
- // Ask bean
- final List<Contact> list = new LinkedList<>();
+ // Init list
+ final List<Contact> contacts = new LinkedList<>();
- // "Walk" through all contacts
- for (final Contact contact : this.contactListController.getAllContacts()) {
- // Is mobile instance the same?
- if (Objects.equals(contact.getContactLandLineNumber(), number)) {
- // Found one
- list.add(contact);
- }
+ // "Walk" through all contacts
+ for (final Contact contact : this.contactListController.getAllContacts()) {
+ // Is mobile instance the same?
+ if (Objects.equals(contact.getContactLandLineNumber(), number)) {
+ // Found one
+ contacts.add(contact);
}
-
- // Store result in cache
- this.contactsPhoneCache.put(number, list);
-
- // Return now-cached list
- return list;
}
- }
-
- /**
- * Getter for all contacts having current mobile number linked
- * <p>
- * @return List of all linked contacts
- */
- public List<Contact> allCurrentMobileNumberContacts () {
- // Get id
- final DialableMobileNumber number = this.getMobileNumber();
-
- // Is cache there?
- if (this.contactsPhoneCache.containsKey(number)) {
- // Return cached version
- return this.contactsPhoneCache.get(number);
- } else {
- // Ask bean
- final List<Contact> list = new LinkedList<>();
-
- // "Walk" through all contacts
- for (final Contact contact : this.contactListController.getAllContacts()) {
- // Is mobile instance the same?
- if (Objects.equals(contact.getContactMobileNumber(), number)) {
- // Found one
- list.add(contact);
- }
- }
- // Store result in cache
- this.contactsPhoneCache.put(number, list);
-
- // Return now-cached list
- return list;
- }
+ // Return now-cached list
+ return contacts;
}
/**
this.landLineNumber = landLineNumber;
}
- /**
- * Getter for chosen mobile number
- * <p>
- * @return mobile number
- */
- public DialableMobileNumber getMobileNumber () {
- return this.mobileNumber;
- }
-
- /**
- * Setter for chosen mobile number
- * <p>
- * @param mobileNumber mobile number
- */
- public void setMobileNumber (final DialableMobileNumber mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
/**
* Clears this bean
*/
// Is cache there?
if (!this.countryCache.iterator().hasNext()) {
// Add all
- for (final Country country : this.countryBean.allCountries()) {
+ for (final Country country : this.countryBean.fetchAllCountries()) {
// Add it to cache
this.countryCache.put(country.getCountryId(), country);
}
@Inject
private Event<ObservableCreatedContactEvent> contactCreatedEvent;
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsContactListWebViewController contactListController;
+
/**
* Fax number
*/
*/
private User user;
- /**
- * Regular user controller
- */
- @Inject
- private FinancialsContactListWebViewController contactListController;
-
/**
* Event for when a user instance was created
*/
if (this.getMobileNumber() == null) {
// Throw NPE
throw new NullPointerException("this.mobileNumber is null"); //NOI18N
- } else if (this.getMobileNumber().getPhoneId() == null) {
+ } else if (this.getMobileNumber().getMobileId() == null) {
// Throw again
- throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N
- } else if (this.getMobileNumber().getPhoneId() < 1) {
+ throw new NullPointerException("this.mobileNumber.mobileId is null"); //NOI18N
+ } else if (this.getMobileNumber().getMobileId() < 1) {
// Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileId={0} is not valid", this.getMobileNumber().getMobileId())); //NOI18N
} else if (this.getMobileNumber().getMobileProvider() == null) {
// Throw NPE again
throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
} else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
// Invalid id
throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
- } else if (this.getMobileNumber().getPhoneNumber() == null) {
+ } else if (this.getMobileNumber().getMobileNumber() == null) {
// Throw NPE again ...
- throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N
- } else if (this.getMobileNumber().getPhoneNumber() < 1) {
+ throw new NullPointerException("this.mobileNumber.mobileNumber is null"); //NOI18N
+ } else if (this.getMobileNumber().getMobileNumber() < 1) {
// Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileNumber={0} is not valid", this.getMobileNumber().getMobileNumber())); //NOI18N
}
// Fire event
// Is a branch office instance given?
if (branchOffice instanceof BranchOffice) {
// This should not happen:
- assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N
+ if (branchOffice.getBranchId() == null) {
+ // Throw NPE
+ throw new NullPointerException("branchOffice.branchId is null"); //NOI18N
+ } else if (branchOffice.getBranchId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is invalid.", branchOffice.getBranchId())); //NOI18N
+ } else if (branchOffice.getBranchCompany() == null) {
+ // Throw NPE
+ throw new NullPointerException("branchOffice.branchCompany is null"); //NOI18N
+ } else if (branchOffice.getBranchCountry() == null) {
+ // Throw NPE again
+ throw new NullPointerException("branchOffice.branchCountry is null"); //NOI18N
+ }
// Yes, then append all data
sb.append(this.renderBasicData(branchOffice.getBranchCompany(), true));
sb.append(" ("); //NOI18N
sb.append(mobileNumber.getMobileProvider().getProviderDialPrefix());
sb.append(") "); //NOI18N
- sb.append(mobileNumber.getPhoneNumber());
+ sb.append(mobileNumber.getMobileNumber());
}
// Return it
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobile;
+
+import java.text.MessageFormat;
+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.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.application.FacesMessage;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.mobile.list.FinancialsMobileListWebViewController;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminMobileNumberDeletedEvent;
+import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent;
+import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
+import org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote;
+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 bean (controller) for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminMobileController")
+@RequestScoped
+public class FinancialsAdminMobileWebRequestBean extends BaseFinancialsBean implements FinancialsAdminMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 184_598_175_371_269_017L;
+
+ /**
+ * Remote EJB for phone number (administrative)
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/adminMobile!org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote")
+ private AdminMobileSessionBeanRemote adminMobileBean;
+
+ /**
+ * When the phone entry has been created (persisted)
+ */
+ private Date mobileEntryCreated;
+
+ /**
+ * When the phone entry has been updated
+ */
+ private Date mobileEntryUpdated;
+
+ /**
+ * Mobile id (aka primary key)
+ */
+ private Long mobileId;
+
+ /**
+ * Generic hone controller
+ */
+ @Inject
+ private FinancialsMobileListWebViewController mobileListController;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * Event being fired when an administrator has deleted mobile number
+ */
+ @Inject
+ @Any
+ private Event<AdminDeletedMobileNumberEvent> mobileNumberDeletedEvent;
+
+ /**
+ * Event being fired when an administrator has updated land-line number
+ */
+ @Inject
+ @Any
+ private Event<AdminUpdatedMobileNumberEvent> mobileNumberUpdatedEvent;
+
+ /**
+ * Mobile provider
+ */
+ private MobileProvider mobileProvider;
+
+ /**
+ * Event being fired when a list of all unused mobile numbers is being
+ * created.
+ */
+ @Inject
+ @Any
+ private Event<AdminRemoveMobileNumberFromListEvent> removeLinkedMobileNumbersEvent;
+
+ /**
+ * Chosen mobile number
+ */
+ private DialableMobileNumber selectedMobileNumber;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminMobileWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * mobile number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.mobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.mobileNumber.mobileId={0} is invalid", event.getMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Get fax number from event
+ final DialableMobileNumber number = event.getMobileNumber();
+
+ // Copy all data to this bean
+ this.setMobileId(number.getMobileId());
+ this.setMobileProvider(number.getMobileProvider());
+ this.setMobileNumber(number.getMobileNumber());
+ this.setMobileEntryCreated(number.getMobileEntryCreated());
+ this.setMobileEntryUpdated(number.getMobileEntryUpdated());
+ }
+
+ /**
+ * Returns a list of all unused ("non-linked") mobile numbers
+ * <p>
+ * @return List with all unused mobile numbers
+ */
+ public List<DialableMobileNumber> allNonLinkedMobileNumbers () {
+ // Get list of all mobile numbers
+ final List<DialableMobileNumber> numbers = this.mobileListController.getAllMobileNumbers();
+
+ // Visit all controllers to reduce the list
+ this.removeLinkedMobileNumbersEvent.fire(new AdminMobileNumberRemovedFromListEvent(numbers));
+
+ // Return it
+ return numbers;
+ }
+
+ /**
+ * Deletes given mobile entry data
+ */
+ public void deleteMobileData () {
+ // Get mobile number from helper
+ final DialableMobileNumber number = this.createMobileNumber();
+
+ // Is all data set
+ if (number == null) {
+ // Not set, throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (number.getMobileId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (number.getMobileId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() == null) {
+ // ... throw again
+ throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
+ } else if (number.getMobileNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
+ }
+
+ // Call EJB
+ this.adminMobileBean.deleteMobileData(number);
+
+ // Fire event
+ this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
+ }
+
+ /**
+ * Changes mobile entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doUpdateMobileNumber () {
+ // Get mobile number from helper
+ final DialableMobileNumber number = this.createMobileNumber();
+
+ // Is all data set
+ if (number == null) {
+ // Not set, throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (number.getMobileId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (number.getMobileId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() == null) {
+ // ... throw again
+ throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
+ } else if (number.getMobileNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
+ } else if (this.getMobileProvider() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.mobileProvider is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() == null) {
+ // Throw NPE again ...
+ throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() < 0) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.mobileProvider.providerId={0} is not valid.", this.getMobileProvider().getProviderId())); //NOI18N
+ } else if (this.getMobileNumber() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.phoneNumber is null"); //NOI18N
+ }
+
+ // Is the mobile provider and number the same?
+ if ((Objects.equals(this.getMobileProvider(), number.getMobileProvider())) && (Objects.equals(this.getMobileNumber(), number.getMobileNumber()))) {
+ // Show message
+ this.showFacesMessage("form_edit_mobile:mobileNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED", FacesMessage.SEVERITY_WARN); //NOI18N
+
+ // No difference in both together, no need to edit
+ return ""; //NOI18N
+ }
+
+ // Set all data
+ number.setMobileProvider(this.getMobileProvider());
+ number.setMobileNumber(this.getMobileNumber());
+
+ // Send to bean
+ final DialableMobileNumber updatedNumber = this.adminMobileBean.updateMobileData(number);
+
+ // Fire event
+ this.mobileNumberUpdatedEvent.fire(new AdminMobileNumberUpdatedEvent(updatedNumber));
+
+ // All fine, redirect
+ return "admin_show_mobile"; //NOI18N
+ }
+
+ /**
+ * Getter for phone entry created timestamp
+ * <p>
+ * @return Mobile entry created timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getMobileEntryCreated () {
+ return this.mobileEntryCreated;
+ }
+
+ /**
+ * Setter for phone entry created timestamp
+ * <p>
+ * @param mobileEntryCreated Mobile entry created timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setMobileEntryCreated (final Date mobileEntryCreated) {
+ this.mobileEntryCreated = mobileEntryCreated;
+ }
+
+ /**
+ * Getter for phone entry updated timestamp
+ * <p>
+ * @return Mobile entry updated timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getMobileEntryUpdated () {
+ return this.mobileEntryUpdated;
+ }
+
+ /**
+ * Setter for phone entry updated timestamp
+ * <p>
+ * @param mobileEntryUpdated Mobile entry updated timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setMobileEntryUpdated (final Date mobileEntryUpdated) {
+ this.mobileEntryUpdated = mobileEntryUpdated;
+ }
+
+ /**
+ * Getter for phone id
+ * <p>
+ * @return Mobile id
+ */
+ public Long getMobileId () {
+ return this.mobileId;
+ }
+
+ /**
+ * Setter for phone id
+ * <p>
+ * @param mobileId Mobile id
+ */
+ public void setMobileId (final Long mobileId) {
+ this.mobileId = mobileId;
+ }
+
+ /**
+ * Getter for dial number without prefix
+ * <p>
+ * @return Dial number without prefix
+ */
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ /**
+ * Setter for dial number without prefix
+ * <p>
+ * @param mobileNumber Dial number without prefix
+ */
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ /**
+ * Getter for mobile provider
+ * <p>
+ * @return Mobile provider
+ */
+ public MobileProvider getMobileProvider () {
+ return this.mobileProvider;
+ }
+
+ /**
+ * Setter for mobile provider
+ * <p>
+ * @param mobileProvider Mobile provider
+ */
+ public void setMobileProvider (final MobileProvider mobileProvider) {
+ this.mobileProvider = mobileProvider;
+ }
+
+ /**
+ * Getter for chosen mobile number
+ * <p>
+ * @return mobile number
+ */
+ public DialableMobileNumber getSelectedMobileNumber () {
+ return this.selectedMobileNumber;
+ }
+
+ /**
+ * Setter for chosen mobile number
+ * <p>
+ * @param selectedMobileNumber mobile number
+ */
+ public void setSelectedMobileNumber (final DialableMobileNumber selectedMobileNumber) {
+ this.selectedMobileNumber = selectedMobileNumber;
+ }
+
+ /**
+ * Returns an instance of a DialableMobileNumber from all fields stored in
+ * this bean.
+ * <p>
+ * @return An instance of a DialableMobileNumber class
+ */
+ private DialableMobileNumber createMobileNumber () {
+ // Initialize it
+ final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+
+ // Add all other data
+ number.setMobileEntryCreated(this.getMobileEntryCreated());
+ number.setMobileEntryUpdated(this.getMobileEntryUpdated());
+ number.setMobileId(this.getMobileId());
+
+ // Return it
+ return number;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobile;
+
+import java.io.Serializable;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminMobileWebRequestController extends Serializable {
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobile.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.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
+import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+
+/**
+ * Administrative listing controller (bean) for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("mobileListController")
+@ViewScoped
+public class FinancialsMobileListWebViewBean extends BaseFinancialsBean implements FinancialsMobileListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 491_058_674_675_690_106L;
+
+ /**
+ * A list of all mobile numbers
+ */
+ private final List<DialableMobileNumber> allMobileNumbers;
+
+ /**
+ * A list of filtered mobile numbers
+ */
+ private List<DialableMobileNumber> filteredMobileNumbers;
+
+ /**
+ * General EJB for mobile numbers
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/mobile!org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote")
+ private MobileSessionBeanRemote mobileBean;
+
+ /**
+ * Cache for mobile numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "mobileNumberCache")
+ private transient Cache<Long, DialableMobileNumber> mobileNumberCache;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsMobileListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allMobileNumbers = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.updateContactMobileNumbers(event.getAddedContact());
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.updateContactMobileNumbers(event.getAddedUser().getUserContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a land-line
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent 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.getDeletedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedMobileNumber is null"); //NOI18N
+ } else if (event.getDeletedMobileNumber().getMobileId() == null) {
+ // userId is null
+ throw new NullPointerException("event.deletedMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getDeletedMobileNumber().getMobileId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getDeletedMobileNumber(), event.getDeletedMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.getAllMobileNumbers().remove(event.getDeletedMobileNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a
+ * land-line number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedMobileNumberEvent (@Observes final ObservableAdminLinkedMobileNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactMobileNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactMobileNumber is null"); //NOI18N
+ } else if (event.getContact().getContactMobileNumber().getMobileId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getContact().getContactMobileNumber().getMobileId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactMobileNumber.mobileId={0} is invalid", event.getContact().getContactMobileNumber().getMobileId())); //NOI18N
+ } else if (event.getLinkedMobileNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedMobileNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedMobileNumber().getMobileId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddMobileNumber(event.getContact().getContactMobileNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated contact
+ * data.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent 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();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a land-line
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent 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.getUpdatedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedMobileNumber is null"); //NOI18N
+ } else if (event.getUpdatedMobileNumber().getMobileId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getUpdatedMobileNumber().getMobileId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getUpdatedMobileNumber(), event.getUpdatedMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddMobileNumber(event.getUpdatedMobileNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ @Override
+ public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws MobileEntityNotFoundException {
+ // Validate paramter
+ if (null == mobileNumberId) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumberId is null"); //NOI18N
+ } else if (mobileNumberId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is invalid.", mobileNumberId)); //NOI18N
+ } else if (!this.mobileNumberCache.containsKey(mobileNumberId)) {
+ // Not found
+ throw new MobileEntityNotFoundException(mobileNumberId);
+ }
+
+ // Get it from cache
+ final DialableMobileNumber mobileNumber = this.mobileNumberCache.get(mobileNumberId);
+
+ // Return it
+ return mobileNumber;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableMobileNumber> getAllMobileNumbers () {
+ return this.allMobileNumbers;
+ }
+
+ /**
+ * Getter for filtered mobile numbers
+ * <p>
+ * @return Filtered mobile numbers
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableMobileNumber> getFilteredMobileNumbers () {
+ return this.filteredMobileNumbers;
+ }
+
+ /**
+ * Setter for filtered mobile numbers
+ * <p>
+ * @param filteredMobileNumbers Filtered mobile numbers
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredMobileNumbers (final List<DialableMobileNumber> filteredMobileNumbers) {
+ this.filteredMobileNumbers = filteredMobileNumbers;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.mobileNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableMobileNumber currentNumber : this.mobileBean.fetchAllMobileNumbers()) {
+ // Add it to cache
+ this.mobileNumberCache.put(currentNumber.getMobileId(), currentNumber);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.mobileNumberCache.iterator().hasNext()) && (this.getAllMobileNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableMobileNumber> currentEntry : this.mobileNumberCache) {
+ // Add to list
+ this.getAllMobileNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllMobileNumbers().sort(new Comparator<DialableMobileNumber>() {
+ @Override
+ public int compare (final DialableMobileNumber mobileNumber1, final DialableMobileNumber mobileNumber2) {
+ return mobileNumber1.getMobileId() > mobileNumber2.getMobileId() ? 1 : mobileNumber1.getMobileId() < mobileNumber2.getMobileId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredMobileNumbers(this.getAllMobileNumbers());
+ }
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Uniquely add given land-line number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param mobileNumber Land-line number to add
+ */
+ private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
+ // Make sure the parameter is valid
+ if (null == mobileNumber) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (mobileNumber.getMobileId() == null) {
+ // Throw again ...
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (mobileNumber.getMobileId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid.", mobileNumber.getMobileId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllMobileNumbers().remove(mobileNumber)) {
+ // Did not work, try by id number
+ for (final DialableMobileNumber currentNumber : this.getAllMobileNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getMobileId(), mobileNumber.getMobileId())) {
+ // Found it
+ this.getAllMobileNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllMobileNumbers().add(mobileNumber);
+ }
+
+ /**
+ * Updates given contact's mobile number
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactMobileNumbers (final Contact contact) {
+ // Parameter must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id number is not valid
+ }
+
+ // Is land-line set?
+ if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ // Unique-add it
+ this.uniqueAddMobileNumber(contact.getContactMobileNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobile.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsMobileListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all mobile numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all mobile numbers
+ */
+ List<DialableMobileNumber> getAllMobileNumbers ();
+
+ /**
+ * Finds a mobile entry by given id number
+ * <p>
+ * @param mobileNumberId Mobile entry id number
+ * <p>
+ * @return A valid mobile instance
+ * <p>
+ * @throws MobileEntityNotFoundException If the entity was not found
+ */
+ DialableMobileNumber findMobileNumberById (Long mobileNumberId) throws MobileEntityNotFoundException;
+
+}
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.mobileprovider.list.FinancialsMobileProviderListWebViewController;
import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent;
import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderAlreadyAddedException;
private AdminMobileProviderSessionBeanRemote adminRemoteBean;
/**
- * Regular bean
+ * Mobile provider list view
*/
@Inject
- private FinancialsMobileProviderWebRequestController mobileController;
+ private FinancialsMobileProviderListWebViewController mobileProviderListController;
/**
* Event being fired when the mobile provider was added
boolean isFound = false;
// Loop through all
- for (final MobileProvider currentMobileProvider : this.mobileController.allMobileProviders()) {
+ for (final MobileProvider currentMobileProvider : this.mobileProviderListController.getAllMobileProviders()) {
// Is the provider's dial prefix and country the same?
if (Objects.equals(mobileProvider, currentMobileProvider)) {
// Is the same, abort loop
*/
package org.mxchange.jfinancials.beans.mobileprovider;
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-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.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
/**
*/
private static final long serialVersionUID = 15_869_423_671_950_276L;
- /**
- * A list of all mobile providers
- */
- private final List<MobileProvider> allMobileProviders;
-
- /**
- * A list of filtered mobile providers
- */
- private List<MobileProvider> filteredMobileProviders;
-
/**
* Remote EJB for mobile providers (regular)
*/
@EJB (lookup = "java:global/jfinancials-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
private MobileProviderSingletonBeanRemote mobileProviderBean;
- /**
- * "Cached" list of mobile providers
- */
- @Inject
- @NamedCache (cacheName = "mobileProviderCache")
- private Cache<Long, MobileProvider> mobileProviderCache;
-
/**
* Default constructor
*/
public FinancialsMobileProviderWebRequestBean () {
// Call super constructor
super();
-
- // Init list
- this.allMobileProviders = new LinkedList<>();
- }
-
- /**
- * Observes events being fired after the administrator has added a new
- * mobile provider
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedMobileProviderEvent (@Observes final AdminAddedMobileProviderEvent event) {
- // Is all valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedMobileProvider() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId() == null) {
- // And again ...
- throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId() < 1) {
- // Id is invalid
- throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
- }
-
- // Add it to the list
- this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider());
- this.allMobileProviders.add(event.getAddedMobileProvider());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<MobileProvider> allMobileProviders () {
- // Return it
- return this.allMobileProviders;
- }
-
- @Override
- public MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException {
- // Validate parameter
- if (null == mobileProviderId) {
- // Throw NPE
- throw new NullPointerException("mobileProviderId is null"); //NOI18N
- } else if (mobileProviderId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("mobileProviderId=" + mobileProviderId + " is invalid."); //NOI18N
- } else if (!this.mobileProviderCache.containsKey(mobileProviderId)) {
- // Not found
- throw new MobileProviderNotFoundException(mobileProviderId);
- }
-
- // Get it from cache
- final MobileProvider mobileProvider = this.mobileProviderCache.get(mobileProviderId);
-
- // Return it
- return mobileProvider;
- }
-
- /**
- * Getter for filtered mobile provider list
- * <p>
- * @return Filtered mobile providers
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<MobileProvider> getFilteredMobileProviders () {
- return this.filteredMobileProviders;
- }
-
- /**
- * Getter for filtered mobile provider list
- * <p>
- * @param filteredMobileProviders Filtered mobile providers
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredMobileProviders (final List<MobileProvider> filteredMobileProviders) {
- this.filteredMobileProviders = filteredMobileProviders;
- }
-
- /**
- * Post-construction method
- */
- @PostConstruct
- public void initCache () {
- // Is cache there?
- if (!this.mobileProviderCache.iterator().hasNext()) {
- // Add all
- for (final MobileProvider mobileProvider : this.mobileProviderBean.allMobileProviders()) {
- // Add it to cache
- this.mobileProviderCache.put(mobileProvider.getProviderId(), mobileProvider);
- }
- }
-
- // Is the list empty, but filled cache?
- if (this.allMobileProviders.isEmpty() && this.mobileProviderCache.iterator().hasNext()) {
- // Build up list
- for (final Cache.Entry<Long, MobileProvider> currentEntry : this.mobileProviderCache) {
- // Add to list
- this.allMobileProviders.add(currentEntry.getValue());
- }
-
- // Sort list
- this.allMobileProviders.sort(new Comparator<MobileProvider>() {
- @Override
- public int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
- return mobileProvider1.getProviderId() > mobileProvider2.getProviderId() ? 1 : mobileProvider1.getProviderId() < mobileProvider2.getProviderId() ? -1 : 0;
- }
- });
- }
}
}
package org.mxchange.jfinancials.beans.mobileprovider;
import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
/**
* An interface for general mobile provider controller
*/
public interface FinancialsMobileProviderWebRequestController extends Serializable {
- /**
- * Returns a mobile provider instance by given primary key. If not found, a
- * proper exception is thrown.
- * <p>
- * @param mobileProviderId Primary key
- * <p>
- * @return Mobile provider instance
- * <p>
- * @throws MobileProviderNotFoundException If the primary key could not be
- * found
- */
- MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException;
-
- /**
- * Returns a list of all mobile providers
- * <p>
- * @return A list of all mobile providers
- */
- List<MobileProvider> allMobileProviders ();
-
}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobileprovider.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 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.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
+import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
+
+/**
+ * A views-scoped bean for mobile providers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("mobileProviderListController")
+@ViewScoped
+public class FinancialsMobileProviderListWebViewBean extends BaseFinancialsBean implements FinancialsMobileProviderListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 15_869_423_671_950_277L;
+
+ /**
+ * A list of all mobile providers
+ */
+ private final List<MobileProvider> allMobileProviders;
+
+ /**
+ * A list of filtered mobile providers
+ */
+ private List<MobileProvider> filteredMobileProviders;
+
+ /**
+ * Remote EJB for mobile providers (regular)
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+ private MobileProviderSingletonBeanRemote mobileProviderBean;
+
+ /**
+ * "Cached" list of mobile providers
+ */
+ @Inject
+ @NamedCache (cacheName = "mobileProviderCache")
+ private transient Cache<Long, MobileProvider> mobileProviderCache;
+
+ /**
+ * Selected mobile provider instance
+ */
+ private MobileProvider selectedMobileProvider;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsMobileProviderListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allMobileProviders = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired after the administrator has added a new
+ * mobile provider
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedMobileProviderEvent (@Observes final AdminAddedMobileProviderEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedMobileProvider() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId() == null) {
+ // And again ...
+ throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
+ }
+
+ // Add it to the list
+ this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider());
+ this.getAllMobileProviders().add(event.getAddedMobileProvider());
+ }
+
+ @Override
+ public MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException {
+ // Validate parameter
+ if (null == mobileProviderId) {
+ // Throw NPE
+ throw new NullPointerException("mobileProviderId is null"); //NOI18N
+ } else if (mobileProviderId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("mobileProviderId=" + mobileProviderId + " is invalid."); //NOI18N
+ } else if (!this.mobileProviderCache.containsKey(mobileProviderId)) {
+ // Not found
+ throw new MobileProviderNotFoundException(mobileProviderId);
+ }
+
+ // Get it from cache
+ final MobileProvider mobileProvider = this.mobileProviderCache.get(mobileProviderId);
+
+ // Return it
+ return mobileProvider;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<MobileProvider> getAllMobileProviders () {
+ // Return it
+ return this.allMobileProviders;
+ }
+
+ /**
+ * Getter for filtered mobile provider list
+ * <p>
+ * @return Filtered mobile providers
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<MobileProvider> getFilteredMobileProviders () {
+ return this.filteredMobileProviders;
+ }
+
+ /**
+ * Getter for filtered mobile provider list
+ * <p>
+ * @param filteredMobileProviders Filtered mobile providers
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredMobileProviders (final List<MobileProvider> filteredMobileProviders) {
+ this.filteredMobileProviders = filteredMobileProviders;
+ }
+
+ /**
+ * Getter for selected mobile provider instance
+ * <p>
+ * @return Selected mobile provider instance
+ */
+ public MobileProvider getSelectedMobileProvider () {
+ return this.selectedMobileProvider;
+ }
+
+ /**
+ * Setter for selected mobile provider instance
+ * <p>
+ * @param selectedMobileProvider Selected mobile provider instance
+ */
+ public void setSelectedMobileProvider (final MobileProvider selectedMobileProvider) {
+ this.selectedMobileProvider = selectedMobileProvider;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.mobileProviderCache.iterator().hasNext()) {
+ // Add all
+ for (final MobileProvider mobileProvider : this.mobileProviderBean.fetchAllMobileProviders()) {
+ // Add it to cache
+ this.mobileProviderCache.put(mobileProvider.getProviderId(), mobileProvider);
+ }
+ }
+
+ // Is the list empty, but filled cache?
+ if (this.getAllMobileProviders().isEmpty() && this.mobileProviderCache.iterator().hasNext()) {
+ // Build up list
+ for (final Cache.Entry<Long, MobileProvider> currentEntry : this.mobileProviderCache) {
+ // Add to list
+ this.getAllMobileProviders().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllMobileProviders().sort(new Comparator<MobileProvider>() {
+ @Override
+ public int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
+ return mobileProvider1.getProviderId() > mobileProvider2.getProviderId() ? 1 : mobileProvider1.getProviderId() < mobileProvider2.getProviderId() ? -1 : 0;
+ }
+ });
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.mobileprovider.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An interface for general mobile provider controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsMobileProviderListWebViewController extends Serializable {
+
+ /**
+ * Returns a mobile provider instance by given primary key. If not found, a
+ * proper exception is thrown.
+ * <p>
+ * @param mobileProviderId Primary key
+ * <p>
+ * @return Mobile provider instance
+ * <p>
+ * @throws MobileProviderNotFoundException If the primary key could not be
+ * found
+ */
+ MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException;
+
+ /**
+ * Returns a list of all mobile providers
+ * <p>
+ * @return A list of all mobile providers
+ */
+ List<MobileProvider> getAllMobileProviders ();
+
+}
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewController;
import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
import org.mxchange.jphone.events.fax.deleted.AdminFaxNumberDeletedEvent;
import org.mxchange.jphone.events.landline.removed.AdminRemoveLandLineNumberFromListEvent;
import org.mxchange.jphone.events.landline.updated.AdminLandLineNumberUpdatedEvent;
import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
-import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
-import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
-import org.mxchange.jphone.events.mobile.deleted.AdminMobileNumberDeletedEvent;
-import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent;
import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
-import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
-import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
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.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote;
/**
@Any
private Event<AdminUpdatedLandLineNumberEvent> landLineNumberUpdatedEvent;
- /**
- * Chosen mobile number
- */
- private DialableMobileNumber mobileNumber;
-
- /**
- * Event being fired when an administrator has deleted mobile number
- */
- @Inject
- @Any
- private Event<AdminDeletedMobileNumberEvent> mobileNumberDeletedEvent;
-
- /**
- * Event being fired when an administrator has updated land-line number
- */
- @Inject
- @Any
- private Event<AdminUpdatedMobileNumberEvent> mobileNumberUpdatedEvent;
-
- /**
- * Mobile provider
- */
- private MobileProvider mobileProvider;
-
/**
* Area code (city dial prefix)
*/
private Integer phoneAreaCode;
- /**
- * Generic hone controller
- */
- @Inject
- private FinancialsPhoneWebRequestController phoneController;
-
/**
* Country (for dial prefix)
*/
*/
private Long phoneId;
+ /**
+ * Generic hone controller
+ */
+ @Inject
+ private FinancialsPhoneListWebViewController phoneListController;
+
/**
* Phone number
*/
/**
* Observes events being fired when a bean helper has successfully created a
- * fax number instance.
+ * land-line number instance.
* <p>
* @param event Event being fired
*/
throw new NullPointerException("event is null"); //NOI18N
} else if (event.getFaxNumber() == null) {
// Throw NPE again
- throw new NullPointerException("event.faxNumber is null"); //NOI18N
+ throw new NullPointerException("event.landLineNumber is null"); //NOI18N
} else if (event.getFaxNumber().getPhoneId() == null) {
// Throw NPE yet again
- throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N
+ throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N
} else if (event.getFaxNumber().getPhoneId() < 1) {
// Throw NPE yet again
- throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N
}
// Get fax number from event
- DialableFaxNumber number = event.getFaxNumber();
+ final DialableFaxNumber number = event.getFaxNumber();
// Copy all data to this bean
this.setPhoneId(number.getPhoneId());
}
// Get fax number from event
- DialableLandLineNumber number = event.getLandLineNumber();
+ final DialableLandLineNumber number = event.getLandLineNumber();
// Copy all data to this bean
this.setPhoneId(number.getPhoneId());
this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
}
- /**
- * Observes events being fired when a bean helper has successfully created a
- * mobile number instance.
- * <p>
- * @param event Event being fired
- */
- public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
- // The event instance must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.mobileNumber is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() == null) {
- // Throw NPE yet again
- throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N
- } else if (event.getMobileNumber().getPhoneId() < 1) {
- // Throw NPE yet again
- throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Get fax number from event
- DialableMobileNumber number = event.getMobileNumber();
-
- // Copy all data to this bean
- this.setPhoneId(number.getPhoneId());
- this.setMobileProvider(number.getMobileProvider());
- this.setPhoneNumber(number.getPhoneNumber());
- this.setPhoneEntryCreated(number.getPhoneEntryCreated());
- this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
- }
-
/**
* Returns a list of all unused ("non-linked") land-line numbers
* <p>
*/
public List<DialableFaxNumber> allNonLinkedFaxNumbers () {
// Get list of all mobile numbers
- List<DialableFaxNumber> list = this.phoneController.allFaxNumbers();
+ final List<DialableFaxNumber> numbers = this.phoneListController.getAllFaxNumbers();
// Visit all controllers to reduce the list
- this.removeLinkedFaxNumbersEvent.fire(new AdminFaxNumberRemovedFromListEvent(list));
+ this.removeLinkedFaxNumbersEvent.fire(new AdminFaxNumberRemovedFromListEvent(numbers));
// Return it
- return list;
+ return numbers;
}
/**
*/
public List<DialableLandLineNumber> allNonLinkedLandLineNumbers () {
// Get list of all mobile numbers
- List<DialableLandLineNumber> list = this.phoneController.allLandLineNumbers();
+ final List<DialableLandLineNumber> numbers = this.phoneListController.getAllLandLineNumbers();
// Visit all controllers to reduce the list
- this.removeLinkedLandLineNumbersEvent.fire(new AdminLandLineNumberRemovedFromListEvent(list));
+ this.removeLinkedLandLineNumbersEvent.fire(new AdminLandLineNumberRemovedFromListEvent(numbers));
// Return it
- return list;
- }
-
- /**
- * Returns a list of all unused ("non-linked") mobile numbers
- * <p>
- * @return List with all unused mobile numbers
- */
- public List<DialableMobileNumber> allNonLinkedMobileNumbers () {
- // Get list of all mobile numbers
- List<DialableMobileNumber> list = this.phoneController.allMobileNumbers();
-
- // Visit all controllers to reduce the list
- this.removeLinkedMobileNumbersEvent.fire(new AdminMobileNumberRemovedFromListEvent(list));
-
- // Return it
- return list;
+ return numbers;
}
/**
*/
public void deleteFaxData () {
// Get fax number from bean helper
- DialableFaxNumber number = this.createFaxNumber();
+ final DialableFaxNumber number = this.createFaxNumber();
// Is all data set
if (number == null) {
*/
public void deleteLandLineData () {
// Get land-line number from helper
- DialableLandLineNumber number = this.createLandLineNumber();
+ final DialableLandLineNumber number = this.createLandLineNumber();
// Is all data set
if (number == null) {
this.landLineNumberDeletedEvent.fire(new AdminLandLineNumberDeletedEvent(number));
}
- /**
- * Deletes given mobile entry data
- */
- public void deleteMobileData () {
- // Get mobile number from helper
- DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (number.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (number.getPhoneId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getPhoneNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
- } else if (number.getPhoneNumber() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
- }
-
- // Call EJB
- this.adminPhoneBean.deleteMobileData(number);
-
- // Fire event
- this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
- }
-
/**
* Changes fax entry data
* <p>
*/
public String doChangeFaxNumber () {
// Get fax number from bean helper
- DialableFaxNumber number = this.createFaxNumber();
+ final DialableFaxNumber number = this.createFaxNumber();
// Is all data set
if (number == null) {
number.setPhoneNumber(this.getPhoneNumber());
// Send to bean
- DialableFaxNumber updatedNumber = this.adminPhoneBean.updateFaxData(number);
+ final DialableFaxNumber updatedNumber = this.adminPhoneBean.updateFaxData(number);
// Fire event
this.faxNumberUpdatedEvent.fire(new AdminFaxNumberUpdatedEvent(updatedNumber));
*/
public String doChangeLandLineNumber () {
// Get land-line number from helper
- DialableLandLineNumber number = this.createLandLineNumber();
+ final DialableLandLineNumber number = this.createLandLineNumber();
// Is all data set
if (number == null) {
number.setPhoneNumber(this.getPhoneNumber());
// Send to bean
- DialableLandLineNumber updatedNumber = this.adminPhoneBean.updateLandLineData(number);
+ final DialableLandLineNumber updatedNumber = this.adminPhoneBean.updateLandLineData(number);
// Fire event
this.landLineNumberUpdatedEvent.fire(new AdminLandLineNumberUpdatedEvent(updatedNumber));
return "admin_show_landline"; //NOI18N
}
- /**
- * Changes mobile entry data
- * <p>
- * @return Redirect outcome
- */
- public String doUpdateMobileNumber () {
- // Get mobile number from helper
- DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (number.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (number.getPhoneId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getPhoneNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
- } else if (number.getPhoneNumber() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
- } else if (this.getMobileProvider() == null) {
- // Throw NPE again
- throw new NullPointerException("this.mobileProvider is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() == null) {
- // Throw NPE again ...
- throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() < 0) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.mobileProvider.providerId={0} is not valid.", this.getMobileProvider().getProviderId())); //NOI18N
- } else if (this.getPhoneNumber() == null) {
- // Throw NPE
- throw new NullPointerException("this.phoneNumber is null"); //NOI18N
- }
-
- // Is the mobile provider and number the same?
- if ((Objects.equals(this.getMobileProvider(), number.getMobileProvider())) && (Objects.equals(this.getPhoneNumber(), number.getPhoneNumber()))) {
- // Show message
- this.showFacesMessage("form_edit_mobile:mobileNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED", FacesMessage.SEVERITY_WARN); //NOI18N
-
- // No difference in both together, no need to edit
- return ""; //NOI18N
- }
-
- // Set all data
- number.setMobileProvider(this.getMobileProvider());
- number.setPhoneNumber(this.getPhoneNumber());
-
- // Send to bean
- DialableMobileNumber updatedNumber = this.adminPhoneBean.updateMobileData(number);
-
- // Fire event
- this.mobileNumberUpdatedEvent.fire(new AdminMobileNumberUpdatedEvent(updatedNumber));
-
- // All fine, redirect
- return "admin_show_mobile"; //NOI18N
- }
-
/**
* Getter for chosen fax number
* <p>
this.landLineNumber = landLineNumber;
}
- /**
- * Getter for chosen mobile number
- * <p>
- * @return mobile number
- */
- public DialableMobileNumber getMobileNumber () {
- return this.mobileNumber;
- }
-
- /**
- * Setter for chosen mobile number
- * <p>
- * @param mobileNumber mobile number
- */
- public void setMobileNumber (final DialableMobileNumber mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
- /**
- * Getter for mobile provider
- * <p>
- * @return Mobile provider
- */
- public MobileProvider getMobileProvider () {
- return this.mobileProvider;
- }
-
- /**
- * Setter for mobile provider
- * <p>
- * @param mobileProvider Mobile provider
- */
- public void setMobileProvider (final MobileProvider mobileProvider) {
- this.mobileProvider = mobileProvider;
- }
-
/**
* Getter for phone area code
* <p>
*/
private DialableFaxNumber createFaxNumber () {
// Initialize it
- DialableFaxNumber number = new FaxNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ final DialableFaxNumber number = new FaxNumber(
+ this.getPhoneCountry(),
+ this.getPhoneAreaCode(),
+ this.getPhoneNumber()
+ );
// Add all other data
number.setPhoneEntryCreated(this.getPhoneEntryCreated());
*/
private DialableLandLineNumber createLandLineNumber () {
// Initialize it
- DialableLandLineNumber number = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
-
- // Add all other data
- number.setPhoneEntryCreated(this.getPhoneEntryCreated());
- number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
-
- // Is id number set?
- if (this.getPhoneId() instanceof Long) {
- // Set it
- number.setPhoneId(this.getPhoneId());
- }
-
- // Return it
- return number;
- }
-
- /**
- * Returns an instance of a DialableMobileNumber from all fields stored in
- * this bean.
- * <p>
- * @return An instance of a DialableMobileNumber class
- */
- private DialableMobileNumber createMobileNumber () {
- // Initialize it
- DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getPhoneNumber());
+ final DialableLandLineNumber number = new LandLineNumber(
+ this.getPhoneCountry(),
+ this.getPhoneAreaCode(),
+ this.getPhoneNumber()
+ );
// Add all other data
number.setPhoneEntryCreated(this.getPhoneEntryCreated());
*/
package org.mxchange.jfinancials.beans.phone;
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-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.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
-import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
-import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
-import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
-import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
-import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
-import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
-import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
-import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
-import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
/**
* Regular controller (bean) for phone numbers
*/
private static final long serialVersionUID = 491_058_674_675_690_105L;
- /**
- * All fax numbers
- */
- @Inject
- @NamedCache (cacheName = "faxNumberCache")
- private Cache<Long, DialableFaxNumber> faxNumberCache;
-
- /**
- * All land-line numbers
- */
- @Inject
- @NamedCache (cacheName = "landLineNumberCache")
- private Cache<Long, DialableLandLineNumber> landLineNumberCache;
-
- /**
- * All mobile numbers
- */
- @Inject
- @NamedCache (cacheName = "mobileNumberCache")
- private Cache<Long, DialableMobileNumber> mobileNumberCache;
-
- /**
- * General EJB for phone numbers
- */
- @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
- private PhoneSessionBeanRemote phoneBean;
-
/**
* Default constructor
*/
super();
}
- /**
- * Observes events being fired when an administrator has added a new
- * contact.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedContact is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() == null) {
- // ... and again
- throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.updateContactPhoneNumbers(event.getAddedContact());
-
- // Clear this bean
- this.clear();
- }
-
- /**
- * Event observer for newly added users by administrator
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addedUser is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.updateContactPhoneNumbers(event.getAddedUser().getUserContact());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a fax
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent 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.getDeletedFaxNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedFaxNumber is null"); //NOI18N
- } else if (event.getDeletedFaxNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getDeletedFaxNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedFaxNumber(), event.getDeletedFaxNumber().getPhoneId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.allFaxNumbers().remove(event.getDeletedFaxNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a land-line
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent 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.getDeletedLandLineNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedLandLineNumber is null"); //NOI18N
- } else if (event.getDeletedLandLineNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getDeletedLandLineNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedLandLineNumber(), event.getDeletedLandLineNumber().getPhoneId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.allLandLineNumbers().remove(event.getDeletedLandLineNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a mobile
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent 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.getDeletedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedMobileNumber is null"); //NOI18N
- } else if (event.getDeletedMobileNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedMobileNumber.phoneId is null"); //NOI18N
- } else if (event.getDeletedMobileNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedMobileNumber(), event.getDeletedMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.allMobileNumbers().remove(event.getDeletedMobileNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has a linked a fax
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedFaxNumberEvent (@Observes final ObservableAdminLinkedFaxNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N
- } else if (event.getContact().getContactFaxNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactFaxNumber is null"); //NOI18N
- } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactFaxNumber.phoneId=" + event.getContact().getContactFaxNumber().getPhoneId() + " is invalid"); //NOI18N
- } else if (event.getLinkedFaxNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedFaxNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedFaxNumber().getPhoneId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddFaxNumber(event.getContact().getContactFaxNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has a linked a
- * land-line number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedLandLineNumberEvent (@Observes final ObservableAdminLinkedLandLineNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N
- } else if (event.getContact().getContactLandLineNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactLandLineNumber is null"); //NOI18N
- } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactLandLineNumber.phoneId=" + event.getContact().getContactLandLineNumber().getPhoneId() + " is invalid"); //NOI18N
- } else if (event.getLinkedLandLineNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedLandLineNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedLandLineNumber().getPhoneId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddLandLineNumber(event.getContact().getContactLandLineNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has a linked a mobile
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedMobileNumberEvent (@Observes final ObservableAdminLinkedMobileNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId=" + event.getContact().getContactId() + " is invalid"); //NOI18N
- } else if (event.getContact().getContactMobileNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactMobileNumber is null"); //NOI18N
- } else if (event.getContact().getContactMobileNumber().getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactMobileNumber.phoneId is null"); //NOI18N
- } else if (event.getContact().getContactMobileNumber().getPhoneId() < 1) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactMobileNumber.phoneId=" + event.getContact().getContactMobileNumber().getPhoneId() + " is invalid"); //NOI18N
- } else if (event.getLinkedMobileNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedMobileNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedMobileNumber().getPhoneId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddMobileNumber(event.getContact().getContactMobileNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has updated contact
- * data.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent 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 fax number
- this.updateContactPhoneNumbers(event.getUpdatedContact());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a fax
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent 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.getUpdatedFaxNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedFaxNumber is null"); //NOI18N
- } else if (event.getUpdatedFaxNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getUpdatedFaxNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedFaxNumber(), event.getUpdatedFaxNumber().getPhoneId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddFaxNumber(event.getUpdatedFaxNumber());
-
- // Clear it
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a land-line
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent 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.getUpdatedLandLineNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedLandLineNumber is null"); //NOI18N
- } else if (event.getUpdatedLandLineNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getUpdatedLandLineNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedLandLineNumber(), event.getUpdatedLandLineNumber().getPhoneId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddLandLineNumber(event.getUpdatedLandLineNumber());
-
- // Clear it
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a mobile
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent 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.getUpdatedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedMobileNumber is null"); //NOI18N
- } else if (event.getUpdatedMobileNumber().getPhoneId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedMobileNumber.phoneId is null"); //NOI18N
- } else if (event.getUpdatedMobileNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedMobileNumber(), event.getUpdatedMobileNumber().getPhoneId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddMobileNumber(event.getUpdatedMobileNumber());
-
- // Clear it
- this.clear();
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableFaxNumber> allFaxNumbers () {
- // Init list
- final List<DialableFaxNumber> list = new LinkedList<>();
-
- // Loop over all
- for (final Cache.Entry<Long, DialableFaxNumber> currentEntry : this.faxNumberCache) {
- // Add value to list
- list.add(currentEntry.getValue());
- }
-
- // Return it
- return list;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableLandLineNumber> allLandLineNumbers () {
- // Init list
- final List<DialableLandLineNumber> list = new LinkedList<>();
-
- // Loop over all
- for (final Cache.Entry<Long, DialableLandLineNumber> currentEntry : this.landLineNumberCache) {
- // Add value to list
- list.add(currentEntry.getValue());
- }
-
- // Return it
- return list;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableMobileNumber> allMobileNumbers () {
- // Init list
- final List<DialableMobileNumber> list = new LinkedList<>();
-
- // Loop over all
- for (final Cache.Entry<Long, DialableMobileNumber> currentEntry : this.mobileNumberCache) {
- // Add value to list
- list.add(currentEntry.getValue());
- }
-
- // Return it
- return list;
- }
-
- @Override
- public DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException {
- // Validate paramter
- if (null == faxNumberId) {
- // Throw NPE
- throw new NullPointerException("faxNumberId is null"); //NOI18N
- } else if (faxNumberId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("faxNumberId=" + faxNumberId + " is invalid."); //NOI18N
- } else if (!this.faxNumberCache.containsKey(faxNumberId)) {
- // Not found
- throw new PhoneEntityNotFoundException(faxNumberId);
- }
-
- // Get it from cache
- final DialableFaxNumber faxNumber = this.faxNumberCache.get(faxNumberId);
-
- // Return it
- return faxNumber;
- }
-
- @Override
- public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
- // Validate paramter
- if (null == landLineNumberId) {
- // Throw NPE
- throw new NullPointerException("landLineNumberId is null"); //NOI18N
- } else if (landLineNumberId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("landLineNumberId=" + landLineNumberId + " is invalid."); //NOI18N
- } else if (!this.landLineNumberCache.containsKey(landLineNumberId)) {
- // Not found
- throw new PhoneEntityNotFoundException(landLineNumberId);
- }
-
- // Get it from cache
- final DialableLandLineNumber landLineNumber = this.landLineNumberCache.get(landLineNumberId);
-
- // Return it
- return landLineNumber;
- }
-
- @Override
- public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException {
- // Validate paramter
- if (null == mobileNumberId) {
- // Throw NPE
- throw new NullPointerException("mobileNumberId is null"); //NOI18N
- } else if (mobileNumberId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("mobileNumberId=" + mobileNumberId + " is invalid."); //NOI18N
- } else if (!this.mobileNumberCache.containsKey(mobileNumberId)) {
- // Not found
- throw new PhoneEntityNotFoundException(mobileNumberId);
- }
-
- // Get it from cache
- final DialableMobileNumber mobileNumber = this.mobileNumberCache.get(mobileNumberId);
-
- // Return it
- return mobileNumber;
- }
-
- /**
- * Post-construction method
- */
- @PostConstruct
- public void init () {
- // Is cache there?
- if (!this.faxNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableFaxNumber faxNumber : this.phoneBean.allFaxNumbers()) {
- // Add it to cache
- this.faxNumberCache.put(faxNumber.getPhoneId(), faxNumber);
- }
- }
-
- // Is cache there?
- if (!this.landLineNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableLandLineNumber lineNumber : this.phoneBean.allLandLineNumbers()) {
- // Add it to cache
- this.landLineNumberCache.put(lineNumber.getPhoneId(), lineNumber);
- }
- }
-
- // Is cache there?
- if (!this.mobileNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableMobileNumber mobileNumber : this.phoneBean.allMobileNumbers()) {
- // Add it to cache
- this.mobileNumberCache.put(mobileNumber.getPhoneId(), mobileNumber);
- }
- }
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- }
-
- /**
- * Uniquely add given fax number to this bean's list. First remove the old
- * instance (by id number), then re-add it again.
- * <p>
- * @param faxNumber number to add
- */
- private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
- // Make sure the parameter is valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
- } else if (faxNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); //NOI18N
- }
-
- // First remove it
- if (!this.allFaxNumbers().remove(faxNumber)) {
- // Did not work, try by id number
- for (final DialableFaxNumber fax : this.allFaxNumbers()) {
- // Is id number the same?
- if (Objects.equals(fax.getPhoneId(), faxNumber.getPhoneId())) {
- // Found it
- this.allFaxNumbers().remove(fax);
- break;
- }
- }
- }
-
- // ... then add it
- this.allFaxNumbers().add(faxNumber);
- }
-
- /**
- * Uniquely add given land-line number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param landLineNumber Land-line number to add
- */
- private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
- // Make sure the parameter is valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); //NOI18N
- }
-
- // First remove it
- if (!this.allLandLineNumbers().remove(landLineNumber)) {
- // Did not work, try by id number
- for (final DialableLandLineNumber landLine : this.allLandLineNumbers()) {
- // Is id number the same?
- if (Objects.equals(landLine.getPhoneId(), landLineNumber.getPhoneId())) {
- // Found it
- this.allLandLineNumbers().remove(landLine);
- break;
- }
- }
- }
-
- // ... then add it
- this.allLandLineNumbers().add(landLineNumber);
- }
-
- /**
- * Uniquely add given mobile number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param mobileNumber Mobile number to add
- */
- private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
- // Make sure the parameter is valid
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid.", mobileNumber.getPhoneId())); //NOI18N
- }
-
- // First remove it by object
- if (!this.allMobileNumbers().remove(mobileNumber)) {
- // Did not work, try by id number
- for (final DialableMobileNumber cell : this.allMobileNumbers()) {
- // Is id number the same?
- if (Objects.equals(cell.getPhoneId(), mobileNumber.getPhoneId())) {
- // Found it
- this.allMobileNumbers().remove(cell);
- break;
- }
- }
- }
-
- // ... then add it
- this.allMobileNumbers().add(mobileNumber);
- }
-
- /**
- * Updates given contact's mobile, land-line and fax number
- * <p>
- * @param contact Contact instance
- */
- private void updateContactPhoneNumbers (final Contact contact) {
- // Parameter must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw again
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Id number is not valid
- }
-
- // Is mobile set?
- if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
- // Unique-add it
- this.uniqueAddMobileNumber(contact.getContactMobileNumber());
- }
-
- // Is land-line set?
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Unique-add it
- this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
- }
-
- // Is fax set?
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Unique-add it
- this.uniqueAddFaxNumber(contact.getContactFaxNumber());
- }
- }
-
}
package org.mxchange.jfinancials.beans.phone;
import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
/**
* An interface for a request web controller (bean) for administrative phone
*/
public interface FinancialsPhoneWebRequestController extends Serializable {
- /**
- * Returns a list of all mobile numbers. For performance reasons, the
- * controller (bean) should be application-scoped as from user to user
- * nothing changes. And the controller's post-construct method should load
- * all numbers and cache it in the controller.
- * <p>
- * @return List of all mobile numbers
- */
- List<DialableMobileNumber> allMobileNumbers ();
-
- /**
- * Returns a list of all fax numbers. For performance reasons, the
- * controller (bean) should be application-scoped as from user to user
- * nothing changes. And the controller's post-construct method should load
- * all numbers and cache it in the controller.
- * <p>
- * @return List of all fax numbers
- */
- List<DialableFaxNumber> allFaxNumbers ();
-
- /**
- * Returns a list of all land-line numbers. For performance reasons, the
- * controller (bean) should be application-scoped as from user to user
- * nothing changes. And the controller's post-construct method should load
- * all numbers and cache it in the controller.
- * <p>
- * @return List of all land-line numbers
- */
- List<DialableLandLineNumber> allLandLineNumbers ();
-
- /**
- * Finds a fax entry by given id number
- * <p>
- * @param faxNumberId Fax entry id number
- * <p>
- * @return A valid fax instance
- * <p>
- * @throws PhoneEntityNotFoundException If the entity was not found
- */
- DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException;
-
- /**
- * Finds a land-line entry by given id number
- * <p>
- * @param landLineNumberId Land-line entry id number
- * <p>
- * @return A valid land-line instance
- * <p>
- * @throws PhoneEntityNotFoundException If the entity was not found
- */
- DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException;
-
- /**
- * Finds a mobile entry by given id number
- * <p>
- * @param mobileNumberId Mobile entry id number
- * <p>
- * @return A valid mobile instance
- * <p>
- * @throws PhoneEntityNotFoundException If the entity was not found
- */
- DialableMobileNumber findMobileNumberById (Long mobileNumberId) throws PhoneEntityNotFoundException;
-
}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.phone.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.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
+import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
+import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
+import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
+import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
+
+/**
+ * Administrative listing controller (bean) for phone numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("phoneListController")
+@ViewScoped
+public class FinancialsPhoneListWebViewBean extends BaseFinancialsBean implements FinancialsPhoneListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 491_058_674_675_690_107L;
+
+ /**
+ * A list of all fax numbers
+ */
+ private final List<DialableFaxNumber> allFaxNumbers;
+
+ /**
+ * A list of all land-line numbers
+ */
+ private final List<DialableLandLineNumber> allLandLineNumbers;
+
+ /**
+ * All fax numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "faxNumberCache")
+ private transient Cache<Long, DialableFaxNumber> faxNumberCache;
+
+ /**
+ * A list of filtered fax numbers
+ */
+ private List<DialableFaxNumber> filteredFaxNumbers;
+
+ /**
+ * A list of filtered land-line numbers
+ */
+ private List<DialableLandLineNumber> filteredLandLineNumbers;
+
+ /**
+ * All land-line numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "landLineNumberCache")
+ private transient Cache<Long, DialableLandLineNumber> landLineNumberCache;
+
+ /**
+ * General EJB for phone numbers
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
+ private PhoneSessionBeanRemote phoneBean;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsPhoneListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Initialize lists
+ this.allFaxNumbers = new LinkedList<>();
+ this.allLandLineNumbers = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.updateContactPhoneNumbers(event.getAddedContact());
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a fax
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent 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.getDeletedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedFaxNumber is null"); //NOI18N
+ } else if (event.getDeletedFaxNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.deletedFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getDeletedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedFaxNumber(), event.getDeletedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.getAllFaxNumbers().remove(event.getDeletedFaxNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a land-line
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent 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.getDeletedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedLandLineNumber is null"); //NOI18N
+ } else if (event.getDeletedLandLineNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.deletedLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getDeletedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedLandLineNumber(), event.getDeletedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.getAllLandLineNumbers().remove(event.getDeletedLandLineNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a fax
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedFaxNumberEvent (@Observes final ObservableAdminLinkedFaxNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactFaxNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactFaxNumber is null"); //NOI18N
+ } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactFaxNumber.phoneId={0} is invalid", event.getContact().getContactFaxNumber().getPhoneId())); //NOI18N
+ } else if (event.getLinkedFaxNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedFaxNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedFaxNumber().getPhoneId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddFaxNumber(event.getContact().getContactFaxNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a
+ * land-line number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedLandLineNumberEvent (@Observes final ObservableAdminLinkedLandLineNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactLandLineNumber is null"); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactLandLineNumber.phoneId={0} is invalid", event.getContact().getContactLandLineNumber().getPhoneId())); //NOI18N
+ } else if (event.getLinkedLandLineNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedLandLineNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedLandLineNumber().getPhoneId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddLandLineNumber(event.getContact().getContactLandLineNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated contact
+ * data.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent 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();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a fax
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent 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.getUpdatedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedFaxNumber is null"); //NOI18N
+ } else if (event.getUpdatedFaxNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.updatedFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getUpdatedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedFaxNumber(), event.getUpdatedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddFaxNumber(event.getUpdatedFaxNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a land-line
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent 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.getUpdatedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedLandLineNumber is null"); //NOI18N
+ } else if (event.getUpdatedLandLineNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.updatedLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getUpdatedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedLandLineNumber(), event.getUpdatedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddLandLineNumber(event.getUpdatedLandLineNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ @Override
+ public DialableFaxNumber findFaxNumberById (final Long phoneId) throws PhoneEntityNotFoundException {
+ // Validate paramter
+ if (null == phoneId) {
+ // Throw NPE
+ throw new NullPointerException("phoneId is null"); //NOI18N
+ } else if (phoneId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("phoneId=" + phoneId + " is invalid."); //NOI18N
+ } else if (!this.faxNumberCache.containsKey(phoneId)) {
+ // Not found
+ throw new PhoneEntityNotFoundException(phoneId);
+ }
+
+ // Get it from cache
+ final DialableFaxNumber faxNumber = this.faxNumberCache.get(phoneId);
+
+ // Return it
+ return faxNumber;
+ }
+
+ @Override
+ public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
+ // Validate paramter
+ if (null == landLineNumberId) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumberId is null"); //NOI18N
+ } else if (landLineNumberId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is invalid.", landLineNumberId)); //NOI18N
+ } else if (!this.landLineNumberCache.containsKey(landLineNumberId)) {
+ // Not found
+ throw new PhoneEntityNotFoundException(landLineNumberId);
+ }
+
+ // Get it from cache
+ final DialableLandLineNumber landLineNumber = this.landLineNumberCache.get(landLineNumberId);
+
+ // Return it
+ return landLineNumber;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableFaxNumber> getAllFaxNumbers () {
+ return this.allFaxNumbers;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableLandLineNumber> getAllLandLineNumbers () {
+ return this.allLandLineNumbers;
+ }
+
+ /**
+ * Getter for filtered fax number list
+ * <p>
+ * @return Filtered fax number list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableFaxNumber> getFilteredFaxNumbers () {
+ return this.filteredFaxNumbers;
+ }
+
+ /**
+ * Setter for filtered fax number list
+ *
+ * @param filteredFaxNumbers Filtered fax number list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredFaxNumbers (final List<DialableFaxNumber> filteredFaxNumbers) {
+ this.filteredFaxNumbers = filteredFaxNumbers;
+ }
+
+ /**
+ * Getter for filtered land-line number list
+ * <p>
+ * @return Filtered land-line number list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableLandLineNumber> getFilteredLandLineNumbers () {
+ return this.filteredLandLineNumbers;
+ }
+
+ /**
+ * Setter for filtered land-line number list
+ *
+ * @param filteredLandLineNumbers Filtered land-line number list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredLandLineNumbers (final List<DialableLandLineNumber> filteredLandLineNumbers) {
+ this.filteredLandLineNumbers = filteredLandLineNumbers;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.faxNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableFaxNumber currentNumber : this.phoneBean.fetchAllFaxNumbers()) {
+ // Add it to cache
+ this.faxNumberCache.put(currentNumber.getPhoneId(), currentNumber);
+ }
+ }
+
+ // Is cache there?
+ if (!this.landLineNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableLandLineNumber currentNumber : this.phoneBean.fetchAllLandLineNumbers()) {
+ // Add it to cache
+ this.landLineNumberCache.put(currentNumber.getPhoneId(), currentNumber);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.faxNumberCache.iterator().hasNext()) && (this.getAllFaxNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableFaxNumber> currentEntry : this.faxNumberCache) {
+ // Add to list
+ this.getAllFaxNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllFaxNumbers().sort(new Comparator<DialableFaxNumber>() {
+ @Override
+ public int compare (final DialableFaxNumber faxNumber1, final DialableFaxNumber faxNumber2) {
+ return faxNumber1.getPhoneId() > faxNumber2.getPhoneId() ? 1 : faxNumber1.getPhoneId() < faxNumber2.getPhoneId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredFaxNumbers(this.getAllFaxNumbers());
+ }
+
+ // Is cache filled and list is empty
+ if ((this.landLineNumberCache.iterator().hasNext()) && (this.getAllLandLineNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableLandLineNumber> currentEntry : this.landLineNumberCache) {
+ // Add to list
+ this.getAllLandLineNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllLandLineNumbers().sort(new Comparator<DialableLandLineNumber>() {
+ @Override
+ public int compare (final DialableLandLineNumber landLineNumber1, final DialableLandLineNumber landLineNumber2) {
+ return landLineNumber1.getPhoneId() > landLineNumber2.getPhoneId() ? 1 : landLineNumber1.getPhoneId() < landLineNumber2.getPhoneId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredLandLineNumbers(this.getAllLandLineNumbers());
+ }
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Uniquely add given fax number to this bean's list. First remove the old
+ * instance (by id number), then re-add it again.
+ * <p>
+ * @param faxNumber number to add
+ */
+ private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
+ // Make sure the parameter is valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllFaxNumbers().remove(faxNumber)) {
+ // Did not work, try by id number
+ for (final DialableFaxNumber currentNumber : this.getAllFaxNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getPhoneId(), faxNumber.getPhoneId())) {
+ // Found it
+ this.getAllFaxNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllFaxNumbers().add(faxNumber);
+ }
+
+ /**
+ * Uniquely add given land-line number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param landLineNumber Land-line number to add
+ */
+ private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
+ // Make sure the parameter is valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllLandLineNumbers().remove(landLineNumber)) {
+ // Did not work, try by id number
+ for (final DialableLandLineNumber currentNumber : this.getAllLandLineNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getPhoneId(), landLineNumber.getPhoneId())) {
+ // Found it
+ this.getAllLandLineNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllLandLineNumbers().add(landLineNumber);
+ }
+
+ /**
+ * Updates given contact's mobile, land-line and fax number
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactPhoneNumbers (final Contact contact) {
+ // Parameter must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id number is not valid
+ }
+
+ // Is land-line set?
+ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Unique-add it
+ this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
+ }
+
+ // Is fax set?
+ if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Unique-add it
+ this.uniqueAddFaxNumber(contact.getContactFaxNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.phone.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsPhoneListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all fax numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all fax numbers
+ */
+ List<DialableFaxNumber> getAllFaxNumbers ();
+
+ /**
+ * Returns a list of all land-line numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all land-line numbers
+ */
+ List<DialableLandLineNumber> getAllLandLineNumbers ();
+
+ /**
+ * Finds a fax entry by given id number
+ * <p>
+ * @param faxNumberId Fax entry id number
+ * <p>
+ * @return A valid fax instance
+ * <p>
+ * @throws PhoneEntityNotFoundException If the entity was not found
+ */
+ DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException;
+
+ /**
+ * Finds a land-line entry by given id number
+ * <p>
+ * @param landLineNumberId Land-line entry id number
+ * <p>
+ * @return A valid land-line instance
+ * <p>
+ * @throws PhoneEntityNotFoundException If the entity was not found
+ */
+ DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException;
+
+}
import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent;
import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
-import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.user.update.post.AdminPostUserDataUpdatedEvent;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.juserlogincore.exceptions.UserPasswordRepeatMismatchException;
import org.mxchange.juserlogincore.login.UserLoginUtils;
+import org.mxchange.jusercore.events.user.update.post.ObservableAdminPostUserDataUpdatedEvent;
/**
* A user bean (controller)
*/
@Inject
@Any
- private Event<ObservableAdminUpdatedUserDataEvent> updatedUserDataEvent;
+ private Event<ObservableAdminPostUserDataUpdatedEvent> updatedUserDataEvent;
/**
* User instance
final User updatedUser = this.userBean.updateUserData(this.getUser());
// Fire event
- this.updatedUserDataEvent.fire(new AdminUpdatedUserDataEvent(updatedUser));
+ this.updatedUserDataEvent.fire(new AdminPostUserDataUpdatedEvent(updatedUser));
}
/**
*/
package org.mxchange.jfinancials.beans.user;
-import java.text.MessageFormat;
-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.context.FacesContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
import javax.inject.Named;
-import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
-import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
-import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
-import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
-import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
-import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent;
-import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
-import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.model.user.LoginUser;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
-import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
-import org.mxchange.juserlogincore.login.UserLoginUtils;
/**
* A user bean (controller)
*/
private static final long serialVersionUID = 542_145_347_916L;
- /**
- * General contact controller
- */
- @Inject
- private FinancialsContactWebRequestController contactController;
-
- /**
- * Features controller
- */
- @Inject
- private FinancialsFeaturesWebApplicationController featureController;
-
- /**
- * Localization controller
- */
- @Inject
- private FinancialsLocalizationSessionController localizationController;
-
- /**
- * Event being fired when user updated personal data
- */
- @Inject
- @Any
- private Event<ObservableUpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
-
- /**
- * Remote user bean
- */
- @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
-
- /**
- * User id
- */
- private Long userId;
-
- /**
- * Login controller (bean)
- */
- @Inject
- private FinancialsUserLoginWebSessionController userLoginController;
-
- /**
- * User name
- */
- private String userName;
-
- /**
- * User password (clear-text from web form)
- */
- private String userPassword;
-
- /**
- * User password repeated (clear-text from web form)
- */
- private String userPasswordRepeat;
-
- /**
- * Whether the user wants a public profile
- */
- private ProfileMode userProfileMode;
-
/**
* Default constructor
*/
super();
}
- /**
- * Event observer for newly added users by administrator
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addedUser is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
- }
-
- // Set user id again
- this.setUserId(event.getAddedUser().getUserId());
- }
-
- /**
- * Event observer for linked users with existing contact data
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent 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.getLinkedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.linkedUser is null"); //NOI18N
- } else if (event.getLinkedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
- } else if (event.getLinkedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
- }
-
- // Set user id again
- this.setUserId(event.getLinkedUser().getUserId());
- }
-
- /**
- * Event observer for when a bean helper has successfully created a user
- * instance, means the user exists. If the user does not exist, this event
- * should not fire but instead a proper exception must be thrown.
- * <p>
- * @param event User created event
- */
- public void afterCreatedUserEvent (@Observes final ObservableCreatedUserEvent event) {
- // Is the instance valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getCreatedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.createdUser is null"); //NOI18N
- } else if (event.getCreatedUser().getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("event.createdUser.userId is null"); //NOI18N
- } else if (event.getCreatedUser().getUserId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("event.createdUser.userId={0} is not valid", event.getCreatedUser().getUserId())); //NOI18N
- }
-
- // Get user instance
- final User user = event.getCreatedUser();
-
- // Set all fields here
- this.copyUser(user);
- }
-
- /**
- * Event observer for logged-in user
- * <p>
- * @param event Event instance
- */
- public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent 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.getLoggedInUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.registeredUser is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
- }
-
- // "Cache" user instance
- final User loggedInUser = event.getLoggedInUser();
-
- // Copy all data to this bean
- this.copyUser(loggedInUser);
- }
-
- /**
- * Event observer for user password changes
- * <p>
- * @param event Event being fired
- */
- public void afterUserPasswordChangedEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
- // Is it valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUserPassword() == null) {
- // Throw NPE
- throw new NullPointerException("event.userPassword is null"); //NOI18N
- } else if (event.getUserPassword().isEmpty()) {
- // Throw NPE
- throw new IllegalArgumentException("event.userPassword is empty"); //NOI18N
- }
-
- // Set it here
- this.setUserPassword(event.getUserPassword());
- this.setUserPasswordRepeat(event.getUserPassword());
- }
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent 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.getRegisteredUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.registeredUser is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
- }
-
- // Get user instance
- final User registeredUser = event.getRegisteredUser();
-
- // Copy all data from registered->user
- this.copyUser(registeredUser);
-
- // Set user id again
- this.setUserId(registeredUser.getUserId());
- }
-
- /**
- * Event observer for when a user name should be cleared
- * <p>
- * @param event Event being fired
- */
- public void clearUserNameEvent (@Observes final ObservableClearUserNameEvent event) {
- // Is it valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- }
-
- // Clear it
- this.clearUserName();
- }
-
- /**
- * Event observer for when both user passwords should be cleared
- * <p>
- * @param event Event being fired
- */
- public void clearUserPasswordEvent (@Observes final ObservableClearUserPasswordEvent event) {
- // Is it valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- }
-
- // Clear it
- this.clearUserPasswords();
- }
-
- @Override
- public User createUserInstance (final boolean createContactData) {
- // Required personal data must be set
- assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
-
- // Is user name required?
- if (!this.isUserNameRequired()) {
- // Generate pseudo-random user name
- // @TODO Refacture this to avoid EJB call
- final String randomName = this.userBean.generateRandomUserName();
-
- // Set it and inivisible profile
- this.setUserName(randomName);
- this.setUserProfileMode(ProfileMode.INVISIBLE);
-
- // Generate random password
- final String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
-
- // Set random password
- this.setUserPassword(randomPassword);
- this.setUserPasswordRepeat(randomPassword);
- }
-
- // Create new user instance
- final User user = new LoginUser();
-
- // Set user name profile mode and locale
- user.setUserName(this.getUserName());
- user.setUserProfileMode(this.getUserProfileMode());
- user.setUserLocale(this.localizationController.getLocale());
-
- // Is multiple registration page
- if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
- // Create contact instance
- final Contact contact = this.contactController.createContactInstance();
-
- // Set contact in user
- user.setUserContact(contact);
- }
-
- // Return it
- return user;
- }
-
- @Override
- public User createUserLogin () {
- // Is all data set?
- if (this.getUserName() == null) {
- // Throw NPE
- throw new NullPointerException("userName is null"); //NOI18N
- } else if (this.getUserName().isEmpty()) {
- // Is empty
- throw new IllegalStateException("userName is empty."); //NOI18N
- }
-
- // Create new user instance
- final User user = new LoginUser();
-
- // Update all data ...
- user.setUserName(this.getUserName());
-
- // Return the new instance
- return user;
- }
-
- @Override
- public String doChangePersonalData () {
- // This method shall only be called if the user is logged-in
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged-in
- throw new IllegalStateException("User is not logged-in"); //NOI18N
- } else if (!this.isRequiredChangePersonalDataSet()) {
- // Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
- } else if (!this.featureController.isFeatureEnabled("change_user_personal_data")) { //NOI18N
- // Editing is not allowed
- throw new IllegalStateException("User tried to edit personal data."); //NOI18N
- }
-
- // Get user instance
- final User user = this.userLoginController.getLoggedInUser();
-
- // Copy contact data to contact instance
- this.contactController.updateContactDataFromController(user.getUserContact());
-
- // It should be there, so run some tests on it
- assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N
- assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N
- assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
- assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
- assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
- assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
-
- // Update all fields
- user.setUserProfileMode(this.getUserProfileMode());
-
- // Send it to the EJB
- final User updatedUser = this.userBean.updateUserPersonalData(user);
-
- // Fire event
- this.updatedPersonalDataEvent.fire(new UpdatedUserPersonalDataEvent(updatedUser));
-
- // All fine
- return "user_contact_data_saved"; //NOI18N
- }
-
- /**
- * Getter for user id
- * <p>
- * @return User id
- */
- public Long getUserId () {
- return this.userId;
- }
-
- /**
- * Setter for user id
- * <p>
- * @param userId User id
- */
- public void setUserId (final Long userId) {
- this.userId = userId;
- }
-
- /**
- * Getter for user name
- * <p>
- * @return User name
- */
- public String getUserName () {
- return this.userName;
- }
-
- /**
- * Setter for user name
- * <p>
- * @param userName User name
- */
- public void setUserName (final String userName) {
- this.userName = userName;
- }
-
- @Override
- public String getUserPassword () {
- return this.userPassword;
- }
-
- /**
- * Setter for clear-text user password
- * <p>
- * @param userPassword Clear-text user password
- */
- public void setUserPassword (final String userPassword) {
- this.userPassword = userPassword;
- }
-
- /**
- * Getter for clear-text user password repeated
- * <p>
- * @return Clear-text user password repeated
- */
- public String getUserPasswordRepeat () {
- return this.userPasswordRepeat;
- }
-
- /**
- * Setter for clear-text user password repeated
- * <p>
- * @param userPasswordRepeat Clear-text user password repeated
- */
- public void setUserPasswordRepeat (final String userPasswordRepeat) {
- this.userPasswordRepeat = userPasswordRepeat;
- }
-
- /**
- * Getter for user profile mode
- * <p>
- * @return User profile mode
- */
- public ProfileMode getUserProfileMode () {
- return this.userProfileMode;
- }
-
- /**
- * Setter for user profile mode
- * <p>
- * @param userProfileMode User profile mode
- */
- public void setUserProfileMode (final ProfileMode userProfileMode) {
- this.userProfileMode = userProfileMode;
- }
-
- @Override
- public boolean ifBothPasswordsEmptyAllowed () {
- // Check feature first
- return ((this.featureController.isFeatureEnabled("allow_user_registration_empty_password")) && //NOI18N
- ((this.getUserPassword() == null) || (this.getUserPassword().isEmpty())) &&
- ((this.getUserPasswordRepeat() == null) || (this.getUserPasswordRepeat().isEmpty())));
- }
-
- @Override
- public boolean isRequiredChangePersonalDataSet () {
- return ((this.getUserProfileMode() != null) &&
- (this.getUserName() != null) && (!this.getUserName().isEmpty()) &&
- (this.contactController.isRequiredChangePersonalDataSet()));
- }
-
- @Override
- public boolean isRequiredPersonalDataSet () {
- if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
- // Multiple registration page
- return this.contactController.isRequiredPersonalDataSet();
- } else {
- // Single registration page
- return (((this.getUserName() != null) || (!this.isUserNameRequired())) &&
- (this.getUserProfileMode() != null) &&
- (this.contactController.isRequiredPersonalDataSet()) &&
- (this.getUserPassword() != null) &&
- (this.getUserPasswordRepeat() != null));
- }
- }
-
- @Override
- public boolean isSamePasswordEntered () {
- return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
- }
-
- @Override
- public boolean isUserIdEmpty () {
- return ((this.getUserId() == null) || (this.getUserId() == 0));
- }
-
- @Override
- public boolean isUserNameRequired () {
- // Get context parameter
- final String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_user_login_require_user_name"); //NOI18N
-
- // Is it set?
- final boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
-
- // Return value
- return isRequired;
- }
-
- /**
- * Clears user name
- */
- private void clearUserName () {
- // Clear it
- this.setUserName(null);
- }
-
- /**
- * Clears both user passwords
- */
- private void clearUserPasswords () {
- // Clear both
- this.setUserPassword(null);
- this.setUserPasswordRepeat(null);
- }
-
- /**
- * Copies given user into the controller
- * <p>
- * @param user User instance
- */
- private void copyUser (final User user) {
- // Make sure the instance is valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
- }
-
- // Copy all fields:
- // - base data
- this.setUserId(user.getUserId());
- this.setUserProfileMode(user.getUserProfileMode());
- }
-
}
package org.mxchange.jfinancials.beans.user;
import java.io.Serializable;
-import org.mxchange.jusercore.model.user.User;
/**
* An interface for user beans
@Deprecated
public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
- /**
- * Getter for clear-text user password
- * <p>
- * @return Clear-text user password
- */
- String getUserPassword ();
-
- /**
- * Checks if both user passwords are left empty and if this is enabled
- * (allowed) in context parameter. If true, the calling bean should create a
- * random password (preferable with UserUtils.createRandomPassword() and set
- * it in both user password fields.
- * <p>
- * @return Whether empty passwords are allowed
- */
- boolean ifBothPasswordsEmptyAllowed ();
-
- /**
- * Creates an instance from all properties
- * <p>
- * @param createContactData Whether contact data should be created
- * <p>
- * @return A user instance
- */
- User createUserInstance (final boolean createContactData);
-
- /**
- * Creates a user instance for login phase
- * <p>
- * @return User instance
- */
- User createUserLogin ();
-
- /**
- * Checks whether all required personal data is set
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredPersonalDataSet ();
-
- /**
- * Checks whether all required personal data is set for changing them
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredChangePersonalDataSet ();
-
- /**
- * Checks whether same passwords has been entered
- * <p>
- * @return Whether same passwords has been entered
- */
- boolean isSamePasswordEntered ();
-
- /**
- * Checks if the user id is empty
- * <p>
- * @return Whether the user id is empty
- */
- boolean isUserIdEmpty ();
-
- /**
- * Changes logged-in user's personal data if the current password matches
- * and TAC + privacy statement has been accepted.
- * <p>
- * @return New target page
- */
- String doChangePersonalData ();
-
- /**
- * Checks whether this application requires a user name to be entered.
- * Otherwise a random name like "userXXXXX" is generated
- * <p>
- * @return Whether this application requires a user name
- */
- boolean isUserNameRequired ();
-
}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.user.action;
+
+import java.text.MessageFormat;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jusercore.events.user.update.post.ObservablePostUserPersonalDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.post.PostUserPersonalDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.pre.PreUserPersonalDataUpdatedEvent;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
+
+/**
+ * A user action bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userActionController")
+@RequestScoped
+public class FinancialsUserActionWebRequestBean extends BaseFinancialsBean implements FinancialsUserActionWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_920L;
+
+ /**
+ * General contact controller
+ */
+ @Inject
+ private FinancialsContactWebRequestController contactController;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * Event being fired when user updated personal data
+ */
+ @Inject
+ @Any
+ private Event<ObservablePostUserPersonalDataUpdatedEvent> postUpdatedPersonalDataEvent;
+
+ /**
+ * Event being fired when user updated personal data
+ */
+ @Inject
+ @Any
+ private Event<ObservablePreUserPersonalDataUpdatedEvent> preUpdatedPersonalDataEvent;
+
+ /**
+ * Remote user bean
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * Login controller (bean)
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserActionWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ @Override
+ public String doChangePersonalData () {
+ // This method shall only be called if the user is logged-in
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (!this.contactController.isRequiredChangePersonalDataSet()) {
+ // Not all required fields are set
+ throw new FaceletException("Not all required fields are set."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+ } else if (!this.featureController.isFeatureEnabled("change_user_personal_data")) { //NOI18N
+ // Editing is not allowed
+ throw new IllegalStateException("User tried to edit personal data."); //NOI18N
+ }
+
+ // Get user instance
+ final User user = this.userLoginController.getLoggedInUser();
+
+ // Fire pre-update event
+ this.preUpdatedPersonalDataEvent.fire(new PreUserPersonalDataUpdatedEvent(user));
+
+ // It should be there, so run some tests on it
+ assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N
+ assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N
+ assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
+ assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
+ assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
+ assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
+
+ // Send it to the EJB
+ final User updatedUser = this.userBean.updateUserPersonalData(user);
+
+ // Fire post-update event
+ this.postUpdatedPersonalDataEvent.fire(new PostUserPersonalDataUpdatedEvent(updatedUser));
+
+ // All fine
+ return "user_contact_data_saved"; //NOI18N
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.user.action;
+
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsUserActionWebRequestController extends Serializable {
+
+ /**
+ * Minimum password length
+ * <p>
+ * @deprecated Better set as context parameter
+ */
+ @Deprecated
+ public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
+ /**
+ * Changes logged-in user's personal data if the current password matches
+ * and TAC + privacy statement has been accepted.
+ * <p>
+ * @return New target page
+ */
+ String doChangePersonalData ();
+
+}
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
-import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.activity.LogableUserActivity;
import org.mxchange.jusercore.model.user.activity.UserActivityLog;
import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.juserlogincore.events.resendlink.ObservableUserResendLinkAccountEvent;
import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.update.post.ObservableAdminPostUserDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.post.ObservablePostUserPersonalDataUpdatedEvent;
/**
* A controller (bean) for user activity log
* <p>
* @param event Event being updated
*/
- public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
+ public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminPostUserDataUpdatedEvent event) {
// Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
* <p>
* @param event Event being fired
*/
- public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
+ public void afterUserUpdatedPersonalDataEvent (@Observes final ObservablePostUserPersonalDataUpdatedEvent event) {
// Check parameter
if (null == event) {
// Throw NPE
*/
package org.mxchange.jfinancials.beans.user.email_address;
-import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.user.email_address.list.FinancialsEmailChangeListWebViewController;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
import org.mxchange.jusercore.model.email_address.EmailAddressChange;
private UserEmailChangeSessionBeanRemote emailChangeBean;
/**
- * Features controller
+ * Controller for listing email address changes
*/
@Inject
- private FinancialsFeaturesWebApplicationController featureController;
+ private FinancialsEmailChangeListWebViewController emailChangeListController;
/**
- * Local list of already queued email addresses
+ * Features controller
*/
@Inject
- @NamedCache (cacheName = "queuedEmailCache")
- private Cache<String, Boolean> queuedEmailCache;
+ private FinancialsFeaturesWebApplicationController featureController;
/**
* Login controller (bean)
assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
// Check if the email address is already enqueued
- if (this.isEmailAddressQueued(this.getEmailAddress())) {
+ if (this.emailChangeListController.isEmailAddressQueued(this.getEmailAddress())) {
// Clear both email addresses
this.setEmailAddress(null);
this.setEmailAddressRepeat(null);
this.emailAddressRepeat = emailAddressRepeat;
}
- /**
- * Post-construction
- */
- @PostConstruct
- public void init () {
- // Is cache there?
- if (!this.queuedEmailCache.iterator().hasNext()) {
- // Add all
- for (final String currentEmailAddress : this.emailChangeBean.allQueuedAddresses()) {
- // Add it to cache
- this.queuedEmailCache.put(currentEmailAddress, Boolean.TRUE);
- }
- }
- }
-
@Override
public boolean isRequiredChangeEmailAddressSet () {
return ((this.getEmailAddress() != null) &&
this.setEmailAddressRepeat(null);
}
- /**
- * Checks if given email address has already been queued. First a local list
- * is being checked, if not found, the EJB is called. Only if found, the
- * result is "cached" in the list.
- * <p>
- * @param emailAddress Email address to verify
- * <p>
- * @return Whether the email address in field emailAddress is already queued
- */
- private boolean isEmailAddressQueued (final String emailAddress) {
- // It should be there
- assert (emailAddress != null) : "emailAddress should not be null"; //NOI18N
- assert (!emailAddress.trim().isEmpty()) : "emailAddress should not be empty"; //NOI18N
-
- // Check list
- if (this.queuedEmailCache.containsKey(emailAddress)) {
- // Okay, found it
- return true;
- }
-
- // Check EJB
- final boolean isQueued = this.emailChangeBean.isEmailAddressEnqueued(emailAddress);
-
- // Is it there?
- if (isQueued) {
- // Add to list
- this.queuedEmailCache.put(emailAddress, Boolean.TRUE);
- }
-
- // Return status
- return isQueued;
- }
-
}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.user.email_address.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
+import org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote;
+
+/**
+ * A view-scoped bean for listing email address changes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("emailChangeListController")
+@ViewScoped
+public class FinancialsEmailChangeListWebViewBean extends BaseFinancialsBean implements FinancialsEmailChangeListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 186_078_724_659_154L;
+
+ /**
+ * A list of all mobile numbers
+ */
+ private final List<ChangeableEmailAddress> allEmailAddressChanges;
+
+ /**
+ * Remote email change bean
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/userEmailChange!org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote")
+ private UserEmailChangeSessionBeanRemote emailChangeBean;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * A list of filtered mobile numbers
+ */
+ private List<ChangeableEmailAddress> filteredEmailAddressChanges;
+
+ /**
+ * Local list of already queued email addresses
+ */
+ @Inject
+ @NamedCache (cacheName = "queuedEmailCache")
+ private transient Cache<Long, ChangeableEmailAddress> queuedEmailCache;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsEmailChangeListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Initialize list
+ this.allEmailAddressChanges = new LinkedList<>();
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<ChangeableEmailAddress> getAllEmailAddressChanges () {
+ return this.allEmailAddressChanges;
+ }
+
+ /**
+ * Getter for filtered email address changed
+ * <p>
+ * @return Filtered email address changed
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<ChangeableEmailAddress> getFilteredEmailAddressChanges () {
+ return this.filteredEmailAddressChanges;
+ }
+
+ /**
+ * Setter for filtered email address changed
+ * <p>
+ * @param filteredEmailAddressChanges Filtered email address changed
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredEmailAddressChanges (final List<ChangeableEmailAddress> filteredEmailAddressChanges) {
+ this.filteredEmailAddressChanges = filteredEmailAddressChanges;
+ }
+
+ /**
+ * Post-construction
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.queuedEmailCache.iterator().hasNext()) {
+ // Add all
+ for (final ChangeableEmailAddress currentEmailAddress : this.emailChangeBean.fetchAllQueuedAddressChanges()) {
+ // Add it to cache
+ this.queuedEmailCache.put(currentEmailAddress.getEmailChangeId(), currentEmailAddress);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.queuedEmailCache.iterator().hasNext()) && (this.getAllEmailAddressChanges().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, ChangeableEmailAddress> currentEntry : this.queuedEmailCache) {
+ // Add to list
+ this.getAllEmailAddressChanges().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllEmailAddressChanges().sort(new Comparator<ChangeableEmailAddress>() {
+ @Override
+ public int compare (final ChangeableEmailAddress queuedEmail1, final ChangeableEmailAddress queuedEmail2) {
+ return queuedEmail1.getEmailChangeId() > queuedEmail2.getEmailChangeId() ? 1 : queuedEmail1.getEmailChangeId() < queuedEmail2.getEmailChangeId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredEmailAddressChanges(this.getAllEmailAddressChanges());
+ }
+ }
+
+ @Override
+ public boolean isEmailAddressQueued (final String emailAddress) {
+ // Check if parameter is valid
+ 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;
+
+ // Iterate through whole list
+ for (final ChangeableEmailAddress address : this.getAllEmailAddressChanges()) {
+ // Does current match?
+ if (emailAddress.equals(address.getEmailAddress())) {
+ // Yes, set flag and abort iteration
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return isFound;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.user.email_address.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
+
+/**
+ * An interface for an email change controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsEmailChangeListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all email address changes. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all mobile numbers
+ */
+ List<ChangeableEmailAddress> getAllEmailAddressChanges ();
+
+ /**
+ * Checks if given email address has already been queued. First a local list
+ * is being checked, if not found, the EJB is called. Only if found, the
+ * result is "cached" in the list.
+ * <p>
+ * @param emailAddress Email address to verify
+ * <p>
+ * @return Whether the email address in field emailAddress is already queued
+ */
+ boolean isEmailAddressQueued (final String emailAddress);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 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.user.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.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
+import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
+import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
+import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.update.post.ObservableAdminPostUserDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.post.ObservablePostUserPersonalDataUpdatedEvent;
+
+/**
+ * A user list bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userListController")
+@ViewScoped
+public class FinancialsUserListWebViewBean extends BaseFinancialsBean implements FinancialsUserListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_918L;
+
+ /**
+ * List of all users
+ */
+ private final List<User> allUsers;
+
+ /**
+ * List of filtered users
+ */
+ private List<User> filteredUsers;
+
+ /**
+ * Selected user instance
+ */
+ private User selectedUser;
+
+ /**
+ * Remote user bean
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * A list of all user profiles
+ */
+ @Inject
+ @NamedCache (cacheName = "userCache")
+ private transient Cache<Long, User> userCache;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allUsers = new LinkedList<>();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getAddedUser());
+ }
+
+ /**
+ * Event observer for deleted user accounts (by administrator)
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent 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.getDeletedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedUser is null"); //NOI18N
+ } else if (event.getDeletedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.deletedUser.userId is null"); //NOI18N
+ } else if (event.getDeletedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedUser(), event.getDeletedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.removeFromList(event.getDeletedUser());
+ }
+
+ /**
+ * Event observer for linked users with existing contact data
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent 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.getLinkedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.linkedUser is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getLinkedUser());
+ }
+
+ /**
+ * Event observer for locked users
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent 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.getLockedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.lockedUser is null"); //NOI18N
+ } else if (event.getLockedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N
+ } else if (event.getLockedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getLockedUser());
+ }
+
+ /**
+ * Event observer for unlocked users
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent 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.getUnlockedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlockedUser is null"); //NOI18N
+ } else if (event.getUnlockedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N
+ } else if (event.getUnlockedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUnlockedUser());
+ }
+
+ /**
+ * Event observer for updated user data by administrator
+ * <p>
+ * @param event Event being updated
+ */
+ public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminPostUserDataUpdatedEvent 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.getUpdatedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUpdatedUser());
+ }
+
+ /**
+ * Event observer when user confirmed account.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent 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.getConfirmedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.confirmedUser is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getConfirmedUser());
+ }
+
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent 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.getRegisteredUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getRegisteredUser());
+ }
+
+ /**
+ * Method being call after user's password has been updated (and history
+ * entry has been created).
+ * <p>
+ * @param event Event being observed
+ */
+ public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
+ // Check parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getPasswordHistory() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.passwordHistory is null"); //NOI18N
+ } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
+ // ... and again
+ throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
+ } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
+ // Invalid value
+ throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
+ }
+
+ /**
+ * Listens to fired event when user updated personal data
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserUpdatedPersonalDataEvent (@Observes final ObservablePostUserPersonalDataUpdatedEvent event) {
+ // Check parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() == null) {
+ // ... and again
+ throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() < 1) {
+ // Invalid value
+ throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUpdatedUser());
+ }
+
+ @Override
+ public User findUserById (final Long userId) throws UserNotFoundException {
+ // Validate parameter
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
+ } else if (!this.userCache.containsKey(userId)) {
+ // Not found
+ throw new UserNotFoundException(userId);
+ }
+
+ // Get it from cache
+ final User user = this.userCache.get(userId);
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> getAllUsers () {
+ return this.allUsers;
+ }
+
+ /**
+ * Getter for filtered users list
+ * <p>
+ * @return Filtered users list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> getFilteredUsers () {
+ return this.filteredUsers;
+ }
+
+ /**
+ * Setter for filtered users list
+ * <p>
+ * @param filteredUsers Filtered users list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredUsers (final List<User> filteredUsers) {
+ this.filteredUsers = filteredUsers;
+ }
+
+ /**
+ * Getter for selected user instance
+ * <p>
+ * @return Selected user instance
+ */
+ public User getSelectedUser () {
+ return this.selectedUser;
+ }
+
+ /**
+ * Setter for selected user instance
+ * <p>
+ * @param selectedUser Selected user instance
+ */
+ public void setSelectedUser (final User selectedUser) {
+ this.selectedUser = selectedUser;
+ }
+
+ @Override
+ public boolean ifUserIdExists (final Long userId) {
+ // Validate parameter
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
+ }
+
+ // Check if key is there
+ boolean isFound = this.userCache.containsKey(userId);
+
+ // Return flag
+ return isFound;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.userCache.iterator().hasNext()) {
+ // Add all
+ for (final User user : this.userBean.fetchAllUsers()) {
+ // Add it to cache
+ this.userCache.put(user.getUserId(), user);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.userCache.iterator().hasNext()) && (this.getAllUsers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, User> currentEntry : this.userCache) {
+ // Add to list
+ this.getAllUsers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllUsers().sort(new Comparator<User>() {
+ @Override
+ public int compare (final User user1, final User user2) {
+ return user1.getUserId() > user2.getUserId() ? 1 : user1.getUserId() < user2.getUserId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredUsers(this.getAllUsers());
+ }
+ }
+
+ @Override
+ public boolean isUserNameRegistered (final User user) {
+ // Default is not found
+ boolean isFound = false;
+
+ // Determine it
+ for (final User currentUser : this.getAllUsers()) {
+ // Is same name found?
+ if (Objects.equals(user.getUserName(), currentUser.getUserName())) {
+ // Yes, then set flag and abort loop
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return isFound;
+ }
+
+ @Override
+ public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
+ // Parameter must be valid
+ if (null == emailAddress) {
+ // Throw NPE
+ throw new NullPointerException("emailAddress is null"); //NOI18N
+ } else if (emailAddress.isEmpty()) {
+ // Not valid
+ throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+ }
+
+ // Init variable
+ User user = null;
+
+ // Try to lookup it in visible user list
+ for (final Cache.Entry<Long, User> currentUser : this.userCache) {
+ // Contact should be set
+ if (currentUser.getValue().getUserContact() == null) {
+ // Contact is null
+ throw new NullPointerException(MessageFormat.format("currentUser.userContact is null for user id {0}", currentUser.getKey())); //NOI18N
+ } else if (currentUser.getValue().getUserContact().getContactEmailAddress() == null) {
+ // Email address should be set
+ throw new NullPointerException(MessageFormat.format("currentUser.userContact.contactEmailAddress is null for user id {0}", currentUser.getKey())); //NOI18N
+ }
+
+ // Is the email address found?
+ if (Objects.equals(currentUser.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
+ // Copy to other variable
+ user = currentUser.getValue();
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == user) {
+ // Not visible for the current user
+ throw new UserEmailAddressNotFoundException(emailAddress);
+ }
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ public User lookupUserById (final Long userId) throws UserNotFoundException {
+ // Parameter must be valid
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
+ }
+
+ // Init variable
+ User user = null;
+
+ // Try to lookup it in visible user list
+ for (final Cache.Entry<Long, User> currentUser : this.userCache) {
+ // Is the user id found?
+ if (Objects.equals(currentUser.getKey(), userId)) {
+ // Copy to other variable
+ user = currentUser.getValue();
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == user) {
+ // Not visible for the current user
+ throw new UserNotFoundException(userId);
+ }
+
+ // Return it
+ return user;
+ }
+
+ /**
+ * Removes user from all lists
+ * <p>
+ * @param user User to remove
+ */
+ private void removeFromList (final User user) {
+ // Remove it from lists
+ this.getAllUsers().remove(user);
+ this.userCache.remove(user.getUserId());
+ }
+
+ /**
+ * Updates list with given user instance
+ * <p>
+ * @param user User instance
+ */
+ private void updateList (final User user) {
+ // Add/update user
+ this.userCache.put(user.getUserId(), user);
+ this.getAllUsers().add(user);
+ }
+
+}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 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.user.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.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
-import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
-import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
-import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
-import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-
-/**
- * A user list bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("userListController")
-@ViewScoped
-public class FinancialsUserListWebViewtBean extends BaseFinancialsBean implements FinancialsUserListWebViewController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_918L;
-
- /**
- * List of all users
- */
- private final List<User> allUsers;
-
- /**
- * List of filtered users
- */
- private List<User> filteredUsers;
-
- /**
- * Selected user instance
- */
- private User selectedUser;
-
- /**
- * Remote user bean
- */
- @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
-
- /**
- * A list of all user profiles
- */
- @Inject
- @NamedCache (cacheName = "userCache")
- private transient Cache<Long, User> userCache;
-
- /**
- * Default constructor
- */
- public FinancialsUserListWebViewtBean () {
- // Call super constructor
- super();
-
- // Init list
- this.allUsers = new LinkedList<>();
- }
-
- /**
- * Event observer for newly added users by administrator
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addedUser is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getAddedUser());
- }
-
- /**
- * Event observer for deleted user accounts (by administrator)
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent 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.getDeletedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedUser is null"); //NOI18N
- } else if (event.getDeletedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedUser.userId is null"); //NOI18N
- } else if (event.getDeletedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedUser(), event.getDeletedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.removeFromList(event.getDeletedUser());
- }
-
- /**
- * Event observer for linked users with existing contact data
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent 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.getLinkedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.linkedUser is null"); //NOI18N
- } else if (event.getLinkedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
- } else if (event.getLinkedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getLinkedUser());
- }
-
- /**
- * Event observer for locked users
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent 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.getLockedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.lockedUser is null"); //NOI18N
- } else if (event.getLockedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N
- } else if (event.getLockedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getLockedUser());
- }
-
- /**
- * Event observer for unlocked users
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent 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.getUnlockedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlockedUser is null"); //NOI18N
- } else if (event.getUnlockedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N
- } else if (event.getUnlockedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUnlockedUser());
- }
-
- /**
- * Event observer for updated user data by administrator
- * <p>
- * @param event Event being updated
- */
- public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent 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.getUpdatedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedUser is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUpdatedUser());
- }
-
- /**
- * Event observer when user confirmed account.
- * <p>
- * @param event Event being fired
- */
- public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent 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.getConfirmedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.confirmedUser is null"); //NOI18N
- } else if (event.getConfirmedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
- } else if (event.getConfirmedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getConfirmedUser());
- }
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent 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.getRegisteredUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.registeredUser is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getRegisteredUser());
- }
-
- /**
- * Method being call after user's password has been updated (and history
- * entry has been created).
- * <p>
- * @param event Event being observed
- */
- public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
- // Check parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getPasswordHistory() == null) {
- // Throw NPE again
- throw new NullPointerException("event.passwordHistory is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
- // ... and again
- throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
- // Invalid value
- throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
- }
-
- /**
- * Listens to fired event when user updated personal data
- * <p>
- * @param event Event being fired
- */
- public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
- // Check parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedUser is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() == null) {
- // ... and again
- throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() < 1) {
- // Invalid value
- throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUpdatedUser());
- }
-
- @Override
- public User findUserById (final Long userId) throws UserNotFoundException {
- // Validate parameter
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
- } else if (!this.userCache.containsKey(userId)) {
- // Not found
- throw new UserNotFoundException(userId);
- }
-
- // Get it from cache
- final User user = this.userCache.get(userId);
-
- // Return it
- return user;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> getAllUsers () {
- return this.allUsers;
- }
-
- /**
- * Getter for filtered users list
- * <p>
- * @return Filtered users list
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> getFilteredUsers () {
- return this.filteredUsers;
- }
-
- /**
- * Setter for filtered users list
- * <p>
- * @param filteredUsers Filtered users list
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredUsers (final List<User> filteredUsers) {
- this.filteredUsers = filteredUsers;
- }
-
- /**
- * Getter for selected user instance
- * <p>
- * @return Selected user instance
- */
- public User getSelectedUser () {
- return this.selectedUser;
- }
-
- /**
- * Setter for selected user instance
- * <p>
- * @param selectedUser Selected user instance
- */
- public void setSelectedUser (final User selectedUser) {
- this.selectedUser = selectedUser;
- }
-
- @Override
- public boolean ifUserIdExists (final Long userId) {
- // Validate parameter
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
- }
-
- // Check if key is there
- boolean isFound = this.userCache.containsKey(userId);
-
- // Return flag
- return isFound;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.userCache.iterator().hasNext()) {
- // Add all
- for (final User user : this.userBean.allUsers()) {
- // Add it to cache
- this.userCache.put(user.getUserId(), user);
- }
- }
-
- // Is cache filled and list is empty
- if ((this.userCache.iterator().hasNext()) && (this.getAllUsers().isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, User> currentEntry : this.userCache) {
- // Add to list
- this.getAllUsers().add(currentEntry.getValue());
- }
-
- // Sort list
- this.getAllUsers().sort(new Comparator<User>() {
- @Override
- public int compare (final User user1, final User user2) {
- return user1.getUserId() > user2.getUserId() ? 1 : user1.getUserId() < user2.getUserId() ? -1 : 0;
- }
- });
-
- // Set full list
- this.setFilteredUsers(this.getAllUsers());
- }
- }
-
- @Override
- public boolean isUserNameRegistered (final User user) {
- // Default is not found
- boolean isFound = false;
-
- // Determine it
- for (final User currentUser : this.getAllUsers()) {
- // Is same name found?
- if (Objects.equals(user.getUserName(), currentUser.getUserName())) {
- // Yes, then set flag and abort loop
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
- }
-
- @Override
- public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
- // Parameter must be valid
- if (null == emailAddress) {
- // Throw NPE
- throw new NullPointerException("emailAddress is null"); //NOI18N
- } else if (emailAddress.isEmpty()) {
- // Not valid
- throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
- }
-
- // Init variable
- User user = null;
-
- // Try to lookup it in visible user list
- for (final Cache.Entry<Long, User> currentUser : this.userCache) {
- // Contact should be set
- if (currentUser.getValue().getUserContact() == null) {
- // Contact is null
- throw new NullPointerException(MessageFormat.format("currentUser.userContact is null for user id {0}", currentUser.getKey())); //NOI18N
- } else if (currentUser.getValue().getUserContact().getContactEmailAddress() == null) {
- // Email address should be set
- throw new NullPointerException(MessageFormat.format("currentUser.userContact.contactEmailAddress is null for user id {0}", currentUser.getKey())); //NOI18N
- }
-
- // Is the email address found?
- if (Objects.equals(currentUser.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
- // Copy to other variable
- user = currentUser.getValue();
- break;
- }
- }
-
- // Is it still null?
- if (null == user) {
- // Not visible for the current user
- throw new UserEmailAddressNotFoundException(emailAddress);
- }
-
- // Return it
- return user;
- }
-
- @Override
- public User lookupUserById (final Long userId) throws UserNotFoundException {
- // Parameter must be valid
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
- }
-
- // Init variable
- User user = null;
-
- // Try to lookup it in visible user list
- for (final Cache.Entry<Long, User> currentUser : this.userCache) {
- // Is the user id found?
- if (Objects.equals(currentUser.getKey(), userId)) {
- // Copy to other variable
- user = currentUser.getValue();
- break;
- }
- }
-
- // Is it still null?
- if (null == user) {
- // Not visible for the current user
- throw new UserNotFoundException(userId);
- }
-
- // Return it
- return user;
- }
-
- /**
- * Removes user from all lists
- * <p>
- * @param user User to remove
- */
- private void removeFromList (final User user) {
- // Remove it from lists
- this.getAllUsers().remove(user);
- this.userCache.remove(user.getUserId());
- }
-
- /**
- * Updates list with given user instance
- * <p>
- * @param user User instance
- */
- private void updateList (final User user) {
- // Add/update user
- this.userCache.put(user.getUserId(), user);
- this.getAllUsers().add(user);
- }
-
-}
import javax.inject.Named;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
+import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
import org.mxchange.juserlogincore.events.login.UserLoggedInEvent;
import org.mxchange.juserlogincore.events.logout.ObservableUserLogoutEvent;
import org.mxchange.juserlogincore.events.logout.UserLogoutEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
import org.mxchange.juserlogincore.login.UserLoginUtils;
-import org.mxchange.juserlogincore.model.user.login.UserLoginSessionBeanRemote;
/**
* A web bean for user registration
private String userCurrentPassword;
/**
- * Flag whether the user has logged-in, set only from inside
+ * User id
*/
- private boolean userLoggedIn;
+ private Long userId;
+
+ /**
+ * Administrative user-list controller
+ */
+ @Inject
+ private FinancialsUserListWebViewController userListController;
/**
- * Remote register session-scoped bean
+ * Flag whether the user has logged-in, set only from inside
*/
- @EJB (lookup = "java:global/jfinancials-ejb/userLogin!org.mxchange.juserlogincore.model.user.login.UserLoginSessionBeanRemote")
- private UserLoginSessionBeanRemote userLoginBean;
+ private boolean userLoggedIn;
/**
* Event fired when user has logged in
@Any
private Event<ObservableUserLogoutEvent> userLogoutEvent;
+ /**
+ * User name
+ */
+ private String userName;
+
+ /**
+ * User password (clear-text from web form)
+ */
+ private String userPassword;
+
/**
* User's password history
*/
@EJB (lookup = "java:global/jfinancials-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote")
private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
+ /**
+ * Whether the user wants a public profile
+ */
+ private ProfileMode userProfileMode;
+
/**
* Default constructor
*/
}
/**
- * Method being call after user's password has been updated (and history
- * entry has been created).
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent 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.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Set user id again
+ this.setUserId(event.getAddedUser().getUserId());
+ }
+
+ /**
+ * Event observer for linked users with existing contact data
* <p>
- * @param event Event being observed
+ * @param event Event being fired
*/
- public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
- // Check parameter
+ public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent 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.getPasswordHistory() == null) {
+ } else if (event.getLinkedUser() == null) {
// Throw NPE again
- throw new NullPointerException("event.passwordHistory is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
- // ... and again
- throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
- // Invalid value
- throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
+ throw new NullPointerException("event.linkedUser is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
}
- // All fine, so update list
+ // Set user id again
+ this.setUserId(event.getLinkedUser().getUserId());
+ }
+
+ /**
+ * Event observer for when a bean helper has successfully created a user
+ * instance, means the user exists. If the user does not exist, this event
+ * should not fire but instead a proper exception must be thrown.
+ * <p>
+ * @param event User created event
+ */
+ public void afterCreatedUserEvent (@Observes final ObservableCreatedUserEvent event) {
+ // Is the instance valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getCreatedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.createdUser is null"); //NOI18N
+ } else if (event.getCreatedUser().getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.createdUser.userId is null"); //NOI18N
+ } else if (event.getCreatedUser().getUserId() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("event.createdUser.userId={0} is not valid", event.getCreatedUser().getUserId())); //NOI18N
+ }
+
+ // Get user instance
+ final User user = event.getCreatedUser();
+
+ // Set all fields here
+ this.copyUser(user);
+ }
+
+ /**
+ * Event observer for logged-in user
+ * <p>
+ * @param event Event instance
+ */
+ public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent 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.getLoggedInUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+ }
+
+ // "Cache" user instance
+ final User user = event.getLoggedInUser();
+
+ // Copy all data to this bean
+ this.copyUser(user);
+ }
+
+ /**
+ * Event observer for user password changes
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserPasswordChangedEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
+ // Is it valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUserPassword() == null) {
+ // Throw NPE
+ throw new NullPointerException("event.userPassword is null"); //NOI18N
+ } else if (event.getUserPassword().isEmpty()) {
+ // Throw NPE
+ throw new IllegalArgumentException("event.userPassword is empty"); //NOI18N
+ }
+
+ // Set it here
+ this.setUserPassword(event.getUserPassword());
this.updatePasswordHistory(event.getPasswordHistory());
}
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent 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.getRegisteredUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ }
+
+ // Get user instance
+ final User registeredUser = event.getRegisteredUser();
+
+ // Copy all data from registered->user
+ this.copyUser(registeredUser);
+
+ // Set user id again
+ this.setUserId(registeredUser.getUserId());
+ }
+
/**
* Logout for administrator area. If a logged-in user instance exists, it is
* being logged-out, too.
* @return Redirect target
*/
public String doUserLogin () {
- // Get user instance
- final User user = this.userController.createUserLogin();
-
- // Create login container
- final LoginContainer loginContainer = new UserLoginContainer(user, this.userController.getUserPassword());
-
- try {
- // Call bean
- final User confirmedUser = this.userLoginBean.validateUserAccountStatus(loginContainer);
-
- // All fine here so set it here
- this.setLoggedInUser(confirmedUser);
-
- // Retrieve user's password list
- this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser);
-
- // Set template to "login"
- this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
-
- // Fire event away. Keep this last before return statement.
- this.userLoginEvent.fire(new UserLoggedInEvent(confirmedUser));
-
- // Clear this bean
- this.clear();
+ // Found user instance
+ User updatedUser = null;
+
+ // Iterate over all users
+ for (final User currentUser : this.userListController.getAllUsers()) {
+ // Is the user name matching?
+ if (currentUser.getUserName().equals(this.getUserName())) {
+ // Yes, same user, then set it and stop iteration
+ updatedUser = currentUser;
+ break;
+ }
+ }
- // All fine
- return "login_user"; //NOI18N
- } catch (final UserNotFoundException ex) {
+ if (null == updatedUser) {
// Show JSF message
this.showFacesMessage("form_user_login:userName", "ERROR_USER_NOT_FOUND", FacesMessage.SEVERITY_ERROR); //NOI18N
return ""; //NOI18N
- } catch (final UserStatusLockedException ex) {
+ } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.LOCKED)) {
this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_LOCKED", FacesMessage.SEVERITY_WARN); //NOI18N
return ""; //NOI18N
- } catch (final UserStatusUnconfirmedException ex) {
+ } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.UNCONFIRMED)) {
this.showFacesMessage("form_user_login:userName", "ERROR_USER_STATUS_UNCONFIRMED", FacesMessage.SEVERITY_INFO); //NOI18N
return ""; //NOI18N
- } catch (final UserPasswordMismatchException ex) {
+ } else if (!UserLoginUtils.ifPasswordMatches(this.getUserPassword(), updatedUser)) {
// Show JSF message
this.showFacesMessage("form_user_login:userPassword", "ERROR_USER_PASSWORD_MISMATCH", FacesMessage.SEVERITY_WARN); //NOI18N
return ""; //NOI18N
}
+
+ // All fine here so set it here
+ this.setLoggedInUser(updatedUser);
+
+ // Retrieve user's password list
+ this.userPasswordHistory = this.userPasswordHistoryBean.fetchPasswordHistoryByUser(updatedUser);
+
+ // Set template to "login"
+ this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME);
+
+ // Fire event away. Keep this last before return statement.
+ this.userLoginEvent.fire(new UserLoggedInEvent(updatedUser));
+
+ // Clear this bean
+ this.clear();
+
+ // All fine
+ return "login_user"; //NOI18N
}
/**
this.userCurrentPassword = userCurrentPassword;
}
+ /**
+ * Getter for user id
+ * <p>
+ * @return User id
+ */
+ public Long getUserId () {
+ return this.userId;
+ }
+
+ /**
+ * Setter for user id
+ * <p>
+ * @param userId User id
+ */
+ public void setUserId (final Long userId) {
+ this.userId = userId;
+ }
+
+ /**
+ * Getter for user name
+ * <p>
+ * @return User name
+ */
+ public String getUserName () {
+ return this.userName;
+ }
+
+ /**
+ * Setter for user name
+ * <p>
+ * @param userName User name
+ */
+ public void setUserName (final String userName) {
+ this.userName = userName;
+ }
+
+ /**
+ * Getter for clear-text user password
+ * <p>
+ * @return Clear-text user password
+ */
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
+ /**
+ * Setter for clear-text user password
+ * <p>
+ * @param userPassword Clear-text user password
+ */
+ public void setUserPassword (final String userPassword) {
+ this.userPassword = userPassword;
+ }
+
@Override
public List<PasswordHistory> getUserPasswordHistory () {
return Collections.unmodifiableList(this.userPasswordHistory);
}
+ /**
+ * Getter for user profile mode
+ * <p>
+ * @return User profile mode
+ */
+ public ProfileMode getUserProfileMode () {
+ return this.userProfileMode;
+ }
+
+ /**
+ * Setter for user profile mode
+ * <p>
+ * @param userProfileMode User profile mode
+ */
+ public void setUserProfileMode (final ProfileMode userProfileMode) {
+ this.userProfileMode = userProfileMode;
+ }
+
@Override
public boolean ifCurrentPasswordMatches () {
// The current password must be set and not empty
return isPasswordInHistory;
}
+ /**
+ * Checks if the user id is empty
+ * <p>
+ * @return Whether the user id is empty
+ */
+ public boolean isUserIdEmpty () {
+ return ((this.getUserId() == null) || (this.getUserId() == 0));
+ }
+
@Override
public boolean isUserLoggedIn () {
// Compare instance
*/
private void clear () {
// Clear all fields
+ this.setLoggedInUser(null);
+ this.setUserName(null);
+ this.setUserPassword(null);
this.setUserCurrentPassword(null);
+ this.setUserProfileMode(null);
+ }
+
+ /**
+ * Copies given user into the controller
+ * <p>
+ * @param user User instance
+ */
+ private void copyUser (final User user) {
+ // Copy all fields:
+ // - base data
+ this.setUserId(user.getUserId());
+ this.setUserName(user.getUserName());
+ this.setUserProfileMode(user.getUserProfileMode());
}
/**
*/
package org.mxchange.jfinancials.beans.user.register;
+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.application.FacesMessage;
import javax.faces.view.facelets.FaceletException;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
-import org.mxchange.jusercore.events.user.clear.password.ClearUserPasswordEvent;
-import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
-import org.mxchange.jusercore.events.user.clear.username.ClearUserNameEvent;
-import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent;
import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
+import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.Users;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.juserlogincore.events.registration.UserRegisteredEvent;
*/
private static final long serialVersionUID = 47_828_986_719_691_592L;
- /**
- * An event being fired when a user name should be cleared
- */
- @Inject
- @Any
- private Event<ObservableClearUserNameEvent> clearUserNameEvent;
-
- /**
- * An event being fired when a user password should be cleared
- */
- @Inject
- @Any
- private Event<ObservableClearUserPasswordEvent> clearUserPasswordEvent;
-
/**
* Contact controller
*/
@Inject
private FinancialsFeaturesWebApplicationController featureController;
+ /**
+ * Localization controller
+ */
+ @Inject
+ private FinancialsLocalizationSessionController localizationController;
+
/**
* Remote register session-scoped bean
*/
private UserRegistrationSessionBeanRemote registerBean;
/**
- * User controller
+ * User list controller
*/
@Inject
- private FinancialsUserWebRequestController userController;
+ private FinancialsUserListWebViewController userListController;
/**
- * User list controller
+ * User name
*/
- @Inject
- private FinancialsUserListWebViewController userListController;
+ private String userName;
+
+ /**
+ * User password (clear-text from web form)
+ */
+ private String userPassword;
/**
* An event being fired when a user password was changed
@Any
private Event<ObservableUpdatedUserPasswordEvent> userPasswordChangedEvent;
+ /**
+ * User password repeated (clear-text from web form)
+ */
+ private String userPasswordRepeat;
+
+ /**
+ * Whether the user wants a public profile
+ */
+ private ProfileMode userProfileMode;
+
/**
* An event being fired when a new user has registered
*/
super();
}
+ /**
+ * Event observer for user password changes
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserPasswordChangedEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
+ // Is it valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUserPassword() == null) {
+ // Throw NPE
+ throw new NullPointerException("event.userPassword is null"); //NOI18N
+ } else if (event.getUserPassword().isEmpty()) {
+ // Throw NPE
+ throw new IllegalArgumentException("event.userPassword is empty"); //NOI18N
+ }
+
+ // Set it here
+ this.setUserPassword(event.getUserPassword());
+ this.setUserPasswordRepeat(event.getUserPassword());
+ }
+
/**
* Registers the user, if not found. Otherwise this method should throw an
* exception.
}
// Get user instance
- final User user = this.userController.createUserInstance(true);
+ final User user = this.createUserInstance(true);
// Null random password means registration requires user-entered password
String randomPassword = null;
if (null == user) {
// user must be set
throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
- } else if (!this.userController.isRequiredPersonalDataSet()) {
+ } else if (!this.isRequiredPersonalDataSet()) {
// Not all required fields are set
throw new FaceletException("Not all required fields are set."); //NOI18N
} else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userListController.isUserNameRegistered(user))) { //NOI18N
// User name is already used, should not happen here
throw new FaceletException(new UserNameAlreadyRegisteredException(user));
} else {
- // May happen here, fire event
- this.clearUserNameEvent.fire(new ClearUserNameEvent());
+ // May happen here, clear user name
+ this.clearUserName();
// Output message
this.showFacesMessage("form_register_single:userName", "ERROR_USER_NAME_ALREADY_USED", FacesMessage.SEVERITY_WARN); //NOI18N
this.showFacesMessage("form_register_single:emailAddressRepeat", "ERROR_EMAIL_ADDRESSES_MISMATCHING", FacesMessage.SEVERITY_INFO); //NOI18N
return ""; //NOI18N
}
- } else if (!this.userController.isSamePasswordEntered()) {
+ } else if (!this.isSamePasswordEntered()) {
// Is multi-page enabled?
if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
// Not same password entered, should no longer happen here
throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N
- } else if (this.userController.ifBothPasswordsEmptyAllowed()) {
+ } else if (this.ifBothPasswordsEmptyAllowed()) {
// Both passwords are left empty and is allowed, then generate a random password
randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
}
// Encrypt password
- final String encryptedPassword = UserLoginUtils.encryptPassword(this.userController.getUserPassword());
+ final String encryptedPassword = UserLoginUtils.encryptPassword(this.getUserPassword());
// Set it here
user.setUserEncryptedPassword(encryptedPassword);
}
// Get user instance
- final User user = this.userController.createUserInstance(false);
+ final User user = this.createUserInstance(false);
// First check if user is not null and user name is not used + if same email address is entered
if (null == user) {
throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
} else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userListController.isUserNameRegistered(user))) { //NOI18N
// User name is already used, so clear it
- this.clearUserNameEvent.fire(new ClearUserNameEvent());
+ this.clearUserName();
// Output message
this.showFacesMessage("form_register_page1:userName", "ERROR_USER_NAME_ALREADY_USED", FacesMessage.SEVERITY_WARN); //NOI18N
this.contactController.clearEmailAddresses();
this.showFacesMessage("form_register_page1:emailAddressRepeat", "ERROR_EMAIL_ADDRESSES_MISMATCHING", FacesMessage.SEVERITY_WARN); //NOI18N
return ""; //NOI18N
- } else if (!this.userController.isSamePasswordEntered()) {
+ } else if (!this.isSamePasswordEntered()) {
// Is multi-page enabled?
if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
- // Unset both
- this.clearUserPasswordEvent.fire(new ClearUserPasswordEvent());
+ // Clear passwords
+ this.clearUserPasswords();
// Output faces message
this.showFacesMessage("form_register_page1:userPassword", "ERROR_USER_PASSWORD_EMPTY", FacesMessage.SEVERITY_WARN); //NOI18N
this.showFacesMessage("form_register_page1:userPasswordRepeat", "ERROR_USER_PASSWORD_REPEAT_EMPTY", FacesMessage.SEVERITY_WARN); //NOI18N
return ""; //NOI18N
- } else if (this.userController.ifBothPasswordsEmptyAllowed()) {
+ } else if (this.ifBothPasswordsEmptyAllowed()) {
// Both passwords are left empty and is allowed, then generate a random password
- String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
+ final String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
// Generate (ignored) password-history
- PasswordHistory passwordHistory = new UserPasswordHistory(randomPassword, user);
+ final PasswordHistory passwordHistory = new UserPasswordHistory(randomPassword, user);
// Fire event
this.userPasswordChangedEvent.fire(new UpdatedUserPasswordEvent(passwordHistory, randomPassword));
return "user_register_page2"; //NOI18N
}
+ /**
+ * Getter for user name
+ * <p>
+ * @return User name
+ */
+ public String getUserName () {
+ return this.userName;
+ }
+
+ /**
+ * Setter for user name
+ * <p>
+ * @param userName User name
+ */
+ public void setUserName (final String userName) {
+ this.userName = userName;
+ }
+
+ /**
+ * Getter for clear-text user password
+ * <p>
+ * @return Clear-text user password
+ */
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
+ /**
+ * Setter for clear-text user password
+ * <p>
+ * @param userPassword Clear-text user password
+ */
+ public void setUserPassword (final String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ /**
+ * Getter for clear-text user password repeated
+ * <p>
+ * @return Clear-text user password repeated
+ */
+ public String getUserPasswordRepeat () {
+ return this.userPasswordRepeat;
+ }
+
+ /**
+ * Setter for clear-text user password repeated
+ * <p>
+ * @param userPasswordRepeat Clear-text user password repeated
+ */
+ public void setUserPasswordRepeat (final String userPasswordRepeat) {
+ this.userPasswordRepeat = userPasswordRepeat;
+ }
+
+ /**
+ * Getter for user profile mode
+ * <p>
+ * @return User profile mode
+ */
+ public ProfileMode getUserProfileMode () {
+ return this.userProfileMode;
+ }
+
+ /**
+ * Setter for user profile mode
+ * <p>
+ * @param userProfileMode User profile mode
+ */
+ public void setUserProfileMode (final ProfileMode userProfileMode) {
+ this.userProfileMode = userProfileMode;
+ }
+
+ @Override
+ public boolean isRequiredChangePersonalDataSet () {
+ return ((this.getUserProfileMode() != null) &&
+ (this.getUserName() != null) &&
+ (!this.getUserName().isEmpty()) &&
+ (this.contactController.isRequiredChangePersonalDataSet()));
+ }
+
+ /**
+ * Clears user name
+ */
+ private void clearUserName () {
+ // Clear it
+ this.setUserName(null);
+ }
+
+ /**
+ * Clears both user passwords
+ */
+ private void clearUserPasswords () {
+ // Clear both
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+ }
+
+ /**
+ * Creates an instance from all properties
+ * <p>
+ * @param createContactData Whether contact data should be created
+ * <p>
+ * @return A user instance
+ */
+ private User createUserInstance (final boolean createContactData) {
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "All required personal data must be set before invoking this method."; //NOI18N
+
+ // Is user name required?
+ if (!this.featureController.isFeatureEnabled("user_login_require_username")) {
+ // Init variables
+ String randomName = null;
+ boolean isUsernameFree = false;
+
+ // Get full list
+ for (final User user : this.userListController.getAllUsers()) {
+ // Loop until a user name is found
+ while ((randomName == null) || (randomName.equals(user.getUserName()))) {
+ // Generate random name
+ randomName = Users.generateRandomUserName();
+ isUsernameFree = true;
+ }
+
+ // Is non-existing username found
+ if (isUsernameFree) {
+ // Also stop looping here
+ break;
+ }
+ }
+
+ // Set it and inivisible profile
+ this.setUserName(randomName);
+ this.setUserProfileMode(ProfileMode.INVISIBLE);
+
+ // Generate random password
+ final String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
+
+ // Set random password
+ this.setUserPassword(randomPassword);
+ this.setUserPasswordRepeat(randomPassword);
+ }
+
+ // Create new user instance
+ final User user = new LoginUser();
+
+ // Set user name profile mode and locale
+ user.setUserName(this.getUserName());
+ user.setUserProfileMode(this.getUserProfileMode());
+ user.setUserLocale(this.localizationController.getLocale());
+
+ // Is multiple registration page
+ if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
+ // Create contact instance
+ final Contact contact = this.contactController.createContactInstance();
+
+ // Set contact in user
+ user.setUserContact(contact);
+ }
+
+ // Return it
+ return user;
+ }
+
+ /**
+ * Checks if both user passwords are left empty and if this is enabled
+ * (allowed) in context parameter. If true, the calling bean should create a
+ * random password (preferable with UserUtils.createRandomPassword() and set
+ * it in both user password fields.
+ * <p>
+ * @return Whether empty passwords are allowed
+ */
+ private boolean ifBothPasswordsEmptyAllowed () {
+ // Check feature first
+ return ((this.featureController.isFeatureEnabled("allow_user_registration_empty_password")) && //NOI18N
+ ((this.getUserPassword() == null) || (this.getUserPassword().isEmpty())) &&
+ ((this.getUserPasswordRepeat() == null) || (this.getUserPasswordRepeat().isEmpty())));
+ }
+
+ /**
+ * Checks whether all required personal data is set
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ private boolean isRequiredPersonalDataSet () {
+ // Check conditions based on of multi-page registration is enabled
+ if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
+ // Multiple registration page
+ return this.contactController.isRequiredPersonalDataSet();
+ } else {
+ // Single registration page
+ return (((this.getUserName() != null) || (!this.featureController.isFeatureEnabled("user_login_require_username"))) && //NOI18N
+ (this.getUserProfileMode() != null) &&
+ (this.contactController.isRequiredPersonalDataSet()) &&
+ (this.getUserPassword() != null) &&
+ (this.getUserPasswordRepeat() != null));
+ }
+ }
+
+ /**
+ * Checks whether same passwords has been entered
+ * <p>
+ * @return Whether same passwords has been entered
+ */
+ private boolean isSamePasswordEntered () {
+ return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
+ }
+
}
*/
public interface FinancialsUserRegisterWebRequestController extends Serializable {
+ /**
+ * Checks whether all required personal data is set for changing them
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredChangePersonalDataSet ();
+
}
import javax.faces.convert.FacesConverter;
import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
import org.mxchange.jcontactsbusiness.model.employee.Employable;
-import org.mxchange.jfinancials.beans.business.employee.FinancialsEmployeeWebRequestBean;
-import org.mxchange.jfinancials.beans.business.employee.FinancialsEmployeeWebRequestController;
+import org.mxchange.jfinancials.beans.business.employee.list.FinancialsEmployeeListWebViewBean;
+import org.mxchange.jfinancials.beans.business.employee.list.FinancialsEmployeeListWebViewController;
/**
* Converter for converting company employee to and from id number
/**
* Employable EJB
*/
- private static FinancialsEmployeeWebRequestController EMPLOYEE_CONTROLLER;
+ private static FinancialsEmployeeListWebViewController EMPLOYEE_LIST_CONTROLLER;
@Override
public Employable getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == EMPLOYEE_CONTROLLER) {
- // Get bean from CDI directly
- EMPLOYEE_CONTROLLER = CDI.current().select(FinancialsEmployeeWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Try to parse the value as long
final Long employeeId = Long.valueOf(submittedValue);
+ // Is the instance there?
+ if (null == EMPLOYEE_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ EMPLOYEE_LIST_CONTROLLER = CDI.current().select(FinancialsEmployeeListWebViewBean.class).get();
+ }
+
// Try to get user instance from it
- companyEmployee = EMPLOYEE_CONTROLLER.findEmployeeById(employeeId);
+ companyEmployee = EMPLOYEE_LIST_CONTROLLER.findEmployeeById(employeeId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
import javax.faces.convert.FacesConverter;
import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
-import org.mxchange.jfinancials.beans.business.opening_time.FinancialsOpeningTimeWebRequestBean;
-import org.mxchange.jfinancials.beans.business.opening_time.FinancialsOpeningTimeWebRequestController;
+import org.mxchange.jfinancials.beans.business.opening_time.list.FinancialsOpeningTimeListWebViewBean;
+import org.mxchange.jfinancials.beans.business.opening_time.list.FinancialsOpeningTimeListWebViewController;
/**
* Converter for opening time id <-> instance
/**
* Opening time backing bean
*/
- private static FinancialsOpeningTimeWebRequestController OPENING_TIMES_CONTROLLER;
+ private static FinancialsOpeningTimeListWebViewController OPENING_TIME_LIST_CONTROLLER;
@Override
public OpeningTime getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == OPENING_TIMES_CONTROLLER) {
- // Get bean from CDI directly
- OPENING_TIMES_CONTROLLER = CDI.current().select(FinancialsOpeningTimeWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
// Warning message
try {
// Try to parse the value as long
- final Long openingId = Long.valueOf(submittedValue);
+ final Long openingTimeId = Long.valueOf(submittedValue);
+
+ // Is the instance there?
+ if (null == OPENING_TIME_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ OPENING_TIME_LIST_CONTROLLER = CDI.current().select(FinancialsOpeningTimeListWebViewBean.class).get();
+ }
// Try to get user instance from it
- openingTime = OPENING_TIMES_CONTROLLER.findOpeningTimeById(openingId);
+ openingTime = OPENING_TIME_LIST_CONTROLLER.findOpeningTimeById(openingTimeId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
}
// Return id number
- return String.valueOf(value.getOpeningId());
+ return String.valueOf(value.getOpeningTimeId());
}
}
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestBean;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestController;
+import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewBean;
+import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
/**
* Phone EJB
*/
- private static FinancialsPhoneWebRequestController PHONE_CONTROLLER;
+ private static FinancialsPhoneListWebViewController PHONE_LIST_CONTROLLER;
@Override
public DialableFaxNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == PHONE_CONTROLLER) {
- // Get bean from CDI directly
- PHONE_CONTROLLER = CDI.current().select(FinancialsPhoneWebRequestBean.class).get();
- }
-
- // Log message
- // @TODO Not possible here: this.loggerBeanLocal.logTrace(MessageFormat.format("{0}.getAsObject: context={1},component={2},submittedValue={3} - CALLED!", this.getClass().getSimpleName(), context, component, submittedValue)); //NOI18N
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not possible here: this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Try to parse the value as long
final Long faxNumberId = Long.valueOf(submittedValue);
- // Log message
- // @TODO Not possible here: this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject: faxNumberId={1}", this.getClass().getSimpleName(), faxNumberId)); //NOI18N
+ // Is the instance there?
+ if (null == PHONE_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ PHONE_LIST_CONTROLLER = CDI.current().select(FinancialsPhoneListWebViewBean.class).get();
+ }
+
// Try to get mobile instance from it
- faxNumber = PHONE_CONTROLLER.findFaxNumberById(faxNumberId);
+ faxNumber = PHONE_LIST_CONTROLLER.findFaxNumberById(faxNumberId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
// @TODO Not possible here: this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
}
- // Log message
- // @TODO Not possible here: this.loggerBeanLocal.logTrace(MessageFormat.format("{0}.getAsObject: faxNumber={1} - EXIT!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
// Return it
return faxNumber;
}
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestBean;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestController;
+import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewBean;
+import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
/**
* Phone EJB
*/
- private static FinancialsPhoneWebRequestController PHONE_CONTROLLER;
+ private static FinancialsPhoneListWebViewController PHONE_LIST_CONTROLLER;
@Override
public DialableLandLineNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == PHONE_CONTROLLER) {
- // Get bean from CDI directly
- PHONE_CONTROLLER = CDI.current().select(FinancialsPhoneWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not possible here: this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Try to parse the value as long
final Long landLineNumberId = Long.valueOf(submittedValue);
+ // Is the instance there?
+ if (null == PHONE_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ PHONE_LIST_CONTROLLER = CDI.current().select(FinancialsPhoneListWebViewBean.class).get();
+ }
+
// Try to get mobile instance from it
- landLineNumber = PHONE_CONTROLLER.findLandLineNumberById(landLineNumberId);
+ landLineNumber = PHONE_LIST_CONTROLLER.findLandLineNumberById(landLineNumberId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestBean;
-import org.mxchange.jfinancials.beans.phone.FinancialsPhoneWebRequestController;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
+import org.mxchange.jfinancials.beans.mobile.list.FinancialsMobileListWebViewBean;
+import org.mxchange.jfinancials.beans.mobile.list.FinancialsMobileListWebViewController;
+import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
/**
/**
* Phone EJB
*/
- private static FinancialsPhoneWebRequestController PHONE_CONTROLLER;
+ private static FinancialsMobileListWebViewController MOBILE_LIST_CONTROLLER;
@Override
public DialableMobileNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == PHONE_CONTROLLER) {
- // Get bean from CDI directly
- PHONE_CONTROLLER = CDI.current().select(FinancialsPhoneWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Try to parse the value as long
final Long mobileNumberId = Long.valueOf(submittedValue);
+ // Is the instance there?
+ if (null == MOBILE_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ MOBILE_LIST_CONTROLLER = CDI.current().select(FinancialsMobileListWebViewBean.class).get();
+ }
+
// Try to get mobile instance from it
- mobileNumber = PHONE_CONTROLLER.findMobileNumberById(mobileNumberId);
+ mobileNumber = MOBILE_LIST_CONTROLLER.findMobileNumberById(mobileNumberId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
- } catch (final PhoneEntityNotFoundException ex) {
+ } catch (final MobileEntityNotFoundException ex) {
// Debug message
// @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
}
}
// Return id number
- return String.valueOf(value.getPhoneId());
+ return String.valueOf(value.getMobileId());
}
}
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.mobileprovider.FinancialsMobileProviderWebRequestBean;
-import org.mxchange.jfinancials.beans.mobileprovider.FinancialsMobileProviderWebRequestController;
+import org.mxchange.jfinancials.beans.mobileprovider.list.FinancialsMobileProviderListWebViewBean;
+import org.mxchange.jfinancials.beans.mobileprovider.list.FinancialsMobileProviderListWebViewController;
import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
/**
* Mobile provider backing bean
*/
- private static FinancialsMobileProviderWebRequestController MOBILE_PROVIDER_CONTROLLER;
+ private static FinancialsMobileProviderListWebViewController MOBILE_PROVIDER_LIST_CONTROLLER;
@Override
public MobileProvider getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Is the instance there?
- if (null == MOBILE_PROVIDER_CONTROLLER) {
- // Get bean from CDI directly
- MOBILE_PROVIDER_CONTROLLER = CDI.current().select(FinancialsMobileProviderWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Convert it to long
final Long providerId = Long.parseLong(submittedValue);
+ // Is the instance there?
+ if (null == MOBILE_PROVIDER_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ MOBILE_PROVIDER_LIST_CONTROLLER = CDI.current().select(FinancialsMobileProviderListWebViewBean.class).get();
+ }
+
// Lookup of mobile provider
- mobileProvider = MOBILE_PROVIDER_CONTROLLER.findMobileProviderById(providerId);
+ mobileProvider = MOBILE_PROVIDER_LIST_CONTROLLER.findMobileProviderById(providerId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
-import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewtBean;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewBean;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
// Is the instance there?
if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewtBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewBean.class).get();
}
// Is the value null or empty?
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.jfinancials.beans.business.employee.FinancialsEmployeeWebRequestBean;
-import org.mxchange.jfinancials.beans.business.employee.FinancialsEmployeeWebRequestController;
+import org.mxchange.jfinancials.beans.business.employee.list.FinancialsEmployeeListWebViewBean;
+import org.mxchange.jfinancials.beans.business.employee.list.FinancialsEmployeeListWebViewController;
/**
* A validator for employee email address validation
/**
* Employee backing bean
*/
- private static FinancialsEmployeeWebRequestController EMPLOYEE_CONTROLLER;
+ private static FinancialsEmployeeListWebViewController EMPLOYEE_LIST_CONTROLLER;
/**
* Pattern matcher
final String clientId = component.getClientId();
// Is the instance there?
- if (null == EMPLOYEE_CONTROLLER) {
+ if (null == EMPLOYEE_LIST_CONTROLLER) {
// Get bean from CDI directly
- EMPLOYEE_CONTROLLER = CDI.current().select(FinancialsEmployeeWebRequestBean.class).get();
+ EMPLOYEE_LIST_CONTROLLER = CDI.current().select(FinancialsEmployeeListWebViewBean.class).get();
}
// Is it registered?
- final Boolean isRegistered = EMPLOYEE_CONTROLLER.isEmailAddressRegistered(emailAddress);
+ final Boolean isRegistered = EMPLOYEE_LIST_CONTROLLER.isEmailAddressRegistered(emailAddress);
// Is the email address already registered?
if ((!clientId.endsWith("resendEmailAddress")) && (isRegistered)) { //NOI18N
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
-import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewtBean;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewBean;
/**
* A validator for user ids
// Is the instance there?
if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewtBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewBean.class).get();
}
// Cast value
ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern
ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Handynummern
ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=Alle Mobilfunknummern auflisten.
-ADMIN_SHOW_PHONE_CREATED=Telefoneintrag erstellt:
-ADMIN_SHOW_PHONE_UPDATED=Telefoneintrag zuletzt ge\u00e4ndert:
ADMIN_EDIT_MOBILE_NUMBER_TITLE=Mobiltelefoneintrag {0} editieren:
ADMIN_MOBILE_NUMBER_DATA_LEGEND=Mobiltelefonnummerdaten editeren:
ADMIN_EDIT_MOBILE_PROVIDER=Mobilfunkanbieter \u00e4ndern:
ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers
ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS=Mobile numbers
ADMIN_LINK_LIST_MOBILE_PHONE_NUMBERS_TITLE=List all mobile numbers.
-ADMIN_SHOW_PHONE_CREATED=Created:
-ADMIN_SHOW_PHONE_UPDATED=Last changed:
ADMIN_EDIT_MOBILE_NUMBER_TITLE=Edit mobile entry {0}:
ADMIN_MOBILE_NUMBER_DATA_LEGEND=Edit mobile data:
ADMIN_EDIT_MOBILE_PROVIDER=Change mobile phone provider:
<type>java.lang.Boolean</type>
</attribute>
</tag>
- <tag>
- <tag-name>outputFaxNumberAdminDropdownMenu</tag-name>
- <description>This tag renders a full h:panelGroup for an administrative drop-down menu for fax data.</description>
- <source>resources/tags/admin/dropdown/fax/admin_fax_links.tpl</source>
- <attribute>
- <name>faxNumber</name>
- <description>The fax instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber</type>
- </attribute>
- <attribute>
- <name>contact</name>
- <description>The contact instance that provides contact data for additional JSF links.</description>
- <required>false</required>
- <type>org.mxchange.jcontacts.model.contact.Contact</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether this tag is used to show fax data (default true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputLandLineNumberAdminDropdownMenu</tag-name>
- <description>This tag renders a full h:panelGroup for an administrative drop-down menu for land-line data.</description>
- <source>resources/tags/admin/dropdown/landline/admin_landline_links.tpl</source>
- <attribute>
- <name>landLineNumber</name>
- <description>The fax instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber</type>
- </attribute>
- <attribute>
- <name>contact</name>
- <description>The contact instance that provides contact data for additional JSF links.</description>
- <required>false</required>
- <type>org.mxchange.jcontacts.model.contact.Contact</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether this tag is used to show land-line data (default true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputMobileNumberAdminDropdownMenu</tag-name>
- <description>This tag renders a full h:panelGroup for an administrative drop-down menu for mobile data.</description>
- <source>resources/tags/admin/dropdown/mobile/admin_mobile_links.tpl</source>
- <attribute>
- <name>mobileNumber</name>
- <description>The mobile number instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber</type>
- </attribute>
- <attribute>
- <name>contact</name>
- <description>The contact instance that provides contact data for additional JSF links.</description>
- <required>false</required>
- <type>org.mxchange.jcontacts.model.contact.Contact</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether this tag is used to show mobile data (default true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputMobileProviderAdminDropdownMenu</tag-name>
- <description>This tag renders a full h:panelGroup for an administrative drop-down menu for mobile provider data.</description>
- <source>resources/tags/admin/dropdown/mobile_provider/admin_mobile_provider_links.tpl</source>
- <attribute>
- <name>mobileProvider</name>
- <description>The mobile provider instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether this tag is used to show mobile provider data (default true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputBasicDataAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given basic data instance.</description>
- <source>resources/tags/admin/dropdown/basic_data/admin_basic_data_links.tpl</source>
- <attribute>
- <name>basicData</name>
- <description>The basic company data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show basic data" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputHeadquarterAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given headquarter instance.</description>
- <source>resources/tags/admin/dropdown/headquarter/admin_headquarter_links.tpl</source>
- <attribute>
- <name>headquarter</name>
- <description>The headquarter instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterData</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show headquarter" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputBranchOfficeAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given branchOffice instance.</description>
- <source>resources/tags/admin/dropdown/branch_office/admin_branch_office_links.tpl</source>
- <attribute>
- <name>branchOffice</name>
- <description>The branch office instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show branch office" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputDepartmentAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given department instance.</description>
- <source>resources/tags/admin/dropdown/department/admin_department_links.tpl</source>
- <attribute>
- <name>department</name>
- <description>The department instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.department.Department</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show department" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputEmployeeAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given employee instance.</description>
- <source>resources/tags/admin/dropdown/employee/admin_employee_links.tpl</source>
- <attribute>
- <name>employee</name>
- <description>The employee instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.employee.Employee</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show employee" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
- <tag>
- <tag-name>outputOpeningTimeAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given opening time instance.</description>
- <source>resources/tags/admin/dropdown/opening_time/admin_opening_time_links.tpl</source>
- <attribute>
- <name>openingTime</name>
- <description>The opening time instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcontactsbusiness.model.opening_time.OpeningTimes</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show opening time" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
<tag>
<tag-name>outputContactAdminDropdownMenu</tag-name>
<description>This tag renders an administrative drop-down menu for given contact instance.</description>
<type>java.lang.Boolean</type>
</attribute>
</tag>
- <tag>
- <tag-name>outputCountryAdminDropdownMenu</tag-name>
- <description>This tag renders an administrative drop-down menu for given country instance.</description>
- <source>resources/tags/admin/dropdown/country/admin_country_links.tpl</source>
- <attribute>
- <name>country</name>
- <description>The country instance that provides the data for this tag.</description>
- <required>true</required>
- <type>org.mxchange.jcountry.model.data.Country</type>
- </attribute>
- <attribute>
- <name>renderShowLink</name>
- <description>Whether to render (default: true) "show country" link.</description>
- <required>false</required>
- <type>java.langBoolean</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- </tag>
<tag>
<tag-name>outputUserAdminDropdownMenu</tag-name>
<description>This tag renders an administrative drop-down menu for given user instance.</description>
</p:column>
<p:column>
- <p:outputLabel for="contactCreated" styleClass="table-data-label" value="#{msg.ADMIN_CONTACT_CREATED}" />
+ <p:outputLabel for="contactEntryCreated" styleClass="table-data-label" value="#{msg.ADMIN_CONTACT_CREATED}" />
- <h:outputText id="contactCreated" styleClass="table-data-field" value="#{beanHelper.contact.contactCreated}">
+ <h:outputText id="contactEntryCreated" styleClass="table-data-field" value="#{beanHelper.contact.contactEntryCreated}">
<f:convertDateTime type="both" />
</h:outputText>
</p:column>
<p:column>
- <p:outputLabel for="contactUpdated" styleClass="table-data-label" value="#{msg.ADMIN_CONTACT_UPDATED}" />
+ <p:outputLabel for="contactEntryUpdated" styleClass="table-data-label" value="#{msg.ADMIN_CONTACT_UPDATED}" />
- <h:outputText id="contactUpdated" styleClass="table-data-field" value="#{beanHelper.contact.contactUpdated}">
+ <h:outputText id="contactEntryUpdated" styleClass="table-data-field" value="#{beanHelper.contact.contactEntryUpdated}">
<f:convertDateTime type="both" />
</h:outputText>
</p:column>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_basic_data" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_BASIC_DATA_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="basicDataId" value="#{basicData.basicDataId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_basic_data" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_BASIC_DATA_TITLE}">
- <f:param name="basicDataId" value="#{basicData.basicDataId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_basic_data">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_BASIC_DATA_TITLE}" />
- <f:param name="basicDataId" value="#{basicData.basicDataId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_branch_office" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_BRANCH_OFFICE_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="branchId" value="#{branchOffice.branchId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_branch_office" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_BRANCH_OFFICE_TITLE}">
- <f:param name="branchId" value="#{branchOffice.branchId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_branch_office">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_BRANCH_OFFICE_TITLE}" />
- <f:param name="branchId" value="#{branchOffice.branchId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_country" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_COUNTRY_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="countryId" value="#{country.countryId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_country" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_COUNTRY_TITLE}">
- <f:param name="countryId" value="#{country.countryId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_country">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_COUNTRY_TITLE}" />
- <f:param name="countryId" value="#{country.countryId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_department" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_DEPARTMENT_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="departmentId" value="#{department.departmentId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_department" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_DEPARTMENT_TITLE}">
- <f:param name="departmentId" value="#{department.departmentId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_department">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_DEPARTMENT_TITLE}" />
- <f:param name="departmentId" value="#{department.departmentId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_employee" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_EMPLOYEE_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="employeeId" value="#{employee.employeeId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_employee" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_EMPLOYEE_TITLE}">
- <f:param name="employeeId" value="#{employee.employeeId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_employee">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_EMPLOYEE_TITLE}" />
- <f:param name="employeeId" value="#{employee.employeeId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_fax" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_FAX_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="phoneId" value="#{faxNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_fax" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_FAX_NUMBER_TITLE}">
- <f:param name="phoneId" value="#{faxNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_unlink_contact_fax" rendered="#{not empty contact}">
- <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_FAX_NUMBER_CONTACT_TITLE}" />
- <f:param name="phoneId" value="#{faxNumber.phoneId}" />
- <f:param name="contactId" value="#{contact.contactId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_fax">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_FAX_NUMBER_TITLE}" />
- <f:param name="phoneId" value="#{faxNumber.phoneId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_headquarter" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_HEADQUARTER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_headquarter" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_HEADQUARTER_TITLE}">
- <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_headquarter">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_HEADQUARTER_TITLE}" />
- <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_landline" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_LAND_LINE_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_landline" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_LAND_LINE_NUMBER_TITLE}">
- <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_unlink_contact_landline" rendered="#{not empty contact}">
- <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_LAND_LINE_NUMBER_CONTACT_TITLE}" />
- <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
- <f:param name="contactId" value="#{contact.contactId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_landline">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_LAND_LINE_NUMBER_TITLE}" />
- <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_mobile" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_MOBILE_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="phoneId" value="#{mobileNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_mobile" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_MOBILE_NUMBER_TITLE}">
- <f:param name="phoneId" value="#{mobileNumber.phoneId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_unlink_contact_mobile" rendered="#{not empty contact}">
- <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_MOBILE_NUMBER_CONTACT_TITLE}" />
- <f:param name="phoneId" value="#{mobileNumber.phoneId}" />
- <f:param name="contactId" value="#{contact.contactId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_mobile">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_MOBILE_NUMBER_TITLE}" />
- <f:param name="phoneId" value="#{mobileNumber.phoneId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_mobile_provider" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_MOBILE_PROVIDER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="providerId" value="#{mobileProvider.providerId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_mobile_provider" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_MOBILE_PROVIDER_TITLE}">
- <f:param name="providerId" value="#{mobileProvider.providerId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_mobile_provider">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_MOBILE_PROVIDER_TITLE}" />
- <f:param name="providerId" value="#{mobileProvider.providerId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
- <p:menuitem outcome="admin_show_opening_time" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_OPENING_TIME_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
- <f:param name="openingId" value="#{openingTime.openingId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_edit_opening_time" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_OPENING_TIME_TITLE}">
- <f:param name="openingId" value="#{openingTime.openingId}" />
- </p:menuitem>
-
- <p:menuitem outcome="admin_delete_opening_time">
- <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_OPENING_TIME_TITLE}" />
- <f:param name="openingId" value="#{openingTime.openingId}" />
- </p:menuitem>
- </p:menuButton>
-</ui:composition>
</div>
<div class="table-right-medium">
- <h:outputText id="mobileNumberId" value="#{mobileNumber.phoneId}" />
+ <h:outputText id="mobileNumberId" value="#{mobileNumber.mobileId}" />
</div>
</h:panelGroup>
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{mobileProviderController.allMobileProviders()}"
+ value="#{mobileProviderListController.allMobileProviders}"
var="mobileProvider"
itemValue="#{mobileProvider}"
itemLabel="#{mobileProvider.providerCountry.countryExternalDialPrefix}#{mobileProvider.providerDialPrefix} (#{mobileProvider.providerName})"
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
- xmlns:links="http://mxchange.org/jsf/core/links"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
</p:column>
<p:column>
- <p:outputLabel for="faxCreated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <p:outputLabel for="faxCreated" styleClass="table-data-label" value="#{msg.ENTRY_CREATED_HEADER}" />
<h:outputText id="faxCreated" styleClass="table-data-field" value="#{faxNumber.phoneEntryCreated}">
<f:convertDateTime type="both" />
</p:column>
<p:column>
- <p:outputLabel for="faxUpdated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <p:outputLabel for="faxUpdated" styleClass="table-data-label" value="#{msg.ENTRY_UPDATED_HEADER}" />
<h:outputText id="faxUpdated" styleClass="table-data-field" value="#{faxNumber.phoneEntryUpdated}">
<f:convertDateTime type="both" />
<p:outputLabel styleClass="table-data-label" value="#{msg.ADMIN_SHOW_ADMINISTRATIVE_LINKS}" />
<h:panelGroup styleClass="table-data-field" layout="block">
- <links:outputFaxNumberAdminDropdownMenu faxNumber="#{faxNumber}" contact="#{contact}" renderShowLink="#{renderShowLink == true}" />
+ <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
+ <p:menuitem outcome="admin_show_fax" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_FAX_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
+ <f:param name="phoneId" value="#{faxNumber.phoneId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_edit_fax" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_FAX_NUMBER_TITLE}">
+ <f:param name="phoneId" value="#{faxNumber.phoneId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_unlink_contact_fax" rendered="#{not empty contact}">
+ <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_FAX_NUMBER_CONTACT_TITLE}" />
+ <f:param name="phoneId" value="#{faxNumber.phoneId}" />
+ <f:param name="contactId" value="#{contact.contactId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_fax">
+ <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_FAX_NUMBER_TITLE}" />
+ <f:param name="phoneId" value="#{faxNumber.phoneId}" />
+ </p:menuitem>
+ </p:menuButton>
</h:panelGroup>
</p:column>
</p:panelGrid>
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
- xmlns:links="http://mxchange.org/jsf/core/links"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
</p:column>
<p:column>
- <p:outputLabel for="landLineCreated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <p:outputLabel for="landLineCreated" styleClass="table-data-label" value="#{msg.ENTRY_CREATED_HEADER}" />
<h:outputText id="landLineCreated" styleClass="table-data-field" value="#{landLineNumber.phoneEntryCreated}">
<f:convertDateTime type="both" />
</p:column>
<p:column>
- <p:outputLabel for="landLineUpdated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <p:outputLabel for="landLineUpdated" styleClass="table-data-label" value="#{msg.ENTRY_UPDATED_HEADER}" />
<h:outputText id="landLineUpdated" styleClass="table-data-field" value="#{landLineNumber.phoneEntryUpdated}">
<f:convertDateTime type="both" />
<p:outputLabel styleClass="table-data-label" value="#{msg.ADMIN_SHOW_ADMINISTRATIVE_LINKS}" />
<h:panelGroup styleClass="table-data-field" layout="block">
- <links:outputLandLineNumberAdminDropdownMenu landLineNumber="#{landLineNumber}" contact="#{contact}" renderShowLink="#{renderShowLink == true}" />
+ <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
+ <p:menuitem outcome="admin_show_landline" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_LAND_LINE_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
+ <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_edit_landline" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_LAND_LINE_NUMBER_TITLE}">
+ <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_unlink_contact_landline" rendered="#{not empty contact}">
+ <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_LAND_LINE_NUMBER_CONTACT_TITLE}" />
+ <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
+ <f:param name="contactId" value="#{contact.contactId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_landline">
+ <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_LAND_LINE_NUMBER_TITLE}" />
+ <f:param name="phoneId" value="#{landLineNumber.phoneId}" />
+ </p:menuitem>
+ </p:menuButton>
</h:panelGroup>
</p:column>
</p:panelGrid>
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
- xmlns:links="http://mxchange.org/jsf/core/links"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
<p:column>
<p:outputLabel for="mobileNumberId" styleClass="table-data-label" value="#{msg.ADMIN_LABEL_ID_NUMBER}" />
- <h:outputText id="mobileNumberId" styleClass="table-data-field" value="#{mobileNumber.phoneId}" />
+ <h:outputText id="mobileNumberId" styleClass="table-data-field" value="#{mobileNumber.mobileId}" />
</p:column>
<p:column>
</p:column>
<p:column>
- <p:outputLabel for="mobileCreated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <p:outputLabel for="mobileCreated" styleClass="table-data-label" value="#{msg.ENTRY_CREATED_HEADER}" />
<h:outputText id="mobileCreated" styleClass="table-data-field" value="#{mobileNumber.phoneEntryCreated}">
<f:convertDateTime type="both" />
</p:column>
<p:column>
- <p:outputLabel for="mobileUpdated" styleClass="table-data-label" value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <p:outputLabel for="mobileUpdated" styleClass="table-data-label" value="#{msg.ENTRY_UPDATED_HEADER}" />
<h:outputText id="mobileUpdated" styleClass="table-data-field" value="#{mobileNumber.phoneEntryUpdated}">
<f:convertDateTime type="both" />
<p:outputLabel styleClass="table-data-label" value="#{msg.ADMIN_SHOW_ADMINISTRATIVE_LINKS}" />
<h:panelGroup styleClass="table-data-field" layout="block">
- <links:outputMobileNumberAdminDropdownMenu mobileNumber="#{mobileNumber}" contact="#{contact}" renderShowLink="#{renderShowLink == true}" />
+ <p:menuButton value="#{msg.OPTIONS}" rendered="#{empty rendered or rendered}">
+ <p:menuitem outcome="admin_show_mobile" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_MOBILE_NUMBER_TITLE}" rendered="#{empty renderShowLink or renderShowLink}">
+ <f:param name="phoneId" value="#{mobileNumber.mobileId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_edit_mobile" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_MOBILE_NUMBER_TITLE}">
+ <f:param name="phoneId" value="#{mobileNumber.mobileId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_unlink_contact_mobile" rendered="#{not empty contact}">
+ <h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_MOBILE_NUMBER_CONTACT_TITLE}" />
+ <f:param name="phoneId" value="#{mobileNumber.mobileId}" />
+ <f:param name="contactId" value="#{contact.contactId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_mobile">
+ <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_MOBILE_NUMBER_TITLE}" />
+ <f:param name="phoneId" value="#{mobileNumber.mobileId}" />
+ </p:menuitem>
+ </p:menuButton>
</h:panelGroup>
</p:column>
</p:panelGrid>
<f:converter converterId="MobileProviderConverter" />
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{mobileProviderController.allMobileProviders()}"
+ value="#{mobileProviderListController.allMobileProviders}"
var="mobileProvider"
itemValue="#{mobileProvider}"
itemLabel="#{mobileProvider.providerCountry.countryExternalDialPrefix}#{mobileProvider.providerDialPrefix} (#{mobileProvider.providerName})"
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:p="http://primefaces.org/ui"
- >
-
- <p:row rendered="#{empty rendered or rendered == true}">
- <p:outputLabel for="profileMode" value="#{labelMessage}" />
-
- <p:selectOneMenu
- id="profileMode"
- value="#{targetController.userProfileMode}"
- filter="true"
- filterMatchMode="contains"
- >
-
- <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
-
- <f:selectItems
- value="#{dataController.profileModes}"
- var="profileMode"
- itemValue="#{profileMode}"
- itemLabel="#{msg[profileMode.messageKey]}"
- />
- </p:selectOneMenu>
-
- <p:message for="personalTitle" />
- </p:row>
-</ui:composition>
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="companyEmployee"
itemValue="#{companyEmployee}"
itemLabel="#{beanHelper.renderEmployee(companyEmployee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="companyEmployee"
itemValue="#{companyEmployee}"
itemLabel="#{beanHelper.renderEmployee(companyEmployee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="companyEmployee"
itemValue="#{companyEmployee}"
itemLabel="#{beanHelper.renderEmployee(companyEmployee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="companyEmployee"
itemValue="#{companyEmployee}"
itemLabel="#{beanHelper.renderEmployee(companyEmployee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{branchOfficeListController.allBranchOffices()}"
+ value="#{branchOfficeListController.allBranchOffices}"
var="branchOffice"
itemValue="#{branchOffice}"
itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{branchOfficeListController.allBranchOffices()}"
+ value="#{branchOfficeListController.allBranchOffices}"
var="branchOffice"
itemValue="#{branchOffice}"
itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{adminPhoneController.allNonLinkedFaxNumbers()}"
+ value="#{adminPhoneListController.allNonLinkedFaxNumbers}"
var="faxNumber"
itemValue="#{faxNumber}"
itemLabel="#{faxNumber.phoneCountry.countryExternalDialPrefix} (#{faxNumber.phoneAreaCode}) #{faxNumber.phoneNumber}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="companyEmployee"
itemValue="#{companyEmployee}"
itemLabel="#{beanHelper.renderEmployee(companyEmployee)}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{adminPhoneController.allNonLinkedLandLineNumbers()}"
+ value="#{adminPhoneListController.allNonLinkedLandLineNumbers}"
var="landlineNumber"
itemValue="#{landlineNumber}"
itemLabel="#{landlineNumber.phoneCountry.countryExternalDialPrefix} (#{landlineNumber.phoneAreaCode}) #{landlineNumber.phoneNumber}"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{adminPhoneController.allNonLinkedMobileNumbers()}"
+ value="#{adminPhoneListController.allNonLinkedMobileNumbers}"
var="mobileNumber"
itemValue="#{mobileNumber}"
itemLabel="#{beanHelper.renderMobileNumber(mobileNumber)}"
<h:outputText value="#{msg.USER_PROFILE_LEGEND}" />
</legend>
- <core:outputProfileModeTableRow targetController="#{userController}" labelMessage="#{msg.USER_PROFILE_MODE}" />
+ <h:panelGroup styleClass="table-row" layout="block">
+ <p:outputLabel for="profileMode" value="#{msg.USER_PROFILE_MODE}" />
+
+ <p:selectOneMenu
+ id="profileMode"
+ value="#{targetController.userProfileMode}"
+ filter="true"
+ filterMatchMode="contains"
+ >
+
+ <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
+
+ <f:selectItems
+ value="#{dataController.profileModes}"
+ var="profileMode"
+ itemValue="#{profileMode}"
+ itemLabel="#{msg[profileMode.messageKey]}"
+ />
+ </p:selectOneMenu>
+ </h:panelGroup>
<h:panelGroup styleClass="table-row" layout="block">
<div class="para notice">
</div>
<div class="table-right">
- <p:inputText id="userName" value="#{userController.userName}" size="10" maxlength="20" required="true" requiredMessage="#{msg.LOGIN_NO_USER_NAME_MESSAGE}" />
+ <p:inputText id="userName" value="#{userLoginController.userName}" size="10" maxlength="20" required="true" requiredMessage="#{msg.LOGIN_NO_USER_NAME_MESSAGE}" />
</div>
</h:panelGroup>
</div>
<div class="table-right">
- <p:inputText type="secret" id="userPassword" value="#{userController.userPassword}" size="10" maxlength="255" required="true" requiredMessage="#{msg.LOGIN_NO_PASSWORD_MESSAGE}" />
+ <p:inputText type="secret" id="userPassword" value="#{userLoginController.userPassword}" size="10" maxlength="255" required="true" requiredMessage="#{msg.LOGIN_NO_PASSWORD_MESSAGE}" />
</div>
</h:panelGroup>
</div>
<div class="table-right-medium">
- <p:inputText id="userName" size="20" maxlength="255" value="#{userController.userName}" required="true" requiredMessage="#{msg.GUEST_REGISTRATION_USER_NAME_NOT_ENTERED}" />
+ <p:inputText
+ id="userName"
+ size="20"
+ maxlength="255"
+ value="#{userRegistrationController.userName}"
+ required="true"
+ requiredMessage="#{msg.GUEST_REGISTRATION_USER_NAME_NOT_ENTERED}"
+ />
</div>
</h:panelGroup>
</div>
<div class="table-right-medium">
- <p:inputText type="secret" id="userPassword" size="10" maxlength="255" value="#{userController.userPassword}" required="#{not featureController.isFeatureEnabled('allow_user_registration_empty_password')}" requiredMessage="#{msg.GUEST_REGISTRATION_PASSWORD_NOT_ENTERED}" />
+ <p:inputText type="secret" id="userPassword" size="10" maxlength="255" value="#{userRegistrationController.userPassword}" required="#{not featureController.isFeatureEnabled('allow_user_registration_empty_password')}" requiredMessage="#{msg.GUEST_REGISTRATION_PASSWORD_NOT_ENTERED}" />
</div>
</h:panelGroup>
</div>
<div class="table-right-medium">
- <p:inputText type="secret" id="userPasswordRepeat" size="10" maxlength="255" value="#{userController.userPasswordRepeat}" required="#{not featureController.isFeatureEnabled('allow_user_registration_empty_password')}" requiredMessage="#{msg.GUEST_REGISTRATION_PASSWORD_REPEAT_NOT_ENTERED}" />
+ <p:inputText type="secret" id="userPasswordRepeat" size="10" maxlength="255" value="#{userRegistrationController.userPasswordRepeat}" required="#{not featureController.isFeatureEnabled('allow_user_registration_empty_password')}" requiredMessage="#{msg.GUEST_REGISTRATION_PASSWORD_REPEAT_NOT_ENTERED}" />
</div>
</h:panelGroup>
<h:outputText value="#{msg.GUEST_REGISTRATION_PAGE2_TITLE}" />
</div>
- <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl" />
+ <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl">
+ <ui:param name="targetController" value="#{userRegistrationController}" />
+ </ui:include>
<p:panelGrid columns="2" layout="grid">
<p:commandButton
<h:outputText value="#{msg.GUEST_REGISTRATION_TITLE}" />
</div>
- <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl" />
+ <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl">
+ <ui:param name="targetController" value="#{userRegistrationController}" />
+ </ui:include>
<div class="para">
<fieldset class="fieldset">
</div>
<div class="table-right">
- <p:inputText id="userName" size="20" maxlength="255" value="#{userController.userName}" required="true" requiredMessage="#{msg.GUEST_REGISTRATION_USER_NAME_NOT_ENTERED}" />
+ <p:inputText
+ id="userName"
+ size="20"
+ maxlength="255"
+ value="#{userRegistrationController.userName}"
+ required="true"
+ requiredMessage="#{msg.GUEST_REGISTRATION_USER_NAME_NOT_ENTERED}"
+ />
</div>
</h:panelGroup>
</div>
<div class="table-right">
- <p:inputText type="secret" id="userPassword" size="10" maxlength="255" value="#{userController.userPassword}" />
+ <p:inputText type="secret" id="userPassword" size="10" maxlength="255" value="#{userRegistrationController.userPassword}" />
</div>
</h:panelGroup>
</div>
<div class="table-right">
- <p:inputText type="secret" id="userPasswordRepeat" size="10" maxlength="255" value="#{userController.userPasswordRepeat}" />
+ <p:inputText type="secret" id="userPasswordRepeat" size="10" maxlength="255" value="#{userRegistrationController.userPasswordRepeat}" />
</div>
</h:panelGroup>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
- <description>An application to handle all your receipts and do some calculation with it.</description>
- <display-name>JFinancials Application v1.0</display-name>
- <context-param>
- <description>Name of this project.</description>
- <param-name>project_title</param-name>
- <param-value>JFinancials</param-value>
- </context-param>
- <context-param>
- <description>PrimeFaces theme</description>
- <param-name>primefaces.THEME</param-name>
- <param-value>bootstrap</param-value>
- </context-param>
- <context-param>
- <description>Whether PrimeFaces should collect all scripts and bundle it automatically.</description>
- <param-name>primefaces.COLLECT_SCRIPTS</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Refresh period of facelets.</description>
- <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
- <param-value>-1</param-value>
- </context-param>
- <context-param>
- <description>Development mode for WELD, keep disabled unless really needed. Currently it messes up the website.</description>
- <param-name>org.jboss.weld.development</param-name>
- <param-value>false</param-value>
- </context-param>
- <context-param>
- <description>Generic custom JSF tags library</description>
- <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
- <param-value>/WEB-INF/widgets.jsf.taglib.xml;/WEB-INF/validators.jsf.taglib.xml;/WEB-INF/links.jsf.taglib.xml;/WEB-INF/project-links.jsf.taglib.xml;/WEB-INF/product.jsf.taglib.xml;/WEB-INF/product-links.jsf.taglib.xml</param-value>
- </context-param>
- <context-param>
- <description>Project stage</description>
- <param-name>javax.faces.PROJECT_STAGE</param-name>
- <param-value>Development</param-value>
- </context-param>
- <context-param>
- <description>Whether the date converter's default timezone is system's timezone.</description>
- <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>All empty strings should be converted to null.</description>
- <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Bar-code type for products</description>
- <param-name>product_barcode_type</param-name>
- <param-value>ean13</param-value>
- </context-param>
- <context-param>
- <description>Whether the multi-page registration page or a single registration page is active</description>
- <param-name>is_feature_user_register_multiple_page_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether a user name is required for this application.</description>
- <param-name>is_feature_user_login_require_user_name_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether "resend confirmation link" is enabled.</description>
- <param-name>is_feature_user_resend_confirmation_link_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether registration page is enabled.</description>
- <param-name>is_feature_user_registration_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether the guest menu is enabled/shown to the user.</description>
- <param-name>is_feature_guest_menu_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether the guest's index content is shown</description>
- <param-name>is_feature_guest_index_content_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether recovery of user passwords is enabled.</description>
- <param-name>is_feature_user_password_recovery_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether the personal title is required for using the general contact controller.</description>
- <param-name>is_feature_general_personal_title_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether personal title is required for administrative contact controller.</description>
- <param-name>is_feature_admin_personal_title_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether users are allowed to edit their user data.</description>
- <param-name>is_feature_user_edit_data_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether the user list is accessible and visible.</description>
- <param-name>is_feature_user_list_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether imprint page is enabled.</description>
- <param-name>is_feature_imprint_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether terms page is enabled.</description>
- <param-name>is_feature_terms_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether privacy page is enabled.</description>
- <param-name>is_feature_privacy_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Feature: Users must change password after login (with current password). Administrators can enforce this.</description>
- <param-name>is_feature_user_must_change_password_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether users are allowed to change their login password.</description>
- <param-name>is_feature_change_user_password_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether users can change their email address.</description>
- <param-name>is_feature_user_must_change_email_address_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether user registration page is in index or own page.</description>
- <param-name>is_feature_user_registration_in_index_enabled</param-name>
- <param-value>false</param-value>
- </context-param>
- <context-param>
- <description>Whether user can leave both passwords empty on registration. Then a random password will be created.</description>
- <param-name>is_feature_allow_user_registration_empty_password_enabled</param-name>
- <param-value>false</param-value>
- </context-param>
- <context-param>
- <description>Whether business contacts are used in this project.</description>
- <param-name>is_feature_basic_data_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether company employees are used in this project. Maybe used in conjuction with business contacts only.</description>
- <param-name>is_feature_company_employee_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Whether the public user profile is enabled. If this option is enabled, the setting "is_user_login_require_user_name" must also be enabled as it is mandadory.</description>
- <param-name>is_feature_public_user_profile_enabled</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Maximum passwords that must be different.</description>
- <param-name>max_user_password_history</param-name>
- <param-value>5</param-value>
- </context-param>
- <context-param>
- <description>Whether debugging of registration form is enabled.</description>
- <param-name>is_debug_register_enabled</param-name>
- <param-value>false</param-value>
- </context-param>
- <context-param>
- <description>Whether user names are required for completing registration.</description>
- <param-name>is_user_login_require_user_name</param-name>
- <param-value>true</param-value>
- </context-param>
- <context-param>
- <description>Minimum password score (default 50 may be to low)</description>
- <param-name>min_user_password_score</param-name>
- <param-value>50</param-value>
- </context-param>
- <context-param>
- <description>Type of receipt barcode (see p:barcode)</description>
- <param-name>receipt_barcode_type</param-name>
- <param-value>codabar</param-value>
- </context-param>
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>pdf</servlet-name>
- <servlet-class>org.mxchange.pizzaapplication.servlet.receipt.PizzaPdfReceiptServlet</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
- </servlet-mapping>
- <mime-mapping>
- <extension>tpl</extension>
- <mime-type>text/plain</mime-type>
- </mime-mapping>
- <servlet-mapping>
- <servlet-name>pdf</servlet-name>
- <url-pattern>/customer/recipt.pdf</url-pattern>
- </servlet-mapping>
- <session-config>
- <session-timeout>
- 30
- </session-timeout>
- </session-config>
- <welcome-file-list>
- <welcome-file>faces/index.xhtml</welcome-file>
- </welcome-file-list>
- <security-constraint>
- <display-name>AdminConstraint</display-name>
- <web-resource-collection>
- <web-resource-name>admin</web-resource-name>
- <description>Administrative Area</description>
- <url-pattern>/faces/admin/*</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <description>Administrative Area Login</description>
- <role-name>admin</role-name>
- </auth-constraint>
- </security-constraint>
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>file</realm-name>
- </login-config>
- <security-role>
- <description>Administrative role</description>
- <role-name>admin</role-name>
- </security-role>
+ <description>An application to handle all your receipts and do some calculation with it.</description>
+ <display-name>JFinancials Application v1.0</display-name>
+ <context-param>
+ <description>Name of this project.</description>
+ <param-name>project_title</param-name>
+ <param-value>JFinancials</param-value>
+ </context-param>
+ <context-param>
+ <description>PrimeFaces theme</description>
+ <param-name>primefaces.THEME</param-name>
+ <param-value>bootstrap</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether PrimeFaces should collect all scripts and bundle it automatically.</description>
+ <param-name>primefaces.COLLECT_SCRIPTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Refresh period of facelets.</description>
+ <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
+ <param-value>-1</param-value>
+ </context-param>
+ <context-param>
+ <description>Development mode for WELD, keep disabled unless really needed. Currently it messes up the website.</description>
+ <param-name>org.jboss.weld.development</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>Generic custom JSF tags library</description>
+ <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
+ <param-value>/WEB-INF/widgets.jsf.taglib.xml;/WEB-INF/validators.jsf.taglib.xml;/WEB-INF/links.jsf.taglib.xml;/WEB-INF/project-links.jsf.taglib.xml;/WEB-INF/product.jsf.taglib.xml;/WEB-INF/product-links.jsf.taglib.xml</param-value>
+ </context-param>
+ <context-param>
+ <description>Project stage</description>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+ <param-value>Development</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the date converter's default timezone is system's timezone.</description>
+ <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>All empty strings should be converted to null.</description>
+ <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Bar-code type for products</description>
+ <param-name>product_barcode_type</param-name>
+ <param-value>ean13</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the multi-page registration page or a single registration page is active</description>
+ <param-name>is_feature_user_register_multiple_page_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether a user name is required for this application.</description>
+ <param-name>is_feature_user_login_require_user_name_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether "resend confirmation link" is enabled.</description>
+ <param-name>is_feature_user_resend_confirmation_link_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether registration page is enabled.</description>
+ <param-name>is_feature_user_registration_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the guest menu is enabled/shown to the user.</description>
+ <param-name>is_feature_guest_menu_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the guest's index content is shown</description>
+ <param-name>is_feature_guest_index_content_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether recovery of user passwords is enabled.</description>
+ <param-name>is_feature_user_password_recovery_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the personal title is required for using the general contact controller.</description>
+ <param-name>is_feature_general_personal_title_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether personal title is required for administrative contact controller.</description>
+ <param-name>is_feature_admin_personal_title_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether users are allowed to edit their user data.</description>
+ <param-name>is_feature_user_edit_data_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the user list is accessible and visible.</description>
+ <param-name>is_feature_user_list_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether imprint page is enabled.</description>
+ <param-name>is_feature_imprint_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether terms page is enabled.</description>
+ <param-name>is_feature_terms_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether privacy page is enabled.</description>
+ <param-name>is_feature_privacy_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Feature: Users must change password after login (with current password). Administrators can enforce this.</description>
+ <param-name>is_feature_user_must_change_password_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether users are allowed to change their login password.</description>
+ <param-name>is_feature_change_user_password_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether users can change their email address.</description>
+ <param-name>is_feature_user_must_change_email_address_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether user registration page is in index or own page.</description>
+ <param-name>is_feature_user_registration_in_index_enabled</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether user can leave both passwords empty on registration. Then a random password will be created.</description>
+ <param-name>is_feature_allow_user_registration_empty_password_enabled</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether business contacts are used in this project.</description>
+ <param-name>is_feature_basic_data_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether company employees are used in this project. Maybe used in conjuction with business contacts only.</description>
+ <param-name>is_feature_company_employee_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether the public user profile is enabled. If this option is enabled, the setting "is_feature_user_login_require_username_enabled" must also be enabled as it is mandadory.</description>
+ <param-name>is_feature_public_user_profile_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether user names are required for completing registration.</description>
+ <param-name>is_feature_user_login_require_username_enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <description>Maximum passwords that must be different.</description>
+ <param-name>max_user_password_history</param-name>
+ <param-value>5</param-value>
+ </context-param>
+ <context-param>
+ <description>Whether debugging of registration form is enabled.</description>
+ <param-name>is_debug_register_enabled</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <description>Minimum password score (default 50 may be to low)</description>
+ <param-name>min_user_password_score</param-name>
+ <param-value>50</param-value>
+ </context-param>
+ <context-param>
+ <description>Type of receipt barcode (see p:barcode)</description>
+ <param-name>receipt_barcode_type</param-name>
+ <param-value>codabar</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <servlet-name>pdf</servlet-name>
+ <servlet-class>org.mxchange.pizzaapplication.servlet.receipt.PizzaPdfReceiptServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <mime-mapping>
+ <extension>tpl</extension>
+ <mime-type>text/plain</mime-type>
+ </mime-mapping>
+ <servlet-mapping>
+ <servlet-name>pdf</servlet-name>
+ <url-pattern>/customer/recipt.pdf</url-pattern>
+ </servlet-mapping>
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+ <welcome-file-list>
+ <welcome-file>faces/index.xhtml</welcome-file>
+ </welcome-file-list>
+ <security-constraint>
+ <display-name>AdminConstraint</display-name>
+ <web-resource-collection>
+ <web-resource-name>admin</web-resource-name>
+ <description>Administrative Area</description>
+ <url-pattern>/faces/admin/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <description>Administrative Area Login</description>
+ <role-name>admin</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>file</realm-name>
+ </login-config>
+ <security-role>
+ <description>Administrative role</description>
+ <role-name>admin</role-name>
+ </security-role>
</web-app>
<type>org.mxchange.jcoreee.bean.faces.BaseFacesBean</type>
</attribute>
</tag>
- <tag>
- <tag-name>outputProfileModeTableRow</tag-name>
- <description>This tag renders a selection box for user's profile mode.</description>
- <source>resources/tags/table_rows/user_profile_mode_table_row.tpl</source>
- <attribute>
- <name>labelMessage</name>
- <description>A localized message for the rendered label tag. You should use EL code here to add a label message from your bundle.</description>
- <required>true</required>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <name>rendered</name>
- <description>Whether this tag is being rendered by JSF engine (default: true).</description>
- <required>false</required>
- <type>java.lang.Boolean</type>
- </attribute>
- <attribute>
- <name>targetController</name>
- <description>A target backing bean (EL code resolving into it) extending at least BaseFacesBean where to set the data in.</description>
- <required>true</required>
- <!-- @TODO Find an interface for BaseFacesBean and set it here instead -->
- <type>org.mxchange.jcoreee.bean.faces.BaseFacesBean</type>
- </attribute>
- </tag>
<tag>
<tag-name>outputAdminContactDataFormFields</tag-name>
<description>This tag renders a fieldset for administrative purposes of contact data.</description>
<f:converter converterId="EmployeeConverter" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
<f:converter converterId="EmployeeConverter" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
<h:outputText value="#{basicData.companyTaxNumber}" />
</p:column>
+ <p:column
+ headerText="#{msg.LANDLINE_NUMBER_HEADER}"
+ sortBy="#{basicData.companyLandLineNumber}"
+ filterBy="#{basicData.companyLandLineNumber}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{beanHelper.renderPhoneNumber(basicData.companyLandLineNumber)}" />
+ </p:column>
+
+ <p:column
+ headerText="#{msg.FAX_NUMBER_HEADER}"
+ sortBy="#{basicData.companyFaxNumber}"
+ filterBy="#{basicData.companyFaxNumber}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{beanHelper.renderPhoneNumber(basicData.companyFaxNumber)}" />
+ </p:column>
+
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
- sortBy="#{basicData.companyCreated}"
- filterBy="#{basicData.companyCreated}"
+ sortBy="#{basicData.companyEntryCreated}"
+ filterBy="#{basicData.companyEntryCreated}"
filterMatchMode="contains"
>
- <h:outputText value="#{basicData.companyCreated}">
+ <h:outputText value="#{basicData.companyEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{basicData.companyEntryUpdated}"
+ filterBy="#{basicData.companyEntryUpdated}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{basicData.companyEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
sortable="false"
filterable="false"
>
- <links:outputBasicDataAdminDropdownMenu basicData="#{basicData}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_basic_data"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_BASIC_DATA_TITLE}"
+ >
+ <f:param name="basicDataId" value="#{basicData.basicDataId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_basic_data"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_BASIC_DATA_TITLE}"
+ >
+ <f:param name="basicDataId" value="#{basicData.basicDataId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_basic_data">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_BASIC_DATA_TITLE}"
+ />
+ <f:param name="basicDataId" value="#{basicData.basicDataId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
<p:dataTable
id="branchOfficeList"
var="branchOffice"
- value="#{branchOfficeListController.allBranchOffices()}"
+ value="#{branchOfficeListController.allBranchOffices}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
filteredValue="#{branchOfficeListController.filteredBranchOffices}"
<f:converter converterId="EmployeeConverter" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
- sortBy="#{branchOffice.branchCreated}"
+ sortBy="#{branchOffice.branchEntryCreated}"
filterable="false"
>
- <h:outputText id="branchCreated" value="#{branchOffice.branchCreated}">
+ <h:outputText value="#{branchOffice.branchEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{branchOffice.branchEntryUpdated}"
+ filterable="false"
+ >
+ <h:outputText value="#{branchOffice.branchEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
sortable="false"
filterable="false"
>
- <links:outputBranchOfficeAdminDropdownMenu branchOffice="#{branchOffice}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_branch_office"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_BRANCH_OFFICE_TITLE}"
+ >
+ <f:param name="branchId" value="#{branchOffice.branchId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_branch_office"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_BRANCH_OFFICE_TITLE}"
+ >
+ <f:param name="branchId" value="#{branchOffice.branchId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_branch_office">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_BRANCH_OFFICE_TITLE}"
+ />
+ <f:param name="branchId" value="#{branchOffice.branchId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
<h:outputText value="#{msg.ADMIN_EXPORT_CONTACT_CREATED}" />
</f:facet>
- <h:outputText id="contactCreated" value="#{contact.contactCreated}">
- <f:convertDateTime type="both" timeStyle="short" dateStyle="short" locale="#{localizationController.locale}" />
+ <h:outputText value="#{contact.contactEntryCreated}">
+ <f:convertDateTime
+ type="both"
+ timeStyle="short"
+ dateStyle="short"
+ locale="#{localizationController.locale}"
+ />
+ </h:outputText>
+ </p:column>
+
+ <p:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_EXPORT_CONTACT_UPDATED}" />
+ </f:facet>
+
+ <h:outputText value="#{contact.contactEntryUpdated}">
+ <f:convertDateTime
+ type="both"
+ timeStyle="short"
+ dateStyle="short"
+ locale="#{localizationController.locale}"
+ />
</h:outputText>
</p:column>
</p:dataTable>
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
- sortBy="#{contact.contactCreated}"
- filterBy="#{contact.contactCreated}"
+ sortBy="#{contact.contactEntryCreated}"
+ filterBy="#{contact.contactEntryCreated}"
filterMatchMode="contains"
>
- <h:outputText value="#{contact.contactCreated}">
+ <h:outputText value="#{contact.contactEntryCreated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
<p:column
headerText="#{msg.ENTRY_UPDATED_HEADER}"
- sortBy="#{contact.contactUpdated}"
- filterBy="#{contact.contactUpdated}"
+ sortBy="#{contact.contactEntryUpdated}"
+ filterBy="#{contact.contactEntryUpdated}"
filterMatchMode="contains"
>
- <h:outputText value="#{contact.contactUpdated}">
+ <h:outputText value="#{contact.contactEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
</h:form>
<h:outputFormat styleClass="alert-danger" value="#{msg.ERROR_MOBILE_NUMBER_CONTACT_NOT_LINKED}" rendered="#{not empty beanHelper.mobileNumber and not empty beanHelper.contact and beanHelper.contact.contactMobileNumber != beanHelper.mobileNumber}">
- <f:param value="#{beanHelper.mobileNumber.phoneId}" />
+ <f:param value="#{beanHelper.mobileNumber.mobileId}" />
<f:param value="#{beanHelper.contact.contactId}" />
</h:outputFormat>
</ui:define>
filterable="false"
sortable="false"
>
- <links:outputCountryAdminDropdownMenu country="#{country}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_country"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_COUNTRY_TITLE}"
+ >
+ <f:param name="countryId" value="#{country.countryId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_country"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_COUNTRY_TITLE}"
+ >
+ <f:param name="countryId" value="#{country.countryId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_country">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_COUNTRY_TITLE}"
+ />
+ <f:param name="countryId" value="#{country.countryId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
<f:converter converterId="BranchOfficeConverter" />
<f:selectItems
- value="#{branchOfficeListController.allBranchOffices()}"
+ value="#{branchOfficeListController.allBranchOffices}"
var="branchOffice"
itemValue="#{branchOffice}"
itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}"
<f:converter converterId="EmployeeConverter" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
sortable="false"
filterable="false"
>
- <links:outputDepartmentAdminDropdownMenu department="#{department}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_department"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_DEPARTMENT_TITLE}"
+ >
+ <f:param name="departmentId" value="#{department.departmentId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_department"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_DEPARTMENT_TITLE}"
+ >
+ <f:param name="departmentId" value="#{department.departmentId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_department">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_DEPARTMENT_TITLE}"
+ />
+ <f:param name="departmentId" value="#{department.departmentId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
</ui:define>
<ui:define name="content">
- <h:form id="form-list-company-employees">
+ <h:form id="form-list-employees">
<p:dataTable
id="employeeList"
var="employee"
- value="#{employeeController.allEmployees()}"
- filteredValue="#{employeeController.filteredEmployees}"
+ value="#{employeeListController.allEmployees}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
+ filteredValue="#{employeeListController.filteredEmployees}"
rows="10"
+ rowKey="#{employee.employeeId}"
reflow="true"
resizableColumns="true"
rowsPerPageTemplate="5,10,20,50,100"
sortMode="multiple"
- summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_EMPLOYEES}"
- emptyMessage="#{msg.ADMIN_EMPTY_LIST_EMPLOYEES}"
+ summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_EMPLOYEESS}"
+ emptyMessage="#{msg.ADMIN_EMPTY_LIST_EMPLOYEESS}"
widgetVar="employeeList"
+ selectionMode="single"
+ selection="#{employeeListController.selectedEmployee}"
+ 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_EMPLOYEES_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('employeeList').filter()"
+ placeholder="#{msg.ENTER_KEYWORD}"
+ />
+ </p:panelGrid>
+
+ <p:outputPanel>
+ <p:spacer height="4" />
- <h:panelGroup>
<p:commandButton
id="toggler"
type="button"
/>
<p:columnToggler datasource="employeeList" trigger="toggler" />
- </h:panelGroup>
+ </p:outputPanel>
</p:panelGrid>
</f:facet>
+ <p:ajax
+ event="rowSelect"
+ update="form-list-employees:employee-details"
+ oncomplete="PF('employeeDialog').show()"
+ />
+
<p:column
headerText="#{msg.ID_HEADER}"
sortBy="#{employee.employeeId}"
<f:converter converterId="BranchOfficeConverter" />
<f:selectItems
- value="#{branchOfficeListController.allBranchOffices()}"
+ value="#{branchOfficeListController.allBranchOffices}"
var="branchOffice"
itemValue="#{branchOffice}"
itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}"
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
- sortBy="#{employee.employeeCreated}"
+ sortBy="#{employee.employeeEntryCreated}"
+ filterable="false"
+ >
+ <h:outputText value="#{employee.employeeEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{employee.employeeEntryUpdated}"
filterable="false"
>
- <h:outputText id="employeeCreated" value="#{employee.employeeCreated}">
+ <h:outputText value="#{employee.employeeEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
sortable="false"
filterable="false"
>
- <links:outputEmployeeAdminDropdownMenu employee="#{employee}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_employee"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_EMPLOYEE_TITLE}"
+ >
+ <f:param name="employeeId" value="#{employee.employeeId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_employee"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_EMPLOYEE_TITLE}"
+ >
+ <f:param name="employeeId" value="#{employee.employeeId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_employee">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_EMPLOYEE_TITLE}"
+ />
+ <f:param name="employeeId" value="#{employee.employeeId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
+
+ <p:dialog
+ dynamic="true"
+ modal="true"
+ resizable="false"
+ header="#{msg.ADMIN_SINGLE_EMPLOYEE_DETAILS_HEADER}"
+ hideEffect="fade"
+ showEffect="fade"
+ widgetVar="employeeDialog"
+ position="top"
+ responsive="true"
+ closeOnEscape="true"
+ >
+ <p:outputPanel id="employee-details">
+ <p:panelGrid
+ columns="2"
+ rendered="#{not empty employeeListController.selectedEmployee}"
+ >
+ <f:facet name="header">
+ <h:outputFormat
+ value="#{msg.ADMIN_EMPLOYEE_NUMBER_DETAILS_HEADER}"
+ rendered="#{empty employeeListController.selectedEmployee.employeePersonalData}"
+ >
+ <f:param value="#{employeeListController.selectedEmployee.employeeId}" />
+ </h:outputFormat>
+
+ <h:outputFormat
+ value="#{msg.ADMIN_EMPLOYEE_NAME_DETAILS_HEADER}"
+ rendered="#{not empty employeeListController.selectedEmployee.employeePersonalData}"
+ >
+ <f:param value="#{beanHelper.renderContact(employeeListController.selectedEmployee.employeePersonalData)}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.EMPLOYEE_ID_NUMBER_TITLE}" />
+ <h:outputText value="#{employeeListController.selectedEmployee.employeeId}" />
+ </p:panelGrid>
+ </p:outputPanel>
+ </p:dialog>
</h:form>
<h:form>
type="submit"
value="#{msg.BUTTON_ADMIN_ADD_EMPLOYEE}"
action="#{adminEmployeeController.addEmployee()}"
- update="form-list-company-employees:employeeList"
+ update="form-list-employees:employeeList"
/>
</p:panelGrid>
</f:facet>
<p:dataTable
id="table_list_fax"
var="faxNumber"
- value="#{phoneController.allFaxNumbers()}"
+ value="#{phoneListController.allFaxNumbers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_FAXS}"
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <h:outputText value="#{msg.ENTRY_CREATED_HEADER}" />
</f:facet>
<h:outputText value="#{faxNumber.phoneEntryCreated}">
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <h:outputText value="#{msg.ENTRY_UPDATED_HEADER}" />
</f:facet>
<h:outputText value="#{faxNumber.phoneEntryUpdated}">
<p:dataTable
id="contact_fax_link"
var="contact"
- value="#{contactPhoneController.allCurrentFaxNumberContacts}"
+ value="#{contactPhoneController.allCurrentFaxNumberContacts()}"
summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}"
>
<f:facet name="header">
<f:converter converterId="EmployeeConverter" />
<f:selectItems
- value="#{employeeController.allEmployees()}"
+ value="#{employeeListController.allEmployees}"
var="employee"
itemValue="#{employee}"
itemLabel="#{beanHelper.renderEmployee(employee)}"
sortable="false"
filterable="false"
>
- <links:outputHeadquarterAdminDropdownMenu headquarter="#{headquarter}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_headquarter"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_HEADQUARTER_TITLE}"
+ >
+ <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_headquarter"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_HEADQUARTER_TITLE}"
+ >
+ <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_headquarter">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_HEADQUARTER_TITLE}"
+ />
+ <f:param name="headquarterId" value="#{headquarter.headquarterId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
<p:dataTable
id="table_list_landline"
var="landLineNumber"
- value="#{phoneController.allLandLineNumbers()}"
+ value="#{phoneListController.allLandLineNumbers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_LAND_LINES}"
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <h:outputText value="#{msg.ENTRY_CREATED_HEADER}" />
</f:facet>
<h:outputText value="#{landLineNumber.phoneEntryCreated}">
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <h:outputText value="#{msg.ENTRY_UPDATED_HEADER}" />
</f:facet>
<h:outputText value="#{landLineNumber.phoneEntryUpdated}">
<p:dataTable
id="table_list_mobiles"
var="mobile"
- value="#{phoneController.allMobileNumbers()}"
+ value="#{phoneListController.allMobileNumbers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_MOBILE_NUMBERS}"
<h:panelGroup layout="block">
<div class="table-header">
<h:outputFormat value="#{msg.ADMIN_EDIT_MOBILE_NUMBER_TITLE}">
- <f:param value="#{beanHelper.mobileNumber.phoneId}" />
+ <f:param value="#{beanHelper.mobileNumber.mobileId}" />
</h:outputFormat>
</div>
<p:dataTable
id="mobileNumberList"
var="mobileNumber"
- value="#{phoneController.allMobileNumbers()}"
+ value="#{mobileListController.allMobileNumbers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_MOBILES}"
<p:link
outcome="admin_show_mobile"
- value="#{mobileNumber.phoneId}"
+ value="#{mobileNumber.mobileId}"
title="#{msg.ADMIN_LINK_SHOW_MOBILE_NUMBER_TITLE}"
>
- <f:param name="phoneId" value="#{mobileNumber.phoneId}" />
+ <f:param name="mobileId" value="#{mobileNumber.mobileId}" />
</p:link>
</p:column>
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_CREATED}" />
+ <h:outputText value="#{msg.ENTRY_CREATED_HEADER}" />
</f:facet>
- <h:outputText value="#{mobileNumber.phoneEntryCreated}">
+ <h:outputText value="#{mobileNumber.mobileEntryCreated}">
<f:convertDateTime type="both" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_PHONE_UPDATED}" />
+ <h:outputText value="#{msg.ENTRY_UPDATED_HEADER}" />
</f:facet>
- <h:outputText value="#{mobileNumber.phoneEntryUpdated}">
+ <h:outputText value="#{mobileNumber.mobileEntryUpdated}">
<f:convertDateTime type="both" />
</h:outputText>
</p:column>
<p:dataTable
id="contact_mobile_link"
var="contact"
- value="#{contactPhoneController.allCurrentMobileNumberContacts()}"
+ value="#{contactMobileController.allCurrentMobileNumberContacts()}"
summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}"
>
<f:facet name="header">
<h:outputFormat value="#{msg.ADMIN_SHOW_MOBILE_NUMBER_LINKS_HEADER}">
- <f:param value="#{beanHelper.mobileNumber.phoneId}" />
+ <f:param value="#{beanHelper.mobileNumber.mobileId}" />
</h:outputFormat>
</f:facet>
outcome="admin_unlink_contact_mobile"
>
<h:outputText styleClass="link-warning" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_MOBILE_NUMBER_CONTACT_TITLE}" />
- <f:param name="phoneId" value="#{beanHelper.mobileNumber.phoneId}" />
+ <f:param name="phoneId" value="#{beanHelper.mobileNumber.mobileId}" />
<f:param name="contactId" value="#{contact.contactId}" />
</p:link>
</li>
</ui:define>
<ui:define name="content">
- <h:form id="form-list-mobile-provider">
+ <h:form id="form-list-mobile-providers">
<p:dataTable
id="mobileProviderList"
var="mobileProvider"
- value="#{mobileProviderController.allMobileProviders()}"
+ value="#{mobileProviderListController.allMobileProviders}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
- filteredValue="#{mobileProviderController.filteredMobileProviders}"
+ filteredValue="#{mobileProviderListController.filteredMobileProviders}"
rows="10"
+ rowKey="#{mobileProvider.providerId}"
reflow="true"
resizableColumns="true"
rowsPerPageTemplate="5,10,20,50,100"
sortMode="multiple"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_MOBILE_PROVIDERS}"
- emptyMessage="#{msg.ADMIN_EMPTY_LIST_MOBILE_PROVIDER}"
+ emptyMessage="#{msg.ADMIN_EMPTY_LIST_MOBILE_PROVIDERS}"
widgetVar="mobileProviderList"
+ selectionMode="single"
+ selection="#{mobileProviderListController.selectedMobileProvider}"
+ 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_MOBILE_PROVIDERS_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('mobileProviderList').filter()"
+ placeholder="#{msg.ENTER_KEYWORD}"
+ />
+ </p:panelGrid>
- <p:commandButton
- id="toggler"
- type="button"
- value="#{msg.SELECT_SHOWN_COLUMNS}"
- styleClass="column-selector"
- />
+ <p:outputPanel>
+ <p:spacer height="4" />
- <p:columnToggler datasource="mobileProviderList" trigger="toggler" />
+ <p:commandButton
+ id="toggler"
+ type="button"
+ value="#{msg.SELECT_SHOWN_COLUMNS}"
+ styleClass="column-selector"
+ />
+
+ <p:columnToggler datasource="mobileProviderList" trigger="toggler" />
+ </p:outputPanel>
</p:panelGrid>
</f:facet>
+ <p:ajax
+ event="rowSelect"
+ update="form-list-mobile-providers:mobile-provider-details"
+ oncomplete="PF('mobileProviderDialog').show()"
+ />
+
<p:column
headerText="#{msg.ID_HEADER}"
sortBy="#{mobileProvider.providerId}"
headerText="#{msg.ENTRY_CREATED_HEADER}"
sortBy="#{mobileProvider.providerEntryCreated}"
>
- <h:outputText id="providerEntryCreated" value="#{mobileProvider.providerEntryCreated}">
+ <h:outputText value="#{mobileProvider.providerEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{mobileProvider.providerEntryUpdated}"
+ >
+ <h:outputText value="#{mobileProvider.providerEntryUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
headerText="#{msg.ADMIN_ACTION_LINKS_HEADER}"
sortable="false"
>
- <links:outputMobileProviderAdminDropdownMenu mobileProvider="#{mobileProvider}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem
+ outcome="admin_show_mobile_provider"
+ value="#{msg.ADMIN_LINK_SHOW_SHORT}"
+ title="#{msg.ADMIN_LINK_SHOW_MOBILE_PROVIDER_TITLE}"
+ >
+ <f:param name="providerId" value="#{mobileProvider.providerId}" />
+ </p:menuitem>
+
+ <p:menuitem
+ outcome="admin_edit_mobile_provider"
+ value="#{msg.ADMIN_LINK_EDIT_SHORT}"
+ title="#{msg.ADMIN_LINK_EDIT_MOBILE_PROVIDER_TITLE}"
+ >
+ <f:param name="providerId" value="#{mobileProvider.providerId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_mobile_provider">
+ <h:outputText
+ styleClass="link-danger"
+ value="#{msg.ADMIN_LINK_DELETE_SHORT}"
+ title="#{msg.ADMIN_LINK_DELETE_MOBILE_PROVIDER_TITLE}"
+ />
+ <f:param name="providerId" value="#{mobileProvider.providerId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
+
+ <p:dialog
+ dynamic="true"
+ modal="true"
+ resizable="false"
+ header="#{msg.ADMIN_SINGLE_MOBILE_PROVIDER_DETAILS_HEADER}"
+ hideEffect="fade"
+ showEffect="fade"
+ widgetVar="mobileProviderDialog"
+ position="top"
+ responsive="true"
+ closeOnEscape="true"
+ >
+ <p:outputPanel id="mobile-provider-details">
+ <p:panelGrid columns="2" rendered="#{not empty mobileProviderListController.selectedMobileProvider}">
+ <f:facet name="header">
+ <h:outputFormat value="#{msg.ADMIN_MOBILE_PROVIDER_DETAILS_HEADER}">
+ <f:param value="#{mobileProviderListController.selectedMobileProvider.providerName}" />
+ <f:param value="#{mobileProviderListController.selectedMobileProvider.providerId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.MOBILE_PROVIDER_ID_NUMBER_TITLE}" />
+ <h:outputText value="#{mobileProviderListController.selectedMobileProvider.providerId}" />
+ </p:panelGrid>
+ </p:outputPanel>
+ </p:dialog>
</h:form>
<h:form>
type="submit"
value="#{msg.BUTTON_ADMIN_ADD_MOBILE_PROVIDER}"
action="#{adminMobileProviderController.addMobileProvider()}"
- update="form-list-mobile-provider:mobileProviderList"
+ update="form-list-mobile-providers:mobileProviderList"
/>
</p:panelGrid>
</h:panelGroup>
</ui:define>
<ui:define name="content">
- <h:form id="form-list-opening-time">
+ <h:form id="form-list-opening-times">
<p:dataTable
id="openingTimeList"
var="openingTime"
- value="#{openingTimeController.allOpeningTimes()}"
+ value="#{openingTimeListController.allOpeningTimes}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
- filteredValue="#{openingTimeController.filteredOpeningTimes}"
+ filteredValue="#{openingTimeListController.filteredOpeningTimes}"
rows="10"
+ rowKey="#{openingTime.openingTimeId}"
reflow="true"
resizableColumns="true"
rowsPerPageTemplate="5,10,20,50,100"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_OPENING_TIMES}"
emptyMessage="#{msg.ADMIN_EMPTY_LIST_OPENING_TIMES}"
widgetVar="openingTimeList"
+ selectionMode="single"
+ selection="#{openingTimeListController.selectedOpeningTime}"
+ 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_OPENING_TIMES_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('openingTimeList').filter()"
+ placeholder="#{msg.ENTER_KEYWORD}"
+ />
+ </p:panelGrid>
+
+ <p:outputPanel>
+ <p:spacer height="4" />
- <h:panelGroup>
<p:commandButton
id="toggler"
type="button"
/>
<p:columnToggler datasource="openingTimeList" trigger="toggler" />
- </h:panelGroup>
+ </p:outputPanel>
</p:panelGrid>
</f:facet>
+ <p:ajax
+ event="rowSelect"
+ update="form-list-opening-times:opening-time-details"
+ oncomplete="PF('openingTimeDialog').show()"
+ />
+
<p:column
headerText="#{msg.ID_HEADER}"
- sortBy="#{openingTime.openingId}"
+ sortBy="#{openingTime.openingTimeId}"
filterable="false"
>
<p:link
outcome="admin_show_opening_time"
- value="#{openingTime.openingId}"
- title="#{msg.ADMIN_LINK_SHOW_DEPARTMENT_TITLE}"
+ value="#{openingTime.openingTimeId}"
+ title="#{msg.ADMIN_LINK_SHOW_OPENING_TIME_TITLE}"
>
- <f:param name="openingId" value="#{openingTime.openingId}" />
+ <f:param name="openingTimeId" value="#{openingTime.openingTimeId}" />
</p:link>
</p:column>
</h:outputText>
</p:column>
+ <p:column
+ headerText="#{msg.ENTRY_CREATED_HEADER}"
+ sortBy="#{openingTime.openingTimeEntryCreated}"
+ filterBy="#{openingTime.openingTimeEntryCreated}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{openingTime.openingTimeEntryCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{openingTime.openingTimeEntryUpdated}"
+ filterBy="#{openingTime.openingTimeEntryUpdated}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{openingTime.openingTimeEntryUpdated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
<p:column
headerText="#{msg.ADMIN_ACTION_LINKS_HEADER}"
sortable="false"
filterable="false"
>
- <links:outputOpeningTimeAdminDropdownMenu openingTime="#{openingTime}" />
+ <p:menuButton value="#{msg.OPTIONS}">
+ <p:menuitem outcome="admin_show_opening_time" value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_OPENING_TIME_TITLE}">
+ <f:param name="openingTimeId" value="#{openingTime.openingTimeId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_edit_opening_time" value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_OPENING_TIME_TITLE}">
+ <f:param name="openingTimeId" value="#{openingTime.openingTimeId}" />
+ </p:menuitem>
+
+ <p:menuitem outcome="admin_delete_opening_time">
+ <h:outputText styleClass="link-danger" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_OPENING_TIME_TITLE}" />
+ <f:param name="openingTimeId" value="#{openingTime.openingTimeId}" />
+ </p:menuitem>
+ </p:menuButton>
</p:column>
</p:dataTable>
+
+ <p:dialog
+ dynamic="true"
+ modal="true"
+ resizable="false"
+ header="#{msg.ADMIN_SINGLE_OPENING_TIME_DETAILS_HEADER}"
+ hideEffect="fade"
+ showEffect="fade"
+ widgetVar="openingTimeDialog"
+ position="top"
+ responsive="true"
+ closeOnEscape="true"
+ >
+ <p:outputPanel id="opening-time-details">
+ <p:panelGrid columns="2" rendered="#{not empty openingTimeListController.selectedOpeningTime}">
+ <f:facet name="header">
+ <h:outputFormat value="#{msg.ADMIN_OPENING_TIME_DETAILS_HEADER}">
+ <f:param value="#{openingTimeListController.selectedOpeningTime.openingTimeId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.OPENING_TIME_ID_NUMBER_TITLE}" />
+ <h:outputText value="#{openingTimeListController.selectedOpeningTime.openingTimeId}" />
+ </p:panelGrid>
+ </p:outputPanel>
+ </p:dialog>
</h:form>
<h:form>
type="submit"
value="#{msg.BUTTON_ADMIN_ADD_OPENING_TIME}"
action="#{adminOpeningTimeController.addOpeningTime()}"
- update="form-list-opening-time:openingTimeList"
+ update="form-list-opening-times:openingTimeList"
/>
</p:panelGrid>
</f:facet>
<h:outputText value="#{msg.ADMIN_EXPORT_CONTACT_CREATED}" />
</f:facet>
- <h:outputText id="contactCreated" value="#{user.userContact.contactCreated}">
- <f:convertDateTime type="both" timeStyle="short" dateStyle="short" locale="#{localizationController.locale}" />
+ <h:outputText value="#{user.userContact.contactEntryCreated}">
+ <f:convertDateTime
+ type="both"
+ timeStyle="short"
+ dateStyle="short"
+ locale="#{localizationController.locale}"
+ />
+ </h:outputText>
+ </p:column>
+
+ <p:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_EXPORT_CONTACT_UPDATED}" />
+ </f:facet>
+
+ <h:outputText value="#{user.userContact.contactEntryUpdated}">
+ <f:convertDateTime
+ type="both"
+ timeStyle="short"
+ dateStyle="short"
+ locale="#{localizationController.locale}"
+ />
</h:outputText>
</p:column>
</p:dataTable>
<ui:define name="metadata">
<f:metadata>
- <f:viewParam name="userId" value="#{beanHelper.user}" converter="UserConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}" converterMessage="#{msg.PARAMETER_USER_ID_INVALID}" />
+ <f:viewParam
+ name="userId"
+ value="#{beanHelper.user}"
+ converter="UserConverter"
+ required="true"
+ requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}"
+ converterMessage="#{msg.PARAMETER_USER_ID_INVALID}"
+ />
<f:viewAction action="#{beanHelper.notifyControllerUserConverted()}" />
</f:metadata>
</ui:define>
</ui:define>
<ui:define name="content">
- <core:outputMessageBox panelGroupId="errorUserProfileDisabled" message="#{msg.ERROR_GUEST_USER_PROFILE_DISABLED}" messageStyleClass="alert-danger" rendered="#{not userController.isPublicUserProfileEnabled()}" />
+ <core:outputMessageBox
+ panelGroupId="errorUserProfileDisabled"
+ message="#{msg.ERROR_GUEST_USER_PROFILE_DISABLED}"
+ messageStyleClass="alert-danger"
+ rendered="#{not featureController.isFeatureEnabled("public_user_profile")}"
+ />
- <core:outputMessageBox panelGroupId="errorUserIdEmpty" message="#{msg.TABLE_HEADER_ERROR_HANDLING_USER_ID}" rendered="#{userController.isUserIdEmpty()}" />
+ <core:outputMessageBox
+ panelGroupId="errorUserIdEmpty"
+ message="#{msg.TABLE_HEADER_ERROR_HANDLING_USER_ID}"
+ rendered="#{userLoginController.isUserIdEmpty()}"
+ />
- <ui:fragment rendered="#{userController.isPublicUserProfileEnabled()}">
- <core:outputMessageBox panelGroupId="errorUserProfileHidden" message="#{msg.ERROR_PROFILE_NOT_VISIBLE}" messageStyleClass="alert-danger" rendered="#{not profileController.isProfileLinkVisibleById(userController.userId)}" />
+ <ui:fragment rendered="#{featureController.isFeatureEnabled("public_user_profile")}">
+ <core:outputMessageBox
+ panelGroupId="errorUserProfileHidden"
+ message="#{msg.ERROR_PROFILE_NOT_VISIBLE}"
+ messageStyleClass="alert-danger"
+ rendered="#{not profileController.isProfileLinkVisibleById(userLoginController.userId)}"
+ />
- <ui:fragment rendered="#{profileController.isProfileLinkVisibleById(userController.userId)}">
+ <ui:fragment rendered="#{profileController.isProfileLinkVisibleById(userLoginController.userId)}">
<p:panelGrid>
<f:facet name="header">
<h:outputText value="#{msg.PUBLIC_USER_PROFILE}" />
</div>
<h:form>
- <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl" />
+ <ui:include src="/WEB-INF/templates/contact/form_contact_data.tpl">
+ <ui:param name="targetController" value="#{userLoginController}" />
+ </ui:include>
<ui:include src="/WEB-INF/templates/login/user/user_enter_current_password.tpl" />