From 3837c4649381662ef65553b7992d8e9ba5b1f17b Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 9 Jan 2013 17:41:55 -0800 Subject: [PATCH] CSPACE-5728: Exclude soft-deleted Movement records from consideration when coming up with computedCurrentLocation value. --- .../batch/batch-update-object-loc.xml | 42 +++++++++++++++++++ services/batch/service/pom.xml | 7 +++- .../nuxeo/UpdateObjectLocationBatchJob.java | 27 ++++++++++-- 3 files changed, 72 insertions(+), 4 deletions(-) diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml index 2619016e6..d8bd2b63a 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/batch/batch-update-object-loc.xml @@ -188,6 +188,48 @@ 200 + + + PUT + /cspace-services/movements/${createMovement4.CSID}/workflow/delete + 200 + + + + + + relation/res/workflowState.res.xml + + deleted + + + + + POST + /cspace-services/batch/${createBatchRecord.CSID} + batch/batch-invoke-updateobjloc-single.xml + + ${createCollectionObject.CSID} + + 200 + + + + + + GET + /cspace-services/collectionobjects/${createCollectionObject.CSID} + batch/updateobjloc.xml + + + batch/res/collectionobject.res.xml + + ${createMovement2.currentLocation} + + + 200 + + diff --git a/services/batch/service/pom.xml b/services/batch/service/pom.xml index 73798b3c0..17b71a01b 100644 --- a/services/batch/service/pom.xml +++ b/services/batch/service/pom.xml @@ -14,6 +14,11 @@ jar + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + org.collectionspace.services org.collectionspace.services.common @@ -63,7 +68,7 @@ org.collectionspace.services org.collectionspace.services.relation.client ${project.version} - + junit diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java index 737efe6be..e7f721f1d 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java @@ -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.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"); + } } -- 2.47.3