use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForRaymond method parseDietObservation.
private void parseDietObservation(LabeledCSVParser dietParser, Study study) throws StudyImporterException {
try {
Specimen predator = getSpecimen(dietParser, "PREDATOR_NAME", "PREDATOR_LIFE_STAGE", study);
dietParser.getValueByLabel("ALTITUDE_MIN");
dietParser.getValueByLabel("ALTITUDE_MAX");
dietParser.getValueByLabel("DEPTH_MIN");
dietParser.getValueByLabel("DEPTH_MAX");
Location sampleLocation = parseLocation(dietParser, study);
predator.caughtIn(sampleLocation);
Specimen prey = getSpecimen(dietParser, "PREY_NAME", "PREY_LIFE_STAGE", study);
prey.caughtIn(sampleLocation);
predator.ate(prey);
Date date = parseCollectionDate(dietParser);
nodeFactory.setUnixEpochProperty(prey, date);
nodeFactory.setUnixEpochProperty(predator, date);
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to import data", e);
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForLifeWatchGreeceTest method addTaxonNameForSpecimenNode.
private void addTaxonNameForSpecimenNode(Set<String> taxa, Node startNode) {
Specimen predatorSpecimen = new SpecimenNode(startNode);
Iterable<Relationship> classifications = NodeUtil.getClassifications(predatorSpecimen);
for (Relationship classification : classifications) {
taxa.add(new TaxonNode(classification.getEndNode()).getName());
}
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForLifeWatchGreeceTest method readAssociations.
@Test
public void readAssociations() throws StudyImporterException {
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
assertThat(studies.size(), is(0));
ParserFactoryLocal parserFactory = new ParserFactoryLocal();
StudyImporterForLifeWatchGreece importer = new StudyImporterForLifeWatchGreece(parserFactory, nodeFactory);
importer.setDataset(new DatasetLocal());
importStudy(importer);
studies = NodeUtil.findAllStudies(getGraphDb());
assertThat(studies.size(), is(146));
Set<String> taxa = new HashSet<String>();
int totalPredatorPreyRelationships = 0;
for (Study study : studies) {
assertThat(study.getCitation(), is(notNullValue()));
assertThat(study.getTitle(), containsString("greece"));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
for (Relationship collectedRel : specimens) {
addTaxonNameForSpecimenNode(taxa, collectedRel.getEndNode());
Specimen predatorSpecimen = new SpecimenNode(collectedRel.getEndNode());
Iterable<Relationship> prey = NodeUtil.getStomachContents(predatorSpecimen);
for (Relationship ateRel : prey) {
totalPredatorPreyRelationships++;
addTaxonNameForSpecimenNode(taxa, ateRel.getEndNode());
}
}
}
assertThat(taxa.contains("Aves"), is(true));
assertThat(totalPredatorPreyRelationships, is(793));
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class StudyImporterForRobledoTest method createAndPopulateStudy.
@Test
public void createAndPopulateStudy() throws StudyImporterException, NodeFactoryException {
StudyImporterForRobledo importer = new StudyImporterForRobledo(new ParserFactoryLocal(), nodeFactory);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertNotNull(taxonIndex.findTaxonByName("Heliconia imbricata"));
assertNotNull(taxonIndex.findTaxonByName("Renealmia alpinia"));
assertNotNull(nodeFactory.findStudy(study.getTitle()));
int count = 0;
Iterable<Relationship> specimenRels = NodeUtil.getSpecimens(study);
for (Relationship specimenRel : specimenRels) {
Specimen specimen1 = new SpecimenNode(specimenRel.getEndNode());
Location sampleLocation = specimen1.getSampleLocation();
assertThat(sampleLocation, is(notNullValue()));
assertThat(sampleLocation.getAltitude(), is(35.0));
assertThat(Math.round(sampleLocation.getLongitude()), is(-84L));
assertThat(Math.round(sampleLocation.getLatitude()), is(10L));
count++;
}
assertThat(count, is(93));
}
use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.
the class ExporterAssociationsTest method createTestData.
private void createTestData(Double length) throws NodeFactoryException, ParseException {
Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl("myStudy", "data\tsource description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:123"));
specimen.setStomachVolumeInMilliLiter(666.0);
specimen.setLifeStage(new TermImpl("GLOBI:JUVENILE", "JUVENILE"));
specimen.setPhysiologicalState(new TermImpl("GLOBI:DIGESTATE", "DIGESTATE"));
specimen.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
nodeFactory.setUnixEpochProperty(specimen, new Date(ExportTestUtil.utcTestTime()));
eats(specimen, "Canis lupus", "EOL:456", myStudy);
eats(specimen, "Felis whateverus", PropertyAndValueDictionary.NO_MATCH, myStudy);
if (null != length) {
specimen.setLengthInMm(length);
}
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(13.0, 45.9, -60.0, null));
specimen.caughtIn(location);
}
Aggregations