X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjjobs%2Fbeans%2Fcontact%2FJobsContactWebSessionBean.java;h=b6cd5ee002f9d6e40d226e05c950f466a30894be;hb=09d2137f89da9234cd2fed7af9021b24c3934662;hp=6f8982e4424d674c928fe1a6135b244d7534e323;hpb=55a781ab2ae6a94d7976a09d07fd5df638da3e10;p=jjobs-war.git
diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
index 6f8982e4..b6cd5ee0 100644
--- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
+++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
@@ -20,6 +20,7 @@ import java.text.MessageFormat;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.annotation.PostConstruct;
@@ -37,29 +38,33 @@ import org.mxchange.jcontacts.contact.UserContact;
import org.mxchange.jcontacts.contact.gender.Gender;
import org.mxchange.jcontacts.contact.utils.ContactUtils;
import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.deleted.AdminDeletedContactEvent;
import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent;
+import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent;
+import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.events.mobile.remove.AdminRemoveMobileNumberFromListEvent;
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.jusercore.events.confirmation.UserConfirmedAccountEvent;
import org.mxchange.jusercore.events.login.UserLoggedInEvent;
import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.model.user.User;
/**
- * A general contact bean (controller)
+ * A general contact controller (bean)
*
* @author Roland Haeder
*/
@@ -77,16 +82,6 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
*/
private Date birthday;
- /**
- * Cellphone number's carrier
- */
- private MobileProvider cellphoneCarrier;
-
- /**
- * Cellphone number
- */
- private Long cellphoneNumber;
-
/**
* City
*/
@@ -105,7 +100,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
/**
* Contact list
*/
- private List contactList;
+ private final List contacts;
/**
* Country instance
@@ -118,14 +113,14 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
private String emailAddress;
/**
- * Email address list
+ * Email address repeated
*/
- private List emailAddressList;
+ private String emailAddressRepeat;
/**
- * Email address repeated
+ * Email address list
*/
- private String emailAddressRepeat;
+ private final List emailAddresses;
/**
* Family name
@@ -163,9 +158,9 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
private Short houseNumber;
/**
- * Whether a cellphone entry has been unlinked
+ * House number extension
*/
- private boolean isCellphoneUnlinked;
+ private String houseNumberExtension;
/**
* Whether a fax entry has been unlinked
@@ -178,19 +173,34 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
private boolean isLandLineUnlinked;
/**
- * Phone number area code
+ * Whether a mobile entry has been unlinked
*/
- private Integer phoneAreaCode;
+ private boolean isMobileUnlinked;
/**
- * Country instance for phone number
+ * Land-line number area code
*/
- private Country phoneCountry;
+ private Integer landLineAreaCode;
/**
- * Phone number
+ * Country instance for land-line number
*/
- private Long phoneNumber;
+ private Country landLineCountry;
+
+ /**
+ * Land-line number
+ */
+ private Long landLineNumber;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * Mobile provider
+ */
+ private MobileProvider mobileProvider;
/**
* A list of all selectable contacts
@@ -202,6 +212,11 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
*/
private String street;
+ /**
+ * Title
+ */
+ private String title;
+
/**
* Regular user controller
*/
@@ -209,7 +224,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
private JobsUserWebSessionController userController;
/**
- * Login bean (controller)
+ * Login controller (bean)
*/
@Inject
private JobsUserLoginWebSessionController userLoginController;
@@ -234,10 +249,14 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
// Throw again
throw new FaceletException(e);
}
+
+ // Init lists/maps
+ this.contacts = new LinkedList<>();
+ this.emailAddresses = new LinkedList<>();
}
@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
@@ -250,7 +269,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
} else if (event.getAddedContact().getContactId() < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
}
// Clear this bean
@@ -285,7 +304,32 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
@Override
- public void afterAdminLinkedUser (@Observes final AdminLinkedUserEvent event) {
+ public void afterAdminDeletedContactEvent (@Observes final AdminDeletedContactEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getDeletedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedContact is null"); //NOI18N
+ } else if (event.getDeletedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.deletedContact.contactId is null"); //NOI18N
+ } else if (event.getDeletedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedContact(), event.getDeletedContact().getContactId())); //NOI18N
+ }
+
+ // Remove from both lists
+ this.contacts.remove(event.getDeletedContact());
+ this.selectableContacts.remove(event.getDeletedContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminLinkedUserEvent (@Observes final AdminLinkedUserEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
@@ -311,6 +355,78 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.clear();
}
+ @Override
+ public void afterAdminUnlinkedFaxContactDataEvent (@Observes final AdminUnlinkedFaxNumberEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUnlinkedFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedFaxNumber is null"); //NOI18N
+ } else if (event.getUnlinkedFaxNumber().getPhoneId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedFaxNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedFaxNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedFaxNumber(), event.getUnlinkedFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Remove it from list
+ this.removeFromContacts(event.getUnlinkedFaxNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminUnlinkedLandLineContactDataEvent (@Observes final AdminUnlinkedLandLineNumberEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUnlinkedLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedLandLineNumber is null"); //NOI18N
+ } else if (event.getUnlinkedLandLineNumber().getPhoneId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedLandLineNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedLandLineNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedLandLineNumber(), event.getUnlinkedLandLineNumber().getPhoneId())); //NOI18N
+ }
+
+ // Remove it from list
+ this.removeFromContacts(event.getUnlinkedLandLineNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminUnlinkedMobileContactDataEvent (@Observes final AdminUnlinkedMobileNumberEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUnlinkedMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlinkedMobileNumber is null"); //NOI18N
+ } else if (event.getUnlinkedMobileNumber().getPhoneId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlinkedMobileNumber.contactId is null"); //NOI18N
+ } else if (event.getUnlinkedMobileNumber().getPhoneId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUnlinkedMobileNumber(), event.getUnlinkedMobileNumber().getPhoneId())); //NOI18N
+ }
+
+ // Remove it from list
+ this.removeFromContacts(event.getUnlinkedMobileNumber());
+
+ // Clear all data
+ this.clear();
+ }
+
@Override
public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
// event should not be null
@@ -332,11 +448,11 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.uniqueAddContact(event.getUpdatedContact());
// Add email address to list
- this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
+ this.emailAddresses.add(event.getUpdatedContact().getContactEmailAddress());
}
@Override
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
+ public void afterUserRegistrationEvent (@Observes final UserRegisteredEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
@@ -369,7 +485,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
@Override
- public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
+ public void afterUserConfirmedAccountEventEvent (@Observes final UserConfirmedAccountEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
@@ -390,7 +506,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
@Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+ public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
@@ -411,12 +527,13 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
@Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
public List allContacts () {
// Debug message
//* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactController.allContacts: contactList.size()={0} - EXIT!", this.contactList.size()));
// Return un-modified list
- return Collections.unmodifiableList(this.contactList);
+ return this.contacts;
}
@Override
@@ -431,14 +548,15 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Generate phone number
- DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
- DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
+ DialableLandLineNumber phone = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+ DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
// Create new contact
Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
contact.setContactStreet(this.getStreet());
contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
contact.setContactZipCode(this.getZipCode());
contact.setContactCity(this.getCity());
contact.setContactCountry(this.getCountry());
@@ -448,9 +566,8 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
// Debug message
//* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: this.emailAddress={1}", this.getClass().getSimpleName(), this.getEmailAddress()));
-
// Don't set null or wrong references
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
+ if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
// Now the number must be given
if (phone.getPhoneAreaCode() == null) {
// Is null
@@ -492,23 +609,22 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Is the provider set?
- if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof MobileProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
+ if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
// Is the number set?
- if (cellphone.getPhoneNumber() == null) {
+ if (mobile.getPhoneNumber() == null) {
// Is null
- throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
- } else if (cellphone.getPhoneNumber() < 1) {
+ throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
+ } else if (mobile.getPhoneNumber() < 1) {
// Abort here
- throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
+ throw new IllegalArgumentException("mobileNumber.phoneNumber is zero or below."); //NOI18N
}
- // Set cellphone number
- contact.setContactCellphoneNumber(cellphone);
+ // Set mobile number
+ contact.setContactMobileNumber(mobile);
}
// Trace message
//* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: contact={1} - EXIT!", this.getClass().getSimpleName(), contact));
-
// Return it
return contact;
}
@@ -524,7 +640,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
throw new FaceletException("Not all required fields are set."); //NOI18N
} else if (!this.userLoginController.ifCurrentPasswordMatches()) {
// Password not matching
- this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
+ this.showFacesMessage("form_login_change_personal:currentPassword", "ERROR_USER_CURRENT_PASSWORD_MISMATCHING"); //NOI18N
return ""; //NOI18N
}
@@ -542,21 +658,22 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
contact.setContactFamilyName(this.getFamilyName());
contact.setContactStreet(this.getStreet());
contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
contact.setContactZipCode(this.getZipCode());
contact.setContactCity(this.getCity());
contact.setContactCountry(this.getCountry());
- // Update contact's cellphone number
- this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
+ // Update contact's mobile number
+ this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileProvider(), this.getMobileNumber());
// Update contact's land-line number
- this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
// Update contact's fax number
this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
// Send it to the EJB
- this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
+ this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
// All fine
return "contact_data_saved"; //NOI18N
@@ -574,26 +691,6 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.birthday = birthday;
}
- @Override
- public MobileProvider getCellphoneCarrier () {
- return this.cellphoneCarrier;
- }
-
- @Override
- public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
- this.cellphoneCarrier = cellphoneCarrier;
- }
-
- @Override
- public Long getCellphoneNumber () {
- return this.cellphoneNumber;
- }
-
- @Override
- public void setCellphoneNumber (Long cellphoneNumber) {
- this.cellphoneNumber = cellphoneNumber;
- }
-
@Override
public String getCity () {
return this.city;
@@ -614,6 +711,17 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.comment = comment;
}
+ @Override
+ public String getControllerType () {
+ return "general"; //NOI18N
+ }
+
+ @Override
+ @Deprecated
+ public void setControllerType (final String controllerType) {
+ throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
+ }
+
@Override
public Country getCountry () {
return this.country;
@@ -715,33 +823,63 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
@Override
- public Integer getPhoneAreaCode () {
- return this.phoneAreaCode;
+ public String getHouseNumberExtension () {
+ return this.houseNumberExtension;
+ }
+
+ @Override
+ public void setHouseNumberExtension (final String houseNumberExtension) {
+ this.houseNumberExtension = houseNumberExtension;
+ }
+
+ @Override
+ public Integer getLandLineAreaCode () {
+ return this.landLineAreaCode;
+ }
+
+ @Override
+ public void setLandLineAreaCode (final Integer landLineAreaCode) {
+ this.landLineAreaCode = landLineAreaCode;
+ }
+
+ @Override
+ public Country getLandLineCountry () {
+ return this.landLineCountry;
}
@Override
- public void setPhoneAreaCode (final Integer phoneAreaCode) {
- this.phoneAreaCode = phoneAreaCode;
+ public void setLandLineCountry (final Country landLineCountry) {
+ this.landLineCountry = landLineCountry;
}
@Override
- public Country getPhoneCountry () {
- return this.phoneCountry;
+ public Long getLandLineNumber () {
+ return this.landLineNumber;
}
@Override
- public void setPhoneCountry (final Country phoneCountry) {
- this.phoneCountry = phoneCountry;
+ public void setLandLineNumber (final Long landLineNumber) {
+ this.landLineNumber = landLineNumber;
}
@Override
- public Long getPhoneNumber () {
- return this.phoneNumber;
+ public Long getMobileNumber () {
+ return this.mobileNumber;
}
@Override
- public void setPhoneNumber (final Long phoneNumber) {
- this.phoneNumber = phoneNumber;
+ public void setMobileNumber (Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ @Override
+ public MobileProvider getMobileProvider () {
+ return this.mobileProvider;
+ }
+
+ @Override
+ public void setMobileProvider (final MobileProvider mobileProvider) {
+ this.mobileProvider = mobileProvider;
}
@Override
@@ -754,6 +892,16 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.street = street;
}
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
+ }
+
@Override
public Integer getZipCode () {
return this.zipCode;
@@ -764,21 +912,16 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.zipCode = zipCode;
}
- @Override
- public boolean hasContacts () {
- return (!this.contactList.isEmpty());
- }
-
/**
* Post-initialization of this class
*/
@PostConstruct
public void init () {
// Get full email address list for reducing EJB calls
- this.emailAddressList = this.contactBean.getEmailAddressList();
+ this.emailAddresses.addAll(this.contactBean.getEmailAddressList());
// Get full contact list
- this.contactList = this.contactBean.getAllContacts();
+ this.contacts.addAll(this.contactBean.getAllContacts());
// Get all users
List allUsers = this.userController.allUsers();
@@ -830,7 +973,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Determine it
- return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
+ return ((this.emailAddresses instanceof List) && (this.emailAddresses.contains(contact.getContactEmailAddress())));
}
@Override
@@ -871,7 +1014,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.clear();
// Try to lookup it in visible user list
- for (final Iterator iterator = this.contactList.iterator(); iterator.hasNext();) {
+ for (final Iterator iterator = this.contacts.iterator(); iterator.hasNext();) {
// Get next user
Contact next = iterator.next();
@@ -896,6 +1039,30 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
return localContact;
}
+ @Override
+ public void removeMobileNumberFromListEvent (@Observes final AdminRemoveMobileNumberFromListEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumberList() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileList is null"); //NOI18N
+ } else if (event.getMobileNumberList().isEmpty()) {
+ // List is empty, no need to check
+ return;
+ }
+
+ // Check all entries
+ for (final Contact contact : this.contacts) {
+ // Is the mobile instance set and in list?
+ if ((contact.getContactMobileNumber() instanceof DialableMobileNumber) && (event.getMobileNumberList().contains(contact.getContactMobileNumber()))) {
+ // Found it, so remvoe it from list
+ event.getMobileNumberList().remove(contact.getContactMobileNumber());
+ }
+ }
+ }
+
@Override
public List selectableContacts () {
return Collections.unmodifiableList(this.selectableContacts);
@@ -926,13 +1093,13 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
*/
private void addUserNameEmailAddress (final Contact contact) {
// Make sure the entry is not added yet
- if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
+ if (this.emailAddresses.contains(contact.getContactEmailAddress())) {
// Already added
throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
}
// Add email addres
- this.emailAddressList.add(contact.getContactEmailAddress());
+ this.emailAddresses.add(contact.getContactEmailAddress());
}
/**
@@ -942,11 +1109,12 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
// Clear all data
// - personal data
this.setGender(null);
- // TODO: Unfinished this.setTitle(null);
+ this.setTitle(null);
this.setFirstName(null);
this.setFamilyName(null);
this.setStreet(null);
this.setHouseNumber(null);
+ this.setHouseNumberExtension(null);
this.setZipCode(null);
this.setCity(null);
this.setCountry(null);
@@ -954,11 +1122,11 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
// - contact data
this.setEmailAddress(null);
this.setEmailAddressRepeat(null);
- this.setPhoneAreaCode(null);
- this.setPhoneCountry(null);
- this.setPhoneNumber(null);
- this.setCellphoneCarrier(null);
- this.setCellphoneNumber(null);
+ this.setLandLineAreaCode(null);
+ this.setLandLineCountry(null);
+ this.setLandLineNumber(null);
+ this.setMobileProvider(null);
+ this.setMobileNumber(null);
this.setFaxAreaCode(null);
this.setFaxCountry(null);
this.setFaxNumber(null);
@@ -989,10 +1157,12 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
// Copy all fields:
// - base data
this.setGender(contact.getContactGender());
+ this.setTitle(contact.getContactTitle());
this.setFirstName(contact.getContactFirstName());
this.setFamilyName(contact.getContactFamilyName());
this.setStreet(contact.getContactStreet());
this.setHouseNumber(contact.getContactHouseNumber());
+ this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
this.setZipCode(contact.getContactZipCode());
this.setCity(contact.getContactCity());
this.setCountry(contact.getContactCountry());
@@ -1000,21 +1170,21 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
this.setBirthday(contact.getContactBirthday());
this.setComment(contact.getContactComment());
- // Get cellphone, phone and fax instance
- DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber();
+ // Get mobile, phone and fax instance
+ DialableMobileNumber mobile = contact.getContactMobileNumber();
DialableFaxNumber fax = contact.getContactFaxNumber();
DialableLandLineNumber phone = contact.getContactLandLineNumber();
// - contact data
if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
- this.setPhoneCountry(phone.getPhoneCountry());
- this.setPhoneAreaCode(phone.getPhoneAreaCode());
- this.setPhoneNumber(phone.getPhoneNumber());
+ this.setLandLineCountry(phone.getPhoneCountry());
+ this.setLandLineAreaCode(phone.getPhoneAreaCode());
+ this.setLandLineNumber(phone.getPhoneNumber());
}
- if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
- this.setCellphoneCarrier(cellphone.getCellphoneProvider());
- this.setCellphoneNumber(cellphone.getPhoneNumber());
+ if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
+ this.setMobileProvider(mobile.getMobileProvider());
+ this.setMobileNumber(mobile.getPhoneNumber());
}
if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
@@ -1043,13 +1213,106 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Remove from general list
- if (!this.contactList.remove(contact)) {
+ if (!this.contacts.remove(contact)) {
// Did not remove contact
throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
}
// Remove from other lists
- this.emailAddressList.remove(contact.getContactEmailAddress());
+ this.emailAddresses.remove(contact.getContactEmailAddress());
+ }
+
+ /**
+ * Removes given fax number from all contacts
+ *
+ * @param faxNumber Fax number to remove
+ */
+ private void removeFromContacts (final DialableFaxNumber faxNumber) {
+ // Is it valid?
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (faxNumber.getPhoneId() == null) {
+ // Throw NPE again
+ 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())); //NOI18N
+ }
+
+ // Loop through all contacts
+ for (final Contact contact : this.contacts) {
+ // Is the number set?
+ if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) {
+ // Found it
+ contact.setContactFaxNumber(null);
+ }
+ }
+ }
+
+ /**
+ * Removes given land-line number from all contacts
+ *
+ * @param landLineNumber Land-line number to remove
+ */
+ private void removeFromContacts (final DialableLandLineNumber landLineNumber) {
+ // Is it valid?
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (landLineNumber.getPhoneId() == null) {
+ // Throw NPE again
+ 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())); //NOI18N
+ }
+
+ // Loop through all contacts
+ for (final Contact contact : this.contacts) {
+ // Is the number set?
+ if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) {
+ // Found it
+ contact.setContactLandLineNumber(null);
+ }
+ }
+ }
+
+ /**
+ * Removes given mobile number from all contacts
+ *
+ * @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"); //NOI18N
+ } else if (mobileNumber.getPhoneId() == null) {
+ // Throw NPE again
+ 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())); //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)) {
+ // Log message
+ System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting ...", this.getClass().getSimpleName())); //NOI18N
+
+ // Unset it
+ contact.setContactMobileNumber(null);
+ }
+ }
}
/**
@@ -1072,7 +1335,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Get iterator from list
- Iterator iterator = this.contactList.iterator();
+ Iterator iterator = this.contacts.iterator();
// "Walk" through all entries
while (iterator.hasNext()) {
@@ -1088,7 +1351,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
}
// Add contact to list
- this.contactList.add(contact);
+ this.contacts.add(contact);
}
}