use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class ExporterTaxaDistinctTest method excludeNoMatchNames.
@Test
public void excludeNoMatchNames() throws NodeFactoryException, IOException {
Study study = nodeFactory.createStudy(new StudyImpl("bla", null, null, null));
Specimen predator = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:1234"));
Specimen prey = nodeFactory.createSpecimen(study, new TaxonImpl(PropertyAndValueDictionary.NO_MATCH, "EOL:122"));
predator.ate(prey);
assertThat(exportStudy(study), not(containsString(PropertyAndValueDictionary.NO_MATCH)));
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class InteractionListenerImpl method createSpecimen.
private Specimen createSpecimen(Map<String, String> link, Study study, String taxonNameLabel, String taxonIdLabel, String bodyPartName, String bodyPartId) throws StudyImporterException {
String sourceTaxonName = link.get(taxonNameLabel);
String sourceTaxonId = link.get(taxonIdLabel);
Specimen source = nodeFactory.createSpecimen(study, new TaxonImpl(sourceTaxonName, sourceTaxonId));
setBasisOfRecordIfAvailable(link, source);
setDateTimeIfAvailable(link, source);
setBodyPartIfAvailable(link, source, bodyPartName, bodyPartId);
return source;
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForPlanque method addInteractionForPredator.
private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(normalizeName(predatorName), null));
// from http://www.geonames.org/630674/barents-sea.html
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(74.0, 36.0, null, null));
predator.caughtIn(location);
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(normalizeName(preyName), null));
prey.caughtIn(location);
predator.ate(prey);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForKelpForest method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
String source = "Beas-Luna, R., Novak, M., Carr, M. H., Tinker, M. T., Black, A., Caselle, J. E., … Iles, A. (2014). An Online Database for Informing Ecological Network Models: http://kelpforest.ucsc.edu. PLoS ONE, 9(10), e109356. doi:10.1371/journal.pone.0109356";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl(source, source, "doi:10.1371/journal.pone.0109356", source));
LabeledCSVParser parser = parserFactory.createParser(NODES, "UTF-8");
String[] line;
Map<String, Long> nameToId = new HashMap<String, Long>();
while ((line = parser.getLine()) != null) {
if (line.length > 2) {
String name = parser.getValueByLabel("working_name");
String itisId = parser.getValueByLabel("itis_id");
Long id = StringUtils.isBlank(itisId) ? null : Long.parseLong(itisId);
id = (id != null && id > 0L) ? id : null;
nameToId.put(name, id);
}
}
Map<String, InteractType> typeToType = new HashMap<String, InteractType>() {
{
put("trophic", InteractType.ATE);
put("parasitic", InteractType.PARASITE_OF);
}
};
parser = parserFactory.createParser(LINKS, "UTF-8");
while ((line = parser.getLine()) != null) {
if (line.length > 2) {
String interactionType = parser.getValueByLabel("type");
InteractType interactType = typeToType.get(interactionType);
if (null == interactType) {
LOG.warn("ignoring type [" + interactionType + "] on line: [" + (parser.getLastLineNumber() + 1) + "]");
} else {
Specimen sourceSpecimen = createSpecimen(parser, nameToId, "node_1_working_name", "node1_stage", study);
Specimen targetSpecimen = createSpecimen(parser, nameToId, "node_2_working_name", "node2_stage", study);
sourceSpecimen.interactsWith(targetSpecimen, interactType);
}
}
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("failed to import", e);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForJRFerrerParis method addAssociation.
private void addAssociation(Study study, LabeledCSVParser parser, String butterflyName, String plantName) throws StudyImporterException {
Specimen instigatorSpecimen;
try {
instigatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(butterflyName, null));
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create butterfly specimen [" + butterflyName + "] on line [" + parser.lastLineNumber() + "]", e);
}
Specimen targetSpecimen;
try {
targetSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(plantName, null));
instigatorSpecimen.ate(targetSpecimen);
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to associate butterfly [" + butterflyName + "] to plant [" + plantName + "] on line [" + parser.lastLineNumber() + "]", e);
}
}
Aggregations