From 1880eb20136a1c1faf7da58eefb858ea6791075b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 26 Jun 2017 21:16:13 +0200 Subject: [PATCH] Please cherry-pick: - 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. :-) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../database/BaseFinancialsDatabaseBean.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java index 54fd899..3b70217 100644 --- a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java +++ b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java @@ -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; @@ -382,16 +385,16 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean { assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N // Then merge it, too - DialableMobileNumber detachedMobile = this.getEntityManager().merge(foundMobile); + DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile); // Should be there - assert (detachedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", detachedMobile.getPhoneId()); //NOI18N + assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N // Copy all - detachedMobile.copyAll(detachedContact.getContactMobileNumber()); + MobileNumbers.copyAll(detachedContact.getContactMobileNumber(), managedMobile); // Set it back - detachedContact.setContactMobileNumber(detachedMobile); + detachedContact.setContactMobileNumber(managedMobile); } // Is there a fax instance set? @@ -406,16 +409,16 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean { assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N // Then merge it, too - DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax); + DialableFaxNumber managedFax = 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()); //NOI18N + assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N // Copy all - detachedFax.copyAll(detachedContact.getContactFaxNumber()); + FaxNumbers.copyAll(detachedContact.getContactFaxNumber(), managedFax); // Set it back - detachedContact.setContactFaxNumber(detachedFax); + detachedContact.setContactFaxNumber(managedFax); } // Is there a fax instance set? @@ -430,16 +433,16 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean { 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 detachedLandLine = this.getEntityManager().merge(foundLandLine); + DialableLandLineNumber managedLandLine = 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()); //NOI18N + assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N // Copy all - detachedLandLine.copyAll(detachedContact.getContactLandLineNumber()); + LandLineNumbers.copyAll(detachedContact.getContactLandLineNumber(), managedLandLine); // Set it back - detachedContact.setContactLandLineNumber(detachedLandLine); + detachedContact.setContactLandLineNumber(managedLandLine); } // Trace message -- 2.39.5