import javax.jms.ObjectMessage;
import javax.mail.Address;
import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactUtils;
import org.mxchange.jcoreee.database.BaseDatabaseBean;
import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
/**
* Merges given contact's data
* <p>
- * @param contact Contact instance to merge
+ * @param detachedContact Contact instance to merge
* <p>
* @return Detached contact instance
*/
- protected Contact mergeContactData (final Contact contact) {
+ protected Contact mergeContactData (final Contact detachedContact) {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: contact={0} - CALLED!", contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - CALLED!", detachedContact)); //NOI18N
// The contact instance must be valid
- if (null == contact) {
+ if (null == detachedContact) {
// Throw NPE again
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
+ throw new NullPointerException("detachedContact is null"); //NOI18N
+ } else if (detachedContact.getContactId() == null) {
// Throw NPE again
- throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
+ throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+ } else if (detachedContact.getContactId() < 1) {
// Not valid
- throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
}
// Set updated timestamp
- contact.setContactUpdated(new GregorianCalendar());
+ detachedContact.setContactUpdated(new GregorianCalendar());
// Get contact from it and find it
- Contact foundContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
+ Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
// Should be found
- assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N
+ assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: foundContact.contactId={0}", foundContact.getContactId())); //NOI18N
// Merge contact instance
- Contact detachedContact = this.getEntityManager().merge(foundContact);
+ Contact managedContact = this.getEntityManager().merge(foundContact);
// Copy all
- detachedContact.copyAll(contact);
+ ContactUtils.copyAll(detachedContact, managedContact);
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", managedContact)); //NOI18N
// Return detached contact
- return detachedContact;
+ return managedContact;
}
/**