Commit 82c12b62 authored by Matija Obreza's avatar Matija Obreza
Browse files

REST update taxonomy, sampstat, storage, dublinst

parent 0c96e0d1
......@@ -24,12 +24,15 @@ import java.util.List;
import java.util.Map;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AllAcqCollect;
import org.genesys2.server.model.genesys.Taxonomy;
import org.genesys2.server.model.impl.AccessionIdentifier3;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.TaxonomyService;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
......@@ -64,6 +67,9 @@ public class AccessionController extends RestController {
@Autowired
GeoService geoService;
@Autowired
TaxonomyService taxonomyService;
/**
* Check if accessions exists in the system
*
......@@ -294,6 +300,12 @@ public class AccessionController extends RestController {
accession.setCountryOfOrigin(country);
updated = true;
}
value = accnJson.get("acqDate");
if (value != null) {
String acqDate = value.isNull() ? null : value.textValue();
accession.setAcquisitionDate(acqDate);
updated = true;
}
value = accnJson.get("mlsStat");
if (value != null) {
Boolean inMls = value.isNull() ? null : value.asBoolean();
......@@ -303,6 +315,47 @@ public class AccessionController extends RestController {
updated = true;
}
}
value = accnJson.get("species");
if (value != null) {
String species = value.isNull() ? null : value.textValue();
Taxonomy taxonomy = taxonomyService.ensureTaxonomy(accession.getGenus(), species);
accession.setTaxonomy(taxonomy);
updated = true;
}
value = accnJson.get("storage");
if (value != null) {
Integer storage = value.isNull() ? null : value.asInt();
accession.setStorage("" + storage);
updated = true;
}
value = accnJson.get("sampStat");
if (value != null) {
Integer sampStat = value.isNull() ? null : value.asInt();
accession.setSampleStatus("" + sampStat);
updated = true;
}
value = accnJson.get("dublInst");
if (value != null) {
String dublInst = value.isNull() ? null : value.textValue();
accession.setDublInst(dublInst);
updated = true;
}
if (accnJson.has("coll")) {
// ObjectNode collecting = (ObjectNode) accnJson.get("coll");
// AllAcqCollect accnColl = accession.getAccessionCollection();
// if (accnColl == null) {
// accnColl = new AllAcqCollect();
// accession.setAccessionCollection(accnColl);
// }
// value = collecting.get("date");
// accnColl.setCollectDate(value != null && value.isTextual() ? value.textValue() : null);
// value = collecting.get("site");
// accnColl.setCollectSite(value != null && value.isTextual() ? value.textValue() : null);
}
if (updated) {
toSave.add(accession);
......
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