<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-1</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Seattle1358215545509)'Seattle, WA, USA'</var>\r
<var ID="locationDate">1900-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-2</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Portland1358215545512)'Portland, OR, USA'</var>\r
<var ID="locationDate">2000-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-3</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Victoria1358215545515)'Victoria, BC, Canada'</var>\r
<var ID="locationDate">1800-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-4</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Vancouver1358215545518)'Vancouver, BC, Canada'</var>\r
<var ID="locationDate">2100-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-1-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Olympia1358215545521)'Olympia, WA, USA'</var>\r
<var ID="locationDate">1900-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-2-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ottawa1358215545567)'Ottawa, ON, Canada'</var>\r
<var ID="locationDate">${createMovement1WithTiebreaker.locationDate}</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-3-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Spokane1358215545524)'Spokane, WA, USA'</var>\r
<var ID="locationDate">${createMovement1WithTiebreaker.locationDate}</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements/${createMovement1WithTiebreaker.CSID}</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-1-modified-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Guadalajara13582155455562)'Guadalajara, Mexico'</var>\r
<var ID="locationDate">${createMovement1WithTiebreaker.locationDate}</var>\r
</vars>\r
<expectedCodes>200</expectedCodes>\r
<uri>/cspace-services/movements/${createMovement2WithTiebreaker.CSID}</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-2-modified-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Ecatepec13582155455560)'Ecatepec, Mexico'</var>\r
<var ID="locationDate">${createMovement1WithTiebreaker.locationDate}</var>\r
</vars>\r
<expectedCodes>200</expectedCodes>\r
<uri>/cspace-services/movements/${createMovement3WithTiebreaker.CSID}</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-3-modified-with-tiebreaker</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Calgary1358215545564)'Calgary, AB, Canada'</var>\r
<var ID="locationDate">${createMovement1WithTiebreaker.locationDate}</var>\r
</vars>\r
<expectedCodes>200</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-1</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Winnipeg13582155455568)'Winnipeg, MB, Canada'</var>\r
<var ID="locationDate">1900-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-2</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Saskatoon13582155455570)'Saskatoon, SK, Canada'</var>\r
<var ID="locationDate">2000-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-3</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Montreal13582155455570)'Montreal, QC, Canada'</var>\r
<var ID="locationDate">1800-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-1</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Eugene13582155455572)'Eugene, OR, USA'</var>\r
<var ID="locationDate">1900-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-2</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Salem13582155455574)'Salem, OR, USA'</var>\r
<var ID="locationDate">2000-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-3</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Gresham13582155455574)'Gresham, OR, USA'</var>\r
<var ID="locationDate">1800-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-nocontext-1</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Hillsboro13582155455576)'Hillsboro, OR, USA'</var>\r
<var ID="locationDate">2050-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
<uri>/cspace-services/movements</uri>\r
<filename>batch/movement.xml</filename>\r
<vars>\r
- <var ID="currentLocation">location-nocontext-2</var>\r
+ <var ID="currentLocation">urn:cspace:core.collectionspace.org:locationauthorities:name(offsite_sla):item:name(Beaverton13582155455578)'Beaverton, OR, USA'</var>\r
<var ID="locationDate">1950-01-01</var>\r
</vars>\r
<expectedCodes>201</expectedCodes>\r
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;
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.
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 =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<document name=\"collectionobject\">"