From: Aron Roberts Date: Thu, 20 Feb 2014 03:35:32 +0000 (-0800) Subject: CSPACE-6134: In the batch job that updates computed current locations in Cataloging... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=7edc0ce0a47354fe655b7632dbbe024b919b2f70;p=tmp%2Fjakarta-migration.git CSPACE-6134: In the batch job that updates computed current locations in Cataloging / CollectionObject records, verify that related L/M/I records with null current locations can't 'null out' existing computed current locations. Add verification that candidate current locations can be successfully parsed as refNames. --- 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 d68b1ac5c..439cc9e4b 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 @@ -32,7 +32,7 @@ /cspace-services/movements batch/movement.xml - location-1 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Seattle1358215545509)'Seattle, WA, USA' 1900-01-01 201 @@ -47,7 +47,7 @@ /cspace-services/movements batch/movement.xml - location-2 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Portland1358215545512)'Portland, OR, USA' 2000-01-01 201 @@ -58,7 +58,7 @@ /cspace-services/movements batch/movement.xml - location-3 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Victoria1358215545515)'Victoria, BC, Canada' 1800-01-01 201 @@ -144,7 +144,7 @@ /cspace-services/movements batch/movement.xml - location-4 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Vancouver1358215545518)'Vancouver, BC, Canada' 2100-01-01 201 @@ -304,7 +304,7 @@ /cspace-services/movements batch/movement.xml - location-1-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Olympia1358215545521)'Olympia, WA, USA' 1900-01-01 201 @@ -315,7 +315,7 @@ /cspace-services/movements batch/movement.xml - location-2-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ottawa1358215545567)'Ottawa, ON, Canada' ${createMovement1WithTiebreaker.locationDate} 201 @@ -326,7 +326,7 @@ /cspace-services/movements batch/movement.xml - location-3-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Spokane1358215545524)'Spokane, WA, USA' ${createMovement1WithTiebreaker.locationDate} 201 @@ -376,7 +376,7 @@ /cspace-services/movements/${createMovement1WithTiebreaker.CSID} batch/movement.xml - location-1-modified-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Guadalajara13582155455562)'Guadalajara, Mexico' ${createMovement1WithTiebreaker.locationDate} 200 @@ -417,7 +417,7 @@ /cspace-services/movements/${createMovement2WithTiebreaker.CSID} batch/movement.xml - location-2-modified-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ecatepec13582155455560)'Ecatepec, Mexico' ${createMovement1WithTiebreaker.locationDate} 200 @@ -452,7 +452,7 @@ /cspace-services/movements/${createMovement3WithTiebreaker.CSID} batch/movement.xml - location-3-modified-with-tiebreaker + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Calgary1358215545564)'Calgary, AB, Canada' ${createMovement1WithTiebreaker.locationDate} 200 @@ -512,7 +512,7 @@ /cspace-services/movements batch/movement.xml - location-1 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Winnipeg13582155455568)'Winnipeg, MB, Canada' 1900-01-01 201 @@ -523,7 +523,7 @@ /cspace-services/movements batch/movement.xml - location-2 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Saskatoon13582155455570)'Saskatoon, SK, Canada' 2000-01-01 201 @@ -534,7 +534,7 @@ /cspace-services/movements batch/movement.xml - location-3 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Montreal13582155455570)'Montreal, QC, Canada' 1800-01-01 201 @@ -652,7 +652,7 @@ /cspace-services/movements batch/movement.xml - location-1 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Eugene13582155455572)'Eugene, OR, USA' 1900-01-01 201 @@ -663,7 +663,7 @@ /cspace-services/movements batch/movement.xml - location-2 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Salem13582155455574)'Salem, OR, USA' 2000-01-01 201 @@ -674,7 +674,7 @@ /cspace-services/movements batch/movement.xml - location-3 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Gresham13582155455574)'Gresham, OR, USA' 1800-01-01 201 @@ -941,7 +941,7 @@ /cspace-services/movements batch/movement.xml - location-nocontext-1 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Hillsboro13582155455576)'Hillsboro, OR, USA' 2050-01-01 201 @@ -952,7 +952,7 @@ /cspace-services/movements batch/movement.xml - location-nocontext-2 + urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Beaverton13582155455578)'Beaverton, OR, USA' 1950-01-01 201 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 590f0cac8..d9d722ca6 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 @@ -20,6 +20,7 @@ import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.ResourceBase; import org.collectionspace.services.common.ResourceMap; +import org.collectionspace.services.common.api.RefNameUtils; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.invocable.InvocationResults; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -229,16 +230,24 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { if (Tools.isBlank(currentLocation)) { continue; } - // FIXME: Add optional validation here that this Movement record's - // currentLocation value parses successfully as an item refName, - // before identifying that record as the most recent Movement. - // Consider making this optional validation, in turn dependent on the + // Validate that this Movement record's currentLocation value parses + // successfully as an item refName, before identifying that record + // as the most recent Movement. + // + // TODO: Consider making this optional validation, in turn dependent on the // value of a parameter passed in during batch job invocation. + if (RefNameUtils.parseAuthorityTermInfo(currentLocation) == null) { + logger.warn(String.format("Could not parse current location refName '%s' in Movement record", + currentLocation)); + continue; + } + if (logger.isTraceEnabled()) { logger.trace("Location date value = " + locationDate); logger.trace("Update date value = " + updateDate); logger.trace("Current location value = " + currentLocation); } + // If this record's location date value is more recent than that of other // Movement records processed so far, set the current Movement record // as the most recent Movement. @@ -320,12 +329,16 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { return numUpdated; } - // Update the location. - // (Updated location values can legitimately be blank, to 'null out' existing locations.) + // At this point in the code, the most recent related Movement record + // should not have a null current location, as such records are + // excluded from consideration altogether in getMostRecentMovement(). + // This is a redundant fallback check, in case that code somehow fails + // or is modified or deleted. if (computedCurrentLocation == null) { - computedCurrentLocation = ""; + return numUpdated; } + // Update the location. String collectionObjectUpdatePayload = "" + ""