]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5728: Exclude soft-deleted Movement records from consideration when coming...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Jan 2013 01:41:55 +0000 (17:41 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 10 Jan 2013 01:41:55 +0000 (17:41 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml
services/batch/service/pom.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java

index 2619016e668a1e08419dbc62ee7a2662a35246c2..d8bd2b63a2fdb3a1223a8088c3259f437db18a86 100644 (file)
             <expectedCodes>200</expectedCodes>\r
         </test>\r
         \r
+        <!-- Test with a soft-deleted related Movement record -->\r
+        <test ID="softDeleteMovement2">\r
+            <method>PUT</method>\r
+            <uri>/cspace-services/movements/${createMovement4.CSID}/workflow/delete</uri>\r
+            <expectedCodes>200</expectedCodes>\r
+            <!-- XmlReplay appears to require a filename on PUT. -->\r
+            <!-- If not present, throws "java.io.FileNotFoundException: File '' does not exist" -->\r
+            <!-- The contents of that file, sent in the PUT payload, will be ignored by the services. -->\r
+            <!-- Note that the filename below is in a different module than -->\r
+            <!-- the present XmlReplay control file. -->\r
+            <filename>relation/res/workflowState.res.xml</filename>\r
+            <vars>\r
+                <var ID="workflowState">deleted</var>\r
+            </vars>\r
+        </test>\r
+        \r
+        <test ID="invokeBatchAfterSoftDeletingMovement" auth="test" autoDeletePOSTS="false">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/batch/${createBatchRecord.CSID}</uri>\r
+            <filename>batch/batch-invoke-updateobjloc-single.xml</filename>\r
+            <vars>\r
+                <var ID="collectionObjectCSID">${createCollectionObject.CSID}</var>\r
+            </vars>\r
+            <expectedCodes>200</expectedCodes>\r
+        </test>\r
+        \r
+        <!-- After soft-deleting related Movement record 4, the computedCurrentLocation -->\r
+        <!-- value should have reverted to the currentLocation value of Movement record 2. -->\r
+        <test ID="readUpdatedCollectionObjectRecordAfterSoftDeletingMovement">\r
+            <method>GET</method>\r
+            <uri>/cspace-services/collectionobjects/${createCollectionObject.CSID}</uri>\r
+            <filename>batch/updateobjloc.xml</filename>\r
+            <response>\r
+                <expected level="ADDOK" />\r
+                <filename>batch/res/collectionobject.res.xml</filename>\r
+                <vars>\r
+                    <var ID="computedCurrentLocationValue">${createMovement2.currentLocation}</var>\r
+                </vars>\r
+            </response>\r
+            <expectedCodes>200</expectedCodes>\r
+        </test>\r
+        \r
     </testGroup>\r
     \r
     <testGroup ID="invocationModeModeList" autoDeletePOSTS="true">\r
index 73798b3c0ec77f301a442111f18899cc7b7287d0..17b71a01b9bc6aa1605bfde65310b325d7863581 100644 (file)
     <packaging>jar</packaging>       
 
     <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.common</artifactId>
@@ -63,7 +68,7 @@
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.relation.client</artifactId>
             <version>${project.version}</version>
-        </dependency>
+        </dependency>        
         <!-- External dependencies -->        
         <dependency>
             <groupId>junit</groupId>
index 737efe6be34ba21047ffb8b0f4ce49036a547c19..e7f721f1d78f57c4680b77795b65989af0830a9b 100644 (file)
@@ -15,6 +15,7 @@ import org.collectionspace.services.batch.AbstractBatchInvocable;
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.client.MovementClient;
+import org.collectionspace.services.client.workflow.WorkflowClient;
 import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ResourceMap;
@@ -99,7 +100,10 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
 
     }
 
-    // Ray's convenience methods from his AbstractBatchJob class for the UC Berkeley Botanical Garden v2.4 implementation.
+    // #################################################################
+    // Ray's convenience methods from his AbstractBatchJob class for the
+    // UC Berkeley Botanical Garden v2.4 implementation.
+    // #################################################################
     protected PoxPayloadOut findByCsid(String serviceName, String csid) throws URISyntaxException, DocumentException {
         ResourceBase resource = getResourceMap().get(serviceName);
         return findByCsid(resource, csid);
@@ -121,6 +125,10 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         return new UriInfoImpl(absolutePath, baseUri, "", queryString, Collections.<PathSegment>emptyList());
     }
 
+    // #################################################################
+    // Other convenience methods
+    // #################################################################
+    
     protected UriInfo createRelatedRecordsUriInfo(String query) throws URISyntaxException {
         URI uri = new URI(null, null, null, query, null);
         return createUriInfo(uri.getRawQuery());
@@ -169,11 +177,17 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
             // For each CollectionObject record
             for (String collectionObjectCsid : csids) {
 
+                if (recordIsDeleted(collectionObjectCsid)) {
+                    continue;
+                }
+
                 // Get the movement records related to this record
 
                 // Get movement records related to this record where the CollectionObject
                 // record is the subject of the relation
-                String queryString = "rtObj=" + collectionObjectCsid; // FIXME: Get from constant
+                // FIXME: Get query string(s) from constant(s)
+                String queryString = "rtObj=" + collectionObjectCsid
+                        + "&" + WorkflowClient.WORKFLOW_QUERY_NONDELETED + "=false";
                 UriInfo uriInfo = createRelatedRecordsUriInfo(queryString);
 
                 AbstractCommonList relatedMovements = movementResource.getList(uriInfo);
@@ -184,7 +198,9 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
 
                 // Get movement records related to this record where the CollectionObject
                 // record is the object of the relation
-                queryString = "rtSbj=" + collectionObjectCsid; // FIXME: Get from constant
+                // FIXME: Get query string(s) from constant(s)
+                queryString = "rtSbj=" + collectionObjectCsid
+                        + "&" + WorkflowClient.WORKFLOW_QUERY_NONDELETED + "=false";
                 uriInfo = createRelatedRecordsUriInfo(queryString);
 
                 AbstractCommonList reverseRelatedMovements = movementResource.getList(uriInfo);
@@ -295,4 +311,9 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         getResults().setNumAffected(numAffected);
         return getResults();
     }
+
+    private boolean recordIsDeleted(String collectionObjectCsid) {
+        return false;
+        // throw new UnsupportedOperationException("Not yet implemented");
+    }
 }