]> git.mxchange.org Git - addressbook-mailer-ejb.git/blobdiff - src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java
Please cherry-pick:
[addressbook-mailer-ejb.git] / src / java / org / mxchange / jusercore / model / user / AddressbookUserSessionBean.java
index 33db34870e8232ecbda1b92b875c553c216c9334..6398fad8eca6703bb11e5a2e09ff5f3282b2be29 100644 (file)
@@ -32,8 +32,11 @@ import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.ContactUtils;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.fax.FaxNumbers;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.landline.LandLineNumbers;
 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumbers;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
@@ -737,7 +740,22 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                // Is there a  mobile instance set?
                if (mobileNumber instanceof DialableMobileNumber) {
                        // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
+
+                       // Then find it, too
+                       DialableMobileNumber foundMobile = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
+
+                       // Should be there
+                       assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
+
+                       // Should be there
+                       assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       MobileNumbers.copyAll(managedUser.getUserContact().getContactMobileNumber(), managedMobile);
 
                        // Set it back
                        managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
@@ -751,8 +769,23 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
 
+                       // Then find it, too
+                       DialableFaxNumber foundFax = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
+
+                       // Should be there
+                       assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
+
+                       // Should be there
+                       assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       FaxNumbers.copyAll(managedUser.getUserContact().getContactFaxNumber(), managedFax);
+
                        // Set it back
-                       managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
+                       managedContact.setContactFaxNumber(managedFax);
                }
 
                // Get mobile instance
@@ -763,8 +796,23 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl
                        // Debug message
                        this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
 
+                       // Then find it, too
+                       DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
+
+                       // Should be there
+                       assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
+
+                       // Then merge it, too
+                       DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
+
+                       // Should be there
+                       assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
+
+                       // Copy all
+                       LandLineNumbers.copyAll(managedUser.getUserContact().getContactLandLineNumber(), managedLandLine);
+
                        // Set it back
-                       managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
+                       managedContact.setContactLandLineNumber(managedLandLine);
                }
 
                // Trace message