]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5728: Initial steps toward supporting list-mode invocation of the batch job...
authorAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Jan 2013 23:39:10 +0000 (15:39 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Wed, 9 Jan 2013 23:39:10 +0000 (15:39 -0800)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-single.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/updateobjloc.xml
services/batch/service/src/main/java/org/collectionspace/services/batch/AbstractBatchInvocable.java
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java

diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-invoke-updateobjloc-list.xml
new file mode 100644 (file)
index 0000000..0d36993
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
+<ns2:invocationContext\r
+    xmlns:ns2="http://collectionspace.org/services/common/invocable"\r
+    xmlns:ns3="http://collectionspace.org/services/jaxb">\r
+    <mode>list</mode>\r
+    <docType>CollectionObject</docType>\r
+    <singleCSID></singleCSID>\r
+    <groupCSID></groupCSID>\r
+    <listCsids>\r
+        <csid>${collectionObject1CSID}</csid>\r
+        <csid>${collectionObject2CSID}</csid>\r
+    </listCsids>\r
+    <params>\r
+        <param>\r
+            <key>some key</key>\r
+            <value>some value</value>\r
+        </param>\r
+    </params>\r
+</ns2:invocationContext>\r
+\r
+\r
index a4a1d6af57416d096f42d91fa59d2b4cc7ef333b..755f5917d4898d1f3ec90e30b3e569a8ab157b9b 100644 (file)
@@ -5,6 +5,9 @@
     <mode>single</mode>\r
     <docType>CollectionObject</docType>\r
     <singleCSID>${collectionObjectCSID}</singleCSID>\r
+    <groupCSID></groupCSID>\r
+    <listCsids></listCsids>\r
+    <params></params>\r
 </ns2:invocationContext>\r
 \r
 \r
index 84088950eeb2c162c3b19310445bca09c41cec3f..43747c2cd62479f05b02ec54648513e705fae805 100644 (file)
@@ -7,7 +7,7 @@
         \r
     <!-- This tests the UpdateObjectLocationBatchJob -->\r
         \r
-    <testGroup ID="testSingleRecordBatchUpdate" autoDeletePOSTS="true">\r
+    <testGroup ID="testBatchUpdateComputedCurrentLocationInvModeSingle" autoDeletePOSTS="true">\r
         \r
         <!-- Tests with CollectionObject->Movement relations -->\r
             \r
         \r
         <!-- This post of a batch job invocation request doesn't create a new record, -->\r
         <!-- so we need to exclude it from the post-run auto-deletion of records. -->\r
-        <test ID="invokeBatch1" auth="test" autoDeletePOSTS="false">\r
+        <test ID="invokeBatch" 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
         \r
     </testGroup>\r
     \r
+    <testGroup ID="testBatchUpdateComputedCurrentLocationInvModeList" autoDeletePOSTS="true">\r
+        \r
+        <test ID="createBatchRecord">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/batch</uri>\r
+            <filename>batch/updateobjloc.xml</filename>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+                \r
+        <test ID="createCollectionObject1">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/collectionobjects</uri>\r
+            <filename>batch/collObj1.xml</filename>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="createCollectionObject2">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/collectionobjects</uri>\r
+            <filename>batch/collObj1.xml</filename>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="createMovement1">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/movements</uri>\r
+            <filename>batch/movement.xml</filename>\r
+            <vars>\r
+                <var ID="currentLocation">location-1</var>\r
+                <var ID="locationDate">1900-01-01</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="createMovement2">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/movements</uri>\r
+            <filename>batch/movement.xml</filename>\r
+            <vars>\r
+                <var ID="currentLocation">location-2</var>\r
+                <var ID="locationDate">2000-01-01</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="createMovement3">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/movements</uri>\r
+            <filename>batch/movement.xml</filename>\r
+            <vars>\r
+                <var ID="currentLocation">location-3</var>\r
+                <var ID="locationDate">1800-01-01</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="relateCollectionObject1ToMovement1">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/relations</uri>\r
+            <filename>batch/relation.xml</filename>\r
+            <vars>\r
+                <var ID="subjectCsid">${createCollectionObject1.CSID}</var>\r
+                <var ID="subjectDocumentType">CollectionObject</var>\r
+                <var ID="objectCsid">${createMovement1.CSID}</var>\r
+                <var ID="objectDocumentType">Movement</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="relateCollection1ObjectToMovement2">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/relations</uri>\r
+            <filename>batch/relation.xml</filename>\r
+            <vars>\r
+                <var ID="subjectCsid">${createCollectionObject1.CSID}</var>\r
+                <var ID="subjectDocumentType">CollectionObject</var>\r
+                <var ID="objectCsid">${createMovement2.CSID}</var>\r
+                <var ID="objectDocumentType">Movement</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="relateCollectionObject2ToMovement3">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/relations</uri>\r
+            <filename>batch/relation.xml</filename>\r
+            <vars>\r
+                <var ID="subjectCsid">${createCollectionObject2.CSID}</var>\r
+                <var ID="subjectDocumentType">CollectionObject</var>\r
+                <var ID="objectCsid">${createMovement3.CSID}</var>\r
+                <var ID="objectDocumentType">Movement</var>\r
+            </vars>\r
+            <expectedCodes>201</expectedCodes>\r
+        </test>\r
+        \r
+        <test ID="invokeBatchWithList" auth="test" autoDeletePOSTS="false">\r
+            <method>POST</method>\r
+            <uri>/cspace-services/batch/${createBatchRecord.CSID}</uri>\r
+            <filename>batch/batch-invoke-updateobjloc-list.xml</filename>\r
+            <vars>\r
+                <var ID="collectionObject1CSID">${createCollectionObject1.CSID}</var>\r
+                <var ID="collectionObject2CSID">${createCollectionObject2.CSID}</var>\r
+            </vars>\r
+            <expectedCodes>200</expectedCodes>\r
+        </test>\r
+        \r
+        <!-- This CollectionObject record's computedCurrentLocation field should -->\r
+        <!-- have been updated with the currentLocation value from Movement record 2 -->\r
+        <test ID="readUpdatedCollectionObjectRecord1">\r
+            <method>GET</method>\r
+            <uri>/cspace-services/collectionobjects/${createCollectionObject1.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
+        <!-- This CollectionObject record's computedCurrentLocation field should -->\r
+        <!-- have been updated with the currentLocation value from Movement record 3 -->\r
+        <test ID="readUpdatedCollectionObjectRecord2">\r
+            <method>GET</method>\r
+            <uri>/cspace-services/collectionobjects/${createCollectionObject2.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">${createMovement3.currentLocation}</var>\r
+                </vars>\r
+            </response>\r
+            <expectedCodes>200</expectedCodes>\r
+        </test>\r
+\r
+    </testGroup>\r
+    \r
 </xmlReplay>\r
 \r
index c83b22db1a850c16dedcae7b4d593aaaba97f101..1129a2a777d7db3b8a17ad66b6e10780e3356668 100644 (file)
@@ -8,7 +8,7 @@
             <forDocType>CollectionObject</forDocType>\r
         </forDocTypes>\r
         <supportsSingleDoc>true</supportsSingleDoc>\r
-        <supportsDocList>false</supportsDocList>\r
+        <supportsDocList>true</supportsDocList>\r
         <createsNewFocus>false</createsNewFocus>\r
         <className>org.collectionspace.services.batch.nuxeo.UpdateObjectLocationBatchJob</className>\r
     </ns2:batch_common>\r
index 1dc9f50014e57ff1f4896e7e2cdc9432565705ef..02c5ddb2a869ace7bcae1c6bf43c08d16c537ff1 100644 (file)
@@ -53,6 +53,38 @@ public abstract class AbstractBatchInvocable implements BatchInvocable {
         this.errorInfo = null;
     }
 
+    protected void logInvocationContext() {
+        if (logger.isInfoEnabled()) {
+            logger.info("Invocation mode=" + this.getInvocationContext().getMode());
+            logger.info("Invocation doc type=" + this.getInvocationContext().getDocType());
+            logger.info("Invocation single CSID=" + this.getInvocationContext().getSingleCSID());
+            logger.info("Invocation group CSID=" + this.getInvocationContext().getGroupCSID());
+            InvocationContext.ListCSIDs lcsids = this.getInvocationContext().getListCSIDs();
+            if (lcsids == null) {
+                logger.info("Invocation list CSIDs are null.");
+            } else {
+                List<String> csidsList = lcsids.getCsid();
+                if (csidsList != null) {
+                    for (String listcsid : csidsList) {
+                        logger.info("List CSID=" + listcsid);
+                    }
+                }
+            }
+            InvocationContext.Params params = this.getInvocationContext().getParams();
+            if (params == null) {
+                logger.info("Invocation list Params are null.");
+            } else {
+                List<InvocationContext.Params.Param> paramsList = params.getParam();
+                if (paramsList != null) {
+                    for (InvocationContext.Params.Param param : paramsList) {
+                        logger.info("Param key=" + param.getKey());
+                        logger.info("Param value=" + param.getValue());
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     public List<String> getSupportedInvocationModes() {
         return invocationModes;
index 455f4ffae50a0e63a405e8e1186a01f42a37e942..cf9cbf42764878fb77f13f158c3eea5a96e6da2b 100644 (file)
@@ -19,6 +19,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ResourceMap;
 import org.collectionspace.services.common.api.Tools;
+import org.collectionspace.services.common.invocable.InvocationContext;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.dom4j.DocumentException;
@@ -62,10 +63,8 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         setCompletionStatus(STATUS_MIN_PROGRESS);
 
         try {
-            if (logger.isTraceEnabled()) {
-                logger.trace("Invoking " + CLASSNAME + " ...");
-                logger.trace("Invocation context is: " + getInvocationContext().getMode());
-            }
+
+            logInvocationContext();
 
             List<String> csids = new ArrayList<String>();
             if (requestIsForInvocationModeSingle()) {
@@ -74,7 +73,11 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
                     csids.add(singleCsid);
                 }
             } else if (requestIsForInvocationModeList()) {
-                List<String> listCsids = (getInvocationContext().getListCSIDs().getCsid());
+                InvocationContext.ListCSIDs invListCsids = getInvocationContext().getListCSIDs();
+                if (invListCsids == null) {
+                    throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
+                }
+                List<String> listCsids = invListCsids.getCsid();
                 if (listCsids == null || listCsids.isEmpty()) {
                     throw new Exception(CSID_VALUES_NOT_PROVIDED_IN_INVOCATION_CONTEXT);
                 }
@@ -296,4 +299,5 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         getResults().setNumAffected(numAffected);
         return getResults();
     }
+
 }