]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6307: Use updatedAt, rather than createdAt, as tiebreaker when identifying...
authorAron Roberts <aron@socrates.berkeley.edu>
Sat, 15 Feb 2014 01:23:21 +0000 (17:23 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Sat, 15 Feb 2014 01:23:21 +0000 (17:23 -0800)
3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/src/main/java/org/collectionspace/services/listener/AbstractUpdateObjectLocationValues.java
services/IntegrationTests/src/test/resources/test-data/xmlreplay/listener/listener-update-object-loc.xml

index 8597226213bb2691045652c6bb8c639589915757..af5e86c4f57e802187de2e335c3ddd0d33c84eea 100644 (file)
@@ -42,6 +42,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene
     protected final static String CURRENT_LOCATION_PROPERTY = "currentLocation"; // FIXME: Get from external constant
     protected final static String COLLECTIONSPACE_CORE_SCHEMA = "collectionspace_core"; // FIXME: Get from external constant
     protected final static String CREATED_AT_PROPERTY = "createdAt"; // FIXME: Get from external constant
+    protected final static String UPDATED_AT_PROPERTY = "updatedAt"; // FIXME: Get from external constant
     private final static String NONVERSIONED_NONPROXY_DOCUMENT_WHERE_CLAUSE_FRAGMENT =
             "AND ecm:isCheckedInVersion = 0"
             + "AND ecm:isProxy = 0 ";
@@ -101,9 +102,9 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene
             if (logger.isTraceEnabled()) {
                 logger.trace("An event involving a Movement document was received by UpdateObjectLocationOnMove ...");
             }
-            // FIXME: exclude creation events for Movement records here, if we can
-            // identify that we'l still be properly handling creation events
-            // that include a relations list as part of the creation payload,
+            // FIXME: exclude update events for Movement records here, if we can
+            // identify that we'l still be properly handling update events
+            // that include a relations list as part of the update payload,
             // perhaps because that may trigger a separate event notification.
             movementCsid = NuxeoUtils.getCsid(docModel);
             if (Tools.isBlank(movementCsid)) {
@@ -400,7 +401,7 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene
         // Note: the following value is used to compare any two records, rather
         // than to identify the most recent value so far encountered. Thus, it may
         // occasionally be set backward or forward in time, within the loop below.
-        GregorianCalendar comparisonCreationDate = EARLIEST_COMPARISON_DATE;
+        GregorianCalendar comparisonUpdatedDate = EARLIEST_COMPARISON_DATE;
         DocumentModel movementDocModel;
         Set<String> alreadyProcessedMovementCsids = new HashSet<>();
         String relatedMovementCsid;
@@ -450,22 +451,22 @@ public abstract class AbstractUpdateObjectLocationValues implements EventListene
             if (locationDate == null) {
                 continue;
             }
-            GregorianCalendar creationDate =
-                    (GregorianCalendar) movementDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, CREATED_AT_PROPERTY);
+            GregorianCalendar updatedDate =
+                    (GregorianCalendar) movementDocModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA, UPDATED_AT_PROPERTY);
             if (locationDate.after(mostRecentLocationDate)) {
                 mostRecentLocationDate = locationDate;
-                if (creationDate != null) {
-                    comparisonCreationDate = creationDate;
+                if (updatedDate != null) {
+                    comparisonUpdatedDate = updatedDate;
                 }
                 mostRecentMovementDocModel = movementDocModel;
                 // If the current Movement record's location date is identical
                 // to that of the (at this time) most recent Movement record, then
-                // instead compare the two records using their creation date values
+                // instead compare the two records using their update date values
             } else if (locationDate.compareTo(mostRecentLocationDate) == 0) {
-                if (creationDate != null && creationDate.after(comparisonCreationDate)) {
+                if (updatedDate != null && updatedDate.after(comparisonUpdatedDate)) {
                     // The most recent location date value doesn't need to be
                     // updated here, as the two records' values are identical
-                    comparisonCreationDate = creationDate;
+                    comparisonUpdatedDate = updatedDate;
                     mostRecentMovementDocModel = movementDocModel;
                 }
             }
index 752390a5161dcfb905a542c50f598e445fde00ea..52147be04ae1a2b960e395f3d154e6b769a42616 100644 (file)
             <expectedCodes>200</expectedCodes>
         </test>
         
-        <!-- CSPACE-6019: A Movement with a later creation timestamp is -->
+        <!-- CSPACE-6309: A Movement with a later update timestamp is -->
         <!-- deemed to have taken place later than a Movement with an earlier -->
-        <!-- creation timestamp, if both have identical location dates. -->
+        <!-- update timestamp, if both have identical location dates. -->
         
         <test ID="createMovement6">
             <method>POST</method>
             <expectedCodes>200</expectedCodes>
         </test>
         
+        <test ID="updateMovement3">
+            <method>PUT</method>
+            <uri>/cspace-services/movements/${createMovement3.CSID}</uri>
+            <filename>listener/movement.xml</filename>
+            <vars>
+                <var ID="currentLocation">${createMovement3.currentLocation}</var>
+                <var ID="locationDate">${updateMovement3WithNonBlankCurrentLocation.locationDate}</var> <!-- Identical to Movement 6 -->
+            </vars>
+            <expectedCodes>200</expectedCodes>
+        </test>
+        
+        <test ID="readCollectionObject1AfterUpdateOfMovement3">
+            <method>GET</method>
+            <uri>/cspace-services/collectionobjects/${createCollectionObject1.CSID}</uri>
+            <response>
+                <expected level="ADDOK" />
+                <filename>listener/res/collectionobject.res.xml</filename>
+                <vars>
+                    <var ID="computedCurrentLocationValue">${createMovement3.currentLocation}</var>
+                </vars>
+            </response>
+            <expectedCodes>200</expectedCodes>
+        </test>
+        
     </testGroup>
  
     <!-- These tests verify that updates to the computed current location values -->