Search in sources :

Example 81 with Specimen

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);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) Date(java.util.Date) Location(org.eol.globi.domain.Location)

Example 82 with Specimen

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());
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonNode(org.eol.globi.domain.TaxonNode) Relationship(org.neo4j.graphdb.Relationship) SpecimenNode(org.eol.globi.domain.SpecimenNode)

Example 83 with Specimen

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));
}
Also used : Study(org.eol.globi.domain.Study) Matchers.containsString(org.hamcrest.Matchers.containsString) SpecimenNode(org.eol.globi.domain.SpecimenNode) DatasetLocal(org.eol.globi.service.DatasetLocal) Specimen(org.eol.globi.domain.Specimen) Relationship(org.neo4j.graphdb.Relationship) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 84 with Specimen

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));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) Relationship(org.neo4j.graphdb.Relationship) SpecimenNode(org.eol.globi.domain.SpecimenNode) Location(org.eol.globi.domain.Location) Test(org.junit.Test)

Example 85 with Specimen

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);
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) LocationImpl(org.eol.globi.domain.LocationImpl) Date(java.util.Date) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

Aggregations

Specimen (org.eol.globi.domain.Specimen)91 TaxonImpl (org.eol.globi.domain.TaxonImpl)59 Study (org.eol.globi.domain.Study)38 StudyImpl (org.eol.globi.domain.StudyImpl)34 Location (org.eol.globi.domain.Location)31 LocationImpl (org.eol.globi.domain.LocationImpl)22 Test (org.junit.Test)17 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)15 IOException (java.io.IOException)15 Date (java.util.Date)14 Relationship (org.neo4j.graphdb.Relationship)12 HashMap (java.util.HashMap)11 Taxon (org.eol.globi.domain.Taxon)11 SpecimenNode (org.eol.globi.domain.SpecimenNode)9 TermImpl (org.eol.globi.domain.TermImpl)9 ArrayList (java.util.ArrayList)8 InteractType (org.eol.globi.domain.InteractType)7 LatLng (org.eol.globi.geo.LatLng)6 Map (java.util.Map)5 TaxonNode (org.eol.globi.domain.TaxonNode)5