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=de484d88fe50906166ec732e5f52251271f2a2f4;hpb=5971b7cb4bf4949a61fe0d1565fca071720d5ddb;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 de484d88..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 @@ -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; @@ -33,35 +34,35 @@ 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.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.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.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.login.PizzaUserLoginWebSessionController; import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; /** * A general contact bean (controller) *

- * @author Roland Haeder + * @author Roland Häder */ @Named ("contactController") @SessionScoped @@ -73,19 +74,14 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P private static final long serialVersionUID = 542_145_347_916L; /** - * Birth day - */ - private Date birthday; - - /** - * Cellphone number's carrier + * Academic academicTitle */ - private MobileProvider cellphoneCarrier; + private String academicTitle; /** - * Cellphone number + * Birth day */ - private Long cellphoneNumber; + private Date birthday; /** * City @@ -100,12 +96,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * Contact list */ - private List contactList; + private final List contactList; /** * Country instance @@ -120,7 +116,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Email address list */ - private List emailAddressList; + private final List emailAddressList; /** * Email address repeated @@ -152,11 +148,6 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ private String firstName; - /** - * Gender instance - */ - private Gender gender; - /** * House number */ @@ -167,11 +158,6 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ private String houseNumberExtension; - /** - * Whether a cellphone entry has been unlinked - */ - private boolean isCellphoneUnlinked; - /** * Whether a fax entry has been unlinked */ @@ -182,20 +168,40 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ private boolean isLandLineUnlinked; + /** + * Whether a mobile entry has been unlinked + */ + private boolean isMobileUnlinked; + /** * Phone number area code */ - private Integer phoneAreaCode; + private Integer landLineAreaCode; /** * Country instance for phone number */ - private Country phoneCountry; + private Country landLineCountry; /** * Phone number */ - private Long phoneNumber; + private Long landLineNumber; + + /** + * Mobile number + */ + private Long mobileNumber; + + /** + * Mobile number's carrier + */ + private MobileProvider mobileProvider; + + /** + * Personal academicTitle + */ + private PersonalTitle personalTitle; /** * A list of all selectable contacts @@ -228,24 +234,21 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P * Default constructor */ public PizzaContactWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); + // Call super constructor + super(); - // 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); - } + // Init lists/maps + this.contactList = new LinkedList<>(); + this.emailAddressList = new LinkedList<>(); } - @Override - public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) { - // Trace message - /* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedContact(): event={0} - CALLED!", event)); //NOI18N - + /** + * Observes events being fired when an administrator has added a new + * contact. + *

+ * @param event Event being fired + */ + public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) { // The event must be valid if (null == event) { // Throw NPE @@ -271,8 +274,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.selectableContacts.add(event.getAddedContact()); } - @Override - public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) { + /** + * 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 @@ -292,8 +299,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.clear(); } - @Override - public void afterAdminLinkedUser (@Observes final AdminLinkedUserEvent event) { + /** + * 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 @@ -319,8 +331,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.clear(); } - @Override - public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) { + /** + * Event observer for updated contact data by administrators + *

+ * @param event Updated contact data event + */ + public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) { // event should not be null if (null == event) { // Throw NPE @@ -333,7 +349,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N } else if (event.getUpdatedContact().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("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N } // Add contact instance only once @@ -343,41 +359,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress()); } - @Override - public void afterRegistrationEvent (@Observes final UserRegisteredEvent 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 - public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) { + /** + * 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 @@ -397,8 +384,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.uniqueAddContact(event.getConfirmedUser().getUserContact()); } - @Override - public void afterUserLogin (@Observes final UserLoggedInEvent event) { + /** + * 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 @@ -418,33 +409,75 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.copyContact(event.getLoggedInUser().getUserContact()); } + /** + * 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 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.contactList; } @Override - public Contact createContactInstance () { - // User message - //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: CALLED!", this.getClass().getSimpleName())); + public void clearEmailAddresses () { + // Clear both + this.setEmailAddress(null); + this.setEmailAddressRepeat(null); + } + @Override + public Contact createContactInstance () { // Is all required data set? if (!this.isRequiredPersonalDataSet()) { // No, then abort here throw new FaceletException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N } + // Required personal data must be set + assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N + // 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 contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName()); contact.setContactStreet(this.getStreet()); contact.setContactHouseNumber(this.getHouseNumber()); contact.setContactHouseNumberExtension(this.getHouseNumberExtension()); @@ -455,11 +488,8 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P contact.setContactBirthday(this.getBirthday()); contact.setContactComment(this.getComment()); - // 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 @@ -501,23 +531,20 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // 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("mobile.phoneNumber is null"); //NOI18N + } else if (mobile.getPhoneNumber() < 1) { // Abort here - throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N + throw new IllegalArgumentException("mobile.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; } @@ -546,7 +573,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N // Update all fields - contact.setContactGender(this.getGender()); + contact.setContactPersonalTitle(this.getPersonalTitle()); contact.setContactFirstName(this.getFirstName()); contact.setContactFamilyName(this.getFamilyName()); contact.setContactStreet(this.getStreet()); @@ -556,70 +583,92 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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.updateMobileNumber(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 } - @Override + /** + * Getter for academic title + *

+ * @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; } @@ -635,12 +684,20 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N } - @Override + /** + * 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; } @@ -650,173 +707,333 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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 + /** + * 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 + /** + * Setter for house number extension + *

+ * @param houseNumberExtension House number extension + */ public void setHouseNumberExtension (final String houseNumberExtension) { this.houseNumberExtension = houseNumberExtension; } - @Override - public Integer getPhoneAreaCode () { - return this.phoneAreaCode; + /** + * Getter for land-line number's area code + *

+ * @return Land-line number's area code + */ + public Integer getLandLineAreaCode () { + return this.landLineAreaCode; } - @Override - public void setPhoneAreaCode (final Integer phoneAreaCode) { - this.phoneAreaCode = phoneAreaCode; + /** + * 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 Country getPhoneCountry () { - return this.phoneCountry; + /** + * Getter for land-line number's country instance + *

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; } - @Override - public void setPhoneCountry (final Country phoneCountry) { - this.phoneCountry = phoneCountry; + /** + * 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 - public Long getPhoneNumber () { - return this.phoneNumber; + /** + * Getter for land-line number + *

+ * @return Land-line number + */ + public Long getLandLineNumber () { + return this.landLineNumber; } - @Override - public void setPhoneNumber (final Long phoneNumber) { - this.phoneNumber = phoneNumber; + /** + * Setter for land-line number + *

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; } - @Override + /** + * 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.contactList.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 allContacts = this.contactBean.getAllContacts(); // Get full contact list - this.contactList = this.contactBean.getAllContacts(); + this.contactList.addAll(allContacts); // Get all users List allUsers = this.userController.allUsers(); - // Get all contacts - List allContacts = this.contactBean.getAllContacts(); - // Get iterator Iterator iterator = allContacts.iterator(); @@ -866,7 +1083,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P @Override public boolean isRequiredChangePersonalDataSet () { - return ((this.getGender() != null) && + return ((this.getPersonalTitle() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && @@ -877,7 +1094,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P @Override public boolean isRequiredPersonalDataSet () { - return ((this.getGender() != null) && + return ((this.getPersonalTitle() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && @@ -972,8 +1189,8 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P private void clear () { // Clear all data // - personal data - this.setGender(null); - // TODO: Unfinished this.setTitle(null); + this.setPersonalTitle(null); + this.setAcademicTitle(null); this.setFirstName(null); this.setFamilyName(null); this.setStreet(null); @@ -984,13 +1201,12 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.setCountry(null); // - contact data - this.setEmailAddress(null); - this.setEmailAddressRepeat(null); - this.setPhoneAreaCode(null); - this.setPhoneCountry(null); - this.setPhoneNumber(null); - this.setCellphoneCarrier(null); - this.setCellphoneNumber(null); + this.clearEmailAddresses(); + this.setLandLineAreaCode(null); + this.setLandLineCountry(null); + this.setLandLineNumber(null); + this.setMobileProvider(null); + this.setMobileNumber(null); this.setFaxAreaCode(null); this.setFaxCountry(null); this.setFaxNumber(null); @@ -1020,7 +1236,8 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P // Copy all fields: // - base data - this.setGender(contact.getContactGender()); + this.setPersonalTitle(contact.getContactPersonalTitle()); + this.setAcademicTitle(contact.getContactTitle()); this.setFirstName(contact.getContactFirstName()); this.setFamilyName(contact.getContactFamilyName()); this.setStreet(contact.getContactStreet()); @@ -1033,21 +1250,21 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P 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)) {