]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
WIP: Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 3 Aug 2017 19:43:01 +0000 (21:43 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Aug 2017 13:31:38 +0000 (15:31 +0200)
- renamed methods to make them more clear (current fax/land-line/mobile number)
- these methods and also getter/setter in bean helper are for JSF views only and
  should not be callable by other beans
- so this change breaks a lot again and I again need to rewrite it
- so more controller interfaces are now empty, maybe one day some methods will
  come back, but ...
- anyway, doing a lot CDI calls (in some methods +10 calls each) is really not
  good as CDI does take some time
- better reimplement it in CDI events which are more flexible as more beans can
  be reached than only those which are hard-coded in
- sorted members again

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestController.java
src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionController.java
src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java
src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperController.java
src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java
src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java
web/admin/fax/admin_fax_show.xhtml
web/admin/landline/admin_landline_show.xhtml
web/admin/mobile/admin_mobile_show.xhtml

index f8ce3f5a4dda8358849db401d2091f32e64396ac..72628b9b0c40d0f5703fed77f4438865d85a8f1f 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Iterator;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
@@ -38,6 +39,7 @@ import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jcontacts.contact.title.PersonalTitle;
 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.helper.created.ObservableHelperCreatedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
@@ -117,14 +119,14 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
        private PizzaContactWebSessionController contactController;
 
        /**
-        * Contact id
+        * Country instance
         */
-       private Long contactId;
+       private Country contactCountry;
 
        /**
-        * Country instance
+        * Contact id
         */
-       private Country contactCountry;
+       private Long contactId;
 
        /**
         * Email address
@@ -307,23 +309,34 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
                return "admin_list_contact"; //NOI18N
        }
 
-       @Override
-       public void copyContactToController (final Contact contact) {
+       /**
+        * Observer for events being fired when a bean helper has successfully
+        * created a contact instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterHelperCreatedContactEvent (@Observes final ObservableHelperCreatedContactEvent event) {
                // Log message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::copyContactToController(): contact={0} - CALLED!", contact)); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminContactController::afterHelperCreatedContactEvent(): contact={0} - CALLED!", contact)); //NOI18N
 
-               // The contact instance must be valid
-               if (null == contact) {
+               // The event instance must be valid
+               if (null == event) {
                        // Throw NPE again
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getCreatedContact() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
-               } else if (contact.getContactId() < 1) {
+                       throw new NullPointerException("event.createdContact is null"); //NOI18N //NOI18N
+               } else if (event.getCreatedContact().getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.createdContact.contactId is null"); //NOI18N //NOI18N
+               } else if (event.getCreatedContact().getContactId() < 1) {
                        // Not valid
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+                       throw new IllegalStateException(MessageFormat.format("event.createdContact.contactId={0} is not valid.", event.getCreatedContact().getContactId())); //NOI18N
                }
 
+               // Get contact instance from event
+               Contact contact = event.getCreatedContact();
+
                // Set all fields: contact
                this.setContactId(contact.getContactId());
                this.setAcademicTitle(contact.getContactTitle());
@@ -367,7 +380,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
                }
 
                // Log message
-               //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("AdminContactController::afterHelperCreatedContactEvent(): EXIT!"); //NOI18N
        }
 
        @Override
@@ -398,6 +411,12 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
                // Create new instance
                Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName());
 
+               // Is contact id set?
+               if (this.getContactId() instanceof Long) {
+                       // Set it, too
+                       contact.setContactId(this.getContactId());
+               }
+
                // Add all others
                contact.setContactTitle(this.getAcademicTitle());
                contact.setContactBirthday(this.getBirthday());
@@ -481,7 +500,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
         */
        public String editContactData () {
                // Get contact instance
-               Contact contact = this.beanHelper.getContact();
+               Contact contact = this.createContactInstance();
 
                // Check if contact instance is in helper and valid
                if (null == contact) {
@@ -638,6 +657,24 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
                this.comment = comment;
        }
 
+       /**
+        * Getter for contactCountry instance
+        * <p>
+        * @return Country instance
+        */
+       public Country getContactCountry () {
+               return this.contactCountry;
+       }
+
+       /**
+        * Setter for contactCountry instance
+        * <p>
+        * @param contactCountry Country instance
+        */
+       public void setContactCountry (final Country contactCountry) {
+               this.contactCountry = contactCountry;
+       }
+
        /**
         * Getter for contact id
         * <p>
@@ -667,24 +704,6 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme
                throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
        }
 
-       /**
-        * Getter for contactCountry instance
-        * <p>
-        * @return Country instance
-        */
-       public Country getContactCountry () {
-               return this.contactCountry;
-       }
-
-       /**
-        * Setter for contactCountry instance
-        * <p>
-        * @param contactCountry Country instance
-        */
-       public void setContactCountry (final Country contactCountry) {
-               this.contactCountry = contactCountry;
-       }
-
        /**
         * Getter for email address
         * <p>
index e430c9f3ab314454072d6c23d77e02f416eefe12..edbff61e2593b2aad84c1d1b72783dffc393f9c1 100644 (file)
@@ -38,13 +38,6 @@ public interface PizzaAdminContactWebRequestController extends Serializable {
         */
        Contact createContactInstance ();
 
-       /**
-        * Copies given contact's data to this controller
-        * <p>
-        * @param contact Contact instance
-        */
-       void copyContactToController (final Contact contact);
-
        /**
         * Getter for controller type
         * <p>
index 58b7560249127f05e2ac079f7bac7c2d8ccf2efc..26fa10e766a6d8f42ee65f3f985aab5e3123a70a 100644 (file)
@@ -245,8 +245,12 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                this.clear();
        }
 
-       @Override
-       public List<Contact> allFaxNumberContacts () {
+       /**
+        * Getter for all contacts having current fax number linked
+        * <p>
+        * @return List of all linked contacts
+        */
+       public List<Contact> allCurrentFaxNumberContacts () {
                // Get id
                DialableFaxNumber faxNumber = this.beanHelper.getFaxNumber();
 
@@ -261,7 +265,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                        // "Walk" through all contacts
                        for (final Contact contact : this.contactController.allContacts()) {
                                // Is mobile instance the same?
-                               if (Objects.equals(contact.getContactFaxNumber(), this.beanHelper.getFaxNumber())) {
+                               if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) {
                                        // Found one
                                        list.add(contact);
                                }
@@ -275,8 +279,12 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                }
        }
 
-       @Override
-       public List<Contact> allLandLineNumberContacts () {
+       /**
+        * Getter for all contacts having current land-line number linked
+        * <p>
+        * @return List of all linked contacts
+        */
+       public List<Contact> allCurrentLandLineNumberContacts () {
                // Get id
                DialableLandLineNumber landLineNumber = this.beanHelper.getLandLineNumber();
 
@@ -291,7 +299,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                        // "Walk" through all contacts
                        for (final Contact contact : this.contactController.allContacts()) {
                                // Is mobile instance the same?
-                               if (Objects.equals(contact.getContactLandLineNumber(), this.beanHelper.getLandLineNumber())) {
+                               if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) {
                                        // Found one
                                        list.add(contact);
                                }
@@ -305,8 +313,12 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                }
        }
 
-       @Override
-       public List<Contact> allMobileNumberContacts () {
+       /**
+        * Getter for all contacts having current mobile number linked
+        * <p>
+        * @return List of all linked contacts
+        */
+       public List<Contact> allCurrentMobileNumberContacts () {
                // Get id
                DialableMobileNumber mobileNumber = this.beanHelper.getMobileNumber();
 
@@ -321,7 +333,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme
                        // "Walk" through all contacts
                        for (final Contact contact : this.contactController.allContacts()) {
                                // Is mobile instance the same?
-                               if (Objects.equals(contact.getContactMobileNumber(), this.beanHelper.getMobileNumber())) {
+                               if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) {
                                        // Found one
                                        list.add(contact);
                                }
index 21f4f8c1f0fa1fcf27f6e2c220aac0a144a70eba..b9ae0042a64b47d5e60c2c32c073adcb6c38f732 100644 (file)
@@ -17,8 +17,6 @@
 package org.mxchange.pizzaapplication.beans.contact.phone;
 
 import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.contact.Contact;
 
 /**
  * An interface for user beans
@@ -27,25 +25,4 @@ import org.mxchange.jcontacts.contact.Contact;
  */
 public interface PizzaContactPhoneWebSessionController extends Serializable {
 
-       /**
-        * Getter for all contacts having current fax number linked
-        * <p>
-        * @return List of all linked contacts
-        */
-       List<Contact> allFaxNumberContacts ();
-
-       /**
-        * Getter for all contacts having current land-line number linked
-        * <p>
-        * @return List of all linked contacts
-        */
-       List<Contact> allLandLineNumberContacts ();
-
-       /**
-        * Getter for all contacts having current mobile number linked
-        * <p>
-        * @return List of all linked contacts
-        */
-       List<Contact> allMobileNumberContacts ();
-
 }
index 2bcc41bc48b80ffd03e773341ecefd2b5870e908..416353c2cb10f2129a4816f4b5e9d3cc57b54b79 100644 (file)
@@ -23,6 +23,8 @@ import javax.enterprise.inject.Any;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.helper.created.HelperCreatedContactEvent;
+import org.mxchange.jcontacts.events.contact.helper.created.ObservableHelperCreatedContactEvent;
 import org.mxchange.jcustomercore.model.customer.Customer;
 import org.mxchange.jphone.events.helper.fax.created.HelperCreatedFaxNumberEvent;
 import org.mxchange.jphone.events.helper.fax.created.ObservableHelperCreatedFaxNumberEvent;
@@ -85,11 +87,19 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
        private Contact contact;
 
        /**
-        * Contact instance
+        * Event for when a contact instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableHelperCreatedContactEvent> contactCreatedEvent;
+
+       /**
+        * Fax number
         */
        private Customer customer;
 
        /**
+<<<<<<< HEAD:src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java
         * General user controller
         */
        @Inject
@@ -142,6 +152,33 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
        @Inject
        private PizzaUserWebSessionController userController;
 
+       /**
+        * Event for when a fax number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableHelperCreatedFaxNumberEvent> faxNumberCreatedEvent;
+
+       /**
+        * Event for when a land-line number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableHelperCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
+
+       /**
+        * Event for when a mobile number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableHelperCreatedMobileNumberEvent> mobileNumberCreatedEvent;
+
+       /**
+        * Regular user controller
+        */
+       @Inject
+       private TrainingsUserWebSessionController userController;
+
        /**
         * Event for when a user instance was created
         */
@@ -160,7 +197,9 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
        }
 
-       @Override
+       /**
+        * Copies currently set contact instances data to adminContactController
+        */
        public void copyContactToController () {
                // Validate user instance
                if (this.getContact() == null) {
@@ -178,7 +217,7 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.setPhoneInstances(this.getContact());
 
                // Set all fields: user
-               this.adminContactController.copyContactToController(this.getContact());
+               this.contactCreatedEvent.fire(new HelperCreatedContactEvent(this.getContact()));
        }
 
        @Override
@@ -199,7 +238,9 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.adminCustomerController.copyCustomerToController(this.getCustomer());
        }
 
-       @Override
+       /**
+        * Copies currently set fax number's data to admin phone controller
+        */
        public void copyFaxNumberToController () {
                // Validate fax instance
                if (this.getFaxNumber() == null) {
@@ -238,7 +279,9 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.faxNumberCreatedEvent.fire(new HelperCreatedFaxNumberEvent(this.getFaxNumber()));
        }
 
-       @Override
+       /**
+        * Copies currently set land-line number's data to admin phone controller
+        */
        public void copyLandLineNumberToController () {
                // Validate land-line instance
                if (this.getLandLineNumber() == null) {
@@ -277,7 +320,9 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.landLineNumberCreatedEvent.fire(new HelperCreatedLandLineNumberEvent(this.getLandLineNumber()));
        }
 
-       @Override
+       /**
+        * Copies currently set mobile number's data to admin phone controller
+        */
        public void copyMobileNumberToController () {
                // Validate mobile instance
                if (this.getMobileNumber() == null) {
@@ -310,7 +355,9 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.mobileNumberCreatedEvent.fire(new HelperCreatedMobileNumberEvent(this.getMobileNumber()));
        }
 
-       @Override
+       /**
+        * Copies currently set user instances data to adminUserController
+        */
        public void copyUserToController () {
                // Validate user instance
                if (this.getUser() == null) {
@@ -337,21 +384,34 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.userCreatedEvent.fire(new HelperCreatedUserEvent(this.getUser()));
        }
 
-       @Override
+       /**
+        * Getter for contact instance
+        * <p>
+        * @return Contact instance
+        */
        public Contact getContact () {
-               // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
-               // System.out.println(MessageFormat.format("{0}: Returning this.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller));
                return this.contact;
        }
 
-       @Override
+       /**
+        * Setter for contact instance
+        * <p>
+        * @param contact Contact instance
+        */
        public void setContact (final Contact contact) {
                // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
                // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller));
                this.contact = contact;
        }
 
-       @Override
+       /**
+        * Returns a message key depending on if this contact is a user and/or a
+        * contact. If this contact is unused, a default key is returned.
+        * <p>
+        * @param contact Contact instance to check
+        * <p>
+        * @return Message key
+        */
        public String getContactUsageMessageKey (final Contact contact) {
                // The contact must be valid
                if (null == contact) {
@@ -398,46 +458,60 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle
                this.customer = customer;
        }
 
-       @Override
+       /**
+        * Getter for dialable fax number
+        * <p>
+        * @return Dialable fax number
+        */
        public DialableFaxNumber getFaxNumber () {
                return this.faxNumber;
        }
 
-       @Override
+       /**
+        * Setter for dialable fax number
+        * <p>
+        * @param faxNumber Dialable fax number
+        */
        public void setFaxNumber (final DialableFaxNumber faxNumber) {
                this.faxNumber = faxNumber;
        }
 
-       @Override
+       /**
+        * Getter for dialable land-line number
+        * <p>
+        * @return Dialable land-line number
+        */
        public DialableLandLineNumber getLandLineNumber () {
                return this.landLineNumber;
        }
 
-       @Override
+       /**
+        * Setter for dialable land-line number
+        * <p>
+        * @param landLineNumber Dialable land-line number
+        */
        public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
                this.landLineNumber = landLineNumber;
        }
 
-       @Override
+       /**
+        * Getter for dialable mobile number
+        * <p>
+        * @return Dialable mobile number
+        */
        public DialableMobileNumber getMobileNumber () {
                return this.mobileNumber;
        }
 
-       @Override
+       /**
+        * Setter for dialable mobile number
+        * <p>
+        * @param mobileNumber Dialable mobile number
+        */
        public void setMobileNumber (final DialableMobileNumber mobileNumber) {
                this.mobileNumber = mobileNumber;
        }
 
-       @Override
-       public User getUser () {
-               return this.user;
-       }
-
-       @Override
-       public void setUser (final User user) {
-               this.user = user;
-       }
-
        /**
         * Set's all given contact's phone instances: land-line, cellphone and fax
         * <p>
index fdb9c1cbc53d16d88cbdbc2262afed5b60b7a47b..4c265a43cfa958995984c63852ff240d2bcbb981 100644 (file)
 package org.mxchange.pizzaapplication.beans.helper;
 
 import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jusercore.model.user.User;
 
 /**
  * An interface for general bean helper
@@ -31,49 +26,6 @@ import org.mxchange.jusercore.model.user.User;
  */
 public interface PizzaWebRequestHelperController extends Serializable {
 
-       /**
-        * Getter for user instance
-        * <p>
-        * @return User instance
-        */
-       User getUser ();
-
-       /**
-        * Setter for user instance
-        * <p>
-        * @param user User instance
-        */
-       void setUser (final User user);
-
-       /**
-        * Copies currently set user instance's data to adminUserController
-        */
-       void copyUserToController ();
-
-       /**
-        * Returns a message key depending on if this contact is a user and/or a
-        * contact. If this contact is unused, a default key is returned.
-        * <p>
-        * @param contact Contact instance to check
-        * <p>
-        * @return Message key
-        */
-       String getContactUsageMessageKey (final Contact contact);
-
-       /**
-        * Getter for contact instance
-        * <p>
-        * @return Contact instance
-        */
-       Contact getContact ();
-
-       /**
-        * Setter for contact instance
-        * <p>
-        * @param contact Contact instance
-        */
-       void setContact (final Contact contact);
-
        /**
         * Getter for customer instance
         * <p>
@@ -88,71 +40,9 @@ public interface PizzaWebRequestHelperController extends Serializable {
         */
        void setCustomer (final Customer customer);
 
-       /**
-        * Copies currently set contact instance's data to adminContactController
-        */
-       void copyContactToController ();
-
        /**
         * Copies currently set customer instance's data to adminCustomerController
         */
        void copyCustomerToController ();
 
-       /**
-        * Copies currently set fax number's data to admin phone controller
-        */
-       void copyFaxNumberToController ();
-
-       /**
-        * Copies currently set land-line number's data to admin phone controller
-        */
-       void copyLandLineNumberToController ();
-
-       /**
-        * Copies currently set mobile number's data to admin phone controller
-        */
-       void copyMobileNumberToController ();
-
-       /**
-        * Getter for dialable mobile number
-        * <p>
-        * @return Dialable mobile number
-        */
-       DialableMobileNumber getMobileNumber ();
-
-       /**
-        * Setter for dialable mobile number
-        * <p>
-        * @param mobileNumber Dialable mobile number
-        */
-       void setMobileNumber (final DialableMobileNumber mobileNumber);
-
-       /**
-        * Getter for dialable land-line number
-        * <p>
-        * @return Dialable land-line number
-        */
-       DialableLandLineNumber getLandLineNumber ();
-
-       /**
-        * Setter for dialable land-line number
-        * <p>
-        * @param landLine Dialable land-line number
-        */
-       void setLandLineNumber (final DialableLandLineNumber landLine);
-
-       /**
-        * Getter for dialable fax number
-        * <p>
-        * @return Dialable fax number
-        */
-       DialableFaxNumber getFaxNumber ();
-
-       /**
-        * Setter for dialable fax number
-        * <p>
-        * @param faxNumber Dialable fax number
-        */
-       void setFaxNumber (final DialableFaxNumber faxNumber);
-
 }
index 90dfbac341038baa476aaff4863ff6b7bdf963e9..cf7adaa2eb32c035503d606e3d44a7cf7658e08e 100644 (file)
 package org.mxchange.pizzaapplication.beans.phone;
 
 import java.text.MessageFormat;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Objects;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
@@ -36,6 +38,9 @@ import org.mxchange.jphone.events.fax.removed.AdminFaxNumberRemovedFromListEvent
 import org.mxchange.jphone.events.fax.removed.AdminRemoveFaxNumberFromListEvent;
 import org.mxchange.jphone.events.fax.updated.AdminFaxNumberUpdatedEvent;
 import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
+import org.mxchange.jphone.events.helper.fax.created.ObservableHelperCreatedFaxNumberEvent;
+import org.mxchange.jphone.events.helper.landline.created.ObservableHelperCreatedLandLineNumberEvent;
+import org.mxchange.jphone.events.helper.mobile.created.ObservableHelperCreatedMobileNumberEvent;
 import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
 import org.mxchange.jphone.events.landline.deleted.AdminLandLineNumberDeletedEvent;
 import org.mxchange.jphone.events.landline.removed.AdminLandLineNumberRemovedFromListEvent;
@@ -49,8 +54,11 @@ import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListE
 import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
 import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
 import org.mxchange.pizzaapplication.beans.BasePizzaController;
@@ -164,6 +172,21 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        private Country phoneCountry;
 
+       /**
+        * When the phone entry has been created (persisted)
+        */
+       private Calendar phoneEntryCreated;
+
+       /**
+        * When the phone entry has been updated
+        */
+       private Calendar phoneEntryUpdated;
+
+       /**
+        * Phone id (aka primary key)
+        */
+       private Long phoneId;
+
        /**
         * Phone number
         */
@@ -203,6 +226,107 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
                // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
        }
 
+       /**
+        * Observes events being fired when a bean helper has successfully created a
+        * fax number instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterHelperCreatedFaxNumberEvent (@Observes final ObservableHelperCreatedFaxNumberEvent event) {
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getFaxNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.faxNumber is null"); //NOI18N
+               } else if (event.getFaxNumber().getPhoneId() == null) {
+                       // Throw NPE yet again
+                       throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N
+               } else if (event.getFaxNumber().getPhoneId() < 1) {
+                       // Throw NPE yet again
+                       throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N
+               }
+
+               // Get fax number from event
+               DialableFaxNumber number = event.getFaxNumber();
+
+               // Copy all data to this bean
+               this.setPhoneId(number.getPhoneId());
+               this.setPhoneCountry(number.getPhoneCountry());
+               this.setPhoneAreaCode(number.getPhoneAreaCode());
+               this.setPhoneNumber(number.getPhoneNumber());
+               this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+               this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+       }
+
+       /**
+        * Observes events being fired when a bean helper has successfully created a
+        * land-line number instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterHelperCreatedLandLineNumberEvent (@Observes final ObservableHelperCreatedLandLineNumberEvent event) {
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLandLineNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.landLineNumber is null"); //NOI18N
+               } else if (event.getLandLineNumber().getPhoneId() == null) {
+                       // Throw NPE yet again
+                       throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N
+               } else if (event.getLandLineNumber().getPhoneId() < 1) {
+                       // Throw NPE yet again
+                       throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getLandLineNumber().getPhoneId())); //NOI18N
+               }
+
+               // Get fax number from event
+               DialableLandLineNumber number = event.getLandLineNumber();
+
+               // Copy all data to this bean
+               this.setPhoneId(number.getPhoneId());
+               this.setPhoneCountry(number.getPhoneCountry());
+               this.setPhoneAreaCode(number.getPhoneAreaCode());
+               this.setPhoneNumber(number.getPhoneNumber());
+               this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+               this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+       }
+
+       /**
+        * Observes events being fired when a bean helper has successfully created a
+        * mobile number instance.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterHelperCreatedMobileNumberEvent (@Observes final ObservableHelperCreatedMobileNumberEvent event) {
+               // The event instance must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getMobileNumber() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+               } else if (event.getMobileNumber().getPhoneId() == null) {
+                       // Throw NPE yet again
+                       throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N
+               } else if (event.getMobileNumber().getPhoneId() < 1) {
+                       // Throw NPE yet again
+                       throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N
+               }
+
+               // Get fax number from event
+               DialableMobileNumber number = event.getMobileNumber();
+
+               // Copy all data to this bean
+               this.setPhoneId(number.getPhoneId());
+               this.setMobileProvider(number.getMobileProvider());
+               this.setPhoneNumber(number.getPhoneNumber());
+               this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+               this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+       }
+
        /**
         * Returns a list of all unused ("non-linked") land-line numbers
         * <p>
@@ -258,7 +382,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String deleteFaxData () {
                // Get fax number from bean helper
-               DialableFaxNumber number = this.beanHelper.getFaxNumber();
+               DialableFaxNumber number = this.createFaxNumber();
 
                // Is all data set
                if (number == null) {
@@ -310,7 +434,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String deleteLandLineData () {
                // Get land-line number from helper
-               DialableLandLineNumber number = this.beanHelper.getLandLineNumber();
+               DialableLandLineNumber number = this.createLandLineNumber();
 
                // Is all data set
                if (number == null) {
@@ -362,7 +486,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String deleteMobileData () {
                // Get mobile number from helper
-               DialableMobileNumber number = this.beanHelper.getMobileNumber();
+               DialableMobileNumber number = this.createMobileNumber();
 
                // Is all data set
                if (number == null) {
@@ -408,7 +532,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String doChangeFaxNumber () {
                // Get fax number from bean helper
-               DialableFaxNumber number = this.beanHelper.getFaxNumber();
+               DialableFaxNumber number = this.createFaxNumber();
 
                // Is all data set
                if (number == null) {
@@ -474,7 +598,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String doChangeLandLineNumber () {
                // Get land-line number from helper
-               DialableLandLineNumber number = this.beanHelper.getLandLineNumber();
+               DialableLandLineNumber number = this.createLandLineNumber();
 
                // Is all data set
                if (number == null) {
@@ -540,7 +664,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
         */
        public String doUpdateMobileNumber () {
                // Get mobile number from helper
-               DialableMobileNumber number = this.beanHelper.getMobileNumber();
+               DialableMobileNumber number = this.createMobileNumber();
 
                // Is all data set
                if (number == null) {
@@ -714,6 +838,64 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
                this.phoneCountry = phoneCountry;
        }
 
+       /**
+        * Getter for phone entry created timestamp
+        * <p>
+        * @return Phone entry created timestamp
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getPhoneEntryCreated () {
+               return this.phoneEntryCreated;
+       }
+
+       /**
+        * Setter for phone entry created timestamp
+        * <p>
+        * @param phoneEntryCreated Phone entry created timestamp
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setPhoneEntryCreated (final Calendar phoneEntryCreated) {
+               this.phoneEntryCreated = phoneEntryCreated;
+       }
+
+       /**
+        * Getter for phone entry updated timestamp
+        * <p>
+        * @return Phone entry updated timestamp
+        */
+       @SuppressWarnings ("ReturnOfDateField")
+       public Calendar getPhoneEntryUpdated () {
+               return this.phoneEntryUpdated;
+       }
+
+       /**
+        * Setter for phone entry updated timestamp
+        * <p>
+        * @param phoneEntryUpdated Phone entry updated timestamp
+        */
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setPhoneEntryUpdated (final Calendar phoneEntryUpdated) {
+               this.phoneEntryUpdated = phoneEntryUpdated;
+       }
+
+       /**
+        * Getter for phone id
+        * <p>
+        * @return Phone id
+        */
+       public Long getPhoneId () {
+               return this.phoneId;
+       }
+
+       /**
+        * Setter for phone id
+        * <p>
+        * @param phoneId Phone id
+        */
+       public void setPhoneId (final Long phoneId) {
+               this.phoneId = phoneId;
+       }
+
        /**
         * Getter for dial number without prefix
         * <p>
@@ -750,4 +932,76 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement
                }
        }
 
+       /**
+        * Returns an instance of a DialableFaxNumber from all fields stored in this
+        * bean.
+        * <p>
+        * @return An instance of a DialableFaxNumber class
+        */
+       private DialableFaxNumber createFaxNumber () {
+               // Initialize it
+               DialableFaxNumber number = new FaxNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+               // Add all other data
+               number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+               number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+               // Is id number set?
+               if (this.getPhoneId() instanceof Long) {
+                       // Set it
+                       number.setPhoneId(this.getPhoneId());
+               }
+
+               // Return it
+               return number;
+       }
+
+       /**
+        * Returns an instance of a DialableLandLineNumber from all fields stored in
+        * this bean.
+        * <p>
+        * @return An instance of a DialableLandLineNumber class
+        */
+       private DialableLandLineNumber createLandLineNumber () {
+               // Initialize it
+               DialableLandLineNumber number = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+               // Add all other data
+               number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+               number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+               // Is id number set?
+               if (this.getPhoneId() instanceof Long) {
+                       // Set it
+                       number.setPhoneId(this.getPhoneId());
+               }
+
+               // Return it
+               return number;
+       }
+
+       /**
+        * Returns an instance of a DialableMobileNumber from all fields stored in
+        * this bean.
+        * <p>
+        * @return An instance of a DialableMobileNumber class
+        */
+       private DialableMobileNumber createMobileNumber () {
+               // Initialize it
+               DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getPhoneNumber());
+
+               // Add all other data
+               number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+               number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+               // Is id number set?
+               if (this.getPhoneId() instanceof Long) {
+                       // Set it
+                       number.setPhoneId(this.getPhoneId());
+               }
+
+               // Return it
+               return number;
+       }
+
 }
index 3bea1917ce045a59333da5b18563e43cc2d16fe4..8cc22846a16e6362b0b55b1b125733472c65c9ae 100644 (file)
@@ -35,7 +35,7 @@ import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
-import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedUserEvent;
+import org.mxchange.jusercore.events.user.helper.created.ObservableHelperCreatedContactEvent;
 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
 import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
 import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
@@ -336,7 +336,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
         * <p>
         * @param event User created event
         */
-       public void afterHelperCreatedUserEvent (@Observes final ObservableHelperCreatedUserEvent event) {
+       public void afterHelperCreatedUserEvent (@Observes final ObservableHelperCreatedContactEvent event) {
                // Is the instance valid?
                if (null == event) {
                        // Throw NPE
index 08be2df618ef8abeaf7a15e7246bede36ac8698d..0fba828b28d108c695b63c0b12f544d23abfb327 100644 (file)
@@ -30,6 +30,8 @@ import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import org.mxchange.jcoreee.events.helper.clear.HelperCleanupEvent;
+import org.mxchange.jcoreee.events.helper.clear.ObservableHelperCleanupEvent;
 import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
@@ -62,6 +64,13 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp
        @Inject
        private PizzaWebRequestHelperController beanHelper;
 
+       /**
+        * Event being fired when a bean helper should be cleaned
+        */
+       @Inject
+       @Any
+       private Event<ObservableHelperCleanupEvent> cleanHelperEvent;
+
        /**
         * Confirmation key
         */
@@ -172,7 +181,7 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp
                // Is the user instance null?
                if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) {
                        // Then clear this bean and the helper
-                       this.beanHelper.setUser(null);
+                       this.cleanHelperEvent.fire(new HelperCleanupEvent());
                } else {
                        // Try to confirm it
                        this.confirmUserAccount(user);
index 9b28b3fa4722a7cd1110bda2ca15739784027cfd..376c04b9733996d5089e90eb6078f21812abd00a 100644 (file)
@@ -25,7 +25,7 @@
                        <ui:param name="isShowPage" value="#{true}" />
                </ui:include>
 
-               <h:dataTable id="contact_fax_link" var="contact" value="#{contactPhoneController.allFaxNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
+               <h:dataTable id="contact_fax_link" var="contact" value="#{contactPhoneController.allCurrentFaxNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
                        <f:facet name="header">
                                <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_FAX_NUMBER_LINKS}">
                                        <f:param value="#{beanHelper.faxNumber.phoneId}" />
index dd860e2285195f78ee12de4493b406cac22ff4ce..ee7fe755be0b721e702cebaf9cf46e822891ebb6 100644 (file)
@@ -25,7 +25,7 @@
                        <ui:param name="isShowPage" value="#{true}" />
                </ui:include>
 
-               <h:dataTable id="contact_landline_link" var="contact" value="#{contactPhoneController.allLandLineNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
+               <h:dataTable id="contact_landline_link" var="contact" value="#{contactPhoneController.allCurrentLandLineNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
                        <f:facet name="header">
                                <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_LAND_LINE_NUMBER_LINKS}">
                                        <f:param value="#{beanHelper.landLineNumber.phoneId}" />
index fa622389efc829f9c2b706416b0711fb21f3657c..f4119d9d61a98d340c9390a11ee078d81320540b 100644 (file)
@@ -25,7 +25,7 @@
                        <ui:param name="isShowPage" value="#{true}" />
                </ui:include>
 
-               <h:dataTable id="contact_mobile_link" var="contact" value="#{contactPhoneController.allMobileNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
+               <h:dataTable id="contact_mobile_link" var="contact" value="#{contactPhoneController.allCurrentMobileNumberContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_ADMINISTRATIVE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
                        <f:facet name="header">
                                <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_MOBILE_NUMBER_LINKS}">
                                        <f:param value="#{beanHelper.mobileNumber.phoneId}" />