]> git.mxchange.org Git - jfinancials-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:25:16 +0000 (21:25 +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/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java

index 6c1a48310692ca83ccab29f192e2978acc030aa8..e11fc05a926393f04429398ed25d4f6d88e22c95 100644 (file)
@@ -344,24 +344,6 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
                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 AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
                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 310508de43d33a26dbc03caefc9b292b634edb66..4923262b96884e35395b18aa20b4d6509af41fdd 100644 (file)
@@ -338,8 +338,8 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
                //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
        }
 
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<Contact> allContacts () {
                return this.contactList;
        }