+++ /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.mobile;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.application.FacesMessage;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.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;
-import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent;
-import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
-import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
-import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
-import org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * Administrative bean (controller) for mobile numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminMobileController")
-@RequestScoped
-public class FinancialsAdminMobileWebRequestBean extends BaseJobsBean implements FinancialsAdminMobileWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 184_598_175_371_269_017L;
-
- /**
- * Remote EJB for phone number (administrative)
- */
- @EJB (lookup = "java:global/jjobs-ejb/adminMobile!org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote")
- private AdminMobileSessionBeanRemote adminMobileBean;
-
- /**
- * When the phone entry has been created (persisted)
- */
- private Date mobileEntryCreated;
-
- /**
- * When the phone entry has been updated
- */
- private Date mobileEntryUpdated;
-
- /**
- * Mobile id (aka primary key)
- */
- private Long mobileId;
-
- /**
- * Generic hone controller
- */
- @Inject
- private FinancialsMobileListWebViewController mobileListController;
-
- /**
- * Mobile number
- */
- private Long mobileNumber;
-
- /**
- * Event being fired when an administrator has deleted mobile number
- */
- @Inject
- @Any
- private Event<AdminDeletedMobileNumberEvent> mobileNumberDeletedEvent;
-
- /**
- * Event being fired when an administrator has updated land-line number
- */
- @Inject
- @Any
- private Event<AdminUpdatedMobileNumberEvent> mobileNumberUpdatedEvent;
-
- /**
- * Mobile provider
- */
- private MobileProvider mobileProvider;
-
- /**
- * Event being fired when a list of all unused mobile numbers is being
- * created.
- */
- @Inject
- @Any
- private Event<AdminRemoveMobileNumberFromListEvent> removeLinkedMobileNumbersEvent;
-
- /**
- * Chosen mobile number
- */
- private DialableMobileNumber selectedMobileNumber;
-
- /**
- * Default constructor
- */
- public FinancialsAdminMobileWebRequestBean () {
- // Call super constructor
- super();
- }
-
- /**
- * Observes events being fired when a bean helper has successfully created a
- * mobile number instance.
- * <p>
- * @param event Event being fired
- */
- public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
- // The event instance must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.mobileNumber is null"); //NOI18N
- } else if (event.getMobileNumber().getMobileId() == null) {
- // Throw NPE yet again
- throw new NullPointerException("event.mobileNumber.mobileId is null"); //NOI18N
- } else if (event.getMobileNumber().getMobileId() < 1) {
- // Throw NPE yet again
- throw new NullPointerException(MessageFormat.format("event.mobileNumber.mobileId={0} is invalid", event.getMobileNumber().getMobileId())); //NOI18N
- }
-
- // Get fax number from event
- final DialableMobileNumber number = event.getMobileNumber();
-
- // Copy all data to this bean
- this.setMobileId(number.getMobileId());
- this.setMobileProvider(number.getMobileProvider());
- this.setMobileNumber(number.getMobileNumber());
- this.setMobileEntryCreated(number.getMobileEntryCreated());
- this.setMobileEntryUpdated(number.getMobileEntryUpdated());
- }
-
- /**
- * Returns a list of all unused ("non-linked") mobile numbers
- * <p>
- * @return List with all unused mobile numbers
- */
- public List<DialableMobileNumber> allNonLinkedMobileNumbers () {
- // Get list of all mobile numbers
- final List<DialableMobileNumber> numbers = this.mobileListController.getAllMobileNumbers();
-
- // Visit all controllers to reduce the list
- this.removeLinkedMobileNumbersEvent.fire(new AdminMobileNumberRemovedFromListEvent(numbers));
-
- // Return it
- return numbers;
- }
-
- /**
- * Deletes given mobile entry data
- */
- public void deleteMobileData () {
- // Get mobile number from helper
- final DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (number.getMobileId() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
- } else if (number.getMobileId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
- } else if (number.getMobileNumber() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
- }
-
- // Call EJB
- this.adminMobileBean.deleteMobileData(number);
-
- // Fire event
- this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
- }
-
- /**
- * Changes mobile entry data
- * <p>
- * @return Redirect outcome
- */
- public String doUpdateMobileNumber () {
- // Get mobile number from helper
- final DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (number.getMobileId() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
- } else if (number.getMobileId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
- } else if (number.getMobileNumber() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
- } else if (this.getMobileProvider() == null) {
- // Throw NPE again
- throw new NullPointerException("this.mobileProvider is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() == null) {
- // Throw NPE again ...
- throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
- } else if (this.getMobileProvider().getProviderId() < 0) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.mobileProvider.providerId={0} is not valid.", this.getMobileProvider().getProviderId())); //NOI18N
- } else if (this.getMobileNumber() == null) {
- // Throw NPE
- throw new NullPointerException("this.phoneNumber is null"); //NOI18N
- }
-
- // Is the mobile provider and number the same?
- if ((Objects.equals(this.getMobileProvider(), number.getMobileProvider())) && (Objects.equals(this.getMobileNumber(), number.getMobileNumber()))) {
- // Show message
- this.showFacesMessage("form_edit_mobile:mobileNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED", FacesMessage.SEVERITY_WARN); //NOI18N
-
- // No difference in both together, no need to edit
- return ""; //NOI18N
- }
-
- // Set all data
- number.setMobileProvider(this.getMobileProvider());
- number.setMobileNumber(this.getMobileNumber());
-
- // Send to bean
- final DialableMobileNumber updatedNumber = this.adminMobileBean.updateMobileData(number);
-
- // Fire event
- this.mobileNumberUpdatedEvent.fire(new AdminMobileNumberUpdatedEvent(updatedNumber));
-
- // All fine, redirect
- return "admin_show_mobile"; //NOI18N
- }
-
- /**
- * Getter for phone entry created timestamp
- * <p>
- * @return Mobile entry created timestamp
- */
- @SuppressWarnings ("ReturnOfDateField")
- public Date getMobileEntryCreated () {
- return this.mobileEntryCreated;
- }
-
- /**
- * Setter for phone entry created timestamp
- * <p>
- * @param mobileEntryCreated Mobile entry created timestamp
- */
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setMobileEntryCreated (final Date mobileEntryCreated) {
- this.mobileEntryCreated = mobileEntryCreated;
- }
-
- /**
- * Getter for phone entry updated timestamp
- * <p>
- * @return Mobile entry updated timestamp
- */
- @SuppressWarnings ("ReturnOfDateField")
- public Date getMobileEntryUpdated () {
- return this.mobileEntryUpdated;
- }
-
- /**
- * Setter for phone entry updated timestamp
- * <p>
- * @param mobileEntryUpdated Mobile entry updated timestamp
- */
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setMobileEntryUpdated (final Date mobileEntryUpdated) {
- this.mobileEntryUpdated = mobileEntryUpdated;
- }
-
- /**
- * Getter for phone id
- * <p>
- * @return Mobile id
- */
- public Long getMobileId () {
- return this.mobileId;
- }
-
- /**
- * Setter for phone id
- * <p>
- * @param mobileId Mobile id
- */
- public void setMobileId (final Long mobileId) {
- this.mobileId = mobileId;
- }
-
- /**
- * Getter for dial number without prefix
- * <p>
- * @return Dial number without prefix
- */
- public Long getMobileNumber () {
- return this.mobileNumber;
- }
-
- /**
- * Setter for dial number without prefix
- * <p>
- * @param mobileNumber Dial number without prefix
- */
- public void setMobileNumber (final Long mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
- /**
- * Getter for mobile provider
- * <p>
- * @return Mobile provider
- */
- public MobileProvider getMobileProvider () {
- return this.mobileProvider;
- }
-
- /**
- * Setter for mobile provider
- * <p>
- * @param mobileProvider Mobile provider
- */
- public void setMobileProvider (final MobileProvider mobileProvider) {
- this.mobileProvider = mobileProvider;
- }
-
- /**
- * Getter for chosen mobile number
- * <p>
- * @return mobile number
- */
- public DialableMobileNumber getSelectedMobileNumber () {
- return this.selectedMobileNumber;
- }
-
- /**
- * Setter for chosen mobile number
- * <p>
- * @param selectedMobileNumber mobile number
- */
- public void setSelectedMobileNumber (final DialableMobileNumber selectedMobileNumber) {
- this.selectedMobileNumber = selectedMobileNumber;
- }
-
- /**
- * Returns an instance of a DialableMobileNumber from all fields stored in
- * this bean.
- * <p>
- * @return An instance of a DialableMobileNumber class
- */
- private DialableMobileNumber createMobileNumber () {
- // Initialize it
- final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
-
- // Add all other data
- number.setMobileEntryCreated(this.getMobileEntryCreated());
- number.setMobileEntryUpdated(this.getMobileEntryUpdated());
- number.setMobileId(this.getMobileId());
-
- // Return it
- return number;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.beans.mobile;
-
-import java.io.Serializable;
-
-/**
- * An interface for a request web controller (bean) for administrative phone
- * number purposes.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsAdminMobileWebRequestController extends Serializable {
-
-}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.mobile;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.application.FacesMessage;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jjobs.beans.BaseJobsBean;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminMobileNumberDeletedEvent;
+import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent;
+import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
+import org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jjobs.beans.mobile.list.JobsMobileListWebViewController;
+
+/**
+ * Administrative bean (controller) for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminMobileController")
+@RequestScoped
+public class JobsAdminMobileWebRequestBean extends BaseJobsBean implements JobsAdminMobileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 184_598_175_371_269_017L;
+
+ /**
+ * Remote EJB for phone number (administrative)
+ */
+ @EJB (lookup = "java:global/jjobs-ejb/adminMobile!org.mxchange.jphone.model.phonenumbers.mobile.AdminMobileSessionBeanRemote")
+ private AdminMobileSessionBeanRemote adminMobileBean;
+
+ /**
+ * When the phone entry has been created (persisted)
+ */
+ private Date mobileEntryCreated;
+
+ /**
+ * When the phone entry has been updated
+ */
+ private Date mobileEntryUpdated;
+
+ /**
+ * Mobile id (aka primary key)
+ */
+ private Long mobileId;
+
+ /**
+ * Generic hone controller
+ */
+ @Inject
+ private JobsMobileListWebViewController mobileListController;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * Event being fired when an administrator has deleted mobile number
+ */
+ @Inject
+ @Any
+ private Event<AdminDeletedMobileNumberEvent> mobileNumberDeletedEvent;
+
+ /**
+ * Event being fired when an administrator has updated land-line number
+ */
+ @Inject
+ @Any
+ private Event<AdminUpdatedMobileNumberEvent> mobileNumberUpdatedEvent;
+
+ /**
+ * Mobile provider
+ */
+ private MobileProvider mobileProvider;
+
+ /**
+ * Event being fired when a list of all unused mobile numbers is being
+ * created.
+ */
+ @Inject
+ @Any
+ private Event<AdminRemoveMobileNumberFromListEvent> removeLinkedMobileNumbersEvent;
+
+ /**
+ * Chosen mobile number
+ */
+ private DialableMobileNumber selectedMobileNumber;
+
+ /**
+ * Default constructor
+ */
+ public JobsAdminMobileWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * mobile number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.mobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getMobileNumber().getMobileId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.mobileNumber.mobileId={0} is invalid", event.getMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Get fax number from event
+ final DialableMobileNumber number = event.getMobileNumber();
+
+ // Copy all data to this bean
+ this.setMobileId(number.getMobileId());
+ this.setMobileProvider(number.getMobileProvider());
+ this.setMobileNumber(number.getMobileNumber());
+ this.setMobileEntryCreated(number.getMobileEntryCreated());
+ this.setMobileEntryUpdated(number.getMobileEntryUpdated());
+ }
+
+ /**
+ * Returns a list of all unused ("non-linked") mobile numbers
+ * <p>
+ * @return List with all unused mobile numbers
+ */
+ public List<DialableMobileNumber> allNonLinkedMobileNumbers () {
+ // Get list of all mobile numbers
+ final List<DialableMobileNumber> numbers = this.mobileListController.getAllMobileNumbers();
+
+ // Visit all controllers to reduce the list
+ this.removeLinkedMobileNumbersEvent.fire(new AdminMobileNumberRemovedFromListEvent(numbers));
+
+ // Return it
+ return numbers;
+ }
+
+ /**
+ * Deletes given mobile entry data
+ */
+ public void deleteMobileData () {
+ // Get mobile number from helper
+ final DialableMobileNumber number = this.createMobileNumber();
+
+ // Is all data set
+ if (number == null) {
+ // Not set, throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (number.getMobileId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (number.getMobileId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() == null) {
+ // ... throw again
+ throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
+ } else if (number.getMobileNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
+ }
+
+ // Call EJB
+ this.adminMobileBean.deleteMobileData(number);
+
+ // Fire event
+ this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
+ }
+
+ /**
+ * Changes mobile entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doUpdateMobileNumber () {
+ // Get mobile number from helper
+ final DialableMobileNumber number = this.createMobileNumber();
+
+ // Is all data set
+ if (number == null) {
+ // Not set, throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (number.getMobileId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (number.getMobileId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid", number.getMobileId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() == null) {
+ // ... throw again
+ throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
+ } else if (number.getMobileProvider().getProviderId() < 1) {
+ // Id not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N
+ } else if (number.getMobileNumber() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", number.getMobileNumber())); //NOI18N
+ } else if (this.getMobileProvider() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.mobileProvider is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() == null) {
+ // Throw NPE again ...
+ throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
+ } else if (this.getMobileProvider().getProviderId() < 0) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.mobileProvider.providerId={0} is not valid.", this.getMobileProvider().getProviderId())); //NOI18N
+ } else if (this.getMobileNumber() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.phoneNumber is null"); //NOI18N
+ }
+
+ // Is the mobile provider and number the same?
+ if ((Objects.equals(this.getMobileProvider(), number.getMobileProvider())) && (Objects.equals(this.getMobileNumber(), number.getMobileNumber()))) {
+ // Show message
+ this.showFacesMessage("form_edit_mobile:mobileNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED", FacesMessage.SEVERITY_WARN); //NOI18N
+
+ // No difference in both together, no need to edit
+ return ""; //NOI18N
+ }
+
+ // Set all data
+ number.setMobileProvider(this.getMobileProvider());
+ number.setMobileNumber(this.getMobileNumber());
+
+ // Send to bean
+ final DialableMobileNumber updatedNumber = this.adminMobileBean.updateMobileData(number);
+
+ // Fire event
+ this.mobileNumberUpdatedEvent.fire(new AdminMobileNumberUpdatedEvent(updatedNumber));
+
+ // All fine, redirect
+ return "admin_show_mobile"; //NOI18N
+ }
+
+ /**
+ * Getter for phone entry created timestamp
+ * <p>
+ * @return Mobile entry created timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getMobileEntryCreated () {
+ return this.mobileEntryCreated;
+ }
+
+ /**
+ * Setter for phone entry created timestamp
+ * <p>
+ * @param mobileEntryCreated Mobile entry created timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setMobileEntryCreated (final Date mobileEntryCreated) {
+ this.mobileEntryCreated = mobileEntryCreated;
+ }
+
+ /**
+ * Getter for phone entry updated timestamp
+ * <p>
+ * @return Mobile entry updated timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getMobileEntryUpdated () {
+ return this.mobileEntryUpdated;
+ }
+
+ /**
+ * Setter for phone entry updated timestamp
+ * <p>
+ * @param mobileEntryUpdated Mobile entry updated timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setMobileEntryUpdated (final Date mobileEntryUpdated) {
+ this.mobileEntryUpdated = mobileEntryUpdated;
+ }
+
+ /**
+ * Getter for phone id
+ * <p>
+ * @return Mobile id
+ */
+ public Long getMobileId () {
+ return this.mobileId;
+ }
+
+ /**
+ * Setter for phone id
+ * <p>
+ * @param mobileId Mobile id
+ */
+ public void setMobileId (final Long mobileId) {
+ this.mobileId = mobileId;
+ }
+
+ /**
+ * Getter for dial number without prefix
+ * <p>
+ * @return Dial number without prefix
+ */
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ /**
+ * Setter for dial number without prefix
+ * <p>
+ * @param mobileNumber Dial number without prefix
+ */
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ /**
+ * Getter for mobile provider
+ * <p>
+ * @return Mobile provider
+ */
+ public MobileProvider getMobileProvider () {
+ return this.mobileProvider;
+ }
+
+ /**
+ * Setter for mobile provider
+ * <p>
+ * @param mobileProvider Mobile provider
+ */
+ public void setMobileProvider (final MobileProvider mobileProvider) {
+ this.mobileProvider = mobileProvider;
+ }
+
+ /**
+ * Getter for chosen mobile number
+ * <p>
+ * @return mobile number
+ */
+ public DialableMobileNumber getSelectedMobileNumber () {
+ return this.selectedMobileNumber;
+ }
+
+ /**
+ * Setter for chosen mobile number
+ * <p>
+ * @param selectedMobileNumber mobile number
+ */
+ public void setSelectedMobileNumber (final DialableMobileNumber selectedMobileNumber) {
+ this.selectedMobileNumber = selectedMobileNumber;
+ }
+
+ /**
+ * Returns an instance of a DialableMobileNumber from all fields stored in
+ * this bean.
+ * <p>
+ * @return An instance of a DialableMobileNumber class
+ */
+ private DialableMobileNumber createMobileNumber () {
+ // Initialize it
+ final DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
+
+ // Add all other data
+ number.setMobileEntryCreated(this.getMobileEntryCreated());
+ number.setMobileEntryUpdated(this.getMobileEntryUpdated());
+ number.setMobileId(this.getMobileId());
+
+ // Return it
+ return number;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.mobile;
+
+import java.io.Serializable;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsAdminMobileWebRequestController 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.mobile.list;
-
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
-import javax.ejb.EJB;
-import javax.enterprise.event.Observes;
-import javax.faces.view.ViewScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
-import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.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;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote;
-import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-
-/**
- * Administrative listing controller (bean) for mobile numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("mobileListController")
-@ViewScoped
-public class FinancialsMobileListWebViewBean extends BaseJobsBean implements FinancialsMobileListWebViewController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 491_058_674_675_690_106L;
-
- /**
- * A list of all mobile numbers
- */
- private final List<DialableMobileNumber> allMobileNumbers;
-
- /**
- * A list of filtered mobile numbers
- */
- private List<DialableMobileNumber> filteredMobileNumbers;
-
- /**
- * General EJB for mobile numbers
- */
- @EJB (lookup = "java:global/jjobs-ejb/mobile!org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote")
- private MobileSessionBeanRemote mobileBean;
-
- /**
- * Cache for mobile numbers
- */
- @Inject
- @NamedCache (cacheName = "mobileNumberCache")
- private transient Cache<Long, DialableMobileNumber> mobileNumberCache;
-
- /**
- * Default constructor
- */
- public FinancialsMobileListWebViewBean () {
- // Call super constructor
- super();
-
- // Init list
- this.allMobileNumbers = new LinkedList<>();
- }
-
- /**
- * Observes events being fired when an administrator has added a new
- * contact.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedContact is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() == null) {
- // ... and again
- throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and mobile number
- this.updateContactMobileNumbers(event.getAddedContact());
-
- // Clear this bean
- this.clear();
- }
-
- /**
- * Event observer for newly added users by administrator
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addedUser is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
- } else if (event.getAddedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and mobile number
- this.updateContactMobileNumbers(event.getAddedUser().getUserContact());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a land-line
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getDeletedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedMobileNumber is null"); //NOI18N
- } else if (event.getDeletedMobileNumber().getMobileId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedMobileNumber.mobileId is null"); //NOI18N
- } else if (event.getDeletedMobileNumber().getMobileId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getDeletedMobileNumber(), event.getDeletedMobileNumber().getMobileId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and mobile number
- this.getAllMobileNumbers().remove(event.getDeletedMobileNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has a linked a
- * land-line number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedMobileNumberEvent (@Observes final ObservableAdminLinkedMobileNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
- } else if (event.getContact().getContactMobileNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactMobileNumber is null"); //NOI18N
- } else if (event.getContact().getContactMobileNumber().getMobileId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactMobileNumber.mobileId is null"); //NOI18N
- } else if (event.getContact().getContactMobileNumber().getMobileId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactMobileNumber.mobileId={0} is invalid", event.getContact().getContactMobileNumber().getMobileId())); //NOI18N
- } else if (event.getLinkedMobileNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedMobileNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedMobileNumber().getMobileId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddMobileNumber(event.getContact().getContactMobileNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has updated contact
- * data.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedContact is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and mobile number
- this.updateContactMobileNumbers(event.getUpdatedContact());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a land-line
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedMobileNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedMobileNumber is null"); //NOI18N
- } else if (event.getUpdatedMobileNumber().getMobileId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedMobileNumber.mobileId is null"); //NOI18N
- } else if (event.getUpdatedMobileNumber().getMobileId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getUpdatedMobileNumber(), event.getUpdatedMobileNumber().getMobileId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddMobileNumber(event.getUpdatedMobileNumber());
-
- // Clear it
- this.clear();
- }
-
- @Override
- public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws MobileEntityNotFoundException {
- // Validate paramter
- if (null == mobileNumberId) {
- // Throw NPE
- throw new NullPointerException("mobileNumberId is null"); //NOI18N
- } else if (mobileNumberId < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is invalid.", mobileNumberId)); //NOI18N
- } else if (!this.mobileNumberCache.containsKey(mobileNumberId)) {
- // Not found
- throw new MobileEntityNotFoundException(mobileNumberId);
- }
-
- // Get it from cache
- final DialableMobileNumber mobileNumber = this.mobileNumberCache.get(mobileNumberId);
-
- // Return it
- return mobileNumber;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableMobileNumber> getAllMobileNumbers () {
- return this.allMobileNumbers;
- }
-
- /**
- * Getter for filtered mobile numbers
- * <p>
- * @return Filtered mobile numbers
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableMobileNumber> getFilteredMobileNumbers () {
- return this.filteredMobileNumbers;
- }
-
- /**
- * Setter for filtered mobile numbers
- * <p>
- * @param filteredMobileNumbers Filtered mobile numbers
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredMobileNumbers (final List<DialableMobileNumber> filteredMobileNumbers) {
- this.filteredMobileNumbers = filteredMobileNumbers;
- }
-
- /**
- * Post-construction method
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.mobileNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableMobileNumber currentNumber : this.mobileBean.fetchAllMobileNumbers()) {
- // Add it to cache
- this.mobileNumberCache.put(currentNumber.getMobileId(), currentNumber);
- }
- }
-
- // Is cache filled and list is empty
- if ((this.mobileNumberCache.iterator().hasNext()) && (this.getAllMobileNumbers().isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, DialableMobileNumber> currentEntry : this.mobileNumberCache) {
- // Add to list
- this.getAllMobileNumbers().add(currentEntry.getValue());
- }
-
- // Sort list
- this.getAllMobileNumbers().sort(new Comparator<DialableMobileNumber>() {
- @Override
- public int compare (final DialableMobileNumber mobileNumber1, final DialableMobileNumber mobileNumber2) {
- return mobileNumber1.getMobileId() > mobileNumber2.getMobileId() ? 1 : mobileNumber1.getMobileId() < mobileNumber2.getMobileId() ? -1 : 0;
- }
- });
-
- // Set full list
- this.setFilteredMobileNumbers(this.getAllMobileNumbers());
- }
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- }
-
- /**
- * Uniquely add given land-line number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param mobileNumber Land-line number to add
- */
- private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
- // Make sure the parameter is valid
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (mobileNumber.getMobileId() == null) {
- // Throw again ...
- throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
- } else if (mobileNumber.getMobileId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid.", mobileNumber.getMobileId())); //NOI18N
- }
-
- // First remove it
- if (!this.getAllMobileNumbers().remove(mobileNumber)) {
- // Did not work, try by id number
- for (final DialableMobileNumber currentNumber : this.getAllMobileNumbers()) {
- // Is id number the same?
- if (Objects.equals(currentNumber.getMobileId(), mobileNumber.getMobileId())) {
- // Found it
- this.getAllMobileNumbers().remove(currentNumber);
- break;
- }
- }
- }
-
- // ... then add it
- this.getAllMobileNumbers().add(mobileNumber);
- }
-
- /**
- * Updates given contact's mobile number
- * <p>
- * @param contact Contact instance
- */
- private void updateContactMobileNumbers (final Contact contact) {
- // Parameter must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw again
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Id number is not valid
- }
-
- // Is land-line set?
- if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
- // Unique-add it
- this.uniqueAddMobileNumber(contact.getContactMobileNumber());
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.beans.mobile.list;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-
-/**
- * An interface for a request web controller (bean) for administrative phone
- * number purposes.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsMobileListWebViewController extends Serializable {
-
- /**
- * Returns a list of all mobile numbers. For performance reasons, the
- * controller (bean) should be view-scoped as from user to user nothing
- * changes. And the controller's post-construct method should load all
- * numbers and cache it in the controller.
- * <p>
- * @return List of all mobile numbers
- */
- List<DialableMobileNumber> getAllMobileNumbers ();
-
- /**
- * Finds a mobile entry by given id number
- * <p>
- * @param mobileNumberId Mobile entry id number
- * <p>
- * @return A valid mobile instance
- * <p>
- * @throws MobileEntityNotFoundException If the entity was not found
- */
- DialableMobileNumber findMobileNumberById (Long mobileNumberId) throws MobileEntityNotFoundException;
-
-}
--- /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.mobile.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.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;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+
+/**
+ * Administrative listing controller (bean) for mobile numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("mobileListController")
+@ViewScoped
+public class JobsMobileListWebViewBean extends BaseJobsBean implements JobsMobileListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 491_058_674_675_690_106L;
+
+ /**
+ * A list of all mobile numbers
+ */
+ private final List<DialableMobileNumber> allMobileNumbers;
+
+ /**
+ * A list of filtered mobile numbers
+ */
+ private List<DialableMobileNumber> filteredMobileNumbers;
+
+ /**
+ * General EJB for mobile numbers
+ */
+ @EJB (lookup = "java:global/jjobs-ejb/mobile!org.mxchange.jphone.model.phonenumbers.mobile.MobileSessionBeanRemote")
+ private MobileSessionBeanRemote mobileBean;
+
+ /**
+ * Cache for mobile numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "mobileNumberCache")
+ private transient Cache<Long, DialableMobileNumber> mobileNumberCache;
+
+ /**
+ * Default constructor
+ */
+ public JobsMobileListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allMobileNumbers = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.updateContactMobileNumbers(event.getAddedContact());
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.updateContactMobileNumbers(event.getAddedUser().getUserContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a land-line
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getDeletedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedMobileNumber is null"); //NOI18N
+ } else if (event.getDeletedMobileNumber().getMobileId() == null) {
+ // userId is null
+ throw new NullPointerException("event.deletedMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getDeletedMobileNumber().getMobileId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getDeletedMobileNumber(), event.getDeletedMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.getAllMobileNumbers().remove(event.getDeletedMobileNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a
+ * land-line number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedMobileNumberEvent (@Observes final ObservableAdminLinkedMobileNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactMobileNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactMobileNumber is null"); //NOI18N
+ } else if (event.getContact().getContactMobileNumber().getMobileId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getContact().getContactMobileNumber().getMobileId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactMobileNumber.mobileId={0} is invalid", event.getContact().getContactMobileNumber().getMobileId())); //NOI18N
+ } else if (event.getLinkedMobileNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedMobileNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedMobileNumber().getMobileId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddMobileNumber(event.getContact().getContactMobileNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated contact
+ * data.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and mobile number
+ this.updateContactMobileNumbers(event.getUpdatedContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a land-line
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedMobileNumber is null"); //NOI18N
+ } else if (event.getUpdatedMobileNumber().getMobileId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedMobileNumber.mobileId is null"); //NOI18N
+ } else if (event.getUpdatedMobileNumber().getMobileId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("mobileId of contact={0} is not valid: {1}", event.getUpdatedMobileNumber(), event.getUpdatedMobileNumber().getMobileId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddMobileNumber(event.getUpdatedMobileNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ @Override
+ public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws MobileEntityNotFoundException {
+ // Validate paramter
+ if (null == mobileNumberId) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumberId is null"); //NOI18N
+ } else if (mobileNumberId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is invalid.", mobileNumberId)); //NOI18N
+ } else if (!this.mobileNumberCache.containsKey(mobileNumberId)) {
+ // Not found
+ throw new MobileEntityNotFoundException(mobileNumberId);
+ }
+
+ // Get it from cache
+ final DialableMobileNumber mobileNumber = this.mobileNumberCache.get(mobileNumberId);
+
+ // Return it
+ return mobileNumber;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableMobileNumber> getAllMobileNumbers () {
+ return this.allMobileNumbers;
+ }
+
+ /**
+ * Getter for filtered mobile numbers
+ * <p>
+ * @return Filtered mobile numbers
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableMobileNumber> getFilteredMobileNumbers () {
+ return this.filteredMobileNumbers;
+ }
+
+ /**
+ * Setter for filtered mobile numbers
+ * <p>
+ * @param filteredMobileNumbers Filtered mobile numbers
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredMobileNumbers (final List<DialableMobileNumber> filteredMobileNumbers) {
+ this.filteredMobileNumbers = filteredMobileNumbers;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.mobileNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableMobileNumber currentNumber : this.mobileBean.fetchAllMobileNumbers()) {
+ // Add it to cache
+ this.mobileNumberCache.put(currentNumber.getMobileId(), currentNumber);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.mobileNumberCache.iterator().hasNext()) && (this.getAllMobileNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableMobileNumber> currentEntry : this.mobileNumberCache) {
+ // Add to list
+ this.getAllMobileNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllMobileNumbers().sort(new Comparator<DialableMobileNumber>() {
+ @Override
+ public int compare (final DialableMobileNumber mobileNumber1, final DialableMobileNumber mobileNumber2) {
+ return mobileNumber1.getMobileId() > mobileNumber2.getMobileId() ? 1 : mobileNumber1.getMobileId() < mobileNumber2.getMobileId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredMobileNumbers(this.getAllMobileNumbers());
+ }
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Uniquely add given land-line number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param mobileNumber Land-line number to add
+ */
+ private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
+ // Make sure the parameter is valid
+ if (null == mobileNumber) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (mobileNumber.getMobileId() == null) {
+ // Throw again ...
+ throw new NullPointerException("mobileNumber.mobileId is null"); //NOI18N
+ } else if (mobileNumber.getMobileId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileId={0} is not valid.", mobileNumber.getMobileId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllMobileNumbers().remove(mobileNumber)) {
+ // Did not work, try by id number
+ for (final DialableMobileNumber currentNumber : this.getAllMobileNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getMobileId(), mobileNumber.getMobileId())) {
+ // Found it
+ this.getAllMobileNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllMobileNumbers().add(mobileNumber);
+ }
+
+ /**
+ * Updates given contact's mobile number
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactMobileNumbers (final Contact contact) {
+ // Parameter must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id number is not valid
+ }
+
+ // Is land-line set?
+ if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ // Unique-add it
+ this.uniqueAddMobileNumber(contact.getContactMobileNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.mobile.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsMobileListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all mobile numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all mobile numbers
+ */
+ List<DialableMobileNumber> getAllMobileNumbers ();
+
+ /**
+ * Finds a mobile entry by given id number
+ * <p>
+ * @param mobileNumberId Mobile entry id number
+ * <p>
+ * @return A valid mobile instance
+ * <p>
+ * @throws MobileEntityNotFoundException If the entity was not found
+ */
+ DialableMobileNumber findMobileNumberById (Long mobileNumberId) throws MobileEntityNotFoundException;
+
+}
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jjobs.beans.BaseJobsBean;
-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;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jjobs.beans.mobileprovider.list.JobsMobileProviderListWebViewController;
/**
* Administrative controller (bean) for mobile provider
* Mobile provider list view
*/
@Inject
- private FinancialsMobileProviderListWebViewController mobileProviderListController;
+ private JobsMobileProviderListWebViewController mobileProviderListController;
/**
* Event being fired when the mobile provider was added
+++ /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.mobileprovider.list;
-
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
-import javax.ejb.EJB;
-import javax.enterprise.event.Observes;
-import javax.faces.view.ViewScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.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;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
-
-/**
- * A views-scoped bean for mobile providers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("mobileProviderListController")
-@ViewScoped
-public class FinancialsMobileProviderListWebViewBean extends BaseJobsBean implements FinancialsMobileProviderListWebViewController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 15_869_423_671_950_277L;
-
- /**
- * A list of all mobile providers
- */
- private final List<MobileProvider> allMobileProviders;
-
- /**
- * A list of filtered mobile providers
- */
- private List<MobileProvider> filteredMobileProviders;
-
- /**
- * Remote EJB for mobile providers (regular)
- */
- @EJB (lookup = "java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
- private MobileProviderSingletonBeanRemote mobileProviderBean;
-
- /**
- * "Cached" list of mobile providers
- */
- @Inject
- @NamedCache (cacheName = "mobileProviderCache")
- private transient Cache<Long, MobileProvider> mobileProviderCache;
-
- /**
- * Selected mobile provider instance
- */
- private MobileProvider selectedMobileProvider;
-
- /**
- * Default constructor
- */
- public FinancialsMobileProviderListWebViewBean () {
- // Call super constructor
- super();
-
- // Init list
- this.allMobileProviders = new LinkedList<>();
- }
-
- /**
- * Observes events being fired after the administrator has added a new
- * mobile provider
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedMobileProviderEvent (@Observes final AdminAddedMobileProviderEvent event) {
- // Is all valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedMobileProvider() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId() == null) {
- // And again ...
- throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId() < 1) {
- // Id is invalid
- throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
- }
-
- // Add it to the list
- this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider());
- this.getAllMobileProviders().add(event.getAddedMobileProvider());
- }
-
- @Override
- public MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException {
- // Validate parameter
- if (null == mobileProviderId) {
- // Throw NPE
- throw new NullPointerException("mobileProviderId is null"); //NOI18N
- } else if (mobileProviderId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("mobileProviderId=" + mobileProviderId + " is invalid."); //NOI18N
- } else if (!this.mobileProviderCache.containsKey(mobileProviderId)) {
- // Not found
- throw new MobileProviderNotFoundException(mobileProviderId);
- }
-
- // Get it from cache
- final MobileProvider mobileProvider = this.mobileProviderCache.get(mobileProviderId);
-
- // Return it
- return mobileProvider;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<MobileProvider> getAllMobileProviders () {
- // Return it
- return this.allMobileProviders;
- }
-
- /**
- * Getter for filtered mobile provider list
- * <p>
- * @return Filtered mobile providers
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<MobileProvider> getFilteredMobileProviders () {
- return this.filteredMobileProviders;
- }
-
- /**
- * Getter for filtered mobile provider list
- * <p>
- * @param filteredMobileProviders Filtered mobile providers
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredMobileProviders (final List<MobileProvider> filteredMobileProviders) {
- this.filteredMobileProviders = filteredMobileProviders;
- }
-
- /**
- * Getter for selected mobile provider instance
- * <p>
- * @return Selected mobile provider instance
- */
- public MobileProvider getSelectedMobileProvider () {
- return this.selectedMobileProvider;
- }
-
- /**
- * Setter for selected mobile provider instance
- * <p>
- * @param selectedMobileProvider Selected mobile provider instance
- */
- public void setSelectedMobileProvider (final MobileProvider selectedMobileProvider) {
- this.selectedMobileProvider = selectedMobileProvider;
- }
-
- /**
- * Post-construction method
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.mobileProviderCache.iterator().hasNext()) {
- // Add all
- for (final MobileProvider mobileProvider : this.mobileProviderBean.fetchAllMobileProviders()) {
- // Add it to cache
- this.mobileProviderCache.put(mobileProvider.getProviderId(), mobileProvider);
- }
- }
-
- // Is the list empty, but filled cache?
- if (this.getAllMobileProviders().isEmpty() && this.mobileProviderCache.iterator().hasNext()) {
- // Build up list
- for (final Cache.Entry<Long, MobileProvider> currentEntry : this.mobileProviderCache) {
- // Add to list
- this.getAllMobileProviders().add(currentEntry.getValue());
- }
-
- // Sort list
- this.getAllMobileProviders().sort(new Comparator<MobileProvider>() {
- @Override
- public int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
- return mobileProvider1.getProviderId() > mobileProvider2.getProviderId() ? 1 : mobileProvider1.getProviderId() < mobileProvider2.getProviderId() ? -1 : 0;
- }
- });
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.beans.mobileprovider.list;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * An interface for general mobile provider controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsMobileProviderListWebViewController extends Serializable {
-
- /**
- * Returns a mobile provider instance by given primary key. If not found, a
- * proper exception is thrown.
- * <p>
- * @param mobileProviderId Primary key
- * <p>
- * @return Mobile provider instance
- * <p>
- * @throws MobileProviderNotFoundException If the primary key could not be
- * found
- */
- MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException;
-
- /**
- * Returns a list of all mobile providers
- * <p>
- * @return A list of all mobile providers
- */
- List<MobileProvider> getAllMobileProviders ();
-
-}
--- /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.mobileprovider.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.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;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
+
+/**
+ * A views-scoped bean for mobile providers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("mobileProviderListController")
+@ViewScoped
+public class JobsMobileProviderListWebViewBean extends BaseJobsBean implements JobsMobileProviderListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 15_869_423_671_950_277L;
+
+ /**
+ * A list of all mobile providers
+ */
+ private final List<MobileProvider> allMobileProviders;
+
+ /**
+ * A list of filtered mobile providers
+ */
+ private List<MobileProvider> filteredMobileProviders;
+
+ /**
+ * Remote EJB for mobile providers (regular)
+ */
+ @EJB (lookup = "java:global/jjobs-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote")
+ private MobileProviderSingletonBeanRemote mobileProviderBean;
+
+ /**
+ * "Cached" list of mobile providers
+ */
+ @Inject
+ @NamedCache (cacheName = "mobileProviderCache")
+ private transient Cache<Long, MobileProvider> mobileProviderCache;
+
+ /**
+ * Selected mobile provider instance
+ */
+ private MobileProvider selectedMobileProvider;
+
+ /**
+ * Default constructor
+ */
+ public JobsMobileProviderListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allMobileProviders = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired after the administrator has added a new
+ * mobile provider
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedMobileProviderEvent (@Observes final AdminAddedMobileProviderEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedMobileProvider() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId() == null) {
+ // And again ...
+ throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
+ }
+
+ // Add it to the list
+ this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider());
+ this.getAllMobileProviders().add(event.getAddedMobileProvider());
+ }
+
+ @Override
+ public MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException {
+ // Validate parameter
+ if (null == mobileProviderId) {
+ // Throw NPE
+ throw new NullPointerException("mobileProviderId is null"); //NOI18N
+ } else if (mobileProviderId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("mobileProviderId=" + mobileProviderId + " is invalid."); //NOI18N
+ } else if (!this.mobileProviderCache.containsKey(mobileProviderId)) {
+ // Not found
+ throw new MobileProviderNotFoundException(mobileProviderId);
+ }
+
+ // Get it from cache
+ final MobileProvider mobileProvider = this.mobileProviderCache.get(mobileProviderId);
+
+ // Return it
+ return mobileProvider;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<MobileProvider> getAllMobileProviders () {
+ // Return it
+ return this.allMobileProviders;
+ }
+
+ /**
+ * Getter for filtered mobile provider list
+ * <p>
+ * @return Filtered mobile providers
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<MobileProvider> getFilteredMobileProviders () {
+ return this.filteredMobileProviders;
+ }
+
+ /**
+ * Getter for filtered mobile provider list
+ * <p>
+ * @param filteredMobileProviders Filtered mobile providers
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredMobileProviders (final List<MobileProvider> filteredMobileProviders) {
+ this.filteredMobileProviders = filteredMobileProviders;
+ }
+
+ /**
+ * Getter for selected mobile provider instance
+ * <p>
+ * @return Selected mobile provider instance
+ */
+ public MobileProvider getSelectedMobileProvider () {
+ return this.selectedMobileProvider;
+ }
+
+ /**
+ * Setter for selected mobile provider instance
+ * <p>
+ * @param selectedMobileProvider Selected mobile provider instance
+ */
+ public void setSelectedMobileProvider (final MobileProvider selectedMobileProvider) {
+ this.selectedMobileProvider = selectedMobileProvider;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.mobileProviderCache.iterator().hasNext()) {
+ // Add all
+ for (final MobileProvider mobileProvider : this.mobileProviderBean.fetchAllMobileProviders()) {
+ // Add it to cache
+ this.mobileProviderCache.put(mobileProvider.getProviderId(), mobileProvider);
+ }
+ }
+
+ // Is the list empty, but filled cache?
+ if (this.getAllMobileProviders().isEmpty() && this.mobileProviderCache.iterator().hasNext()) {
+ // Build up list
+ for (final Cache.Entry<Long, MobileProvider> currentEntry : this.mobileProviderCache) {
+ // Add to list
+ this.getAllMobileProviders().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllMobileProviders().sort(new Comparator<MobileProvider>() {
+ @Override
+ public int compare (final MobileProvider mobileProvider1, final MobileProvider mobileProvider2) {
+ return mobileProvider1.getProviderId() > mobileProvider2.getProviderId() ? 1 : mobileProvider1.getProviderId() < mobileProvider2.getProviderId() ? -1 : 0;
+ }
+ });
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.mobileprovider.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An interface for general mobile provider controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsMobileProviderListWebViewController extends Serializable {
+
+ /**
+ * Returns a mobile provider instance by given primary key. If not found, a
+ * proper exception is thrown.
+ * <p>
+ * @param mobileProviderId Primary key
+ * <p>
+ * @return Mobile provider instance
+ * <p>
+ * @throws MobileProviderNotFoundException If the primary key could not be
+ * found
+ */
+ MobileProvider findMobileProviderById (final Long mobileProviderId) throws MobileProviderNotFoundException;
+
+ /**
+ * Returns a list of all mobile providers
+ * <p>
+ * @return A list of all mobile providers
+ */
+ List<MobileProvider> getAllMobileProviders ();
+
+}
import javax.inject.Named;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jjobs.beans.BaseJobsBean;
-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;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+import org.mxchange.jjobs.beans.phone.list.JobsPhoneListWebViewController;
/**
* Administrative controller (bean) for phone numbers
* Generic hone controller
*/
@Inject
- private FinancialsPhoneListWebViewController phoneListController;
+ private JobsPhoneListWebViewController phoneListController;
/**
* Phone number
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.beans.phone.list;
-
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
-import javax.ejb.EJB;
-import javax.enterprise.event.Observes;
-import javax.faces.view.ViewScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
-import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
-import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
-import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.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;
-import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
-
-/**
- * Administrative listing controller (bean) for phone numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("phoneListController")
-@ViewScoped
-public class FinancialsPhoneListWebViewBean extends BaseJobsBean implements FinancialsPhoneListWebViewController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 491_058_674_675_690_107L;
-
- /**
- * A list of all fax numbers
- */
- private final List<DialableFaxNumber> allFaxNumbers;
-
- /**
- * A list of all land-line numbers
- */
- private final List<DialableLandLineNumber> allLandLineNumbers;
-
- /**
- * All fax numbers
- */
- @Inject
- @NamedCache (cacheName = "faxNumberCache")
- private transient Cache<Long, DialableFaxNumber> faxNumberCache;
-
- /**
- * A list of filtered fax numbers
- */
- private List<DialableFaxNumber> filteredFaxNumbers;
-
- /**
- * A list of filtered land-line numbers
- */
- private List<DialableLandLineNumber> filteredLandLineNumbers;
-
- /**
- * All land-line numbers
- */
- @Inject
- @NamedCache (cacheName = "landLineNumberCache")
- private transient Cache<Long, DialableLandLineNumber> landLineNumberCache;
-
- /**
- * General EJB for phone numbers
- */
- @EJB (lookup = "java:global/jjobs-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
- private PhoneSessionBeanRemote phoneBean;
-
- /**
- * Default constructor
- */
- public FinancialsPhoneListWebViewBean () {
- // Call super constructor
- super();
-
- // Initialize lists
- this.allFaxNumbers = new LinkedList<>();
- this.allLandLineNumbers = new LinkedList<>();
- }
-
- /**
- * Observes events being fired when an administrator has added a new
- * contact.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedContact is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() == null) {
- // ... and again
- throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.updateContactPhoneNumbers(event.getAddedContact());
-
- // Clear this bean
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a fax
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getDeletedFaxNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedFaxNumber is null"); //NOI18N
- } else if (event.getDeletedFaxNumber().getPhoneId() == null) {
- // phoneId is null
- throw new NullPointerException("event.deletedFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getDeletedFaxNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedFaxNumber(), event.getDeletedFaxNumber().getPhoneId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.getAllFaxNumbers().remove(event.getDeletedFaxNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has deleted a land-line
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getDeletedLandLineNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedLandLineNumber is null"); //NOI18N
- } else if (event.getDeletedLandLineNumber().getPhoneId() == null) {
- // phoneId is null
- throw new NullPointerException("event.deletedLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getDeletedLandLineNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedLandLineNumber(), event.getDeletedLandLineNumber().getPhoneId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.getAllLandLineNumbers().remove(event.getDeletedLandLineNumber());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has a linked a fax
- * number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedFaxNumberEvent (@Observes final ObservableAdminLinkedFaxNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
- } else if (event.getContact().getContactFaxNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactFaxNumber is null"); //NOI18N
- } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactFaxNumber.phoneId={0} is invalid", event.getContact().getContactFaxNumber().getPhoneId())); //NOI18N
- } else if (event.getLinkedFaxNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedFaxNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedFaxNumber().getPhoneId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddFaxNumber(event.getContact().getContactFaxNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has a linked a
- * land-line number
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLinkedLandLineNumberEvent (@Observes final ObservableAdminLinkedLandLineNumberEvent event) {
- // Is the event fine?
- if (event == null) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact is null"); //NOI18N
- } else if (event.getContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactId is null"); //NOI18N
- } else if (event.getContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
- } else if (event.getContact().getContactLandLineNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactLandLineNumber is null"); //NOI18N
- } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("event.contact.contactLandLineNumber.phoneId={0} is invalid", event.getContact().getContactLandLineNumber().getPhoneId())); //NOI18N
- } else if (event.getLinkedLandLineNumber() == null) {
- // Throw again ...
- throw new NullPointerException("event.linkedLandLineNumer is null"); //NOI18N
- }
-
- // Is the id number in linked number not set?
- if (event.getLinkedLandLineNumber().getPhoneId() == null) {
- // Then it is a new number, so add it from contact as there the id number has been set
- this.uniqueAddLandLineNumber(event.getContact().getContactLandLineNumber());
- }
- }
-
- /**
- * Observes events being fired when an administrator has updated contact
- * data.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedContact is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() == null) {
- // phoneId is null
- throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
- }
-
- // Update contact's mobile, land-line and fax number
- this.updateContactPhoneNumbers(event.getUpdatedContact());
-
- // Clear all data
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a fax
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedFaxNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedFaxNumber is null"); //NOI18N
- } else if (event.getUpdatedFaxNumber().getPhoneId() == null) {
- // phoneId is null
- throw new NullPointerException("event.updatedFaxNumber.phoneId is null"); //NOI18N
- } else if (event.getUpdatedFaxNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedFaxNumber(), event.getUpdatedFaxNumber().getPhoneId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddFaxNumber(event.getUpdatedFaxNumber());
-
- // Clear it
- this.clear();
- }
-
- /**
- * Observes events being fired when an administrator has updated a land-line
- * number.
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent event) {
- // Event and contained entity instance should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedLandLineNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedLandLineNumber is null"); //NOI18N
- } else if (event.getUpdatedLandLineNumber().getPhoneId() == null) {
- // phoneId is null
- throw new NullPointerException("event.updatedLandLineNumber.phoneId is null"); //NOI18N
- } else if (event.getUpdatedLandLineNumber().getPhoneId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedLandLineNumber(), event.getUpdatedLandLineNumber().getPhoneId())); //NOI18N
- }
-
- // Uniquely add it
- this.uniqueAddLandLineNumber(event.getUpdatedLandLineNumber());
-
- // Clear it
- this.clear();
- }
-
- @Override
- public DialableFaxNumber findFaxNumberById (final Long phoneId) throws PhoneEntityNotFoundException {
- // Validate paramter
- if (null == phoneId) {
- // Throw NPE
- throw new NullPointerException("phoneId is null"); //NOI18N
- } else if (phoneId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("phoneId=" + phoneId + " is invalid."); //NOI18N
- } else if (!this.faxNumberCache.containsKey(phoneId)) {
- // Not found
- throw new PhoneEntityNotFoundException(phoneId);
- }
-
- // Get it from cache
- final DialableFaxNumber faxNumber = this.faxNumberCache.get(phoneId);
-
- // Return it
- return faxNumber;
- }
-
- @Override
- public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
- // Validate paramter
- if (null == landLineNumberId) {
- // Throw NPE
- throw new NullPointerException("landLineNumberId is null"); //NOI18N
- } else if (landLineNumberId < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is invalid.", landLineNumberId)); //NOI18N
- } else if (!this.landLineNumberCache.containsKey(landLineNumberId)) {
- // Not found
- throw new PhoneEntityNotFoundException(landLineNumberId);
- }
-
- // Get it from cache
- final DialableLandLineNumber landLineNumber = this.landLineNumberCache.get(landLineNumberId);
-
- // Return it
- return landLineNumber;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableFaxNumber> getAllFaxNumbers () {
- return this.allFaxNumbers;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableLandLineNumber> getAllLandLineNumbers () {
- return this.allLandLineNumbers;
- }
-
- /**
- * Getter for filtered fax number list
- * <p>
- * @return Filtered fax number list
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableFaxNumber> getFilteredFaxNumbers () {
- return this.filteredFaxNumbers;
- }
-
- /**
- * Setter for filtered fax number list
- *
- * @param filteredFaxNumbers Filtered fax number list
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredFaxNumbers (final List<DialableFaxNumber> filteredFaxNumbers) {
- this.filteredFaxNumbers = filteredFaxNumbers;
- }
-
- /**
- * Getter for filtered land-line number list
- * <p>
- * @return Filtered land-line number list
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<DialableLandLineNumber> getFilteredLandLineNumbers () {
- return this.filteredLandLineNumbers;
- }
-
- /**
- * Setter for filtered land-line number list
- *
- * @param filteredLandLineNumbers Filtered land-line number list
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredLandLineNumbers (final List<DialableLandLineNumber> filteredLandLineNumbers) {
- this.filteredLandLineNumbers = filteredLandLineNumbers;
- }
-
- /**
- * Post-construction method
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.faxNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableFaxNumber currentNumber : this.phoneBean.fetchAllFaxNumbers()) {
- // Add it to cache
- this.faxNumberCache.put(currentNumber.getPhoneId(), currentNumber);
- }
- }
-
- // Is cache there?
- if (!this.landLineNumberCache.iterator().hasNext()) {
- // Add all
- for (final DialableLandLineNumber currentNumber : this.phoneBean.fetchAllLandLineNumbers()) {
- // Add it to cache
- this.landLineNumberCache.put(currentNumber.getPhoneId(), currentNumber);
- }
- }
-
- // Is cache filled and list is empty
- if ((this.faxNumberCache.iterator().hasNext()) && (this.getAllFaxNumbers().isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, DialableFaxNumber> currentEntry : this.faxNumberCache) {
- // Add to list
- this.getAllFaxNumbers().add(currentEntry.getValue());
- }
-
- // Sort list
- this.getAllFaxNumbers().sort(new Comparator<DialableFaxNumber>() {
- @Override
- public int compare (final DialableFaxNumber faxNumber1, final DialableFaxNumber faxNumber2) {
- return faxNumber1.getPhoneId() > faxNumber2.getPhoneId() ? 1 : faxNumber1.getPhoneId() < faxNumber2.getPhoneId() ? -1 : 0;
- }
- });
-
- // Set full list
- this.setFilteredFaxNumbers(this.getAllFaxNumbers());
- }
-
- // Is cache filled and list is empty
- if ((this.landLineNumberCache.iterator().hasNext()) && (this.getAllLandLineNumbers().isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, DialableLandLineNumber> currentEntry : this.landLineNumberCache) {
- // Add to list
- this.getAllLandLineNumbers().add(currentEntry.getValue());
- }
-
- // Sort list
- this.getAllLandLineNumbers().sort(new Comparator<DialableLandLineNumber>() {
- @Override
- public int compare (final DialableLandLineNumber landLineNumber1, final DialableLandLineNumber landLineNumber2) {
- return landLineNumber1.getPhoneId() > landLineNumber2.getPhoneId() ? 1 : landLineNumber1.getPhoneId() < landLineNumber2.getPhoneId() ? -1 : 0;
- }
- });
-
- // Set full list
- this.setFilteredLandLineNumbers(this.getAllLandLineNumbers());
- }
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- }
-
- /**
- * Uniquely add given fax number to this bean's list. First remove the old
- * instance (by id number), then re-add it again.
- * <p>
- * @param faxNumber number to add
- */
- private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
- // Make sure the parameter is valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
- } else if (faxNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); //NOI18N
- }
-
- // First remove it
- if (!this.getAllFaxNumbers().remove(faxNumber)) {
- // Did not work, try by id number
- for (final DialableFaxNumber currentNumber : this.getAllFaxNumbers()) {
- // Is id number the same?
- if (Objects.equals(currentNumber.getPhoneId(), faxNumber.getPhoneId())) {
- // Found it
- this.getAllFaxNumbers().remove(currentNumber);
- break;
- }
- }
- }
-
- // ... then add it
- this.getAllFaxNumbers().add(faxNumber);
- }
-
- /**
- * Uniquely add given land-line number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param landLineNumber Land-line number to add
- */
- private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
- // Make sure the parameter is valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); //NOI18N
- }
-
- // First remove it
- if (!this.getAllLandLineNumbers().remove(landLineNumber)) {
- // Did not work, try by id number
- for (final DialableLandLineNumber currentNumber : this.getAllLandLineNumbers()) {
- // Is id number the same?
- if (Objects.equals(currentNumber.getPhoneId(), landLineNumber.getPhoneId())) {
- // Found it
- this.getAllLandLineNumbers().remove(currentNumber);
- break;
- }
- }
- }
-
- // ... then add it
- this.getAllLandLineNumbers().add(landLineNumber);
- }
-
- /**
- * Updates given contact's mobile, land-line and fax number
- * <p>
- * @param contact Contact instance
- */
- private void updateContactPhoneNumbers (final Contact contact) {
- // Parameter must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw again
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Id number is not valid
- }
-
- // Is land-line set?
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Unique-add it
- this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
- }
-
- // Is fax set?
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Unique-add it
- this.uniqueAddFaxNumber(contact.getContactFaxNumber());
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jjobs.beans.phone.list;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-
-/**
- * An interface for a request web controller (bean) for administrative phone
- * number purposes.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsPhoneListWebViewController extends Serializable {
-
- /**
- * Returns a list of all fax numbers. For performance reasons, the
- * controller (bean) should be view-scoped as from user to user nothing
- * changes. And the controller's post-construct method should load all
- * numbers and cache it in the controller.
- * <p>
- * @return List of all fax numbers
- */
- List<DialableFaxNumber> getAllFaxNumbers ();
-
- /**
- * Returns a list of all land-line numbers. For performance reasons, the
- * controller (bean) should be view-scoped as from user to user nothing
- * changes. And the controller's post-construct method should load all
- * numbers and cache it in the controller.
- * <p>
- * @return List of all land-line numbers
- */
- List<DialableLandLineNumber> getAllLandLineNumbers ();
-
- /**
- * Finds a fax entry by given id number
- * <p>
- * @param faxNumberId Fax entry id number
- * <p>
- * @return A valid fax instance
- * <p>
- * @throws PhoneEntityNotFoundException If the entity was not found
- */
- DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException;
-
- /**
- * Finds a land-line entry by given id number
- * <p>
- * @param landLineNumberId Land-line entry id number
- * <p>
- * @return A valid land-line instance
- * <p>
- * @throws PhoneEntityNotFoundException If the entity was not found
- */
- DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException;
-
-}
--- /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.phone.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
+import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.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;
+import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
+import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote;
+
+/**
+ * Administrative listing controller (bean) for phone numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("phoneListController")
+@ViewScoped
+public class JobsPhoneListWebViewBean extends BaseJobsBean implements JobsPhoneListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 491_058_674_675_690_107L;
+
+ /**
+ * A list of all fax numbers
+ */
+ private final List<DialableFaxNumber> allFaxNumbers;
+
+ /**
+ * A list of all land-line numbers
+ */
+ private final List<DialableLandLineNumber> allLandLineNumbers;
+
+ /**
+ * All fax numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "faxNumberCache")
+ private transient Cache<Long, DialableFaxNumber> faxNumberCache;
+
+ /**
+ * A list of filtered fax numbers
+ */
+ private List<DialableFaxNumber> filteredFaxNumbers;
+
+ /**
+ * A list of filtered land-line numbers
+ */
+ private List<DialableLandLineNumber> filteredLandLineNumbers;
+
+ /**
+ * All land-line numbers
+ */
+ @Inject
+ @NamedCache (cacheName = "landLineNumberCache")
+ private transient Cache<Long, DialableLandLineNumber> landLineNumberCache;
+
+ /**
+ * General EJB for phone numbers
+ */
+ @EJB (lookup = "java:global/jjobs-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote")
+ private PhoneSessionBeanRemote phoneBean;
+
+ /**
+ * Default constructor
+ */
+ public JobsPhoneListWebViewBean () {
+ // Call super constructor
+ super();
+
+ // Initialize lists
+ this.allFaxNumbers = new LinkedList<>();
+ this.allLandLineNumbers = new LinkedList<>();
+ }
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.updateContactPhoneNumbers(event.getAddedContact());
+
+ // Clear this bean
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a fax
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getDeletedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedFaxNumber is null"); //NOI18N
+ } else if (event.getDeletedFaxNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.deletedFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getDeletedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedFaxNumber(), event.getDeletedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.getAllFaxNumbers().remove(event.getDeletedFaxNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has deleted a land-line
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getDeletedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedLandLineNumber is null"); //NOI18N
+ } else if (event.getDeletedLandLineNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.deletedLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getDeletedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedLandLineNumber(), event.getDeletedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.getAllLandLineNumbers().remove(event.getDeletedLandLineNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a fax
+ * number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedFaxNumberEvent (@Observes final ObservableAdminLinkedFaxNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactFaxNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactFaxNumber is null"); //NOI18N
+ } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactFaxNumber.phoneId={0} is invalid", event.getContact().getContactFaxNumber().getPhoneId())); //NOI18N
+ } else if (event.getLinkedFaxNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedFaxNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedFaxNumber().getPhoneId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddFaxNumber(event.getContact().getContactFaxNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has a linked a
+ * land-line number
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedLandLineNumberEvent (@Observes final ObservableAdminLinkedLandLineNumberEvent event) {
+ // Is the event fine?
+ if (event == null) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact is null"); //NOI18N
+ } else if (event.getContact().getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactId is null"); //NOI18N
+ } else if (event.getContact().getContactId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactId={0} is invalid", event.getContact().getContactId())); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactLandLineNumber is null"); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) {
+ // Throw again ...
+ throw new NullPointerException(MessageFormat.format("event.contact.contactLandLineNumber.phoneId={0} is invalid", event.getContact().getContactLandLineNumber().getPhoneId())); //NOI18N
+ } else if (event.getLinkedLandLineNumber() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.linkedLandLineNumer is null"); //NOI18N
+ }
+
+ // Is the id number in linked number not set?
+ if (event.getLinkedLandLineNumber().getPhoneId() == null) {
+ // Then it is a new number, so add it from contact as there the id number has been set
+ this.uniqueAddLandLineNumber(event.getContact().getContactLandLineNumber());
+ }
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated contact
+ * data.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's mobile, land-line and fax number
+ this.updateContactPhoneNumbers(event.getUpdatedContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a fax
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedFaxNumber is null"); //NOI18N
+ } else if (event.getUpdatedFaxNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.updatedFaxNumber.phoneId is null"); //NOI18N
+ } else if (event.getUpdatedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedFaxNumber(), event.getUpdatedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddFaxNumber(event.getUpdatedFaxNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ /**
+ * Observes events being fired when an administrator has updated a land-line
+ * number.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedLandLineNumber is null"); //NOI18N
+ } else if (event.getUpdatedLandLineNumber().getPhoneId() == null) {
+ // phoneId is null
+ throw new NullPointerException("event.updatedLandLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getUpdatedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedLandLineNumber(), event.getUpdatedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Uniquely add it
+ this.uniqueAddLandLineNumber(event.getUpdatedLandLineNumber());
+
+ // Clear it
+ this.clear();
+ }
+
+ @Override
+ public DialableFaxNumber findFaxNumberById (final Long phoneId) throws PhoneEntityNotFoundException {
+ // Validate paramter
+ if (null == phoneId) {
+ // Throw NPE
+ throw new NullPointerException("phoneId is null"); //NOI18N
+ } else if (phoneId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("phoneId=" + phoneId + " is invalid."); //NOI18N
+ } else if (!this.faxNumberCache.containsKey(phoneId)) {
+ // Not found
+ throw new PhoneEntityNotFoundException(phoneId);
+ }
+
+ // Get it from cache
+ final DialableFaxNumber faxNumber = this.faxNumberCache.get(phoneId);
+
+ // Return it
+ return faxNumber;
+ }
+
+ @Override
+ public DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException {
+ // Validate paramter
+ if (null == landLineNumberId) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumberId is null"); //NOI18N
+ } else if (landLineNumberId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumberId={0} is invalid.", landLineNumberId)); //NOI18N
+ } else if (!this.landLineNumberCache.containsKey(landLineNumberId)) {
+ // Not found
+ throw new PhoneEntityNotFoundException(landLineNumberId);
+ }
+
+ // Get it from cache
+ final DialableLandLineNumber landLineNumber = this.landLineNumberCache.get(landLineNumberId);
+
+ // Return it
+ return landLineNumber;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableFaxNumber> getAllFaxNumbers () {
+ return this.allFaxNumbers;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableLandLineNumber> getAllLandLineNumbers () {
+ return this.allLandLineNumbers;
+ }
+
+ /**
+ * Getter for filtered fax number list
+ * <p>
+ * @return Filtered fax number list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableFaxNumber> getFilteredFaxNumbers () {
+ return this.filteredFaxNumbers;
+ }
+
+ /**
+ * Setter for filtered fax number list
+ *
+ * @param filteredFaxNumbers Filtered fax number list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredFaxNumbers (final List<DialableFaxNumber> filteredFaxNumbers) {
+ this.filteredFaxNumbers = filteredFaxNumbers;
+ }
+
+ /**
+ * Getter for filtered land-line number list
+ * <p>
+ * @return Filtered land-line number list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableLandLineNumber> getFilteredLandLineNumbers () {
+ return this.filteredLandLineNumbers;
+ }
+
+ /**
+ * Setter for filtered land-line number list
+ *
+ * @param filteredLandLineNumbers Filtered land-line number list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredLandLineNumbers (final List<DialableLandLineNumber> filteredLandLineNumbers) {
+ this.filteredLandLineNumbers = filteredLandLineNumbers;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.faxNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableFaxNumber currentNumber : this.phoneBean.fetchAllFaxNumbers()) {
+ // Add it to cache
+ this.faxNumberCache.put(currentNumber.getPhoneId(), currentNumber);
+ }
+ }
+
+ // Is cache there?
+ if (!this.landLineNumberCache.iterator().hasNext()) {
+ // Add all
+ for (final DialableLandLineNumber currentNumber : this.phoneBean.fetchAllLandLineNumbers()) {
+ // Add it to cache
+ this.landLineNumberCache.put(currentNumber.getPhoneId(), currentNumber);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.faxNumberCache.iterator().hasNext()) && (this.getAllFaxNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableFaxNumber> currentEntry : this.faxNumberCache) {
+ // Add to list
+ this.getAllFaxNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllFaxNumbers().sort(new Comparator<DialableFaxNumber>() {
+ @Override
+ public int compare (final DialableFaxNumber faxNumber1, final DialableFaxNumber faxNumber2) {
+ return faxNumber1.getPhoneId() > faxNumber2.getPhoneId() ? 1 : faxNumber1.getPhoneId() < faxNumber2.getPhoneId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredFaxNumbers(this.getAllFaxNumbers());
+ }
+
+ // Is cache filled and list is empty
+ if ((this.landLineNumberCache.iterator().hasNext()) && (this.getAllLandLineNumbers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, DialableLandLineNumber> currentEntry : this.landLineNumberCache) {
+ // Add to list
+ this.getAllLandLineNumbers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllLandLineNumbers().sort(new Comparator<DialableLandLineNumber>() {
+ @Override
+ public int compare (final DialableLandLineNumber landLineNumber1, final DialableLandLineNumber landLineNumber2) {
+ return landLineNumber1.getPhoneId() > landLineNumber2.getPhoneId() ? 1 : landLineNumber1.getPhoneId() < landLineNumber2.getPhoneId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredLandLineNumbers(this.getAllLandLineNumbers());
+ }
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Uniquely add given fax number to this bean's list. First remove the old
+ * instance (by id number), then re-add it again.
+ * <p>
+ * @param faxNumber number to add
+ */
+ private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
+ // Make sure the parameter is valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllFaxNumbers().remove(faxNumber)) {
+ // Did not work, try by id number
+ for (final DialableFaxNumber currentNumber : this.getAllFaxNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getPhoneId(), faxNumber.getPhoneId())) {
+ // Found it
+ this.getAllFaxNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllFaxNumbers().add(faxNumber);
+ }
+
+ /**
+ * Uniquely add given land-line number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param landLineNumber Land-line number to add
+ */
+ private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
+ // Make sure the parameter is valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId())); //NOI18N
+ }
+
+ // First remove it
+ if (!this.getAllLandLineNumbers().remove(landLineNumber)) {
+ // Did not work, try by id number
+ for (final DialableLandLineNumber currentNumber : this.getAllLandLineNumbers()) {
+ // Is id number the same?
+ if (Objects.equals(currentNumber.getPhoneId(), landLineNumber.getPhoneId())) {
+ // Found it
+ this.getAllLandLineNumbers().remove(currentNumber);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.getAllLandLineNumbers().add(landLineNumber);
+ }
+
+ /**
+ * Updates given contact's mobile, land-line and fax number
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactPhoneNumbers (final Contact contact) {
+ // Parameter must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Id number is not valid
+ }
+
+ // Is land-line set?
+ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Unique-add it
+ this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
+ }
+
+ // Is fax set?
+ if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Unique-add it
+ this.uniqueAddFaxNumber(contact.getContactFaxNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jjobs.beans.phone.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface JobsPhoneListWebViewController extends Serializable {
+
+ /**
+ * Returns a list of all fax numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all fax numbers
+ */
+ List<DialableFaxNumber> getAllFaxNumbers ();
+
+ /**
+ * Returns a list of all land-line numbers. For performance reasons, the
+ * controller (bean) should be view-scoped as from user to user nothing
+ * changes. And the controller's post-construct method should load all
+ * numbers and cache it in the controller.
+ * <p>
+ * @return List of all land-line numbers
+ */
+ List<DialableLandLineNumber> getAllLandLineNumbers ();
+
+ /**
+ * Finds a fax entry by given id number
+ * <p>
+ * @param faxNumberId Fax entry id number
+ * <p>
+ * @return A valid fax instance
+ * <p>
+ * @throws PhoneEntityNotFoundException If the entity was not found
+ */
+ DialableFaxNumber findFaxNumberById (final Long faxNumberId) throws PhoneEntityNotFoundException;
+
+ /**
+ * Finds a land-line entry by given id number
+ * <p>
+ * @param landLineNumberId Land-line entry id number
+ * <p>
+ * @return A valid land-line instance
+ * <p>
+ * @throws PhoneEntityNotFoundException If the entity was not found
+ */
+ DialableLandLineNumber findLandLineNumberById (final Long landLineNumberId) throws PhoneEntityNotFoundException;
+
+}
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsBean;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
* User list controller
*/
@Inject
- private JobsUserWebRequestController userListController;
+ private JobsUserListWebViewController userListController;
/**
* Login controller
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.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
* Regular user controller
*/
@Inject
- private JobsUserWebRequestController userListController;
+ private JobsUserListWebViewController userListController;
/**
* Event being fired after confirmation link is being sent
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 JobsEmployeeWebRequestController 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(JobsEmployeeWebRequestBean.class).get();
- }
-
// Is the value null or empty?
if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- // @TODO Not working with JNDI (no remote interface) this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
// Return null
return null;
}
// Try to parse the value as long
final Long employeeId = Long.valueOf(submittedValue);
+ // Is the instance there?
+ if (null == EMPLOYEE_LIST_CONTROLLER) {
+ // Get bean from CDI directly
+ EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobsEmployeeListWebViewBean.class).get();
+ }
+
// Try to get user instance from it
companyEmployee = EMPLOYEE_LIST_CONTROLLER.findEmployeeById(employeeId);
} catch (final NumberFormatException ex) {
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
+import org.mxchange.jjobs.beans.phone.list.JobsPhoneListWebViewBean;
+import org.mxchange.jjobs.beans.phone.list.JobsPhoneListWebViewController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
+import org.mxchange.jjobs.beans.phone.list.JobsPhoneListWebViewBean;
+import org.mxchange.jjobs.beans.phone.list.JobsPhoneListWebViewController;
import org.mxchange.jphone.exceptions.phone.PhoneEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
+import org.mxchange.jjobs.beans.mobile.list.JobsMobileListWebViewBean;
+import org.mxchange.jjobs.beans.mobile.list.JobsMobileListWebViewController;
+import org.mxchange.jphone.exceptions.mobile.MobileEntityNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
/**
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
+import org.mxchange.jjobs.beans.mobileprovider.list.JobsMobileProviderListWebViewBean;
+import org.mxchange.jjobs.beans.mobileprovider.list.JobsMobileProviderListWebViewController;
import org.mxchange.jphone.exceptions.mobileprovider.MobileProviderNotFoundException;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestBean;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewBean;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
/**
* User backing bean
*/
- private static JobsUserWebRequestController USER_LIST_CONTROLLER;
+ private static JobsUserListWebViewController USER_LIST_CONTROLLER;
@Override
public User getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_LIST_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(JobsUserListWebViewBean.class).get();
}
// Is the value null or empty?
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.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;
/**
* A validator for employee email address validation
/**
* Employee backing bean
*/
- private static JobsEmployeeWebRequestController EMPLOYEE_LIST_CONTROLLER;
+ private static JobsEmployeeListWebViewController EMPLOYEE_LIST_CONTROLLER;
/**
* Pattern matcher
// Is the instance there?
if (null == EMPLOYEE_LIST_CONTROLLER) {
// Get bean from CDI directly
- EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobsEmployeeWebRequestBean.class).get();
+ EMPLOYEE_LIST_CONTROLLER = CDI.current().select(JobsEmployeeListWebViewBean.class).get();
}
// Is it registered?
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestBean;
-import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewBean;
+import org.mxchange.jjobs.beans.user.list.JobsUserListWebViewController;
/**
* A validator for user ids
/**
* User backing bean
*/
- private static JobsUserWebRequestController USER_LIST_CONTROLLER;
+ private static JobsUserListWebViewController USER_LIST_CONTROLLER;
/**
* Serial number
// Is the instance there?
if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_LIST_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(JobsUserListWebViewBean.class).get();
}
// Cast value