From 1d50ff9235b246e6d17ce2a12508c879b5eba975 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 26 Apr 2016 12:43:04 +0200 Subject: [PATCH] Continued a bit: - setting "created" timestamps for cellphone, land-line and fax number - added object-equality check - added trace message --- .../jcontacts/contact/PizzaContactSessionBean.java | 14 ++++++++++++-- .../customer/PizzaAdminCustomerSessionBean.java | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java index 44edd2c..cd740ec 100644 --- a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java @@ -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; @@ -169,9 +170,15 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co this.getLoggerBeanLocal().logDebug(MessageFormat.format("isContactFound: next={0}", next)); //NOI18N // Is same contact? - if (ContactUtils.isSameContact(contact, next)) { + if ((Objects.equals(contact, next)) || (ContactUtils.isSameContact(contact, next))) { // Debug message - this.getLoggerBeanLocal().logDebug("isContactFound: Found same contact."); //NOI18N + 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; @@ -179,6 +186,9 @@ public class PizzaContactSessionBean extends BasePizzaDatabaseBean implements Co } } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("isContactFound: isFound={0} - EXIT!", isFound)); //NOI18N + // Return status return isFound; } diff --git a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java index 149e230..76c1b63 100644 --- a/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/model/customer/PizzaAdminCustomerSessionBean.java @@ -94,8 +94,9 @@ public class PizzaAdminCustomerSessionBean extends BasePizzaDatabaseBean impleme customer.setCustomerContact(null); } - // Set created timestamp + // Set created timestamp(s) customer.setCustomerCreated(new GregorianCalendar()); + this.setAllContactPhoneEntriesCreated(contact); // Persist the customer this.getEntityManager().persist(customer); -- 2.39.2