Commit 0c96e0d1 authored by Matija Obreza's avatar Matija Obreza
Browse files

Taxonomy only supports genus+species

parent 2c472049
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.service;
import org.genesys2.server.model.genesys.Taxonomy;
......@@ -23,6 +22,7 @@ public interface TaxonomyService {
Taxonomy get(String genus, String species);
Taxonomy ensureTaxonomy(String genus, String species, String fullTaxa);
Taxonomy ensureTaxonomy(String genus, String species); // , String
// fullTaxa);
}
......@@ -16,6 +16,7 @@
package org.genesys2.server.service.impl;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.genesys.Taxonomy;
......@@ -40,24 +41,24 @@ public class TaxonomyServiceImpl implements TaxonomyService {
@Override
@Transactional(readOnly = false)
public Taxonomy ensureTaxonomy(String genus, String species, String fullTaxa) {
public Taxonomy ensureTaxonomy(String genus, String species) {
if (genus == null)
return null;
Taxonomy existing = taxonomyRepository.getByTaxonName(fullTaxa);
Taxonomy existing = taxonomyRepository.getByGenusAndSpecies(genus, species);
if (existing == null) {
return internalEnsure(genus, species, fullTaxa);
return internalEnsure(genus, species);
}
return existing;
}
private synchronized Taxonomy internalEnsure(String genus, String species, String fullTaxa) {
Taxonomy taxonomy = taxonomyRepository.getByTaxonName(fullTaxa);
private synchronized Taxonomy internalEnsure(String genus, String species) {
Taxonomy taxonomy = taxonomyRepository.getByGenusAndSpecies(genus, species);
if (taxonomy == null) {
taxonomy = new Taxonomy();
LOG.warn("Inserting " + genus + " " + species + " " + fullTaxa);
LOG.warn("Inserting " + genus + " " + species);
taxonomy.setGenus(genus);
taxonomy.setSpecies(fullTaxa.substring(genus.length() + 1).trim());
taxonomy.setTaxonName(fullTaxa);
taxonomy.setSpecies(species);
taxonomy.setTaxonName((genus + " " + StringUtils.defaultIfEmpty(species, "")).trim());
// try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
......
......@@ -64,10 +64,10 @@ public class SGSVInsertMissing {
@Autowired
private GeoService geoService;
@Autowired
private TaskExecutor taskExecutor;
private static final String[] institutes = { "AUS039", "BDI003", "BDI004", "BDI005", "BRA001", "BRA008", "CAN004", "CHL002", "CIV039", "CRI001", "ECU076",
"GBR072", "GEO028", "GRC035", "IDN179", "ISR003", "ITA411", "KEN015", "KEN023", "KEN045", "KEN053", "KEN055", "KOR043", "MLI002", "MLI003",
"MLI219", "MMR003", "MNG030", "NGA010", "PAK001", "PER002", "PHL129", "PRK013", "SDN034", "THA214", "TJK027", "TWN006", "UGA031", "UKR001",
......@@ -267,7 +267,8 @@ public class SGSVInsertMissing {
accn.setOrigin(entry.origCty);
accn.setCountryOfOrigin(geoService.getCountry(entry.origCty));
accn.setGenus(entry.genus);
accn.setTaxonomy(taxonomyService.ensureTaxonomy(entry.genus, entry.species, entry.fullTaxa));
accn.setTaxonomy(taxonomyService.ensureTaxonomy(entry.genus, entry.species));
// entry.fullTaxa));
accn.setInstituteCode(entry.instCode);
accn.setInstitute(getFromCache(entry.instCode));
accn.setDataSource("Svalbard");
......@@ -276,8 +277,8 @@ public class SGSVInsertMissing {
LOG.warn("No institute: " + accn.getInstituteCode());
continue;
}
if (accn.getTaxonomy()==null) {
if (accn.getTaxonomy() == null) {
LOG.warn("No taxonomy: " + entry);
continue;
}
......@@ -303,7 +304,6 @@ public class SGSVInsertMissing {
return inst;
}
private class SGSVEntry implements AccessionIdentifier3 {
String instCode;
String acceNumb;
......@@ -330,8 +330,7 @@ public class SGSVInsertMissing {
public String getAccessionName() {
return acceNumb;
}
@Override
public String getGenus() {
return genus;
......
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