Search in sources :

Example 6 with TermImpl

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

the class GeoNamesServiceImpl method getCentroidForLocale.

private LatLng getCentroidForLocale(String locale) throws IOException {
    LatLng point = null;
    TermImpl term = LOCALE_TO_GEONAMES.get(locale);
    // see https://github.com/jhpoelen/eol-globi-data/issues/39
    if (term != null && !term.equals(GEO_TERM_EARTH)) {
        String geoNamesTerm = term.getId();
        if (LOCALE_TO_GEONAMES.containsKey(locale)) {
            point = getCentroidForGeoNameTerm(geoNamesTerm);
        }
        if (point != null) {
            pointCache.put(geoNamesTerm, point);
        }
    }
    return point;
}
Also used : LatLng(org.eol.globi.geo.LatLng) TermImpl(org.eol.globi.domain.TermImpl)

Example 7 with TermImpl

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

the class StudyImporterNodesAndLinks method parseLocality.

private static TermImpl parseLocality(JsonNode desc) {
    TermImpl locality = null;
    JsonNode location = desc.get("location");
    if (location != null) {
        JsonNode locale = location.get("locality");
        if (locale != null) {
            JsonNode id = locale.get("id");
            JsonNode name = locale.get("name");
            if (id != null && name != null) {
                locality = new TermImpl(id.asText(), name.asText());
            }
        }
    }
    return locality;
}
Also used : JsonNode(org.codehaus.jackson.JsonNode) TermImpl(org.eol.globi.domain.TermImpl)

Example 8 with TermImpl

use of org.eol.globi.domain.TermImpl 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 9 with TermImpl

use of org.eol.globi.domain.TermImpl 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)

Example 10 with TermImpl

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

the class ExporterOccurrencesTest method createTestData.

private void createTestData(Double length) throws NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
    Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:327955"));
    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, ExportTestUtil.utcTestDate());
    if (null != length) {
        specimen.setLengthInMm(length);
    }
    Location location = nodeFactory.getOrCreateLocation(new LocationImpl(12.0, -1.0, -60.0, null));
    specimen.caughtIn(location);
    Specimen wolf1 = eatWolf(specimen, myStudy);
    wolf1.caughtIn(location);
    Specimen wolf2 = eatWolf(specimen, myStudy);
    wolf2.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) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

Aggregations

TermImpl (org.eol.globi.domain.TermImpl)19 TaxonImpl (org.eol.globi.domain.TaxonImpl)11 Specimen (org.eol.globi.domain.Specimen)9 Study (org.eol.globi.domain.Study)7 StudyImpl (org.eol.globi.domain.StudyImpl)7 Location (org.eol.globi.domain.Location)6 LocationImpl (org.eol.globi.domain.LocationImpl)6 Date (java.util.Date)5 HashMap (java.util.HashMap)3 Taxon (org.eol.globi.domain.Taxon)3 Term (org.eol.globi.domain.Term)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 LatLng (org.eol.globi.geo.LatLng)2 CSVParse (com.Ostermiller.util.CSVParse)1 Database (com.healthmarketscience.jackcess.Database)1 DatabaseBuilder (com.healthmarketscience.jackcess.DatabaseBuilder)1 Table (com.healthmarketscience.jackcess.Table)1 Record (com.univocity.parsers.common.record.Record)1 TsvParser (com.univocity.parsers.tsv.TsvParser)1