]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
updated code logic to latest changes
authorRoland Häder <roland@mxchange.org>
Tue, 26 Apr 2016 11:11:35 +0000 (13:11 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 19:06:20 +0000 (21:06 +0200)
src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java
src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java

index cd740ec56b317fd18fb41b3da72899bbae02088a..a9505eef8b32eb4dbbedbccab5dc0d7239eab83f 100644 (file)
@@ -127,7 +127,7 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co
        }
 
        @Override
-       public boolean isContactFound (final Contact contact) {
+       public Contact lookupContact (final Contact contact) {
                // Log trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: contact={0} - CALLED!", contact)); //NOI18N
 
@@ -138,7 +138,7 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co
                } else if ((contact.getContactId() instanceof Long) && (contact.getContactId() > 0)) {
                        try {
                                // Id set, ask other method
-                               return (this.findContactById(contact.getContactId()) instanceof Contact);
+                               return this.findContactById(contact.getContactId());
                        } catch (final ContactNotFoundException ex) {
                                // Not found, should not happen
                                throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is set, but not found.", contact.getContactId()), ex); //NOI18N
@@ -146,7 +146,7 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co
                }
 
                // Default is not found
-               boolean isFound = false;
+               Contact foundContact = null;
 
                // Get whole list
                List<Contact> contacts = this.getAllContacts();
@@ -155,7 +155,7 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co
                if (contacts.isEmpty()) {
                        // Then abort here
                        this.getLoggerBeanLocal().logTrace("isContactFound: No contacts registered, returning 'false' ..."); //NOI18N
-                       return false;
+                       return null;
                }
 
                // Get iterator
@@ -174,23 +174,17 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co
                                // Debug message
                                this.getLoggerBeanLocal().logDebug(MessageFormat.format("isContactFound: Found same contact, id={0}", next.getContactId())); //NOI18N
 
-                               // Set contact id
-                               contact.setContactId(next.getContactId());
-
-                               // Update also other ids
-                               this.setAllContactPhoneEntries(contact, next);
-
                                // Found it
-                               isFound = true;
+                               foundContact = next;
                                break;
                        }
                }
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: isFound={0} - EXIT!", isFound)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: foundContact={0} - EXIT!", foundContact)); //NOI18N
 
                // Return status
-               return isFound;
+               return foundContact;
        }
 
        @Override
index 76c1b6395d4821f01af3319b8fdc9e05ed9e9c79..d6adede18a74d6fed2e2bda0bb369ffbe029d8f5 100644 (file)
@@ -83,10 +83,10 @@ public class PizzaAdminCustomerSessionBean extends BasePizzaDatabaseBean impleme
 
                // Get contact instance
                Contact contact = customer.getCustomerContact();
-               Contact updatedContact = null;
+               Contact updatedContact = this.contactBean.lookupContact(contact);
 
                // Is a customer found?
-               if (this.contactBean.isContactFound(contact)) {
+               if (updatedContact instanceof Contact) {
                        // Yes, then get updated version
                        updatedContact = this.contactBean.updateContactData(contact);