Commit 6f7fb7e7 authored by Matija Obreza's avatar Matija Obreza
Browse files

Updating taxonomy must not reuse existing data

parent 05196200
......@@ -16,7 +16,7 @@
package org.genesys2.server.service.impl;
import static org.genesys2.util.NumberUtils.areEqual;
import static org.genesys2.util.NumberUtils.*;
import java.util.ArrayList;
import java.util.Date;
......@@ -108,9 +108,9 @@ public class BatchRESTServiceImpl implements BatchRESTService {
current.setGenus(stringIfProvided(accnJson.get(Api1Constants.Accession.GENUS), current.getGenus()));
current.setGenus(stringIfProvided(accnJson.get(Api1Constants.Accession.GENUS_NEW), current.getGenus()));
current.setSpecies(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPECIES), current.getSpecies()), "sp."));
current.setSpAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPAUTHOR), current.getSpAuthor()), ""));
current.setSubtaxa(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAXA), current.getSubtaxa()), ""));
current.setSubtAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAUTHOR), current.getSubtAuthor()), ""));
current.setSpAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPAUTHOR), current.getSpAuthor()), StringUtils.EMPTY));
current.setSubtaxa(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAXA), current.getSubtaxa()), StringUtils.EMPTY));
current.setSubtAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAUTHOR), current.getSubtAuthor()), StringUtils.EMPTY));
if (current.getGenus().contains("sp.")) {
throw new RESTApiException("GENUS cannot contain 'sp.'. Offending genus: " + current.getGenus());
......@@ -467,7 +467,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
}
final ArrayNode donorNumb = accnJson.arrayNode();
String donorNumbStr = "";
String donorNumbStr = StringUtils.EMPTY;
if (accnExch.getDonorInstitute() != null) {
donorNumbStr = accnExch.getDonorInstitute();
}
......@@ -789,16 +789,14 @@ public class BatchRESTServiceImpl implements BatchRESTService {
return false;
}
// Do not persist this one, temporary use
final Taxonomy2 taxonomy = accession.getTaxonomy();
final Taxonomy2 current = new Taxonomy2(taxonomy);
// Load JSON values into "current"
final Taxonomy2 current = new Taxonomy2();
current.setGenus(stringIfProvided(accnJson.get(Api1Constants.Accession.GENUS), current.getGenus()));
current.setGenus(stringIfProvided(accnJson.get(Api1Constants.Accession.GENUS_NEW), current.getGenus()));
current.setSpecies(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPECIES), current.getSpecies()), "sp."));
current.setSpAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPAUTHOR), current.getSpAuthor()), ""));
current.setSubtaxa(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAXA), current.getSubtaxa()), ""));
current.setSubtAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAUTHOR), current.getSubtAuthor()), ""));
current.setSpecies(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPECIES), StringUtils.EMPTY), "sp."));
current.setSpAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SPAUTHOR), StringUtils.EMPTY), StringUtils.EMPTY));
current.setSubtaxa(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAXA), StringUtils.EMPTY), StringUtils.EMPTY));
current.setSubtAuthor(StringUtils.defaultIfBlank(stringIfProvided(accnJson.get(Api1Constants.Accession.SUBTAUTHOR), StringUtils.EMPTY), StringUtils.EMPTY));
Taxonomy2 ensuredTaxonomy = null;
try {
......
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