From: Roland Häder Date: Tue, 23 Aug 2016 15:34:05 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cdf549164977348b00cabc2c4d776db1113a94b9;p=jjobs-war.git Please cherry-pick: - fixed administrative fax listing (column data was in facet=header) - added event observer afterAdminLinked(Fax|LandLine|Mobile)NumberEvent() - these observers only add new (not existing) phone numbers to the corresponding lists Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index e087f813..1f4ee396 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -1231,13 +1231,13 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job // Is it valid? if (null == faxNumber) { // Throw NPE - throw new NullPointerException("faxNumber is null"); + throw new NullPointerException("faxNumber is null"); //NOI18N } else if (faxNumber.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("faxNumber.phoneId is null"); + throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N } else if (faxNumber.getPhoneId() < 1) { // Throw NPE again - throw new NullPointerException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); + throw new NullPointerException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N } // Loop through all contacts @@ -1259,13 +1259,13 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job // Is it valid? if (null == landLineNumber) { // Throw NPE - throw new NullPointerException("landLineNumber is null"); + throw new NullPointerException("landLineNumber is null"); //NOI18N } else if (landLineNumber.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("landLineNumber.phoneId is null"); + throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N } else if (landLineNumber.getPhoneId() < 1) { // Throw NPE again - throw new NullPointerException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); + throw new NullPointerException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N } // Loop through all contacts @@ -1284,23 +1284,32 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job * @param mobileNumber Mobile number to remove */ private void removeFromContacts (final DialableMobileNumber mobileNumber) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Is it valid? if (null == mobileNumber) { // Throw NPE - throw new NullPointerException("mobileNumber is null"); + throw new NullPointerException("mobileNumber is null"); //NOI18N } else if (mobileNumber.getPhoneId() == null) { // Throw NPE again - throw new NullPointerException("mobileNumber.phoneId is null"); + throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N } else if (mobileNumber.getPhoneId() < 1) { // Throw NPE again - throw new NullPointerException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); + throw new NullPointerException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N } // Loop through all contacts for (final Contact contact : this.contacts) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N + // Is the number set? if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) { - // Found it + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting ...", this.getClass().getSimpleName())); //NOI18N + + // Unset it contact.setContactMobileNumber(null); } } diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java index 09dcbeca..138f07f2 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java @@ -31,6 +31,9 @@ import javax.naming.NamingException; 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.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent; +import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEvent; +import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent; import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent; @@ -220,6 +223,132 @@ public class JobsPhoneWebApplicationBean extends BaseJobsController implements J this.clear(); } + @Override + public void afterAdminLinkedFaxNumberEvent (@Observes final AdminLinkedFaxNumberEvent 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"); + } else if (event.getContact().getContactId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactId is null"); + } else if (event.getContact().getContactId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactId="+ event.getContact().getContactId() + " is invalid"); + } else if (event.getContact().getContactFaxNumber() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactFaxNumber is null"); + } else if (event.getContact().getContactFaxNumber().getPhoneId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactFaxNumber.phoneId is null"); + } else if (event.getContact().getContactFaxNumber().getPhoneId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactFaxNumber.phoneId="+event.getContact().getContactFaxNumber().getPhoneId() + " is invalid"); + } else if (event.getLinkedFaxNumber() == null) { + // Throw again ... + throw new NullPointerException("event.linkedFaxNumer is null"); + } + + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedFaxNumberEvent: event.linkedFaxNumber.phoneId=" + event.getLinkedFaxNumber().getPhoneId()); + + // Is the id number in linked number not set? + if (event.getLinkedFaxNumber().getPhoneId() == null) { + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedFaxNumberEvent: Adding to list: "+event.getContact().getContactFaxNumber()); + + // Then it is a new number, so add it from contact as there the id number has been set + this.uniqueAddFaxNumber(event.getContact().getContactFaxNumber()); + } + } + + @Override + public void afterAdminLinkedLandLineNumberEvent (@Observes final AdminLinkedLandLineNumberEvent 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"); + } else if (event.getContact().getContactId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactId is null"); + } else if (event.getContact().getContactId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactId="+ event.getContact().getContactId() + " is invalid"); + } else if (event.getContact().getContactLandLineNumber() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactLandLineNumber is null"); + } else if (event.getContact().getContactLandLineNumber().getPhoneId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactLandLineNumber.phoneId is null"); + } else if (event.getContact().getContactLandLineNumber().getPhoneId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactLandLineNumber.phoneId="+event.getContact().getContactLandLineNumber().getPhoneId() + " is invalid"); + } else if (event.getLinkedLandLineNumber() == null) { + // Throw again ... + throw new NullPointerException("event.linkedLandLineNumer is null"); + } + + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedLandLineNumberEvent: event.linkedLandLineNumber.phoneId=" + event.getLinkedLandLineNumber().getPhoneId()); + + // Is the id number in linked number not set? + if (event.getLinkedLandLineNumber().getPhoneId() == null) { + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedLandLineNumberEvent: Adding to list: "+event.getContact().getContactLandLineNumber()); + + // Then it is a new number, so add it from contact as there the id number has been set + this.uniqueAddLandLineNumber(event.getContact().getContactLandLineNumber()); + } + } + + @Override + public void afterAdminLinkedMobileNumberEvent (@Observes final AdminLinkedMobileNumberEvent 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"); + } else if (event.getContact().getContactId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactId is null"); + } else if (event.getContact().getContactId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactId="+ event.getContact().getContactId() + " is invalid"); + } else if (event.getContact().getContactMobileNumber() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactMobileNumber is null"); + } else if (event.getContact().getContactMobileNumber().getPhoneId() == null) { + // Throw again ... + throw new NullPointerException("event.contact.contactMobileNumber.phoneId is null"); + } else if (event.getContact().getContactMobileNumber().getPhoneId() < 1) { + // Throw again ... + throw new NullPointerException("event.contact.contactMobileNumber.phoneId="+event.getContact().getContactMobileNumber().getPhoneId() + " is invalid"); + } else if (event.getLinkedMobileNumber() == null) { + // Throw again ... + throw new NullPointerException("event.linkedMobileNumer is null"); + } + + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedMobileNumberEvent: event.linkedMobileNumber.phoneId=" + event.getLinkedMobileNumber().getPhoneId()); + + // Is the id number in linked number not set? + if (event.getLinkedMobileNumber().getPhoneId() == null) { + // Log message + System.out.println(this.getClass().getSimpleName()+".afterAdminLinkedMobileNumberEvent: Adding to list: "+event.getContact().getContactMobileNumber()); + + // Then it is a new number, so add it from contact as there the id number has been set + this.uniqueAddMobileNumber(event.getContact().getContactMobileNumber()); + } + } + @Override public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) { // event should not be null diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java index 8550f90d..ff081654 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java @@ -21,6 +21,9 @@ 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.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent; +import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEvent; +import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent; import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent; import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent; import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent; @@ -57,26 +60,53 @@ public interface JobsPhoneWebApplicationController extends Serializable { void afterAdminAddedContactEvent (final AdminAddedContactEvent event); /** - * Observes events being fired when an administrator has deleted a fax number + * Observes events being fired when an administrator has deleted a fax + * number *

* @param event Event being fired */ void afterAdminDeletedFaxNumberEvent (final AdminDeletedFaxNumberEvent event); /** - * Observes events being fired when an administrator has deleted a land-line number + * Observes events being fired when an administrator has deleted a land-line + * number *

* @param event Event being fired */ void afterAdminDeletedLandLineNumberEvent (final AdminDeletedLandLineNumberEvent event); /** - * Observes events being fired when an administrator has deleted a mobile number + * Observes events being fired when an administrator has deleted a mobile + * number *

* @param event Event being fired */ void afterAdminDeletedMobileNumberEvent (final AdminDeletedMobileNumberEvent event); + /** + * Observes events being fired when an administrator has a linked a fax + * number + *

+ * @param event Event being fired + */ + void afterAdminLinkedFaxNumberEvent (final AdminLinkedFaxNumberEvent event); + + /** + * Observes events being fired when an administrator has a linked a + * land-line number + *

+ * @param event Event being fired + */ + void afterAdminLinkedLandLineNumberEvent (final AdminLinkedLandLineNumberEvent event); + + /** + * Observes events being fired when an administrator has a linked a mobile + * number + *

+ * @param event Event being fired + */ + void afterAdminLinkedMobileNumberEvent (final AdminLinkedMobileNumberEvent event); + /** * Observes events being fired when an administrator has updated a fax * number. diff --git a/web/admin/fax/admin_fax_list.xhtml b/web/admin/fax/admin_fax_list.xhtml index 96c527c1..ee4f4ceb 100644 --- a/web/admin/fax/admin_fax_list.xhtml +++ b/web/admin/fax/admin_fax_list.xhtml @@ -31,10 +31,10 @@ - - - + + +