]> git.mxchange.org Git - jfinancials-mailer-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>
Thu, 28 Apr 2016 18:16:09 +0000 (20:16 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontacts/contact/AddressbookContactSessionBean.java

index aa2886b1af016bab0e5e127042a7aadb9b4ac3b8..4d258539308becc18dc1bbf8616e25b2dbde8090 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jcontacts.contact;
 import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Objects;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
@@ -132,7 +133,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
        }
 
        @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
 
@@ -143,7 +144,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                } else if (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
@@ -151,7 +152,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                }
 
                // Default is not found
-               boolean isFound = false;
+               Contact foundContact = null;
 
                // Get whole list
                List<Contact> contacts = this.getAllContacts();
@@ -160,7 +161,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                if (contacts.isEmpty()) {
                        // Then abort here
                        this.getLoggerBeanLocal().logTrace("isContactFound: No contacts registered, returning 'false' ..."); //NOI18N
-                       return false;
+                       return null;
                }
 
                // Get iterator
@@ -172,20 +173,21 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                        Contact next = iterator.next();
 
                        // Is same contact?
-                       if (ContactUtils.isSameContact(contact, next)) {
+                       if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) {
+                               // Debug message
+                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("isContactFound: Found same contact, id={0}", next.getContactId())); //NOI18N
+
                                // Found it
-                               isFound = true;
+                               foundContact = next;
                                break;
                        }
                }
 
-               // Return status
-               return isFound;
-       }
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: foundContact={0} - EXIT!", foundContact)); //NOI18N
 
-       @Override
-       public Contact lookupContact (Contact contact) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+               // Return status
+               return foundContact;
        }
 
        @Override