/**
* Merges given (detached) 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("{0}.mergeContactData: contact={1} - CALLED!", this.getClass().getSimpleName(), contact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: detachedContact={1} - CALLED!", this.getClass().getSimpleName(), detachedContact)); //NOI18N
// The contact instance must be valid
- if (null == contact) {
+ if (null == detachedContact) {
// Throw NPE again
throw new NullPointerException("detachedContact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
+ } else if (detachedContact.getContactId() == null) {
// Throw NPE again
throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
+ } else if (detachedContact.getContactId() < 1) {
// Not valid
- throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), contact.getContactId())); //NOI18N
+ throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
}
// Get contact from it and find it
- Contact managedContact = this.getEntityManager().find(contact.getClass(), contact.getContactId());
+ Contact managedContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
// Should be found
- assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N
+ assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateUserPersonalData: managedContact.contactId={1}", this.getClass().getSimpleName(), managedContact.getContactId())); //NOI18N
// Is a fax number set?
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ if (detachedContact.getContactFaxNumber() instanceof DialableFaxNumber) {
// Make fax numbers managed
- managedContact.setContactFaxNumber(this.getManaged(contact.getContactFaxNumber(), contact.getContactFaxNumber()));
+ managedContact.setContactFaxNumber(this.getManaged(detachedContact.getContactFaxNumber(), detachedContact.getContactFaxNumber()));
}
// Is a land-line number set?
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ if (detachedContact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
// Make land-line numbers managed
- managedContact.setContactLandLineNumber(this.getManaged(contact.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+ managedContact.setContactLandLineNumber(this.getManaged(detachedContact.getContactLandLineNumber(), detachedContact.getContactLandLineNumber()));
}
// Is a mobile number set?
- if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ if (detachedContact.getContactMobileNumber() instanceof DialableMobileNumber) {
// Make mobile numbers managed
- managedContact.setContactMobileNumber(this.getManaged(contact.getContactMobileNumber(), contact.getContactMobileNumber()));
+ managedContact.setContactMobileNumber(this.getManaged(detachedContact.getContactMobileNumber(), detachedContact.getContactMobileNumber()));
}
// Set updated timestamp
managedContact.setContactUpdated(new GregorianCalendar());
// Copy all
- ContactUtils.copyAll(contact, managedContact);
+ ContactUtils.copyAll(detachedContact, managedContact);
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N