+ public Contact createContactInstance () {
+ // Generate phone number
+ DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
+ DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+
+ // Create new instance
+ Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+
+ // Check if contact instance is in helper and valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("adminHelper.contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("adminHelper.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
+ }
+
+ // 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);
+
+ // Fire event
+ this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
+
+ // Clear bean
+ this.clear();
+
+ // Return it
+ return contact;
+ }
+
+ @Override
+ public String editContactData () {
+ // Get contact instance
+ Contact contact = this.adminHelper.getContact();
+
+ // Check if contact instance is in helper and valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("adminHelper.contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("adminHelper.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
+ }
+
+ // 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);
+
+ // Fire event
+ this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
+
+ // Clear bean
+ this.clear();
+
+ // Return to contact list (for now)
+ return "admin_list_contact"; //NOI18N
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")