+
+ // Get contact from it and find it
+ Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
+
+ // Should be found
+ assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId()));
+
+ // Merge contact instance
+ Contact detachedContact = this.getEntityManager().merge(foundContact);
+
+ // Copy all
+ detachedContact.copyAll(user.getUserContact());
+
+ // Set it back in user
+ user.setUserContact(detachedContact);
+
+ // Should be found!
+ assert (detachedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
+
+ // Get cellphone instance
+ DialableCellphoneNumber cellphone = detachedContact.getContactCellphoneNumber();
+
+ // Is there a cellphone instance set?
+ if (cellphone instanceof DialableCellphoneNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId()));
+
+ // Then find it, too
+ DialableCellphoneNumber foundCellphone = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
+
+ // Should be there
+ assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId());
+
+ // Then merge it, too
+ DialableCellphoneNumber detachedCellphone = this.getEntityManager().merge(foundCellphone);
+
+ // Should be there
+ assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId());
+
+ // Copy all
+ detachedCellphone.copyAll(user.getUserContact().getContactCellphoneNumber());
+
+ // Set it back
+ detachedContact.setContactCellphoneNumber(detachedCellphone);
+ }
+
+ // Get cellphone instance
+ DialableFaxNumber fax = detachedContact.getContactFaxNumber();
+
+ // Is there a fax instance set?
+ if (fax instanceof DialableFaxNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId()));
+
+ // Then find it, too
+ DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
+
+ // Should be there
+ assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId());
+
+ // Then merge it, too
+ DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
+
+ // Should be there
+ assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId());
+
+ // Copy all
+ detachedFax.copyAll(user.getUserContact().getContactFaxNumber());
+
+ // Set it back
+ detachedContact.setContactFaxNumber(detachedFax);
+ }
+
+ // Get cellphone instance
+ DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
+
+ // Is there a fax instance set?
+ if (landLine instanceof DialableLandLineNumber) {
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId()));
+
+ // Then find it, too
+ DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
+
+ // Should be there
+ assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId());
+
+ // Then merge it, too
+ DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
+
+ // Should be there
+ assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId());
+
+ // Copy all
+ detachedLandLine.copyAll(user.getUserContact().getContactLandLineNumber());
+
+ // Set it back
+ detachedContact.setContactLandLineNumber(detachedLandLine);
+ }