]> 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 189f9cea1c16fac602f2a01abf1d9451be743942..f5f168a94f6a491b8565bf6be4915de5852e6627 100644 (file)
@@ -45,11 +45,11 @@ 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.BaseJobsController;
-import org.mxchange.jjobs.beans.helper.JobsWebRequestController;
+import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController;
 import org.mxchange.jphone.phonenumbers.DialableNumber;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
 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;
 
@@ -80,31 +80,16 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        private AdminContactSessionBeanRemote adminContactBean;
 
        /**
-        * Admin helper instance
+        * Bean helper
         */
        @Inject
-       private JobsWebRequestController beanHelper;
+       private JobsWebViewHelperController beanHelper;
 
        /**
         * Birth day
         */
        private Date birthday;
 
-       /**
-        * Cellphone number's carrier
-        */
-       private MobileProvider cellphoneCarrier;
-
-       /**
-        * Cellphone id number
-        */
-       private Long cellphoneId;
-
-       /**
-        * Cellphone number
-        */
-       private Long cellphoneNumber;
-
        /**
         * City
         */
@@ -164,14 +149,14 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        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
@@ -193,11 +178,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
         */
        private String houseNumberExtension;
 
-       /**
-        * Whether a cellphone entry has been unlinked
-        */
-       private boolean isCellphoneUnlinked;
-
        /**
         * Whether a fax entry has been unlinked
         */
@@ -208,25 +188,45 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
         */
        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
@@ -350,7 +350,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                        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
@@ -372,16 +372,16 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                this.setStreet(contact.getContactStreet());
                this.setZipCode(contact.getContactZipCode());
 
-               // ... cellphone data
-               if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
-                       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
                if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       this.setFaxId(contact.getContactFaxNumber().getPhoneId());
+                       this.setFaxNumberId(contact.getContactFaxNumber().getPhoneId());
                        this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
                        this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
                        this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
@@ -390,9 +390,9 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                // .. land-line data
                if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
                        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());
                }
        }
 
@@ -443,7 +443,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                        throw new NullPointerException("beanHelper.contact is null"); //NOI18N
                } else if (contact.getContactId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("beanHelper.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("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
@@ -453,7 +453,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                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));
@@ -466,9 +466,9 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        }
 
        @Override
-       public String generateCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
+       public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
                // Is it null?
-               if (null == cellphoneNumber) {
+               if (null == mobileNumber) {
                        // Return null
                        return null;
                }
@@ -476,9 +476,9 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                // Get all data
                String number = String.format(
                           "%s%d%d", //NOI18N
-                          cellphoneNumber.getCellphoneProvider().getProviderCountry().getCountryExternalDialPrefix(),
-                          cellphoneNumber.getCellphoneProvider().getProviderDialPrefix(),
-                          cellphoneNumber.getPhoneNumber()
+                          mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
+                          mobileNumber.getMobileProvider().getProviderDialPrefix(),
+                          mobileNumber.getPhoneNumber()
           );
 
                // Return it
@@ -517,36 +517,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                this.birthday = birthday;
        }
 
-       @Override
-       public MobileProvider getCellphoneCarrier () {
-               return this.cellphoneCarrier;
-       }
-
-       @Override
-       public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
-               this.cellphoneCarrier = cellphoneCarrier;
-       }
-
-       @Override
-       public Long getCellphoneId () {
-               return this.cellphoneId;
-       }
-
-       @Override
-       public void setCellphoneId (final Long cellphoneId) {
-               this.cellphoneId = cellphoneId;
-       }
-
-       @Override
-       public Long getCellphoneNumber () {
-               return this.cellphoneNumber;
-       }
-
-       @Override
-       public void setCellphoneNumber (Long cellphoneNumber) {
-               this.cellphoneNumber = cellphoneNumber;
-       }
-
        @Override
        public String getCity () {
                return this.city;
@@ -639,23 +609,23 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        }
 
        @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
@@ -698,6 +668,26 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                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;
@@ -709,33 +699,43 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
        }
 
        @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 Long getMobileNumber () {
+               return this.mobileNumber;
        }
 
        @Override
-       public void setPhoneAreaCode (final Integer phoneAreaCode) {
-               this.phoneAreaCode = phoneAreaCode;
+       public void setMobileNumber (Long mobileNumber) {
+               this.mobileNumber = mobileNumber;
        }
 
        @Override
-       public Country getPhoneCountry () {
-               return this.phoneCountry;
+       public Long getMobileNumberId () {
+               return this.mobileNumberId;
        }
 
        @Override
-       public void setPhoneCountry (final Country phoneCountry) {
-               this.phoneCountry = phoneCountry;
+       public void setMobileNumberId (final Long mobileNumberId) {
+               this.mobileNumberId = mobileNumberId;
        }
 
        @Override
-       public Long getPhoneNumber () {
-               return this.phoneNumber;
+       public MobileProvider getMobileProvider () {
+               return this.mobileProvider;
        }
 
        @Override
-       public void setPhoneNumber (final Long phoneNumber) {
-               this.phoneNumber = phoneNumber;
+       public void setMobileProvider (final MobileProvider mobileProvider) {
+               this.mobileProvider = mobileProvider;
        }
 
        @Override
@@ -794,11 +794,11 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
 
                // - 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);
@@ -863,12 +863,14 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                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());