X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fpizzaapplication%2Fbeans%2Fcontact%2FPizzaContactWebSessionBean.java;h=5c01b27eddb99915bf6c70e763a6b401f39ff3da;hb=33f2d7b5075cb337ba33ad938b7ed7a92f933a10;hp=0b5ad4e504d1cfdec21ae59b9530e445b754f711;hpb=acbbcfc107b8963fdfe4c9e9d5308c29b3c4bca7;p=pizzaservice-war.git diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java index 0b5ad4e5..5c01b27e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Roland Haeder + * Copyright (C) 2016, 2017 Roland Häder * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -17,8 +17,10 @@ package org.mxchange.pizzaapplication.beans.contact; 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; @@ -32,35 +34,39 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; +import org.mxchange.jcontacts.contact.ContactUtils; 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.update.AdminUpdatedContactEvent; +import org.mxchange.jcontacts.contact.title.PersonalTitle; +import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; -import org.mxchange.jcustomercore.events.customer.added.AdminAddedCustomerEvent; -import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; 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.login.UserLoggedInEvent; -import org.mxchange.jusercore.events.registration.UserRegisteredEvent; -import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; -import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; -import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController; +import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent; +import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent; +import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent; +import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; +import org.mxchange.pizzaapplication.beans.BasePizzaController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; /** * A general contact bean (controller) *
- * @author Roland Haeder
+ * @param event Event being fired
+ */
+ public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
// The event must be valid
if (null == event) {
// Throw NPE
@@ -237,48 +258,28 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
throw new NullPointerException("event.addedContact is null"); //NOI18N
} else if (event.getAddedContact().getContactId() == null) {
// ... and again
- throw new NullPointerException("event.addedContact.customerId is null"); //NOI18N
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
} else if (event.getAddedContact().getContactId() < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.customerId={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 //NOI18N
}
// Clear this bean
this.clear();
// Call other method
- this.contactList.add(event.getAddedContact());
- }
-
- @Override
- public void afterAdminAddedCustomer (@Observes final AdminAddedCustomerEvent event) {
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedCustomer() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedCustomer is null"); //NOI18N
- } else if (event.getAddedCustomer().getCustomerId() == null) {
- // ... and again
- throw new NullPointerException("event.addedCustomer.customerId is null"); //NOI18N
- } else if (event.getAddedCustomer().getCustomerId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedCustomer.customerId={0} is not valid", event.getAddedCustomer().getCustomerId())); //NOI18N //NOI18N
- }
-
- // Clear this bean
- this.clear();
+ this.uniqueAddContact(event.getAddedContact());
- // Call other method
- this.contactList.add(event.getAddedCustomer().getCustomerContact());
+ // Add to selectable contacts
+ this.selectableContacts.add(event.getAddedContact());
}
- @Override
- public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
+ /**
+ * Event observer for newly added users by administrator
+ *
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
@@ -296,110 +297,109 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
// Clear all data
this.clear();
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
}
- @Override
- public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
-
+ /**
+ * Observes events being fired when an administrator has linked a new user
+ * with existing contact data.
+ *
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedContact() == null) {
+ } else if (event.getLinkedUser() == null) {
// Throw NPE again
- throw new NullPointerException("event.updatedUser is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() == null) {
+ throw new NullPointerException("event.linkedUser is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
// userId is null
- throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() < 1) {
+ throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
// Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
}
- // Get iterator from list
- Iterator
+ * @param event Updated contact data event
+ */
+ public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
}
- // Add contact to list
- this.contactList.add(event.getUpdatedContact());
+ // Add contact instance only once
+ this.uniqueAddContact(event.getUpdatedContact());
// Add email address to list
this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
}
- @Override
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
-
+ /**
+ * Event observer when user confirmed account.
+ *
+ * @param event Event being fired
+ */
+ public void afterUserConfirmedAccount (@Observes final ObservableUserConfirmedAccountEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getRegisteredUser() == null) {
+ } else if (event.getConfirmedUser() == null) {
// Throw NPE again
- throw new NullPointerException("event.user is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
+ throw new NullPointerException("event.confirmedUser is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() == null) {
// userId is null
- throw new NullPointerException("event.user.userId is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() < 1) {
+ throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() < 1) {
// Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
}
- // Get user instance
- Contact registeredContact = event.getRegisteredUser().getUserContact();
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
- // Copy all data from registered->user
- this.copyContact(registeredContact);
-
- // Add user name and email address
- this.addUserNameEmailAddress(registeredContact);
-
- // Clear all data
- this.clear();
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
+ // Add contact instance only once
+ this.uniqueAddContact(event.getConfirmedUser().getUserContact());
}
- @Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
+ /**
+ * Event observer for logged-in user
+ *
+ * @param event Event instance
+ */
+ public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
} else if (event.getLoggedInUser() == null) {
// Throw NPE again
- throw new NullPointerException("event.user is null"); //NOI18N
+ throw new NullPointerException("event.loggedInUser is null"); //NOI18N
} else if (event.getLoggedInUser().getUserId() == null) {
// userId is null
- throw new NullPointerException("event.user.userId is null"); //NOI18N
+ throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
} else if (event.getLoggedInUser().getUserId() < 1) {
// Not avalid id
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
@@ -407,22 +407,61 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
// Copy all data to this bean
this.copyContact(event.getLoggedInUser().getUserContact());
+ }
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
+ /**
+ * Event observer for new user registrations
+ *
+ * @param event User registration event
+ */
+ public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getRegisteredUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ }
+
+ // Get user instance
+ Contact registeredContact = event.getRegisteredUser().getUserContact();
+
+ // Copy all data from registered->user
+ this.copyContact(registeredContact);
+
+ // Add contact instance only once
+ this.uniqueAddContact(registeredContact);
+
+ // Add user name and email address
+ this.addUserNameEmailAddress(registeredContact);
+
+ // Clear all data
+ this.clear();
}
@Override
@SuppressWarnings ("ReturnOfCollectionOrArrayField")
public List
+ * @return Academic title
+ */
+ public String getAcademicTitle () {
+ return this.academicTitle;
+ }
+
+ /**
+ * Setter for academic title
+ *
+ * @param academicTitle Academic title
+ */
+ public void setAcademicTitle (final String academicTitle) {
+ this.academicTitle = academicTitle;
+ }
+
+ /**
+ * Getter for birth day
+ *
+ * @return Birth day
+ */
@SuppressWarnings ("ReturnOfDateField")
public Date getBirthday () {
return this.birthday;
}
- @Override
+ /**
+ * Setter for birth day
+ *
+ * @param birthday Birth day
+ */
@SuppressWarnings ("AssignmentToDateFieldFromParameter")
public void setBirthday (final Date birthday) {
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
+ /**
+ * Getter for city name
+ *
+ * @return City name
+ */
public String getCity () {
return this.city;
}
- @Override
+ /**
+ * Setter for city name
+ *
+ * @param city City name
+ */
public void setCity (final String city) {
this.city = city;
}
- @Override
+ /**
+ * Getter for comments
+ *
+ * @return Comments
+ */
public String getComment () {
return this.comment;
}
- @Override
+ /**
+ * Setter for comment
+ *
+ * @param comment Comments
+ */
public void setComment (final String comment) {
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
+ }
+
+ /**
+ * Getter for country instance
+ *
+ * @return Country instance
+ */
public Country getCountry () {
return this.country;
}
- @Override
+ /**
+ * Setter for country instance
+ *
+ * @param country Country instance
+ */
public void setCountry (final Country country) {
this.country = country;
}
@@ -626,166 +707,383 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
return this.emailAddress;
}
- @Override
+ /**
+ * Setter for email address
+ *
+ * @param emailAddress Email address
+ */
public void setEmailAddress (final String emailAddress) {
this.emailAddress = emailAddress;
}
- @Override
+ /**
+ * Getter for email address, repeated
+ *
+ * @return the emailAddress, repeated
+ */
public String getEmailAddressRepeat () {
return this.emailAddressRepeat;
}
- @Override
+ /**
+ * Setter for email address repeated
+ *
+ * @param emailAddressRepeat the emailAddress to set
+ */
public void setEmailAddressRepeat (final String emailAddressRepeat) {
this.emailAddressRepeat = emailAddressRepeat;
}
- @Override
+ /**
+ * Family name
+ *
+ * @return the familyName
+ */
public String getFamilyName () {
return this.familyName;
}
- @Override
+ /**
+ * Family name
+ *
+ * @param familyName the familyName to set
+ */
public void setFamilyName (final String familyName) {
this.familyName = familyName;
}
- @Override
+ /**
+ * Getter for fax number's area code
+ *
+ * @return Fax number's area code
+ */
public Integer getFaxAreaCode () {
return this.faxAreaCode;
}
- @Override
+ /**
+ * Setter for fax number's area code
+ *
+ * @param faxAreaCode Fax number's area code
+ */
public void setFaxAreaCode (final Integer faxAreaCode) {
this.faxAreaCode = faxAreaCode;
}
- @Override
+ /**
+ * Getter for fax's country instance
+ *
+ * @return Fax' country instance
+ */
public Country getFaxCountry () {
return this.faxCountry;
}
- @Override
+ /**
+ * Setter for fax's country instance
+ *
+ * @param faxCountry Fax' country instance
+ */
public void setFaxCountry (final Country faxCountry) {
this.faxCountry = faxCountry;
}
- @Override
+ /**
+ * Getter for fax number
+ *
+ * @return Fax number
+ */
public Long getFaxNumber () {
return this.faxNumber;
}
- @Override
+ /**
+ * Setter for fax number
+ *
+ * @param faxNumber Fax number
+ */
public void setFaxNumber (final Long faxNumber) {
this.faxNumber = faxNumber;
}
- @Override
+ /**
+ * First name
+ *
+ * @return the first name
+ */
public String getFirstName () {
return this.firstName;
}
- @Override
+ /**
+ * First name
+ *
+ * @param firstName the first name to set
+ */
public void setFirstName (final String firstName) {
this.firstName = firstName;
}
- @Override
- public Gender getGender () {
- return this.gender;
- }
-
- @Override
- public void setGender (final Gender gender) {
- this.gender = gender;
- }
-
- @Override
+ /**
+ * House number
+ *
+ * @return the houseNumber
+ */
public Short getHouseNumber () {
return this.houseNumber;
}
- @Override
+ /**
+ * House number
+ *
+ * @param houseNumber the houseNumber to set
+ */
public void setHouseNumber (final Short houseNumber) {
this.houseNumber = houseNumber;
}
- @Override
- public Integer getPhoneAreaCode () {
- return this.phoneAreaCode;
+ /**
+ * Getter for house number extension, example: 123a 'a' is then the
+ * extension and 123 is the house number.
+ *
+ * @return House number extension
+ */
+ public String getHouseNumberExtension () {
+ return this.houseNumberExtension;
}
- @Override
- public void setPhoneAreaCode (final Integer phoneAreaCode) {
- this.phoneAreaCode = phoneAreaCode;
+ /**
+ * Setter for house number extension
+ *
+ * @param houseNumberExtension House number extension
+ */
+ public void setHouseNumberExtension (final String houseNumberExtension) {
+ this.houseNumberExtension = houseNumberExtension;
}
- @Override
- public Country getPhoneCountry () {
- return this.phoneCountry;
+ /**
+ * Getter for land-line number's area code
+ *
+ * @return Land-line number's area code
+ */
+ public Integer getLandLineAreaCode () {
+ return this.landLineAreaCode;
}
- @Override
- public void setPhoneCountry (final Country phoneCountry) {
- this.phoneCountry = phoneCountry;
+ /**
+ * Setter for land-line number's area code
+ *
+ * @param landLineAreaCode Land-line number's area code
+ */
+ public void setLandLineAreaCode (final Integer landLineAreaCode) {
+ this.landLineAreaCode = landLineAreaCode;
}
- @Override
- public Long getPhoneNumber () {
- return this.phoneNumber;
+ /**
+ * Getter for land-line number's country instance
+ *
+ * @return Land-line number's country instance
+ */
+ public Country getLandLineCountry () {
+ return this.landLineCountry;
}
- @Override
- public void setPhoneNumber (final Long phoneNumber) {
- this.phoneNumber = phoneNumber;
+ /**
+ * Setter for land-line number's country instance
+ *
+ * @param landLineCountry Land-line number's country instance
+ */
+ public void setLandLineCountry (final Country landLineCountry) {
+ this.landLineCountry = landLineCountry;
}
- @Override
+ /**
+ * Getter for land-line number
+ *
+ * @return Land-line number
+ */
+ public Long getLandLineNumber () {
+ return this.landLineNumber;
+ }
+
+ /**
+ * Setter for land-line number
+ *
+ * @param landLineNumber Land-line number
+ */
+ public void setLandLineNumber (final Long landLineNumber) {
+ this.landLineNumber = landLineNumber;
+ }
+
+ /**
+ * Getter for mobile number
+ *
+ * @return Mobile number
+ */
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ /**
+ * Setter for mobile number
+ *
+ * @param mobileNumber Mobile number
+ */
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ /**
+ * Getter for mobile number's carrier
+ *
+ * @return Mobile number's carrier
+ */
+ public MobileProvider getMobileProvider () {
+ return this.mobileProvider;
+ }
+
+ /**
+ * Setter for mobile number's provider
+ *
+ * @param mobileProvider Mobile number's provider
+ */
+ public void setMobileProvider (final MobileProvider mobileProvider) {
+ this.mobileProvider = mobileProvider;
+ }
+
+ /**
+ * Getter for personal title
+ *
+ * @return Personal title
+ */
+ public PersonalTitle getPersonalTitle () {
+ return this.personalTitle;
+ }
+
+ /**
+ * Setter for personal title
+ *
+ * @param personalTitle Personal title
+ */
+ public void setPersonalTitle (final PersonalTitle personalTitle) {
+ this.personalTitle = personalTitle;
+ }
+
+ /**
+ * Getter for street
+ *
+ * @return Street
+ */
public String getStreet () {
return this.street;
}
- @Override
+ /**
+ * Setter for street
+ *
+ * @param street Street
+ */
public void setStreet (final String street) {
this.street = street;
}
- @Override
+ /**
+ * Getter for ZIP code
+ *
+ * @return ZIP code
+ */
public Integer getZipCode () {
return this.zipCode;
}
- @Override
+ /**
+ * Setter for ZIP code
+ *
+ * @param zipCode ZIP code
+ */
public void setZipCode (final Integer zipCode) {
this.zipCode = zipCode;
}
- @Override
- public boolean hasContacts () {
- return (!this.allContacts().isEmpty());
- }
-
/**
- * Post-initialization of this class
+ * Post-construction method
*/
@PostConstruct
public void init () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
// Get full email address list for reducing EJB calls
- this.emailAddressList = this.contactBean.getEmailAddressList();
+ this.emailAddressList.addAll(this.contactBean.getEmailAddressList());
+
+ // Get all contacts
+ List
+ * @param contact Contact instance to remove
+ */
+ private void removeContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Remove from general list
+ if (!this.contactList.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());
+ }
+
+ /**
+ * Adds unique instance to contact list. First any existing instance is
+ * being removed, then the new instance is added.
+ *
+ * @param contact Contact instance to add uniquely
+ */
+ private void uniqueAddContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Get iterator from list
+ Iterator