X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fpizzaapplication%2Fbeans%2Fcontact%2FPizzaAdminContactWebRequestBean.java;h=f8ce3f5a4dda8358849db401d2091f32e64396ac;hb=33f2d7b5075cb337ba33ad938b7ed7a92f933a10;hp=492051b284fd38b6f5bd20f78bbf9c59614d9f36;hpb=7db416306fe8ecc18b5fce0f26ebeb84402c71a5;p=pizzaservice-war.git diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index 492051b2..f8ce3f5a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.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 @@ -19,45 +19,48 @@ package org.mxchange.pizzaapplication.beans.contact; import java.text.MessageFormat; import java.util.Date; import java.util.Iterator; -import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; +import javax.faces.context.FacesContext; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote; 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.contact.title.PersonalTitle; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; -import org.mxchange.jcontacts.events.contact.add.AdminContactAddedEvent; -import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent; +import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; 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.DialableNumber; 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.pizzaapplication.beans.helper.PizzaAdminWebRequestController; +import org.mxchange.pizzaapplication.beans.BasePizzaController; +import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController; /** * Administrative user bean (controller) *

- * @author Roland Haeder + * @author Roland Häder */ @Named ("adminContactController") @RequestScoped -public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequestController { +public class PizzaAdminContactWebRequestBean extends BasePizzaController implements PizzaAdminContactWebRequestController { /** * Serial number @@ -65,37 +68,32 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ private static final long serialVersionUID = 542_145_347_916L; /** - * An event fired when the administrator has added a new contact + * Academic academicTitle */ - @Inject - @Any - private Event addedContactEvent; + private String academicTitle; /** - * Admin helper instance + * An event fired when the administrator has added a new contact */ @Inject - private PizzaAdminWebRequestController adminHelper; - - /** - * Birth day - */ - private Date birthday; + @Any + private Event addedContactEvent; /** - * Cellphone number's carrier + * Administrative contact EJB */ - private MobileProvider cellphoneCarrier; + private AdminContactSessionBeanRemote adminContactBean; /** - * Cellphone id number + * Bean helper instance */ - private Long cellphoneId; + @Inject + private PizzaWebRequestHelperController beanHelper; /** - * Cellphone number + * Birth day */ - private Long cellphoneNumber; + private Date birthday; /** * City @@ -110,7 +108,7 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * General contact controller @@ -126,7 +124,7 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ /** * Country instance */ - private Country country; + private Country contactCountry; /** * Email address @@ -163,20 +161,15 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ */ private String firstName; - /** - * Gender instance - */ - private Gender gender; - /** * House number */ 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 @@ -189,24 +182,49 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ private boolean isLandLineUnlinked; /** - * Land-line id number + * Whether a cmobile entry has been unlinked */ - private Long landLineId; + private boolean isMobileNumberUnlinked; /** * Phone number area code */ - private Integer phoneAreaCode; + private Integer landLineAreaCode; /** * Country instance for phone number */ - private Country phoneCountry; + private Country landLineCountry; + + /** + * Land-line id number + */ + private Long landLineId; /** * Phone number */ - private Long phoneNumber; + private Long landLineNumber; + + /** + * Mobile id number + */ + private Long mobileId; + + /** + * Mobile number + */ + private Long mobileNumber; + + /** + * Mobile number's provider + */ + private MobileProvider mobileProvider; + + /** + * PersonalTitle instance + */ + private PersonalTitle personalTitle; /** * Street @@ -218,7 +236,7 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ */ @Inject @Any - private Event updatedContactEvent; + private Event updatedContactEvent; /** * ZIP code @@ -229,24 +247,35 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ * Default constructor */ public PizzaAdminContactWebRequestBean () { - // Set gender to UNKNOWN - this.gender = Gender.UNKNOWN; - - // 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); - } + // Call super constructor + super(); } - @Override + /** + * Adds contact data to database and redirects on success. If the contact is + * already found, a proper exception is thrown. + *

+ * @return Redirect outcome + */ public String addContact () { + // Are all minimum fields set? + if (this.getPersonalTitle() == null) { + // Throw NPE + throw new NullPointerException("personalTitle is null"); //NOI18N + } else if (this.getFirstName() == null) { + // Throw NPE + throw new NullPointerException("firstName is null"); //NOI18N + } else if (this.getFirstName().isEmpty()) { + // Empty string + throw new IllegalStateException("firstName is empty"); //NOI18N + } else if (this.getFamilyName() == null) { + // Throw NPE + throw new NullPointerException("familyName is null"); //NOI18N + } else if (this.getFamilyName().isEmpty()) { + // Empty string + throw new IllegalStateException("familyName is empty"); //NOI18N + } + // Create new contact instance Contact contact = this.createContactInstance(); @@ -262,14 +291,14 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ // Try to call EJB try { // Call EJB - updatedContact = this.contactBean.addContact(contact); + updatedContact = this.adminContactBean.addContact(contact); } catch (final ContactAlreadyAddedException ex) { // Throw again throw new FaceletException(ex); } // Fire event - this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact)); + this.addedContactEvent.fire(new AdminAddedContactEvent(updatedContact)); // Clear this bean this.clear(); @@ -278,11 +307,6 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ return "admin_list_contact"; //NOI18N } - @Override - public List allContacts () { - return this.contactController.allContacts(); - } - @Override public void copyContactToController (final Contact contact) { // Log message @@ -302,24 +326,26 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ // Set all fields: contact this.setContactId(contact.getContactId()); + this.setAcademicTitle(contact.getContactTitle()); this.setBirthday(contact.getContactBirthday()); this.setCity(contact.getContactCity()); this.setComment(contact.getContactComment()); - this.setCountry(contact.getContactCountry()); + this.setContactCountry(contact.getContactCountry()); this.setEmailAddress(contact.getContactEmailAddress()); this.setFamilyName(contact.getContactFamilyName()); this.setFirstName(contact.getContactFirstName()); - this.setGender(contact.getContactGender()); + this.setPersonalTitle(contact.getContactPersonalTitle()); this.setHouseNumber(contact.getContactHouseNumber()); + this.setHouseNumberExtension(contact.getContactHouseNumberExtension()); this.setStreet(contact.getContactStreet()); this.setZipCode(contact.getContactZipCode()); // Is the cell phone set? - if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) { - // ... cellphone data - this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId()); - this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider()); - this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber()); + if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { + // ... cmobile data + this.setMobileId(contact.getContactMobileNumber().getPhoneId()); + this.setMobileProvider(contact.getContactMobileNumber().getMobileProvider()); + this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber()); } // Is the fax set? @@ -335,9 +361,9 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { // .. land-line data this.setLandLineId(contact.getContactLandLineNumber().getPhoneId()); - this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode()); - this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry()); - this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber()); + this.setLandLineAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode()); + this.setLandLineCountry(contact.getContactLandLineNumber().getPhoneCountry()); + this.setLandLineNumber(contact.getContactLandLineNumber().getPhoneNumber()); } // Log message @@ -347,9 +373,9 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ @Override public Contact createContactInstance () { // Are all minimum fields set? - if (this.getGender() == null) { + if (this.getPersonalTitle() == null) { // Throw NPE - throw new NullPointerException("gender is null"); //NOI18N + throw new NullPointerException("personalTitle is null"); //NOI18N } else if (this.getFirstName() == null) { // Throw NPE throw new NullPointerException("firstName is null"); //NOI18N @@ -365,20 +391,21 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ } // Generate phone number - DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); - DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber()); + DialableLandLineNumber landLine = 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 instance - Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName()); + Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName()); // Add all others + contact.setContactTitle(this.getAcademicTitle()); contact.setContactBirthday(this.getBirthday()); contact.setContactStreet(this.getStreet()); contact.setContactHouseNumber(this.getHouseNumber()); contact.setContactZipCode(this.getZipCode()); contact.setContactCity(this.getCity()); - contact.setContactCountry(this.getCountry()); + contact.setContactCountry(this.getContactCountry()); contact.setContactEmailAddress(this.getEmailAddress()); contact.setContactBirthday(this.getBirthday()); contact.setContactComment(this.getComment()); @@ -387,24 +414,24 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ contact.setContactOwnContact(Boolean.TRUE); // 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 ((landLine instanceof DialableLandLineNumber) && (landLine.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) { + if (landLine.getPhoneAreaCode() == null) { // Is null throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (phone.getPhoneAreaCode() < 1) { + } else if (landLine.getPhoneAreaCode() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (phone.getPhoneNumber() == null) { + } else if (landLine.getPhoneNumber() == null) { // Is null throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (phone.getPhoneNumber() < 1) { + } else if (landLine.getPhoneNumber() < 1) { // Abort here throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N } // Set phone number - contact.setContactLandLineNumber(phone); + contact.setContactLandLineNumber(landLine); } // Don't set null or wrong references @@ -429,49 +456,53 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ } // 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("cmobile.phoneNumber is null"); //NOI18N + } else if (mobile.getPhoneNumber() < 1) { // Abort here - throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N + throw new IllegalArgumentException("cmobile.phoneNumber is zero or below."); //NOI18N } - // Set cellphone number - contact.setContactCellphoneNumber(cellphone); + // Set cmobile number + contact.setContactMobileNumber(mobile); } // Return it return contact; } - @Override + /** + * Edits currently loaded contact's data in database. + *

+ * @return Redirect outcome + */ public String editContactData () { // Get contact instance - Contact contact = this.adminHelper.getContact(); + Contact contact = this.beanHelper.getContact(); // Check if contact instance is in helper and valid if (null == contact) { // Throw NPE - throw new NullPointerException("adminHelper.contact is null"); //NOI18N + throw new NullPointerException("beanHelper.contact is null"); //NOI18N } else if (contact.getContactId() == null) { // Throw NPE again - throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N + throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N } else if (contact.getContactId() < 1) { // Invalid id - throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N } // Update all data in contact this.updateContactData(contact); // Call EJB for updating contact data - Contact updatedContact = this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); + Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileNumberUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); // Fire event - this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact)); + this.updatedContactEvent.fire(new AdminUpdatedContactEvent(updatedContact)); // Clear bean this.clear(); @@ -480,248 +511,581 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ return "admin_list_contact"; //NOI18N } - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getBirthday () { - return this.birthday; - } + /** + * Returns a text representation of given mobile number or null if not set. + *

+ * @param mobileNumber Mobile number + *

+ * @return Text representation or null + */ + public String generateMobileNumber (final DialableMobileNumber mobileNumber) { + // Is it null? + if (null == mobileNumber) { + // Return null + return null; + } - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setBirthday (final Date birthday) { - this.birthday = birthday; - } + // Get all data + String number = String.format( + "%s%d%d", //NOI18N + mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(), + mobileNumber.getMobileProvider().getProviderDialPrefix(), + mobileNumber.getPhoneNumber() + ); - @Override - public MobileProvider getCellphoneCarrier () { - return this.cellphoneCarrier; + // Return it + return number; } - @Override - public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) { - this.cellphoneCarrier = cellphoneCarrier; + /** + * Returns a text representation of given land-line or fax number or null if + * not set. + *

+ * @param phoneNumber Land-line or fax number + *

+ * @return Text representation or null + */ + public String generatePhoneNumber (final DialableNumber phoneNumber) { + // Is it null? + if (null == phoneNumber) { + // Return null + return null; + } + + // Generate it + String number = String.format( + "%s%d%d", //NOI18N + phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(), + phoneNumber.getPhoneAreaCode(), + phoneNumber.getPhoneNumber() + ); + + // Return it + return number; } - @Override - public Long getCellphoneId () { - return this.cellphoneId; + /** + * Getter for academic title + *

+ * @return Academic title + */ + public String getAcademicTitle () { + return this.academicTitle; } - @Override - public void setCellphoneId (final Long cellphoneId) { - this.cellphoneId = cellphoneId; + /** + * Setter for academic title + *

+ * @param academicTitle Academic title + */ + public void setAcademicTitle (final String academicTitle) { + this.academicTitle = academicTitle; } - @Override - public Long getCellphoneNumber () { - return this.cellphoneNumber; + /** + * Getter for birth day + *

+ * @return Birth day + */ + @SuppressWarnings ("ReturnOfDateField") + public Date getBirthday () { + return this.birthday; } - @Override - public void setCellphoneNumber (Long cellphoneNumber) { - this.cellphoneNumber = cellphoneNumber; + /** + * Setter for birth day + *

+ * @param birthday Birth day + */ + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setBirthday (final Date birthday) { + this.birthday = birthday; } - @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 + /** + * Getter for contact id + *

+ * @return Contact id + */ public Long getContactId () { return this.contactId; } - @Override + /** + * Setter for contact id + *

+ * @param contactId Contact id + */ public void setContactId (final Long contactId) { this.contactId = contactId; } @Override - public Country getCountry () { - return this.country; + public String getControllerType () { + return "admin"; //NOI18N } @Override - public void setCountry (final Country country) { - this.country = country; + @Deprecated + public void setControllerType (final String controllerType) { + throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N } - @Override + /** + * Getter for contactCountry instance + *

+ * @return Country instance + */ + public Country getContactCountry () { + return this.contactCountry; + } + + /** + * Setter for contactCountry instance + *

+ * @param contactCountry Country instance + */ + public void setContactCountry (final Country contactCountry) { + this.contactCountry = contactCountry; + } + + /** + * Getter for email address + *

+ * @return Email address + */ public String getEmailAddress () { return this.emailAddress; } - @Override + /** + * Setter for email address + *

+ * @param emailAddress Email address + */ public void setEmailAddress (final String emailAddress) { this.emailAddress = emailAddress; } - @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 id + *

+ * @return Fax id + */ public Long getFaxId () { return this.faxId; } - @Override + /** + * Setter for fax id + *

+ * @param faxId Fax id + */ public void setFaxId (final Long faxId) { this.faxId = faxId; } - @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 + /** + * Getter for first name + *

+ * @return First name + */ public String getFirstName () { return this.firstName; } - @Override + /** + * Setter for first name + *

+ * @param firstName First name + */ 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 + /** + * Getter for house number + *

+ * @return House number + */ public Short getHouseNumber () { return this.houseNumber; } - @Override + /** + * Setter for house number + *

+ * @param houseNumber House number + */ public void setHouseNumber (final Short houseNumber) { this.houseNumber = houseNumber; } - @Override + /** + * Getter for house number extension. Example: 123a, 'a' is the extension + * and 123 is the house number. + *

+ * @return House number extension + */ + public String getHouseNumberExtension () { + return this.houseNumberExtension; + } + + /** + * Setter for house number extension + *

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

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

+ * @return Land-line number's country instance + */ + public Country getLandLineCountry () { + return this.landLineCountry; + } + + /** + * 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; + } + + /** + * Getter for land-line id + *

+ * @return Land-line id + */ public Long getLandLineId () { return this.landLineId; } - @Override + /** + * Setter for land-line id + *

+ * @param landLineId Land-line id + */ public void setLandLineId (final Long landLineId) { this.landLineId = landLineId; } - @Override - public Integer getPhoneAreaCode () { - return this.phoneAreaCode; + /** + * Getter for land-line number + *

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

+ * @param landLineNumber Land-line number + */ + public void setLandLineNumber (final Long landLineNumber) { + this.landLineNumber = landLineNumber; } - @Override - public Country getPhoneCountry () { - return this.phoneCountry; + /** + * Getter for mobile id + *

+ * @return Mobile id + */ + public Long getMobileId () { + return this.mobileId; } - @Override - public void setPhoneCountry (final Country phoneCountry) { - this.phoneCountry = phoneCountry; + /** + * Setter for mobile id + *

+ * @param mobileId Mobile id + */ + public void setMobileId (final Long mobileId) { + this.mobileId = mobileId; } - @Override - public Long getPhoneNumber () { - return this.phoneNumber; + /** + * Getter for mobile number + *

+ * @return Mobile number + */ + public Long getMobileNumber () { + return this.mobileNumber; } - @Override - public void setPhoneNumber (final Long phoneNumber) { - this.phoneNumber = phoneNumber; + /** + * Setter for mobile number + *

+ * @param mobileNumber Mobile number + */ + public void setMobileNumber (final Long mobileNumber) { + this.mobileNumber = mobileNumber; } - @Override + /** + * Getter for mobile number's carrier + *

+ * @return Mobile number's carrier + */ + public MobileProvider getMobileProvider () { + return this.mobileProvider; + } + + /** + * Setter for mobile number's carrier prefix + *

+ * @param mobileProvider Mobile number's carrier prefix + */ + 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 name + *

+ * @return Street name + */ public String getStreet () { return this.street; } - @Override + /** + * Setter for street name + *

+ * @param street Street name + */ 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 */ @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 + + // Try to lookup (administative) + this.adminContactBean = (AdminContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + + @Override + @Deprecated + public boolean isPersonalTitleRequired () { + // Get context parameter + String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_admin_personal_title_enabled"); //NOI18N + + // Is it set? + boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N + + // Return value + return isRequired; + } + + @Override + public void validateContactData () { + if (this.getPersonalTitle() == null) { + // Throw NPE again + throw new NullPointerException("contactController.gender is null"); //NOI18N + } else if (this.getFirstName() == null) { + // ... and again + throw new NullPointerException("contactController.firstName is null"); //NOI18N + } else if (this.getFirstName().isEmpty()) { + // ... and again + throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N + } else if (this.getFamilyName() == null) { + // ... and again + throw new NullPointerException("contactController.familyName is null"); //NOI18N + } else if (this.getFamilyName().isEmpty()) { + // ... and again + throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N + } else if (this.getEmailAddress() == null) { + // ... and again + throw new NullPointerException("contactController.emailAddress is null"); //NOI18N + } else if (this.getEmailAddress().isEmpty()) { + // ... and again + throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N + } } /** @@ -730,22 +1094,23 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ private void clear () { // Clear all data // - personal data - this.setGender(Gender.UNKNOWN); + this.setAcademicTitle(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); + this.setContactCountry(null); // - contact data this.setEmailAddress(null); - this.setPhoneCountry(null); - this.setPhoneAreaCode(null); - this.setPhoneNumber(null); - this.setCellphoneCarrier(null); - this.setCellphoneNumber(null); + this.setLandLineCountry(null); + this.setLandLineAreaCode(null); + this.setLandLineNumber(null); + this.setMobileProvider(null); + this.setMobileNumber(null); this.setFaxCountry(null); this.setFaxAreaCode(null); this.setFaxNumber(null); @@ -767,7 +1132,7 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ boolean IsFound = false; // Get iterator - Iterator iterator = this.allContacts().iterator(); + Iterator iterator = this.contactController.allContacts().iterator(); // Loop through all while (iterator.hasNext()) { @@ -805,20 +1170,22 @@ public class PizzaAdminContactWebRequestBean implements PizzaAdminContactWebRequ } // Update all fields - contact.setContactGender(this.getGender()); + contact.setContactPersonalTitle(this.getPersonalTitle()); + contact.setContactTitle(this.getAcademicTitle()); contact.setContactFirstName(this.getFirstName()); 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()); + contact.setContactCountry(this.getContactCountry()); - // Update contact's cellphone number - this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber()); + // Update contact's cmobile number + this.isMobileNumberUnlinked = 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());