]> git.mxchange.org Git - addressbook-core.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2017 19:16:13 +0000 (21:16 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 26 Jun 2017 19:21:29 +0000 (21:21 +0200)
- had moved copyAll() to new utility classes which is a much better place for
  them. Per EJB standards, no "complex" methods in POJOs/entity classes which
  makes sense. :-)

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java

index 720daa9d8b38a258ea86266ff79ea694388b300f..6074418f04f4235c1b820c50ed5350fbc8099ba1 100644 (file)
@@ -30,8 +30,11 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
 import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
 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.jphone.utils.PhoneUtils;
 import org.mxchange.jusercore.model.user.LoginUser;
 import org.mxchange.jusercore.model.user.User;
@@ -385,11 +388,17 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        // 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
-                       foundMobile.copyAll(detachedContact.getContactMobileNumber());
+                       MobileNumbers.copyAll(detachedContact.getContactMobileNumber(), managedMobile);
 
                        // Set it back
-                       detachedContact.setContactMobileNumber(foundMobile);
+                       detachedContact.setContactMobileNumber(managedMobile);
                }
 
                // Is there a  fax instance set?
@@ -400,11 +409,20 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        // 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()); //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
-                       foundFax.copyAll(detachedContact.getContactFaxNumber());
+                       FaxNumbers.copyAll(detachedContact.getContactFaxNumber(), managedFax);
 
                        // Set it back
-                       detachedContact.setContactFaxNumber(foundFax);
+                       detachedContact.setContactFaxNumber(managedFax);
                }
 
                // Is there a  fax instance set?
@@ -418,11 +436,17 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean {
                        // 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
-                       foundLandLine.copyAll(detachedContact.getContactLandLineNumber());
+                       LandLineNumbers.copyAll(detachedContact.getContactLandLineNumber(), managedLandLine);
 
                        // Set it back
-                       detachedContact.setContactLandLineNumber(foundLandLine);
+                       detachedContact.setContactLandLineNumber(managedLandLine);
                }
 
                // Trace message