]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Fri, 29 Apr 2016 13:43:26 +0000 (15:43 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 29 Apr 2016 19:42:37 +0000 (21:42 +0200)
- renamed method changeUserData() to editUserData() (members sorted)
- surpressed some warnings that are not being fixed
- clear() needs to be called

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java

index 96d913f10a6e3d7a3ff0283aa46f735d1d2cb95a..3532a1e0e3ddca45218d1b498892343265b204f0 100644 (file)
@@ -344,24 +344,6 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
        }
 
-       @Override
-       public String editContactData () {
-               // Get contact instance
-               Contact contact = this.adminHelper.getContact();
-
-               // Is the land-line number set?
-               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());
-               }
-
-               // Log message
-               //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N
-       }
-
        @Override
        public Contact createContactInstance () {
                // Generate phone number
@@ -400,6 +382,39 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                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")
        public Date getBirthday () {
index 29abbe3111e7edf6e5b6f20d315de6bca51dfccf..1203e058e56a153a61948627f1d44bdd9060bb3d 100644 (file)
@@ -338,8 +338,8 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle
                //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
        }
 
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<Contact> allContacts () {
                return this.contactList;
        }