\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
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;
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()) {
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);
}
getResults().setNumAffected(numAffected);
return getResults();
}
+
}