From 0fe2c05d10b0768a1049bf81fb3e7b758a0471c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 26 Jun 2017 21:26:23 +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 --- .../FinancialsAdminPhoneSessionBean.java | 191 ++++++++++++++---- .../model/user/FinancialsUserSessionBean.java | 67 +++--- 2 files changed, 187 insertions(+), 71 deletions(-) diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java index ffb2801..6b2c483 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/FinancialsAdminPhoneSessionBean.java @@ -21,8 +21,11 @@ import java.util.GregorianCalendar; import javax.ejb.Stateless; import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; 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; /** * An EJB for administrative phone purposes @@ -48,10 +51,10 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean @Override public void deleteFaxData (final DialableFaxNumber faxNumber) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); // Is all data set - if (null == faxNumber) { + if (faxNumber == null) { // Not set, throw NPE throw new NullPointerException("faxNumber is null"); //NOI18N } else if (faxNumber.getPhoneId() == null) { @@ -60,15 +63,21 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean } else if (faxNumber.getPhoneId() < 1) { // Invalid number throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N - } else if (faxNumber.getPhoneCountry()== null) { + } else if (faxNumber.getPhoneCountry() == null) { // Throw NPE throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N - } else if (faxNumber.getPhoneCountry().getCountryId()== null) { - // ... throw again + } else if (faxNumber.getPhoneCountry().getCountryId() == null) { + // Throw NPE throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N } else if (faxNumber.getPhoneCountry().getCountryId() < 1) { + // Throw NPE + throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (faxNumber.getPhoneAreaCode() == null) { + // ... throw again + throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N + } else if (faxNumber.getPhoneAreaCode() < 1) { // Id not valid - throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid.", faxNumber.getPhoneCountry().getCountryId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N } else if (faxNumber.getPhoneNumber() == null) { // Throw NPE again throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N @@ -77,7 +86,7 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N } - // Merge it to get a managed entity back + // Get a managed instance DialableFaxNumber managedNumber = this.getEntityManager().getReference(faxNumber.getClass(), faxNumber.getPhoneId()); // Remove it from database @@ -90,10 +99,10 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean @Override public void deleteLandLineData (final DialableLandLineNumber landLineNumber) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); // Is all data set - if (null == landLineNumber) { + if (landLineNumber == null) { // Not set, throw NPE throw new NullPointerException("landLineNumber is null"); //NOI18N } else if (landLineNumber.getPhoneId() == null) { @@ -102,15 +111,21 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean } else if (landLineNumber.getPhoneId() < 1) { // Invalid number throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N - } else if (landLineNumber.getPhoneCountry()== null) { + } else if (landLineNumber.getPhoneCountry() == null) { // Throw NPE throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N - } else if (landLineNumber.getPhoneCountry().getCountryId()== null) { - // ... throw again + } else if (landLineNumber.getPhoneCountry().getCountryId() == null) { + // Throw NPE throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) { + // Throw NPE + throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (landLineNumber.getPhoneAreaCode() == null) { + // ... throw again + throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N + } else if (landLineNumber.getPhoneAreaCode() < 1) { // Id not valid - throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid.", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N } else if (landLineNumber.getPhoneNumber() == null) { // Throw NPE again throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N @@ -119,7 +134,7 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N } - // Merge it to get a managed entity back + // Get a managed instance DialableLandLineNumber managedNumber = this.getEntityManager().getReference(landLineNumber.getClass(), landLineNumber.getPhoneId()); // Remove it from database @@ -146,13 +161,13 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N } else if (mobileNumber.getMobileProvider() == null) { // Throw NPE - throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N + throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N } else if (mobileNumber.getMobileProvider().getProviderId() == null) { // ... throw again - throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N + throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { // Id not valid - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N } else if (mobileNumber.getPhoneNumber() == null) { // Throw NPE again throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N @@ -161,7 +176,7 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N } - // Merge it to get a managed entity back + // Get a managed instance DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getPhoneId()); // Remove it from database @@ -172,19 +187,125 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean } @Override - public DialableFaxNumber updateFaxData (DialableFaxNumber faxNumber) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public DialableFaxNumber updateFaxData (final DialableFaxNumber faxNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); + + // Is all data set + if (faxNumber == null) { + // Not set, throw NPE + throw new NullPointerException("faxNumber is null"); //NOI18N + } else if (faxNumber.getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N + } else if (faxNumber.getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N + } else if (faxNumber.getPhoneCountry() == null) { + // Throw NPE + throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N + } else if (faxNumber.getPhoneCountry().getCountryId() == null) { + // Throw NPE + throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N + } else if (faxNumber.getPhoneCountry().getCountryId() < 1) { + // Throw NPE + throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (faxNumber.getPhoneAreaCode() == null) { + // ... throw again + throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N + } else if (faxNumber.getPhoneAreaCode() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N + } else if (faxNumber.getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N + } else if (faxNumber.getPhoneNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N + } + + // Get contact from it and find it + DialableFaxNumber managedNumber = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId()); + + // Should be found + assert (managedNumber instanceof DialableFaxNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", faxNumber.getPhoneId()); //NOI18N + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateFaxData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N + + // Set updated timestamp + FaxNumbers.copyAll(faxNumber, managedNumber); + managedNumber.setPhoneEntryUpdated(new GregorianCalendar()); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateFaxData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N + + // Return it + return managedNumber; } @Override - public DialableLandLineNumber updateLandLineData (DialableLandLineNumber landLineNumber) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public DialableLandLineNumber updateLandLineData (final DialableLandLineNumber landLineNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); + + // Is all data set + if (landLineNumber == null) { + // Not set, throw NPE + throw new NullPointerException("landLineNumber is null"); //NOI18N + } else if (landLineNumber.getPhoneId() == null) { + // Throw NPE again + throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N + } else if (landLineNumber.getPhoneId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N + } else if (landLineNumber.getPhoneCountry() == null) { + // Throw NPE + throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N + } else if (landLineNumber.getPhoneCountry().getCountryId() == null) { + // Throw NPE + throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N + } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) { + // Throw NPE + throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N + } else if (landLineNumber.getPhoneAreaCode() == null) { + // ... throw again + throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N + } else if (landLineNumber.getPhoneAreaCode() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N + } else if (landLineNumber.getPhoneNumber() == null) { + // Throw NPE again + throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N + } else if (landLineNumber.getPhoneNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N + } + + // Get contact from it and find it + DialableLandLineNumber managedNumber = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId()); + + // Should be found + assert (managedNumber instanceof DialableLandLineNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", landLineNumber.getPhoneId()); //NOI18N + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateLandLineData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N + + // Set updated timestamp + LandLineNumbers.copyAll(landLineNumber, managedNumber); + managedNumber.setPhoneEntryUpdated(new GregorianCalendar()); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateLandLineData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N + + // Return it + return managedNumber; } @Override public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateCellphoneData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); // Is all data set if (null == mobileNumber) { @@ -198,13 +319,13 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N } else if (mobileNumber.getMobileProvider() == null) { // Throw NPE - throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N + throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N } else if (mobileNumber.getMobileProvider().getProviderId() == null) { // ... throw again - throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N + throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { // Id not valid - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N } else if (mobileNumber.getPhoneNumber() == null) { // Throw NPE again throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N @@ -213,26 +334,24 @@ public class FinancialsAdminPhoneSessionBean extends BaseFinancialsDatabaseBean throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N } - // Set updated timestamp - mobileNumber.setPhoneEntryUpdated(new GregorianCalendar()); - // Get contact from it and find it - DialableMobileNumber foundNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId()); + DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId()); // Should be found - assert (foundNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getPhoneId()); //NOI18N + assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getPhoneId()); //NOI18N // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateCellphoneData: foundNumber.phoneId={0}", foundNumber.getPhoneId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N - // Merge contact instance - DialableMobileNumber detachedNumber = this.getEntityManager().merge(foundNumber); + // Set updated timestamp + MobileNumbers.copyAll(mobileNumber, managedNumber); + managedNumber.setPhoneEntryUpdated(new GregorianCalendar()); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateCellphoneData: detachedNumber={1} - EXIT!", this.getClass().getSimpleName(), detachedNumber)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N // Return it - return detachedNumber; + return managedNumber; } } diff --git a/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java index 84677fc..2e3d3c4 100644 --- a/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/FinancialsUserSessionBean.java @@ -32,8 +32,11 @@ import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.ContactUtils; import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; 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; @@ -687,19 +690,13 @@ public class FinancialsUserSessionBean extends BaseFinancialsDatabaseBean implem } // Find the instance - User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId()); + User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId()); // Should be found! - assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N - - // Merge user - User managedUser = this.getEntityManager().merge(foundUser); - - // Should be found! - assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N + assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N // Copy all data - UserUtils.copyAll(managedUser, managedUser); + UserUtils.copyAll(user, managedUser); // Set as updated managedUser.setUserUpdated(new GregorianCalendar()); @@ -715,19 +712,19 @@ public class FinancialsUserSessionBean extends BaseFinancialsDatabaseBean implem this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N // Merge contact instance - Contact detachedContact = this.getEntityManager().merge(foundContact); + Contact managedContact = this.getEntityManager().merge(foundContact); // Copy all - ContactUtils.copyAll(managedUser.getUserContact(), detachedContact); + ContactUtils.copyAll(managedUser.getUserContact(), managedContact); // Set it back in user - managedUser.setUserContact(detachedContact); + managedUser.setUserContact(managedContact); // Should be found! - assert (detachedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", managedUser.getUserContact().getContactId()); //NOI18N + assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", managedUser.getUserContact().getContactId()); //NOI18N // Get mobile instance - DialableMobileNumber mobileNumber = detachedContact.getContactMobileNumber(); + DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber(); // Is there a mobile instance set? if (mobileNumber instanceof DialableMobileNumber) { @@ -741,74 +738,74 @@ public class FinancialsUserSessionBean extends BaseFinancialsDatabaseBean implem 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(managedUser.getUserContact().getContactMobileNumber()); + MobileNumbers.copyAll(managedUser.getUserContact().getContactMobileNumber(), managedMobile); // Set it back - detachedContact.setContactMobileNumber(detachedMobile); + managedContact.setContactMobileNumber(managedMobile); } // Get mobile instance - DialableFaxNumber fax = detachedContact.getContactFaxNumber(); + DialableFaxNumber faxNumber = managedContact.getContactFaxNumber(); // Is there a fax instance set? - if (fax instanceof DialableFaxNumber) { + if (faxNumber instanceof DialableFaxNumber) { // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N // Then find it, too - DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId()); + 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 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(managedUser.getUserContact().getContactFaxNumber()); + FaxNumbers.copyAll(managedUser.getUserContact().getContactFaxNumber(), managedFax); // Set it back - detachedContact.setContactFaxNumber(detachedFax); + managedContact.setContactFaxNumber(managedFax); } // Get mobile instance - DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber(); + DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber(); // Is there a fax instance set? - if (landLine instanceof DialableLandLineNumber) { + if (landLineNumber instanceof DialableLandLineNumber) { // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N + this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N // Then find it, too - DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId()); + 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 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(managedUser.getUserContact().getContactLandLineNumber()); + LandLineNumbers.copyAll(managedUser.getUserContact().getContactLandLineNumber(), managedLandLine); // Set it back - detachedContact.setContactLandLineNumber(detachedLandLine); + managedContact.setContactLandLineNumber(managedLandLine); } // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.user={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N // Return updated user instance return managedUser; -- 2.39.5