From: Aron Roberts Date: Wed, 31 Jul 2013 00:57:22 +0000 (-0700) Subject: CSPACE-6115: Apply PAHMA-895 changes to the UpdateObjectLocationBatchJob. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=d60e13a98ca3d9ea04048616a1fb6de488a7a75f;p=tmp%2Fjakarta-migration.git CSPACE-6115: Apply PAHMA-895 changes to the UpdateObjectLocationBatchJob. --- 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 6abcbccab..36ef17097 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 @@ -280,10 +280,10 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { previousComputedCurrentLocation = getFieldElementValue(collectionObjectPayload, COLLECTIONOBJECTS_COMMON_SCHEMA_NAME, COLLECTIONOBJECTS_COMMON_NAMESPACE, COMPUTED_CURRENT_LOCATION_ELEMENT_NAME); - if (Tools.notBlank(previousComputedCurrentLocation) - && computedCurrentLocation.equals(previousComputedCurrentLocation)) { + if (!shouldUpdateLocation(previousComputedCurrentLocation, computedCurrentLocation)) { return numUpdated; } + // Perform the update only if there is a non-blank object number available. // // In the default CollectionObject validation handler, the object number @@ -303,6 +303,12 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { return numUpdated; } + // Update the location. + // (Updated location values can legitimately be blank, to 'null out' existing locations.) + if (computedCurrentLocation == null) { + computedCurrentLocation = ""; + } + String collectionObjectUpdatePayload = "" + "" @@ -325,6 +331,16 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable { } return numUpdated; } + + protected boolean shouldUpdateLocation(String previousLocation, String currentLocation) { + boolean shouldUpdate = true; + if (Tools.isBlank(previousLocation) && Tools.isBlank(currentLocation)) { + shouldUpdate = false; + } else if (Tools.notBlank(previousLocation) && previousLocation.equals(currentLocation)) { + shouldUpdate = false; + } + return shouldUpdate; + } // ################################################################# // Ray Lee's convenience methods from his AbstractBatchJob class for the