Search in sources :

Example 21 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class StudyImporterForGoMexSI2 method createSpecimen.

private Specimen createSpecimen(Study study, Map<String, String> properties) throws StudyImporterException {
    Specimen specimen = nodeFactory.createSpecimen(study, new TaxonImpl(properties.get(PropertyAndValueDictionary.NAME), null));
    specimen.setLengthInMm(doubleValueOrNull(properties, SpecimenConstant.LENGTH_IN_MM));
    specimen.setFrequencyOfOccurrence(doubleValueOrNull(properties, SpecimenConstant.FREQUENCY_OF_OCCURRENCE));
    setSpecimenProperty(specimen, SpecimenConstant.FREQUENCY_OF_OCCURRENCE_PERCENT, properties);
    specimen.setTotalCount(integerValueOrNull(properties, SpecimenConstant.TOTAL_COUNT));
    setSpecimenProperty(specimen, SpecimenConstant.TOTAL_COUNT_PERCENT, properties);
    specimen.setTotalVolumeInMl(doubleValueOrNull(properties, SpecimenConstant.TOTAL_VOLUME_IN_ML));
    setSpecimenProperty(specimen, SpecimenConstant.TOTAL_VOLUME_PERCENT, properties);
    addLifeStage(properties, specimen);
    addPhysiologicalState(properties, specimen);
    addBodyPart(properties, specimen);
    // add all original GoMexSI properties for completeness
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        if (entry.getKey().startsWith(GOMEXSI_NAMESPACE)) {
            specimen.setProperty(entry.getKey(), entry.getValue());
        }
    }
    return specimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class StudyImporterForINaturalist method createAssociation.

private Specimen createAssociation(long observationId, String interactionDataType, InteractType interactType, JsonNode observation, Taxon targetTaxon, Taxon sourceTaxonName, Study study, Date observationDate) throws StudyImporterException, NodeFactoryException {
    Specimen sourceSpecimen = getSourceSpecimen(observationId, interactionDataType, sourceTaxonName, study);
    setBasisOfRecord(sourceSpecimen);
    Specimen targetSpecimen = nodeFactory.createSpecimen(study, targetTaxon);
    setBasisOfRecord(targetSpecimen);
    sourceSpecimen.interactsWith(targetSpecimen, interactType);
    setCollectionDate(sourceSpecimen, targetSpecimen, observationDate);
    setCollectionDate(sourceSpecimen, sourceSpecimen, observationDate);
    Location location = parseLocation(observation);
    sourceSpecimen.caughtIn(location);
    targetSpecimen.caughtIn(location);
    return sourceSpecimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) Location(org.eol.globi.domain.Location)

Example 23 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class ExporterOccurrenceAggregatesTest method collectSpecimen.

private Specimen collectSpecimen(Study myStudy, String scientificName, String externalId) throws NodeFactoryException {
    Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl(scientificName, externalId));
    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()));
    return specimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) Date(java.util.Date) TermImpl(org.eol.globi.domain.TermImpl)

Example 24 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class ExporterOccurrenceAggregatesTest method eatPrey.

private Specimen eatPrey(Specimen specimen, String scientificName, String externalId, Study study) throws NodeFactoryException {
    Specimen otherSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl(scientificName, externalId));
    otherSpecimen.setVolumeInMilliLiter(124.0);
    specimen.ate(otherSpecimen);
    return otherSpecimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 25 with Specimen

use of org.eol.globi.domain.Specimen in project eol-globi-data by jhpoelen.

the class ExporterOccurrencesTest method dontExportToCSVSpecimenEmptyStomach.

@Test
public void dontExportToCSVSpecimenEmptyStomach() throws NodeFactoryException, IOException {
    Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
    Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:123"));
    specimen.setBasisOfRecord(new TermImpl("test:123", "aBasisOfRecord"));
    resolveNames();
    StringWriter row = new StringWriter();
    exportOccurrences().exportStudy(myStudy, row, true);
    String expected = "";
    expected += getExpectedHeader();
    expected += "\nglobi:occur:2\tEOL:123\t\t\t\t\t\t\t\t\t\t\t\t\taBasisOfRecord\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
    assertThat(row.getBuffer().toString(), equalTo(expected));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) TermImpl(org.eol.globi.domain.TermImpl) Test(org.junit.Test)

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