import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
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.landline.LandLineNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.pizzaapplication.beans.BasePizzaController;
-import org.mxchange.pizzaapplication.beans.helper.PizzaAdminWebRequestController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestController;
/**
* Administrative user bean (controller)
* Admin helper instance
*/
@Inject
- private PizzaAdminWebRequestController adminHelper;
+ private PizzaWebRequestController beanHelper;
/**
* Birth day
*/
private String street;
+ /**
+ * Title
+ */
+ private String title;
+
/**
* An event fired when the administrator has updated contact data
*/
Context context = new InitialContext();
// Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ 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);
// Set all fields: contact
this.setContactId(contact.getContactId());
+ this.setTitle(contact.getContactTitle());
this.setBirthday(contact.getContactBirthday());
this.setCity(contact.getContactCity());
this.setComment(contact.getContactComment());
@Override
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
return "admin_list_contact"; //NOI18N
}
+ @Override
+ public String generateCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
+ // Is it null?
+ if (null == cellphoneNumber) {
+ // Return null
+ return null;
+ }
+
+ // Get all data
+ String number = String.format(
+ "%s%d%d", //NOI18N
+ cellphoneNumber.getCellphoneProvider().getProviderCountry().getCountryExternalDialPrefix(),
+ cellphoneNumber.getCellphoneProvider().getProviderDialPrefix(),
+ cellphoneNumber.getPhoneNumber()
+ );
+
+ // Return it
+ return number;
+ }
+
+ @Override
+ 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
@SuppressWarnings ("ReturnOfDateField")
public Date getBirthday () {
this.street = street;
}
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
+ }
+
@Override
public Integer getZipCode () {
return this.zipCode;
// Clear all data
// - personal data
this.setGender(Gender.UNKNOWN);
+ this.setTitle(null);
this.setFirstName(null);
this.setFamilyName(null);
this.setStreet(null);
// Update all fields
contact.setContactGender(this.getGender());
+ contact.setContactTitle(this.getTitle());
contact.setContactFirstName(this.getFirstName());
contact.setContactFamilyName(this.getFamilyName());
contact.setContactStreet(this.getStreet());