]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / contact / JobsAdminContactWebRequestBean.java
index 2362342448ad25887aedaaf83475d5eecc25489c..f5f168a94f6a491b8565bf6be4915de5852e6627 100644 (file)
@@ -18,10 +18,11 @@ package org.mxchange.jjobs.beans.contact;
 
 import java.text.MessageFormat;
 import java.util.Date;
-import java.util.List;
+import java.util.Iterator;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
@@ -29,26 +30,37 @@ 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.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.add.AdminContactAddedEvent;
+import org.mxchange.jcontacts.events.contact.deleted.AdminContactDeletedEvent;
+import org.mxchange.jcontacts.events.contact.deleted.AdminDeletedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
 import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
 import org.mxchange.jcountry.data.Country;
-import org.mxchange.jjobs.beans.helper.JobsAdminWebRequestController;
+import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
 
 /**
- * An administrative user bean (controller)
+ * An administrative user controller (bean)
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
 @Named ("adminContactController")
 @RequestScoped
-public class JobsAdminContactWebRequestBean implements JobsAdminContactWebRequestController {
+public class JobsAdminContactWebRequestBean extends BaseJobsController implements JobsAdminContactWebRequestController {
 
        /**
         * Serial number
@@ -56,37 +68,27 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        private static final long serialVersionUID = 542_145_347_916L;
 
        /**
-        * An event fired when the administrator has added a new user
+        * An event fired when the administrator has added a new contact
         */
        @Inject
        @Any
-       private Event<AdminAddedUserEvent> addedUserEvent;
+       private Event<AdminAddedContactEvent> addedContactEvent;
 
        /**
-        * Admin helper instance
+        * Administrative contact EJB
         */
-       @Inject
-       private JobsAdminWebRequestController adminHelper;
-
-       /**
-        * Birth day
-        */
-       private Date birthday;
+       private AdminContactSessionBeanRemote adminContactBean;
 
        /**
-        * Cellphone number's carrier
+        * Bean helper
         */
-       private MobileProvider cellphoneCarrier;
-
-       /**
-        * Cellphone id number
-        */
-       private Long cellphoneId;
+       @Inject
+       private JobsWebViewHelperController beanHelper;
 
        /**
-        * Cellphone number
+        * Birth day
         */
-       private Long cellphoneNumber;
+       private Date birthday;
 
        /**
         * City
@@ -99,10 +101,16 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        private String comment;
 
        /**
-        * Remote contact bean
+        * General contact EJB
         */
        private final ContactSessionBeanRemote contactBean;
 
+       /**
+        * General contact controller
+        */
+       @Inject
+       private JobsContactWebSessionController contactController;
+
        /**
         * Contact id
         */
@@ -113,6 +121,13 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
         */
        private Country country;
 
+       /**
+        * Event being fired when contact data has been deleted
+        */
+       @Inject
+       @Any
+       private Event<AdminDeletedContactEvent> deletedContactEvent;
+
        /**
         * Email address
         */
@@ -134,14 +149,14 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        private Country faxCountry;
 
        /**
-        * Fax id number
+        * Fax number
         */
-       private Long faxId;
+       private Long faxNumber;
 
        /**
-        * Fax number
+        * Fax id number
         */
-       private Long faxNumber;
+       private Long faxNumberId;
 
        /**
         * First name
@@ -159,9 +174,9 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        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
@@ -173,31 +188,56 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
         */
        private boolean isLandLineUnlinked;
 
+       /**
+        * Whether a mobile entry has been unlinked
+        */
+       private boolean isMobileUnlinked;
+
+       /**
+        * Land-line number area code
+        */
+       private Integer landLineAreaCode;
+
+       /**
+        * Country instance for land-line number
+        */
+       private Country landLineCountry;
+
        /**
         * Land-line id number
         */
        private Long landLineId;
 
        /**
-        * Phone number area code
+        * Land-line number
         */
-       private Integer phoneAreaCode;
+       private Long landLineNumber;
 
        /**
-        * Country instance for phone number
+        * Mobile number
         */
-       private Country phoneCountry;
+       private Long mobileNumber;
 
        /**
-        * Phone number
+        * Mobile id number
         */
-       private Long phoneNumber;
+       private Long mobileNumberId;
+
+       /**
+        * Mobile provider
+        */
+       private MobileProvider mobileProvider;
 
        /**
         * Street
         */
        private String street;
 
+       /**
+        * Title
+        */
+       private String title;
+
        /**
         * An event fired when the administrator has updated contact data
         */
@@ -214,16 +254,16 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
         * Default constructor
         */
        public JobsAdminContactWebRequestBean () {
-               // 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/jratecalc-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+                       // Try to lookup (general)
+                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+
+                       // Try to lookup (administative)
+                       this.adminContactBean = (AdminContactSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminContact!org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote"); //NOI18N
                } catch (final NamingException e) {
                        // Throw again
                        throw new FaceletException(e);
@@ -232,6 +272,24 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
 
        @Override
        public String addContact () {
+               // Are all minimum fields set?
+               if (this.getGender() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("gender 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();
 
@@ -247,7 +305,7 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                // 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);
@@ -264,8 +322,24 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        }
 
        @Override
-       public List<Contact> allContacts () {
-               return this.contactController.allContacts();
+       public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getAddedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.addedUser is null"); //NOI18N
+               } else if (event.getAddedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+               } else if (event.getAddedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+               }
+
+               // Clear all data
+               this.clear();
        }
 
        @Override
@@ -276,7 +350,7 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                        throw new NullPointerException("contact is null"); //NOI18N
                } else if (contact.getContactId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
                } else if (contact.getContactId() < 1) {
                        // Not valid
                        throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
@@ -284,6 +358,7 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
 
                // Set all fields: contact
                this.setContactId(contact.getContactId());
+               this.setTitle(contact.getContactTitle());
                this.setBirthday(contact.getContactBirthday());
                this.setCity(contact.getContactCity());
                this.setComment(contact.getContactComment());
@@ -293,49 +368,92 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                this.setFirstName(contact.getContactFirstName());
                this.setGender(contact.getContactGender());
                this.setHouseNumber(contact.getContactHouseNumber());
+               this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
                this.setStreet(contact.getContactStreet());
                this.setZipCode(contact.getContactZipCode());
 
-               // ... cellphone data
-               this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
-               this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
-               this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
+               // ... mobile data
+               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       this.setMobileNumberId(contact.getContactMobileNumber().getPhoneId());
+                       this.setMobileProvider(contact.getContactMobileNumber().getMobileProvider());
+                       this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber());
+               }
 
                // ... fax data
-               this.setFaxId(contact.getContactFaxNumber().getPhoneId());
-               this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
-               this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
-               this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       this.setFaxNumberId(contact.getContactFaxNumber().getPhoneId());
+                       this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
+                       this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
+                       this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+               }
 
                // .. land-line data
-               this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
-               this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
-               this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
-               this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
+                       this.setLandLineAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
+                       this.setLandLineCountry(contact.getContactLandLineNumber().getPhoneCountry());
+                       this.setLandLineNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               }
+       }
+
+       @Override
+       public Contact createContactInstance () {
+               // Create new instance
+               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+
+               // Update all data in contact
+               this.updateContactData(contact);
+
+               // Return it
+               return contact;
+       }
+
+       @Override
+       public String deleteContactData (final Contact contact) {
+               // The instance must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+               }
+
+               // Call EJB
+               this.adminContactBean.deleteContactData(contact);
+
+               // Fire event
+               this.deletedContactEvent.fire(new AdminContactDeletedEvent(contact));
+
+               // All fine
+               return "admin_list_contact"; //NOI18N
        }
 
        @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
                } 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.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
 
                // Fire event
                this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
@@ -348,45 +466,55 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        }
 
        @Override
-       @SuppressWarnings ("ReturnOfDateField")
-       public Date getBirthday () {
-               return this.birthday;
-       }
+       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;
-       }
+       public String generatePhoneNumber (final DialableNumber phoneNumber) {
+               // Is it null?
+               if (null == phoneNumber) {
+                       // Return null
+                       return null;
+               }
 
-       @Override
-       public Long getCellphoneId () {
-               return this.cellphoneId;
-       }
+               // Generate it
+               String number = String.format(
+                          "%s%d%d", //NOI18N
+                          phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
+                          phoneNumber.getPhoneAreaCode(),
+                          phoneNumber.getPhoneNumber()
+          );
 
-       @Override
-       public void setCellphoneId (final Long cellphoneId) {
-               this.cellphoneId = cellphoneId;
+               // Return it
+               return number;
        }
 
        @Override
-       public Long getCellphoneNumber () {
-               return this.cellphoneNumber;
+       @SuppressWarnings ("ReturnOfDateField")
+       public Date getBirthday () {
+               return this.birthday;
        }
 
        @Override
-       public void setCellphoneNumber (Long cellphoneNumber) {
-               this.cellphoneNumber = cellphoneNumber;
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+       public void setBirthday (final Date birthday) {
+               this.birthday = birthday;
        }
 
        @Override
@@ -419,6 +547,17 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                this.contactId = contactId;
        }
 
+       @Override
+       public String getControllerType () {
+               return "admin"; //NOI18N
+       }
+
+       @Override
+       @Deprecated
+       public void setControllerType (final String controllerType) {
+               throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
+       }
+
        @Override
        public Country getCountry () {
                return this.country;
@@ -470,23 +609,23 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        }
 
        @Override
-       public Long getFaxId () {
-               return this.faxId;
+       public Long getFaxNumber () {
+               return this.faxNumber;
        }
 
        @Override
-       public void setFaxId (final Long faxId) {
-               this.faxId = faxId;
+       public void setFaxNumber (final Long faxNumber) {
+               this.faxNumber = faxNumber;
        }
 
        @Override
-       public Long getFaxNumber () {
-               return this.faxNumber;
+       public Long getFaxNumberId () {
+               return this.faxNumberId;
        }
 
        @Override
-       public void setFaxNumber (final Long faxNumber) {
-               this.faxNumber = faxNumber;
+       public void setFaxNumberId (final Long faxNumberId) {
+               this.faxNumberId = faxNumberId;
        }
 
        @Override
@@ -519,6 +658,36 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                this.houseNumber = houseNumber;
        }
 
+       @Override
+       public String getHouseNumberExtension () {
+               return this.houseNumberExtension;
+       }
+
+       @Override
+       public void setHouseNumberExtension (final String houseNumberExtension) {
+               this.houseNumberExtension = houseNumberExtension;
+       }
+
+       @Override
+       public Integer getLandLineAreaCode () {
+               return this.landLineAreaCode;
+       }
+
+       @Override
+       public void setLandLineAreaCode (final Integer landLineAreaCode) {
+               this.landLineAreaCode = landLineAreaCode;
+       }
+
+       @Override
+       public Country getLandLineCountry () {
+               return this.landLineCountry;
+       }
+
+       @Override
+       public void setLandLineCountry (final Country landLineCountry) {
+               this.landLineCountry = landLineCountry;
+       }
+
        @Override
        public Long getLandLineId () {
                return this.landLineId;
@@ -530,33 +699,43 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        }
 
        @Override
-       public Integer getPhoneAreaCode () {
-               return this.phoneAreaCode;
+       public Long getLandLineNumber () {
+               return this.landLineNumber;
+       }
+
+       @Override
+       public void setLandLineNumber (final Long landLineNumber) {
+               this.landLineNumber = landLineNumber;
        }
 
        @Override
-       public void setPhoneAreaCode (final Integer phoneAreaCode) {
-               this.phoneAreaCode = phoneAreaCode;
+       public Long getMobileNumber () {
+               return this.mobileNumber;
        }
 
        @Override
-       public Country getPhoneCountry () {
-               return this.phoneCountry;
+       public void setMobileNumber (Long mobileNumber) {
+               this.mobileNumber = mobileNumber;
        }
 
        @Override
-       public void setPhoneCountry (final Country phoneCountry) {
-               this.phoneCountry = phoneCountry;
+       public Long getMobileNumberId () {
+               return this.mobileNumberId;
        }
 
        @Override
-       public Long getPhoneNumber () {
-               return this.phoneNumber;
+       public void setMobileNumberId (final Long mobileNumberId) {
+               this.mobileNumberId = mobileNumberId;
        }
 
        @Override
-       public void setPhoneNumber (final Long phoneNumber) {
-               this.phoneNumber = phoneNumber;
+       public MobileProvider getMobileProvider () {
+               return this.mobileProvider;
+       }
+
+       @Override
+       public void setMobileProvider (final MobileProvider mobileProvider) {
+               this.mobileProvider = mobileProvider;
        }
 
        @Override
@@ -569,6 +748,16 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                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;
@@ -586,6 +775,70 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
        public void init () {
        }
 
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all data
+               // - personal data
+               this.setGender(null);
+               this.setTitle(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);
+
+               // - contact data
+               this.setEmailAddress(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);
+
+               // - other data
+               this.setBirthday(null);
+               this.setComment(null);
+       }
+
+       /**
+        * Checks whether the given contact is found
+        * <p>
+        * @param contact Contact inastance
+        *
+        * @return Wether contact has been found
+        */
+       private boolean isSameContactFound (final Contact contact) {
+               // Default is not found
+               boolean IsFound = false;
+
+               // Get iterator
+               Iterator<Contact> iterator = this.contactController.allContacts().iterator();
+
+               // Loop through all
+               while (iterator.hasNext()) {
+                       // Get next contact
+                       Contact next = iterator.next();
+
+                       // Is the same?
+                       if (ContactUtils.isSameContact(contact, next)) {
+                               // Yes, then abort loop
+                               IsFound = false;
+                               break;
+                       }
+               }
+
+               // Return status
+               return IsFound;
+       }
+
        /**
         * Updates all data in contact instance.
         * <p>
@@ -596,29 +849,28 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                if (null == contact) {
                        // Throw NPE
                        throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Invalid id
-                       throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
                }
 
                // Update all fields
                contact.setContactGender(this.getGender());
+               contact.setContactTitle(this.getTitle());
                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.setContactEmailAddress(this.getEmailAddress());
+               contact.setContactBirthday(this.getBirthday());
+               contact.setContactComment(this.getComment());
 
-               // Update contact's cellphone number
-               this.isCellphoneUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getCellphoneCarrier(), this.getCellphoneNumber());
+               // Update contact's mobile number
+               this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(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());