]> git.mxchange.org Git - pizzaservice-mailer-ejb.git/blobdiff - src/java/org/mxchange/jcontacts/contact/AddressbookContactSessionBean.java
Please cherry-pick:
[pizzaservice-mailer-ejb.git] / src / java / org / mxchange / jcontacts / contact / AddressbookContactSessionBean.java
index 4d37465feadb68f68afa8c4bf5bfbe770026d01e..2610872f0258f580cfcce43096ceb87758a5962d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -24,13 +24,12 @@ import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
-import org.mxchange.jcontacts.contact.utils.ContactUtils;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 
 /**
  * A contact EJB
  * <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Häder<roland@mxchange.org>
  */
 @Stateless (name = "contact", description = "A bean handling contact data")
 public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean implements ContactSessionBeanRemote {
@@ -44,6 +43,8 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
         * Default constructor
         */
        public AddressbookContactSessionBean () {
+               // Call super constructor
+               super();
        }
 
        @Override
@@ -137,7 +138,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getAllContacts - CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("AllContacts", UserContact.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("AllContacts"); //NOI18N
 
                // Get list
                List<Contact> contacts = query.getResultList();
@@ -156,7 +157,7 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList - CALLED!", this.getClass().getSimpleName())); //NOI18N
 
                // Create query instance
-               Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses", String.class); //NOI18N
+               Query query = this.getEntityManager().createNamedQuery("AllContactEmailAddresses"); //NOI18N
 
                // Get list
                List<String> emailAddresses = query.getResultList();
@@ -264,9 +265,9 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
        }
 
        @Override
-       public Contact updateContactData (final Contact contact, final boolean isCellphoneUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
+       public Contact updateContactData (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) {
                // Log trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isCellphoneUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: contact={1},isMobileUnlinked={2},isLandlineUnlinked={3},isFaxUnlinked={4} - CALLED!", this.getClass().getSimpleName(), contact, isMobileUnlinked, isLandlineUnlinked, isFaxUnlinked)); //NOI18N
 
                // The contact instance must be valid
                if (null == contact) {
@@ -274,23 +275,20 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                        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
                }
 
-               // Set updated timestamp
-               this.setAllContactPhoneEntriesUpdated(contact, isCellphoneUnlinked, isLandlineUnlinked, isFaxUnlinked);
-
                // Merge cellphone, land-line and fix
-               Contact detachedContact = this.mergeContactData(contact);
+               Contact managedContact = this.mergeContactData(contact);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
 
                // Return it
-               return detachedContact;
+               return managedContact;
        }
 
        @Override
@@ -304,25 +302,25 @@ public class AddressbookContactSessionBean extends BaseAddressbookDatabaseBean i
                        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
                }
 
                // Is cell phone/land-line/fax number unlinked?
-               boolean isCellphoneUnlinked = (contact.getContactCellphoneNumber() == null);
+               boolean isMobileUnlinked = (contact.getContactMobileNumber() == null);
                boolean isLandLineUnlinked = (contact.getContactLandLineNumber() == null);
                boolean isFaxUnlinked = (contact.getContactFaxNumber() == null);
 
                // Call other Method
-               Contact detachedContact = this.updateContactData(contact, isCellphoneUnlinked, isLandLineUnlinked, isFaxUnlinked);
+               Contact managedContact = this.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: detachedContact={1} - EXIT!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
 
                // Return it
-               return detachedContact;
+               return managedContact;
        }
 
 }