]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 23 Aug 2016 13:29:19 +0000 (15:29 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 24 Aug 2016 19:45:11 +0000 (21:45 +0200)
- added events for updated fax, land-line and mobile number
- added events for deleted fax, land-line and mobile number
- renamed event method to have Event suffix

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java

index d473e4dceb08ae54cd947d32fd016823b9135eff..09dcbecaf842062b3ad8990db6fe673cc009eeab 100644 (file)
@@ -32,6 +32,12 @@ import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
 import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
+import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
+import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
@@ -95,7 +101,7 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
        }
 
        @Override
-       public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+       public void afterAdminAddedContactEvent (@Observes final AdminAddedContactEvent event) {
                // The event must be valid
                if (null == event) {
                        // Throw NPE
@@ -142,6 +148,78 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
                this.clear();
        }
 
+       @Override
+       public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getDeletedFaxNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.deletedFaxNumber is null"); //NOI18N
+               } else if (event.getDeletedFaxNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.deletedFaxNumber.phoneId is null"); //NOI18N
+               } else if (event.getDeletedFaxNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedFaxNumber(), event.getDeletedFaxNumber().getPhoneId())); //NOI18N
+               }
+
+               // Update contact's mobile, land-line and fax number
+               this.allFaxNumbers().remove(event.getDeletedFaxNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getDeletedLandLineNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.deletedLandLineNumber is null"); //NOI18N
+               } else if (event.getDeletedLandLineNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.deletedLandLineNumber.phoneId is null"); //NOI18N
+               } else if (event.getDeletedLandLineNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedLandLineNumber(), event.getDeletedLandLineNumber().getPhoneId())); //NOI18N
+               }
+
+               // Update contact's mobile, land-line and fax number
+               this.allLandLineNumbers().remove(event.getDeletedLandLineNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getDeletedMobileNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.deletedMobileNumber is null"); //NOI18N
+               } else if (event.getDeletedMobileNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.deletedMobileNumber.phoneId is null"); //NOI18N
+               } else if (event.getDeletedMobileNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getDeletedMobileNumber(), event.getDeletedMobileNumber().getPhoneId())); //NOI18N
+               }
+
+               // Update contact's mobile, land-line and fax number
+               this.allMobileNumbers().remove(event.getDeletedMobileNumber());
+
+               // Clear all data
+               this.clear();
+       }
+
        @Override
        public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
                // event should not be null
@@ -166,6 +244,78 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
                this.clear();
        }
 
+       @Override
+       public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedFaxNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedFaxNumber is null"); //NOI18N
+               } else if (event.getUpdatedFaxNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedFaxNumber.phoneId is null"); //NOI18N
+               } else if (event.getUpdatedFaxNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedFaxNumber(), event.getUpdatedFaxNumber().getPhoneId())); //NOI18N
+               }
+
+               // Uniquely add it
+               this.uniqueAddFaxNumber(event.getUpdatedFaxNumber());
+
+               // Clear it
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedLandLineNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedLandLineNumber is null"); //NOI18N
+               } else if (event.getUpdatedLandLineNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedLandLineNumber.phoneId is null"); //NOI18N
+               } else if (event.getUpdatedLandLineNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedLandLineNumber(), event.getUpdatedLandLineNumber().getPhoneId())); //NOI18N
+               }
+
+               // Uniquely add it
+               this.uniqueAddLandLineNumber(event.getUpdatedLandLineNumber());
+
+               // Clear it
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedMobileNumber()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedMobileNumber is null"); //NOI18N
+               } else if (event.getUpdatedMobileNumber().getPhoneId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedMobileNumber.phoneId is null"); //NOI18N
+               } else if (event.getUpdatedMobileNumber().getPhoneId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("phoneId of contact={0} is not valid: {1}", event.getUpdatedMobileNumber(), event.getUpdatedMobileNumber().getPhoneId())); //NOI18N
+               }
+
+               // Uniquely add it
+               this.uniqueAddMobileNumber(event.getUpdatedMobileNumber());
+
+               // Clear it
+               this.clear();
+       }
+
        @Override
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<DialableFaxNumber> allFaxNumbers () {
@@ -190,9 +340,9 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
        @PostConstruct
        public void init () {
                // All phone numbers
-               this.mobileNumbers.addAll(this.phoneBean.allMobileNumbers());
-               this.faxNumbers.addAll(this.phoneBean.allFaxNumbers());
-               this.landLineNumbers.addAll(this.phoneBean.allLandLineNumbers());
+               this.allMobileNumbers().addAll(this.phoneBean.allMobileNumbers());
+               this.allFaxNumbers().addAll(this.phoneBean.allFaxNumbers());
+               this.allLandLineNumbers().addAll(this.phoneBean.allLandLineNumbers());
        }
 
        /**
@@ -202,42 +352,6 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
                // Clear all data
        }
 
-       /**
-        * Uniquely add given mobile number to this bean's list. First remove the
-        * old instance (by id number), then re-add it again.
-        * <p>
-        * @param mobileNumber Mobile number to add
-        */
-       private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
-               // Make sure the parameter is valid
-               if (null == mobileNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("mobileNumber is null");
-               } else if (mobileNumber.getPhoneId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("mobileNumber.phoneId is null");
-               } else if (mobileNumber.getPhoneId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid.", mobileNumber.getPhoneId()));
-               }
-
-               // First remove it by object
-               if (!this.mobileNumbers.remove(mobileNumber)) {
-                       // Did not work, try by id number
-                       for (final DialableMobileNumber cell : this.mobileNumbers) {
-                               // Is id number the same?
-                               if (Objects.equals(cell.getPhoneId(), mobileNumber.getPhoneId())) {
-                                       // Found it
-                                       this.mobileNumbers.remove(cell);
-                                       break;
-                               }
-                       }
-               }
-
-               // ... then add it
-               this.mobileNumbers.add(mobileNumber);
-       }
-
        /**
         * Uniquely add given fax number to this bean's list. First remove the old
         * instance (by id number), then re-add it again.
@@ -258,20 +372,20 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
                }
 
                // First remove it
-               if (!this.faxNumbers.remove(faxNumber)) {
+               if (!this.allFaxNumbers().remove(faxNumber)) {
                        // Did not work, try by id number
-                       for (final DialableFaxNumber fax : this.faxNumbers) {
+                       for (final DialableFaxNumber fax : this.allFaxNumbers()) {
                                // Is id number the same?
                                if (Objects.equals(fax.getPhoneId(), faxNumber.getPhoneId())) {
                                        // Found it
-                                       this.faxNumbers.remove(fax);
+                                       this.allFaxNumbers().remove(fax);
                                        break;
                                }
                        }
                }
 
                // ... then add it
-               this.faxNumbers.add(faxNumber);
+               this.allFaxNumbers().add(faxNumber);
        }
 
        /**
@@ -294,20 +408,56 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J
                }
 
                // First remove it
-               if (!this.landLineNumbers.remove(landLineNumber)) {
+               if (!this.allLandLineNumbers().remove(landLineNumber)) {
                        // Did not work, try by id number
-                       for (final DialableLandLineNumber landLine : this.landLineNumbers) {
+                       for (final DialableLandLineNumber landLine : this.allLandLineNumbers()) {
                                // Is id number the same?
                                if (Objects.equals(landLine.getPhoneId(), landLineNumber.getPhoneId())) {
                                        // Found it
-                                       this.landLineNumbers.remove(landLine);
+                                       this.allLandLineNumbers().remove(landLine);
+                                       break;
+                               }
+                       }
+               }
+
+               // ... then add it
+               this.allLandLineNumbers().add(landLineNumber);
+       }
+
+       /**
+        * Uniquely add given mobile number to this bean's list. First remove the
+        * old instance (by id number), then re-add it again.
+        * <p>
+        * @param mobileNumber Mobile number to add
+        */
+       private void uniqueAddMobileNumber (final DialableMobileNumber mobileNumber) {
+               // Make sure the parameter is valid
+               if (null == mobileNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("mobileNumber is null");
+               } else if (mobileNumber.getPhoneId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("mobileNumber.phoneId is null");
+               } else if (mobileNumber.getPhoneId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid.", mobileNumber.getPhoneId()));
+               }
+
+               // First remove it by object
+               if (!this.allMobileNumbers().remove(mobileNumber)) {
+                       // Did not work, try by id number
+                       for (final DialableMobileNumber cell : this.allMobileNumbers()) {
+                               // Is id number the same?
+                               if (Objects.equals(cell.getPhoneId(), mobileNumber.getPhoneId())) {
+                                       // Found it
+                                       this.allMobileNumbers().remove(cell);
                                        break;
                                }
                        }
                }
 
                // ... then add it
-               this.landLineNumbers.add(landLineNumber);
+               this.allMobileNumbers().add(mobileNumber);
        }
 
        /**
index eade199b40c06ed7b2503536231bd2f41a13a176..8550f90d5bf208a6a005118969233719a08471b5 100644 (file)
@@ -21,6 +21,12 @@ import java.util.List;
 import javax.ejb.Local;
 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
+import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
+import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
+import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
@@ -48,7 +54,52 @@ public interface JobsPhoneWebApplicationController extends Serializable {
         * <p>
         * @param event Event being fired
         */
-       void afterAdminAddedContact (final AdminAddedContactEvent event);
+       void afterAdminAddedContactEvent (final AdminAddedContactEvent event);
+
+       /**
+        * Observes events being fired when an administrator has deleted a fax number
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminDeletedFaxNumberEvent (final AdminDeletedFaxNumberEvent event);
+
+       /**
+        * Observes events being fired when an administrator has deleted a land-line number
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminDeletedLandLineNumberEvent (final AdminDeletedLandLineNumberEvent event);
+
+       /**
+        * Observes events being fired when an administrator has deleted a mobile number
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminDeletedMobileNumberEvent (final AdminDeletedMobileNumberEvent event);
+
+       /**
+        * Observes events being fired when an administrator has updated a fax
+        * number.
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminUpdatedFaxNumberEvent (final AdminUpdatedFaxNumberEvent event);
+
+       /**
+        * Observes events being fired when an administrator has updated a land-line
+        * number.
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminUpdatedLandLineNumberEvent (final AdminUpdatedLandLineNumberEvent event);
+
+       /**
+        * Observes events being fired when an administrator has updated a mobile
+        * number.
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminUpdatedMobileNumberEvent (final AdminUpdatedMobileNumberEvent event);
 
        /**
         * Event observer for updated contact data by administrators