Commit bd8b0e31 authored by Matija Obreza's avatar Matija Obreza

FIX: APIv0 upgrade bredCode, bredName

parent 481f6d4d
......@@ -412,17 +412,20 @@ public class AccessionController extends ApiBaseController {
upgradeRename(update, "subtauthor", "subtAuthor");
upgradeRename(update, "acqDate", "acquisitionDate");
upgradeRename(update, "bredCode", "breederCode");
upgradeRename(update, "bredName", "breederName");
upgradeRename(update, "mlsStat", "mlsStatus");
upgradeRename(update, "orgCty", "origCty");
upgradeToArray(update, "breederCode"); // renamed above
upgradeToArray(update, "breederName"); // renamed above
if (update.has("geo")) {
ObjectNode geo = (ObjectNode) update.get("geo");
upgradeRename(geo, "coordUncert", "uncertainty");
upgradeRename(geo, "coordDatum", "datum");
upgradeRename(geo, "georefMeth", "method");
}
if (update.has("coll")) {
ObjectNode coll = (ObjectNode) update.get("coll");
upgradeToArray(coll, "collCode");
......@@ -444,13 +447,13 @@ public class AccessionController extends ApiBaseController {
upgradeTaxonomy(update, taxonomy, "subtAuthor");
}
private void upgradeToArray(ObjectNode coll, String fieldName) {
JsonNode node = coll.get(fieldName);
private void upgradeToArray(ObjectNode obj, String fieldName) {
JsonNode node = obj.get(fieldName);
if (node != null && !node.isArray()) {
ArrayNode collCode = coll.putArray(fieldName);
ArrayNode arrNode = obj.putArray(fieldName);
for (String x : node.asText().split(";")) {
if (StringUtils.isNotBlank(x)) {
collCode.add(x);
arrNode.add(StringUtils.trim(x));
}
}
}
......
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