]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Wed, 20 May 2020 18:34:41 +0000 (20:34 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 10 Jun 2020 17:23:14 +0000 (19:23 +0200)
- always set EntryUpdated in the managed (and merged) instance, as the
  copyFooData() methods do no longer copy timestamps

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/enterprise/BasePizzaEnterpriseBean.java

index 429a3e202e4fd36978dd30e12595faaa90879cb9..9e040f146e5b6656dddc1371c224bfbb89cc7df2 100644 (file)
@@ -999,59 +999,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                        throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
                }
 
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getMobileId())); //NOI18N
-
-               // Init query instance
-               final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getMobileId());
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
-               // Default is null
-               DialableMobileNumber detachedNumber = null;
-
-               // Is there a difference?
-               if (!MobileNumbers.isSameMobileNumber(mobileNumber, fetchedNumber)) {
-                       // @TODO Copy all to foundNumber, then merge
-
-                       // Merge this entry
-                       detachedNumber = this.getEntityManager().merge(foundNumber);
-
-                       // @TODO Copy all
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
-               // Return it
-               return detachedNumber;
-       }
-
-       /**
-        * Returns a detached instance from given land-line instance
-        * <p>
-        * @param landLineNumber Land-line instance
-        * @param fetchedNumber  Found land-line number in database
-        * <p>
-        * @return Detached instance
-        */
-       protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
-
-               // Should be valid
-               if (null == landLineNumber) {
-                       // Throw NPE
-                       throw new NullPointerException("landLineNumber is null"); //NOI18N
-               } else if (fetchedNumber.getPhoneId() == null) {
-                       // ..and again
-                       throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
                // Init query instance
                final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
 
@@ -1071,6 +1018,9 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                        // @TODO Copy all
                }
 
+               // Set updated timestamp
+               managedBranchOffice.setBranchEntryUpdated(new Date());
+
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
 
@@ -1151,9 +1101,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                        throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N
                }
 
-               // Set updated timestamp
-               detachedContact.setContactEntryUpdated(new Date());
-
                // Get contact from it and find it
                final Contact foundContact = this.createManaged(detachedContact);
 
@@ -1166,8 +1113,8 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                // Merge contact instance
                final Contact managedContact = this.getEntityManager().merge(foundContact);
 
-               // Copy all
-               Contacts.copyAll(detachedContact, managedContact);
+               // Set updated timestamp
+               managedContact.setContactEntryUpdated(new Date());
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N
@@ -1310,9 +1257,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                        throw new IllegalStateException(MessageFormat.format("detachedDepartment.departmentId ={0} is not valid.", detachedDepartment.getDepartmentId())); //NOI18N
                }
 
-               // Set updated timestamp
-               detachedDepartment.setDepartmentEntryUpdated(new Date());
-
                // Get contact from it and find it
                final Department foundDepartment = this.createManaged(detachedDepartment);
 
@@ -1325,6 +1269,9 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean {
                // Merge contact instance
                final Department managedDepartment = this.getEntityManager().merge(foundDepartment);
 
+               // Set updated timestamp
+               managedDepartment.setDepartmentEntryUpdated(new Date());
+
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeDepartmentData: managedDepartment={0} - EXIT!", managedDepartment)); //NOI18N