Commit b48d32fb authored by Matija Obreza's avatar Matija Obreza
Browse files

API v0 fix: coll.collCode, collName, collInstAddr are arrays

parent 208dc9de
......@@ -415,7 +415,7 @@ public class AccessionController extends ApiBaseController {
upgradeRename(update, "mlsStat", "mlsStatus");
upgradeRename(update, "orgCty", "origCty");
if (update.has("geo")) {
ObjectNode geo = (ObjectNode) update.get("geo");
upgradeRename(geo, "coordUncert", "uncertainty");
......@@ -423,6 +423,13 @@ public class AccessionController extends ApiBaseController {
upgradeRename(geo, "georefMeth", "method");
}
if (update.has("coll")) {
ObjectNode coll = (ObjectNode) update.get("coll");
upgradeToArray(update, coll, "collCode");
upgradeToArray(update, coll, "collName");
upgradeToArray(update, coll, "collInstAddress");
}
ObjectNode taxonomy;
if (update.has("taxonomy")) {
taxonomy = (ObjectNode) update.get("taxonomy");
......@@ -437,6 +444,18 @@ public class AccessionController extends ApiBaseController {
upgradeTaxonomy(update, taxonomy, "subtAuthor");
}
private void upgradeToArray(ObjectNode update, ObjectNode coll, String fieldName) {
JsonNode node = coll.get(fieldName);
if (node != null && !node.isArray()) {
ArrayNode collCode = update.putArray(fieldName);
for (String x : node.asText().split(";")) {
if (StringUtils.isNotBlank(x)) {
collCode.add(x);
}
}
}
}
private void upgradeRename(ObjectNode update, String v1name, String v2name) {
if (update.has(v1name)) {
update.set(v2name, update.remove(v1name));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment