]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5728: Relations in the reverse direction are now also reflected when computing...
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 8 Jan 2013 23:00:54 +0000 (15:00 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 8 Jan 2013 23:00:54 +0000 (15:00 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java

index 3f130804196161e5bc72a40d177e4111ab1cc6ec..3b1fb8eaff16ea5272fa47b3ebae143da10c08a5 100644 (file)
@@ -8,6 +8,8 @@
     <!-- This tests the UpdateObjectLocationBatchJob -->\r
         \r
     <testGroup ID="testSingleRecordBatchUpdate" autoDeletePOSTS="true">\r
+        \r
+        <!-- Tests with CollectionObject->Movement relations -->\r
             \r
         <test ID="createBatchRecord">\r
             <method>POST</method>\r
@@ -60,7 +62,7 @@
             <expectedCodes>201</expectedCodes>\r
         </test>\r
         \r
-        <test ID="relateMovement1ToCollectionObject">\r
+        <test ID="relateCollectionObjectToMovement1">\r
             <method>POST</method>\r
             <uri>/cspace-services/relations</uri>\r
             <filename>batch/relation.xml</filename>\r
@@ -73,7 +75,7 @@
             <expectedCodes>201</expectedCodes>\r
         </test>\r
         \r
-        <test ID="relateMovement2ToCollectionObject">\r
+        <test ID="relateCollectionObjectToMovement2">\r
             <method>POST</method>\r
             <uri>/cspace-services/relations</uri>\r
             <filename>batch/relation.xml</filename>\r
@@ -86,7 +88,7 @@
             <expectedCodes>201</expectedCodes>\r
         </test>\r
         \r
-        <test ID="relateMovement3ToCollectionObject">\r
+        <test ID="relateCollectionObjectToMovement3">\r
             <method>POST</method>\r
             <uri>/cspace-services/relations</uri>\r
             <filename>batch/relation.xml</filename>\r
         <!-- computedCurrentLocation field in the CollectionObject record has -->\r
         <!-- been updated to the appropriate value, reflecting the most recent -->\r
         <!-- movement (e.g. the Movement record with the most recent locationDate). -->\r
-        <test ID="readUpdatedCollectionObjectRecord1">\r
+        <test ID="readUpdatedCollectionObjectRecord">\r
             <method>GET</method>\r
             <uri>/cspace-services/collectionobjects/${createCollectionObject.CSID}</uri>\r
             <filename>batch/updateobjloc.xml</filename>\r
             <expectedCodes>200</expectedCodes>\r
         </test>\r
         \r
+        <!-- Tests with Movement->CollectionObject relations -->\r
+        \r
         <!-- The currentLocation value of this new Movement record, which now -->\r
         <!-- has the most recent locationDate value, should thus be -->\r
         <!-- reflected in the computedCurrentLocation value in the -->\r
             <expectedCodes>201</expectedCodes>\r
         </test>\r
         \r
-        <!-- Represents a reversal of the (subject-object) direction of the relationship -->\r
-        <test ID="relateCollectionObjectToMovement4">\r
+        <!-- Note that this payload reflects a reversal of the subject-object directionality -->\r
+        <!-- of the relationship: this is a Movement->CollectionObject relationship, -->\r
+        <!-- rather than a CollectionObject->Movement relationship. -->\r
+        <test ID="relateMovement4ToCollectionObject">\r
             <method>POST</method>\r
             <uri>/cspace-services/relations</uri>\r
             <filename>batch/relation.xml</filename>\r
             <expectedCodes>200</expectedCodes>\r
         </test>\r
         \r
-        <!--\r
         <test ID="readUpdatedCollectionObjectRecordAfterAddingReverseRelation">\r
             <method>GET</method>\r
             <uri>/cspace-services/collectionobjects/${createCollectionObject.CSID}</uri>\r
             </response>\r
             <expectedCodes>200</expectedCodes>\r
         </test>\r
-        -->\r
         \r
     </testGroup>\r
     \r
index f454ef9e2505c0b7eb61718335a691e93e5e3df6..3787d2e3a45e9fb17ddc466c9018773304abbc6a 100644 (file)
@@ -212,26 +212,26 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
                     logger.info("Identified " + relatedMovements.getTotalItems()
                             + " movement records related to CollectionObject record " + csid);
                 }
-                if (relatedMovements.getTotalItems() == 0) {
-                    // continue;
-                }
 
-                // FIXME: Get the reciprocal relation records, via rtSbj=, as well,
-                // and remove duplicates
+                // FIXME: Get relation records in the reverse direction as well,
+                // via rtSbj=, merge with records obtained above, and remove duplicates
 
-                // FIXME Temporary for testing, until we integrate the two list results
                 queryString = "rtSbj=" + csid;
                 uri = new URI(null, null, null, queryString, null);
                 uriInfo = createUriInfo(uri.getRawQuery());
 
-                relatedMovements = movementResource.getList(uriInfo);
+                AbstractCommonList reverseRelatedMovements = movementResource.getList(uriInfo);
                 if (logger.isInfoEnabled()) {
-                    logger.info("Identified " + relatedMovements.getTotalItems()
-                            + " movement records related to CollectionObject record " + csid);
+                    logger.info("Identified " + reverseRelatedMovements.getTotalItems()
+                            + " movement records related in the reverse  to CollectionObject record " + csid);
                 }
-                if (relatedMovements.getTotalItems() == 0) {
+                
+                if ((relatedMovements.getTotalItems() == 0) && reverseRelatedMovements.getTotalItems() == 0) {
                     continue;
                 }
+                
+                // Merge the two lists
+                relatedMovements.getListItem().addAll(reverseRelatedMovements.getListItem());
 
                 // Get the latest movement record from among those, and extract
                 // its current location value