dist.war=${dist.dir}/${war.name}
endorsed.classpath=
excludes=
-file.reference.jaddressbook-core.jar=lib/jaddressbook-core.jar
-file.reference.jaddressbook-lib.jar=lib/jaddressbook-lib.jar
file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
file.reference.jcontacts-business-lib.jar=lib/jcontacts-business-lib.jar
file.reference.cdi-api.jar=lib/cdi-api.jar
${file.reference.juser-activity-lib.jar}:\
${file.reference.jcontacts-business-core.jar}:\
${file.reference.jcontacts-business-lib.jar}:\
- ${file.reference.jaddressbook-core.jar}:\
- ${file.reference.jaddressbook-lib.jar}:\
${reference.jjobs-core.jar}:\
${reference.jjobs-lib.jar}:\
${file.reference.cdi-api.jar}:\
source.reference.juser-activity-lib.jar=../juser-activity-lib/src/
source.reference.juser-core.jar=../juser-core/src/
source.reference.juser-lib.jar=../juser-lib/src/
-source.reference.jaddressbook-core.jar=../jaddressbook-core/src/
-source.reference.jaddressbook-lib.jar=../jaddressbook-lib/src/
source.reference.juser-login-core.jar=../juser-login-core/src/
source.reference.juser-login-lib.jar=../juser-login-lib/src/
source.root=src
<library dirs="200">
<file>${file.reference.jcontacts-business-lib.jar}</file>
</library>
- <library dirs="200">
- <file>${file.reference.jaddressbook-core.jar}</file>
- </library>
- <library dirs="200">
- <file>${file.reference.jaddressbook-lib.jar}</file>
- </library>
<library dirs="200">
<file>${reference.jjobs-core.jar}</file>
</library>
+++ /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.jjobs.beans.addressbook;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbook.events.addressbook.AddressbookLoadedEvent;
-import org.mxchange.jaddressbook.events.addressbook.ObservableAddressbookLoadedEvent;
-import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbook.model.addressbook.Addressbook;
-import org.mxchange.jaddressbook.model.addressbook.UserAddressbook;
-import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jjobs.beans.BaseJobsBean;
-import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
-
-/**
- * An address book bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("addressbookController")
-@SessionScoped
-public class JobsAddressbookWebSessionBean extends BaseJobsBean implements JobsAddressbookWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 185_781_756_712_969L;
-
- /**
- * Address book instance
- */
- private Addressbook addressbook;
-
- /**
- * Remote address book bean
- */
- private AddressbookSessionBeanRemote addressbookBean;
-
- /**
- * When this address book has been created
- */
- private Date addressbookCreated;
-
- /**
- * Address book id number (from URL for example)
- */
- private Long addressbookId;
-
- /**
- * Name of the address book
- */
- private String addressbookName;
-
- /**
- * Who owns this address book
- */
- private User addressbookUser;
-
- /**
- * Event fired when user has logged in
- */
- @Inject
- @Any
- private Event<ObservableAddressbookLoadedEvent> loadedEvent;
-
- /**
- * Login controller
- */
- @Inject
- private JobsUserLoginWebSessionController userLoginController;
-
- /**
- * A list of all user's address books
- */
- private List<Addressbook> usersAddressbooks;
-
- /**
- * Default constructor
- */
- public JobsAddressbookWebSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- public String addAddressbook () {
- // Is this name already used?
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- } else if (this.getAddressbookName() == null) {
- // Address book name is null
- throw new NullPointerException("addressbookName is null"); //NOI18N
- } else if (this.getAddressbookName().isEmpty()) {
- // Address book name is empty
- throw new IllegalStateException("addressbookName is empty."); //NOI18N
- } else if (this.isAddressbookNameUsed(this.getAddressbookName())) {
- // Already used by this user
- throw new FaceletException(MessageFormat.format("Address book name {0} already used.", this.getAddressbookName())); //NOI18N
- }
-
- // Create address book instance with name
- Addressbook book = new UserAddressbook(this.getAddressbookName(), this.userLoginController.getLoggedInUser());
-
- try {
- // Register this address book
- Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(book);
-
- // Remove name
- this.setAddressbookName(null);
-
- // Add address book entry to list
- this.usersAddressbooks.add(updatedAddressbook);
-
- // All fine
- return "login_own_addressbooks"; //NOI18N
- } catch (final AddressbookNameAlreadyUsedException ex) {
- // Throw again as cause
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public void afterAddressbookLoadedEvent (@Observes final ObservableAddressbookLoadedEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddressbook() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addressbook is null"); //NOI18N
- } else if (event.getAddressbook().getAddressbookId() == null) {
- // And again a NPE
- throw new NullPointerException("event.addressbook.addressbookId is null"); //NOI18N
- } else if (event.getAddressbook().getAddressbookId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("Address book instance {0} has invalid id number: {1}", event.getAddressbook(), event.getAddressbook().getAddressbookId())); //NOI18N
- } else if (event.getAddressbook().getAddressbookUser() == null) {
- // One more NPE ...
- throw new NullPointerException("event.addressbook.addressbookUser is null"); //NOI18N
- }
-
- // Get address book instance
- final Addressbook book = event.getAddressbook();
-
- // Set address book data
- this.setAddressbookId(book.getAddressbookId());
- this.setAddressbookName(book.getAddressbookName());
- this.setAddressbookUser(book.getAddressbookUser());
- this.setAddressbookCreated(book.getAddressbookCreated());
-
- // And instance ...
- this.setAddressbook(book);
- }
-
- @Override
- public void afterLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
- // Is the user logged in?
- if (null == event) {
- // Is null
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser() == null) {
- // user is null
- throw new NullPointerException("event.user is null"); //NOI18N
- } else if (!event.getLoggedInUser().equals(this.userLoginController.getLoggedInUser())) {
- // Not matching
- throw new IllegalStateException("event.user and userLoginController.loggedInUser don't match."); //NOI18N
- } else if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Init user's address book list
- this.initAddressbookList();
- }
-
- @Override
- public List<Addressbook> allAddressbooks () {
- // Is the user logged in?
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- return Collections.unmodifiableList(this.usersAddressbooks);
- }
-
- @Override
- public List<AddressbookEntry> allEntries (final Addressbook addressbook) {
- // Is the user logged in?
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Ask the bean
- return this.addressbookBean.allEntries(addressbook);
- }
-
- @Override
- public int allEntriesSize (final Addressbook addressbook) {
- // Ask the bean
- return this.allEntries(addressbook).size();
- }
-
- @Override
- public Addressbook getAddressbook () {
- return this.addressbook;
- }
-
- @Override
- public void setAddressbook (final Addressbook addressbook) {
- this.addressbook = addressbook;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfDateField")
- public Date getAddressbookCreated () {
- return this.addressbookCreated;
- }
-
- @Override
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setAddressbookCreated (final Date addressbookCreated) {
- this.addressbookCreated = addressbookCreated;
- }
-
- @Override
- public Long getAddressbookId () {
- return this.addressbookId;
- }
-
- @Override
- public void setAddressbookId (final Long addressbookId) {
- this.addressbookId = addressbookId;
- }
-
- @Override
- public String getAddressbookName () {
- return this.addressbookName;
- }
-
- @Override
- public void setAddressbookName (final String addressbookName) {
- this.addressbookName = addressbookName;
- }
-
- @Override
- public User getAddressbookUser () {
- return this.addressbookUser;
- }
-
- @Override
- public void setAddressbookUser (final User addressbookUser) {
- this.addressbookUser = addressbookUser;
- }
-
- @Override
- public boolean hasCreatedAddressbooks () {
- // Is the user logged in?
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Check if the list is filled
- return (!this.usersAddressbooks.isEmpty());
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/jjobs-ejb/jjobs-adr!org.mxchange.jjobs.model.addressbook.JobsAddressbookSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
- // Init list
- this.usersAddressbooks = new LinkedList<>();
-
- // Is the user logged-in?
- if (this.userLoginController.isUserLoggedIn()) {
- // Initialize list
- this.initAddressbookList();
- }
-
- // TODO Initialize list from bean with just one call
- //this.addressbookBean.getUserCountMap()
- }
-
- @Override
- public boolean isAddressbookLoaded () {
- return ((this.getAddressbookId() instanceof Long) &&
- (this.getAddressbookName() instanceof String) &&
- (!this.getAddressbookName().isEmpty()) &&
- (this.getAddressbookUser() instanceof User));
- }
-
- @Override
- public boolean isAddressbookNameUsed (final String addressbookName) {
- // Is it zero size?
- if (null == addressbookName) {
- // Is null
- throw new NullPointerException("addressbookName is null"); //NOI18N
- } else if (this.usersAddressbooks.isEmpty()) {
- // Not found!
- return false;
- }
-
- // Default is not found
- boolean isFound = false;
-
- // Check all entries
- for (final Addressbook book : this.usersAddressbooks) {
- // Is the name same?
- if (book.getAddressbookName().equals(addressbookName)) {
- // Found a match
- isFound = true;
- break;
- }
- }
-
- // Return status
- return isFound;
- }
-
- @Override
- public boolean isOtherAddressbook () {
- // Just call the other method and invert it
- return (!this.isOwnAddressbook());
- }
-
- @Override
- public boolean isOwnAddressbook () {
- // Is the user logged in?
- if (!this.userLoginController.isUserLoggedIn()) {
- // No, then no own address book
- throw new IllegalStateException("isOwnAddressbook() has been invoked for a guest account"); //NOI18N
- }
-
- // Is same user?
- return Objects.equals(this.getAddressbookUser(), this.userLoginController.getLoggedInUser());
- }
-
- @Override
- public boolean loadAddressbook () {
- // Check if the id is set
- if (this.getAddressbookId() == null) {
- // Throw NPE
- throw new NullPointerException("this.addressbookId is null");
- } else if (this.getAddressbookId() < 1) {
- // Not valid id
- throw new IllegalStateException(MessageFormat.format("this.addressbook={0} is invalid", this.getAddressbookId()));
- }
-
- // Default is not found
- boolean isFound = false;
-
- try {
- // Then try to look it up
- Addressbook a = this.addressbookBean.getAddressbookById(this.getAddressbookId());
-
- // Fire event here
- this.loadedEvent.fire(new AddressbookLoadedEvent(a));
-
- // Found it
- isFound = true;
- } catch (final AddressbookNotFoundException ex) {
- // Not found!
- throw new FaceletException(ex);
- }
-
- // Return status
- return isFound;
- }
-
- /**
- * Initializes the user user's address book list
- */
- private void initAddressbookList () {
- // Get user instance
- User user = this.userLoginController.getLoggedInUser();
-
- // Fill list with entries
- this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(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.jjobs.beans.addressbook;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-import org.mxchange.jaddressbook.events.addressbook.ObservableAddressbookLoadedEvent;
-import org.mxchange.jaddressbook.model.addressbook.Addressbook;
-import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
-
-/**
- * An interface for address book beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface JobsAddressbookWebSessionController extends Serializable {
-
- /**
- * Checks whether the user has created addressbooks. For this method to work
- * it is vital that the user is logged into his/her account.
- * <p>
- * @return Whether the user has created at least one addressbook
- */
- boolean hasCreatedAddressbooks ();
-
- /**
- * Creates a new address book with a name and redirects to proper target.
- * For this method to work it is vital that the user is logged into his/her
- * account.
- * <p>
- * @return Target to redirect to
- */
- String addAddressbook ();
-
- /**
- * Getter for address book name
- * <p>
- * @return Address book name
- */
- String getAddressbookName ();
-
- /**
- * Setter for address book name
- * <p>
- * @param addressbookName Address book name
- */
- void setAddressbookName (final String addressbookName);
-
- /**
- * Checks if the given address book name is already used by the user.
- * <p>
- * @param addressbookName Address book name to check
- * <p>
- * @return Whether the name has already been used by the user
- */
- boolean isAddressbookNameUsed (final String addressbookName);
-
- /**
- * Returns all address books with this user
- * <p>
- * @return A list of all address books by this user
- */
- List<Addressbook> allAddressbooks ();
-
- /**
- * Returns a list of all address book entries for given address book
- * <p>
- * @param addressbook Address book instance
- * <p>
- * @return List of all entries
- */
- List<AddressbookEntry> allEntries (final Addressbook addressbook);
-
- /**
- * Size of all entries in given address book
- * <p>
- * @param addressbook Address book instance
- * <p>
- * @return Size of the entries in address book
- */
- int allEntriesSize (final Addressbook addressbook);
-
- /**
- * Getter for address book id number
- * <p>
- * @return Address book id number
- */
- Long getAddressbookId ();
-
- /**
- * Setter for address book id number
- * <p>
- * @param addressbookId Address book id number
- */
- void setAddressbookId (final Long addressbookId);
-
- /**
- * Getter for address book user (owner)
- * <p>
- * @return Address book user (owner)
- */
- User getAddressbookUser ();
-
- /**
- * Setter for address book user (owner)
- * <p>
- * @param addressbookUser Address book user (owner)
- */
- void setAddressbookUser (final User addressbookUser);
-
- /**
- * Getter for when the address book has been created
- * <p>
- * @return When the address book has been created
- */
- Date getAddressbookCreated ();
-
- /**
- * Setter for when the address book has been created
- * <p>
- * @param addressbookCreated When the address book has been created
- */
- void setAddressbookCreated (final Date addressbookCreated);
-
- /**
- * This method is called when an address book has been successfully loaded
- * from JPA.
- * <p>
- * @param event Event with address book instance
- */
- void afterAddressbookLoadedEvent (final ObservableAddressbookLoadedEvent event);
-
- /**
- * This method is called when a user has successfully logged in his/her
- * account.
- * <p>
- * @param event
- */
- void afterLoginEvent (final ObservableUserLoggedInEvent event);
-
- /**
- * Checks if the user is logged in and if so if it matches the current
- * address book owner.
- * <p>
- * @return Whether the owner matches currently logged-in user
- */
- boolean isOwnAddressbook ();
-
- /**
- * Checks if the owner of the current address book is NOT matching the
- * logged-in user.
- * <p>
- * @return Whether the user does NOT match
- */
- boolean isOtherAddressbook ();
-
- /**
- * Getter for address book instance
- * <p>
- * @return Address book instance
- */
- Addressbook getAddressbook ();
-
- /**
- * Setter for address book instance
- * <p>
- * @param addressbook Address book instance
- */
- void setAddressbook (final Addressbook addressbook);
-
- /**
- * Checks weather an address book has been loaded by checking the id number.
- * <p>
- * @return Whether the address book is loaded
- */
- boolean isAddressbookLoaded ();
-
- /**
- * Loads address book from current id
- * <p>
- * @return Whether the address book was found
- */
- boolean loadAddressbook ();
-}
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;
+import org.mxchange.jjobs.beans.business.employee.list.JobsEmployeeListWebViewController;
/**
* A request-scoped bean for administrative purposes for administrative employee
* Administrative list-all-employees controller
*/
@Inject
- private FinancialsEmployeeListWebViewController adminEmployeeListController;
+ private JobsEmployeeListWebViewController adminEmployeeListController;
/**
* Assigned basic data instance
+++ /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;
-
-}
--- /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.jjobs.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.jjobs.beans.BaseJobsBean;
+
+/**
+ * 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 JobsEmployeeListWebViewBean extends BaseJobsBean implements JobsEmployeeListWebViewController {
+
+ /**
+ * 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/jjobs-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 JobsEmployeeListWebViewBean () {
+ // 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.jjobs.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 JobsEmployeeListWebViewController 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;
+
+}
+++ /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;
-
-}
--- /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.jjobs.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.jjobs.beans.BaseJobsBean;
+
+/**
+ * A general bean for opening times
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("openingTimeListController")
+@ViewScoped
+public class JobsOpeningTimeListWebViewBean extends BaseJobsBean implements JobsOpeningTimeListWebViewController {
+
+ /**
+ * 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/jjobs-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 JobsOpeningTimeListWebViewBean () {
+ // 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.jjobs.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 JobsOpeningTimeListWebViewController 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;
+
+}
+++ /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 {
-
-}
--- /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.jjobs.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.jjobs.beans.BaseJobsBean;
+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 JobsAdminContactMobileWebRequestBean extends BaseJobsBean implements JobsAdminContactMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_919L;
+
+ /**
+ * Administrative EJB for phone number
+ */
+ @EJB (lookup = "java:global/jjobs-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;
+
+ /**
+ * 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 JobsAdminContactMobileWebRequestBean () {
+ // 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.jjobs.beans.contact.mobile;
+
+import org.mxchange.jjobs.beans.contact.phone.*;
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsAdminContactMobileWebRequestController 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.jjobs.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.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
+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 JobsContactMobileWebRequestBean extends BaseJobsBean implements JobsContactMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * An instance of a contact-list controller
+ */
+ @Inject
+ private JobsContactListWebViewController contactListController;
+
+ /**
+ * Chosen mobile number
+ */
+ private DialableMobileNumber mobileNumber;
+
+ /**
+ * Default constructor
+ */
+ public JobsContactMobileWebRequestBean () {
+ // 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.jjobs.beans.contact.mobile;
+
+import org.mxchange.jjobs.beans.contact.phone.*;
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsContactMobileWebRequestController 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.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.FacesException;
-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 FacesException("Not all required fields are set."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- throw new FacesException(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 ();
-
-}
+++ /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);
-
-}
* 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;
+package org.mxchange.jjobs.beans.user.list;
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
/**
* Remote user bean
*/
- @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
private UserSessionBeanRemote userBean;
/**
* 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;
+package org.mxchange.jjobs.beans.user.list;
import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
-import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek;
-import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jcoreee.dates.DayOfTheWeek;
+import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
* Returns an array of all profile modes <p <p>
* @
*
+ *
* return An array of all profile modes
*/
public ProfileMode[] getProfileModes () {
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
* Regular user controller
*/
@Inject
- private FinancialsContactListWebViewController contactListController;
+ private JobsContactListWebViewController contactListController;
/**
* Fax number
* 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;
+package org.mxchange.jjobs.beans.mobile;
import java.text.MessageFormat;
import java.util.Date;
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.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.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;
*/
@Named ("adminMobileController")
@RequestScoped
-public class FinancialsAdminMobileWebRequestBean extends BaseFinancialsBean implements FinancialsAdminMobileWebRequestController {
+public class FinancialsAdminMobileWebRequestBean extends BaseJobsBean implements FinancialsAdminMobileWebRequestController {
/**
* Serial number
/**
* Remote EJB for phone number (administrative)
*/
- @EJB (lookup = "java:global/jfinancials-ejb/adminMobile!org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/adminMobile!org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote")
private AdminMobileSessionBeanRemote adminMobileBean;
/**
* 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;
+package org.mxchange.jjobs.beans.mobile;
import java.io.Serializable;
* 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;
+package org.mxchange.jjobs.beans.mobile.list;
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
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.jjobs.beans.BaseJobsBean;
import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
*/
@Named ("mobileListController")
@ViewScoped
-public class FinancialsMobileListWebViewBean extends BaseFinancialsBean implements FinancialsMobileListWebViewController {
+public class FinancialsMobileListWebViewBean extends BaseJobsBean implements FinancialsMobileListWebViewController {
/**
* Serial number
/**
* General EJB for mobile numbers
*/
- @EJB (lookup = "java:global/jfinancials-ejb/mobile!org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/mobile!org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote")
private MobileSessionBeanRemote mobileBean;
/**
* 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;
+package org.mxchange.jjobs.beans.mobile.list;
import java.io.Serializable;
import java.util.List;
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jjobs.beans.BaseJobsBean;
-import org.mxchange.jfinancials.beans.mobileprovider.list.FinancialsMobileProviderListWebViewController;
+import org.mxchange.jjobs.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;
* 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;
+package org.mxchange.jjobs.beans.mobileprovider.list;
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
*/
@Named ("mobileProviderListController")
@ViewScoped
-public class FinancialsMobileProviderListWebViewBean extends BaseFinancialsBean implements FinancialsMobileProviderListWebViewController {
+public class FinancialsMobileProviderListWebViewBean extends BaseJobsBean implements FinancialsMobileProviderListWebViewController {
/**
* Serial number
/**
* Remote EJB for mobile providers (regular)
*/
- @EJB (lookup = "java:global/jfinancials-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
private MobileProviderSingletonBeanRemote mobileProviderBean;
/**
* 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;
+package org.mxchange.jjobs.beans.mobileprovider.list;
import java.io.Serializable;
import java.util.List;
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jjobs.beans.BaseJobsBean;
-import org.mxchange.jfinancials.beans.phone.list.FinancialsPhoneListWebViewController;
+import org.mxchange.jjobs.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;
* 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;
+package org.mxchange.jjobs.beans.phone.list;
import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
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.jjobs.beans.BaseJobsBean;
import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
*/
@Named ("phoneListController")
@ViewScoped
-public class FinancialsPhoneListWebViewBean extends BaseFinancialsBean implements FinancialsPhoneListWebViewController {
+public class FinancialsPhoneListWebViewBean extends BaseJobsBean implements FinancialsPhoneListWebViewController {
/**
* Serial number
/**
* General EJB for phone numbers
*/
- @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
+ @EJB (lookup = "java:global/jjobs-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
private PhoneSessionBeanRemote phoneBean;
/**
* 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;
+package org.mxchange.jjobs.beans.phone.list;
import java.io.Serializable;
import java.util.List;
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
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.jjobs.beans.contact.JobsAdminContactWebRequestController;
import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent;
import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
import org.mxchange.jusercore.events.user.update.post.AdminPostUserDataUpdatedEvent;
+import org.mxchange.jusercore.events.user.update.post.ObservableAdminPostUserDataUpdatedEvent;
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 controller (bean)
--- /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.jjobs.beans.user.action;
+
+import java.io.Serializable;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsUserActionWebRequestController 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 ();
+
+}
--- /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.jjobs.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.FacesException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController;
+import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
+import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
+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 JobssUserActionWebRequestBean extends BaseJobsBean implements JobsUserActionWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_920L;
+
+ /**
+ * General contact controller
+ */
+ @Inject
+ private JobsContactWebRequestController contactController;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private JobsFeaturesWebApplicationController 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/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * Login controller (bean)
+ */
+ @Inject
+ private JobsUserLoginWebSessionController userLoginController;
+
+ /**
+ * Default constructor
+ */
+ public JobssUserActionWebRequestBean () {
+ // 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 FacesException("Not all required fields are set."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ throw new FacesException(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
+ }
+
+}
import org.mxchange.jcoreee.events.helper.clear.ObservableHelperCleanupEvent;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jjobs.beans.BaseJobsBean;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
+import org.mxchange.jjobs.beans.user.email_address.list.JobsEmailChangeListWebViewController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
import org.mxchange.jusercore.model.email_address.EmailAddressChange;
* Controller for listing email address changes
*/
@Inject
- private FinancialsEmailChangeListWebViewController emailChangeListController;
+ private JobsEmailChangeListWebViewController emailChangeListController;
/**
* Features controller
*/
@Inject
- private FinancialsFeaturesWebApplicationController featureController;
+ private JobsFeaturesWebApplicationController featureController;
/**
* Login controller (bean)
--- /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.jjobs.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.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
+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 JobsEmailChangeListWebViewBean extends BaseJobsBean implements JobsEmailChangeListWebViewController {
+
+ /**
+ * 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/jjobs-ejb/userEmailChange!org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote")
+ private UserEmailChangeSessionBeanRemote emailChangeBean;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private JobsFeaturesWebApplicationController 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 JobsEmailChangeListWebViewBean () {
+ // 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.jjobs.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 JobsEmailChangeListWebViewController 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);
+
+}
import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
+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;
* Administrative user-list controller
*/
@Inject
- private FinancialsUserListWebViewController userListController;
+ private JobsUserListWebViewController userListController;
/**
* Flag whether the user has logged-in, set only from inside
import org.mxchange.jjobs.beans.BaseJobsBean;
import org.mxchange.jjobs.beans.contact.JobsContactWebRequestController;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
+import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
-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.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
* Localization controller
*/
@Inject
- private FinancialsLocalizationSessionController localizationController;
+ private JobsLocalizationSessionController localizationController;
/**
* Remote register session-scoped bean
* User list controller
*/
@Inject
- private FinancialsUserListWebViewController userListController;
+ private JobsUserListWebViewController userListController;
/**
* User name
return ""; //NOI18N
} else if (this.ifBothPasswordsEmptyAllowed()) {
// Both passwords are left empty and is allowed, then generate a random password
- final String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
+ final String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
// Generate (ignored) password-history
final PasswordHistory passwordHistory = new UserPasswordHistory(randomPassword, user);
this.setUserProfileMode(ProfileMode.INVISIBLE);
// Generate random password
- final String randomPassword = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
+ final String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
// Set random password
this.setUserPassword(randomPassword);
import javax.inject.Named;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import javax.faces.convert.FacesConverter;
import org.mxchange.jcontactsbusiness.exceptions.employee.EmployeeNotFoundException;
import org.mxchange.jcontactsbusiness.model.employee.Employable;
-import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestBean;
-import org.mxchange.jjobs.beans.business.employee.JobsEmployeeWebRequestController;
+import org.mxchange.jjobs.beans.business.employee.list.JobsEmployeeListWebViewBean;
+import org.mxchange.jjobs.beans.business.employee.list.JobsEmployeeListWebViewController;
/**
* Converter for converting company employee to and from id number
/**
* Employable EJB
*/
- private static FinancialsEmployeeListWebViewController EMPLOYEE_LIST_CONTROLLER;
+ private static JobsEmployeeListWebViewController EMPLOYEE_LIST_CONTROLLER;
@Override
public Employable getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
if (null == EMPLOYEE_LIST_CONTROLLER) {
// Get bean from CDI directly
- EMPLOYEE_LIST_CONTROLLER = CDI.current().select(FinancialsEmployeeListWebViewBean.class).get();
+ EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobsEmployeeListWebViewBean.class).get();
}
// Try to get user instance from it
import javax.faces.convert.FacesConverter;
import org.mxchange.jcontactsbusiness.exceptions.opening_time.OpeningTimeNotFoundException;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
-import org.mxchange.jjobs.beans.business.opening_time.JobsOpeningTimeWebRequestBean;
-import org.mxchange.jjobs.beans.business.opening_time.JobsOpeningTimeWebRequestController;
+import org.mxchange.jjobs.beans.business.opening_time.list.JobsOpeningTimeListWebViewBean;
+import org.mxchange.jjobs.beans.business.opening_time.list.JobsOpeningTimeListWebViewController;
/**
* Converter for opening time id <-> instance
/**
* Opening time backing bean
*/
- private static JobsOpeningTimeWebRequestController OPENING_TIMES_LIST_CONTROLLER;
+ private static JobsOpeningTimeListWebViewController OPENING_TIMES_LIST_CONTROLLER;
@Override
public OpeningTime getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
final Long openingTimeId = Long.valueOf(submittedValue);
// Is the instance there?
- if (null == OPENING_TIME_LIST_CONTROLLER) {
+ if (null == OPENING_TIMES_LIST_CONTROLLER) {
// Get bean from CDI directly
- OPENING_TIME_LIST_CONTROLLER = CDI.current().select(FinancialsOpeningTimeListWebViewBean.class).get();
+ OPENING_TIMES_LIST_CONTROLLER = CDI.current().select(JobsOpeningTimeListWebViewBean.class).get();
}
// Try to get user instance from it
- openingTime = OPENING_TIME_LIST_CONTROLLER.findOpeningTimeById(openingTimeId);
+ openingTime = OPENING_TIMES_LIST_CONTROLLER.findOpeningTimeById(openingTimeId);
} 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.jjobs.beans.phone.JobsPhoneWebRequestBean;
-import org.mxchange.jjobs.beans.phone.JobsPhoneWebRequestController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
/**
* Phone EJB
*/
- private static JobsPhoneWebRequestController PHONE_LIST_CONTROLLER;
+ private static JobsPhoneListWebViewController PHONE_LIST_CONTROLLER;
@Override
public DialableFaxNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
if (null == PHONE_LIST_CONTROLLER) {
// Get bean from CDI directly
- PHONE_LIST_CONTROLLER = CDI.current().select(FinancialsPhoneListWebViewBean.class).get();
+ PHONE_LIST_CONTROLLER = CDI.current().select(JobsPhoneListWebViewBean.class).get();
}
// Try to get mobile instance from it
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jjobs.beans.phone.JobsPhoneWebRequestBean;
-import org.mxchange.jjobs.beans.phone.JobsPhoneWebRequestController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
/**
* Phone EJB
*/
- private static JobsPhoneWebRequestController PHONE_LIST_CONTROLLER;
+ private static JobsPhoneListWebViewController PHONE_LIST_CONTROLLER;
@Override
public DialableLandLineNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
if (null == PHONE_LIST_CONTROLLER) {
// Get bean from CDI directly
- PHONE_LIST_CONTROLLER = CDI.current().select(FinancialsPhoneListWebViewBean.class).get();
+ PHONE_LIST_CONTROLLER = CDI.current().select(JobsPhoneListWebViewBean.class).get();
}
// Try to get mobile instance from it
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jjobs.beans.phone.JobsPhoneWebRequestBean;
-import org.mxchange.jjobs.beans.phone.JobsPhoneWebRequestController;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
/**
/**
* Phone EJB
*/
- private static JobsPhoneWebRequestController PHONE_LIST_CONTROLLER;
+ private static JobsMobileListWebViewController MOBILE_LIST_CONTROLLER;
@Override
public DialableMobileNumber getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
if (null == MOBILE_LIST_CONTROLLER) {
// Get bean from CDI directly
- MOBILE_LIST_CONTROLLER = CDI.current().select(FinancialsMobileListWebViewBean.class).get();
+ MOBILE_LIST_CONTROLLER = CDI.current().select(JobsMobileListWebViewBean.class).get();
}
// Try to get mobile instance from it
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jjobs.beans.mobileprovider.JobsMobileProviderWebRequestBean;
-import org.mxchange.jjobs.beans.mobileprovider.JobsMobileProviderWebRequestController;
import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
/**
* Mobile provider backing bean
*/
- private static JobsMobileProviderWebRequestController MOBILE_PROVIDER_LIST_CONTROLLER;
+ private static JobsMobileProviderListWebViewController 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_LIST_CONTROLLER) {
// Get bean from CDI directly
- MOBILE_PROVIDER_LIST_CONTROLLER = CDI.current().select(FinancialsMobileProviderListWebViewBean.class).get();
+ MOBILE_PROVIDER_LIST_CONTROLLER = CDI.current().select(JobsMobileProviderListWebViewBean.class).get();
}
// Lookup of mobile provider
+++ /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 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.validator.addressbook;
-
-import java.text.MessageFormat;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbook.model.addressbook.Addressbook;
-import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-
-/**
- * A validator for address book id verification
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator ("AddressbookIdValidator")
-public class JobsAddressbookIdValidator extends BaseNumberValidator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 158_768_467_186_951_809L;
-
- /**
- * Remote bean
- */
- private AddressbookSessionBeanRemote addressbookBean;
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Public consutructor
- */
- public JobsAddressbookIdValidator () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/jjobs-ejb/jjobs-adr!org.mxchange.jjobs.model.addressbook.JobsAddressbookSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // All accepted, required fields
- String[] requiredFields = {"addressbookId"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Cast to long
- Long addressbookId = (Long) value;
-
- // Is the address book id valid?
- if (!this.addressbookBean.isAddressbookIdUsed(addressbookId)) {
- // Is not valid
- throw new ValidatorException(new FacesMessage(MessageFormat.format("No address book found with id {0}. Please check your link.", addressbookId))); //NOI18N
- }
-
- // Init variable
- Addressbook addressbook;
-
- // Try it
- try {
- // Get full data
- addressbook = this.addressbookBean.getAddressbookById(addressbookId);
-
- // Is it set?
- if (null == addressbook) {
- // Is null?!
- throw new NullPointerException(MessageFormat.format("addressbook for id={0} is null", addressbookId)); //NOI18N
- }
- } catch (final AddressbookNotFoundException ex) {
- // Continue to throw
- throw new ValidatorException(new FacesMessage(MessageFormat.format("Cannot find address book with id {0}", addressbookId)), ex); //NOI18N
- }
-
- // Trace message
- this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
- }
-}