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;
}
@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
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
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 () {
@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());
}
/**
// 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.
}
// 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);
}
/**
}
// 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);
}
/**
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;
* <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