use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfo method createSpecimen.
private Specimen createSpecimen(Study study, LabeledCSVParser labeledCSVParser, String externalId) throws StudyImporterException {
try {
Specimen specimen = nodeFactory.createSpecimen(study, new TaxonImpl(null, TaxonomyProvider.NBN.getIdPrefix() + externalId));
setSpecimenExternalId(labeledCSVParser, specimen);
return specimen;
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create taxon with scientific name [" + externalId + "]", e);
}
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForByrnes method addInteractionForPredator.
private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(predatorName, null));
String preyName = parser.getValueByLabel("Prey");
if (StringUtils.isBlank(preyName)) {
getLogger().warn(localStudy, "found empty prey name on line [" + parser.lastLineNumber() + "]");
} else {
Specimen prey = nodeFactory.createSpecimen(localStudy, new TaxonImpl(preyName, null));
String feedingLink = parser.getValueByLabel("Feeding Link?");
if (StringUtils.equals("1", StringUtils.trim(feedingLink))) {
predator.ate(prey);
} else {
predator.interactsWith(prey, InteractType.INTERACTS_WITH);
}
}
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfo method buildTaxonMap.
protected static Map<String, Taxon> buildTaxonMap(LabeledCSVParser parser) throws IOException {
Map<String, Taxon> taxonMap = new HashMap<String, Taxon>();
while (parser.getLine() != null) {
if (StringUtils.isBlank(parser.getValueByLabel("NBN Code"))) {
Taxon taxon = new TaxonImpl();
taxon.setRank(parser.getValueByLabel("rank"));
taxon.setName(StringUtils.replaceChars(parser.getValueByLabel("latin"), "'", ""));
String bioInfoTaxonId = parser.getValueByLabel("my taxon id");
taxon.setExternalId(TaxonomyProvider.BIO_INFO + "taxon:" + bioInfoTaxonId);
taxonMap.put(bioInfoTaxonId, taxon);
}
}
return taxonMap;
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method addPredator.
private Specimen addPredator(Study study, LabeledCSVParser parser, String[] line) throws NodeFactoryException, TermLookupServiceException {
Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Centropomus undecimalis", null));
predatorSpecimen.setLifeStage(nodeFactory.getTermLookupService().lookupTermByName("adult"));
try {
String length = parser.getValueByLabel("Standard Length");
predatorSpecimen.setLengthInMm(Double.parseDouble(length));
} catch (NumberFormatException ex) {
getLogger().warn(study, "found malformed length in line:" + parser.lastLineNumber() + " [" + StringUtils.join(line, ",") + "]");
}
return predatorSpecimen;
}
use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.
the class TaxonUtilTest method toTaxonImageNonEOL.
@Test
public void toTaxonImageNonEOL() {
TaxonImage image = new TaxonImage();
Taxon taxon = new TaxonImpl("Donald duckus", "ZZZ:123");
taxon.setCommonNames("bla @en | boo @de");
taxon.setPath("one | two | three");
Map<String, String> taxonMap = new TreeMap<String, String>(TaxonUtil.taxonToMap(taxon));
taxonMap.put(PropertyAndValueDictionary.THUMBNAIL_URL, "http://foo/bar/thumb");
taxonMap.put(PropertyAndValueDictionary.EXTERNAL_URL, "http://foo/bar");
TaxonImage enrichedImage = TaxonUtil.enrichTaxonImageWithTaxon(taxonMap, image);
assertThat(enrichedImage.getCommonName(), is("bla"));
assertThat(enrichedImage.getTaxonPath(), is("one | two | three"));
assertThat(enrichedImage.getInfoURL(), is("http://foo/bar"));
assertThat(enrichedImage.getThumbnailURL(), is("http://foo/bar/thumb"));
assertThat(enrichedImage.getPageId(), is(nullValue()));
assertThat(enrichedImage.getImageURL(), is(nullValue()));
}
Aggregations