Search in sources :

Example 6 with Study

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

the class StudyImporterForSPIRE method importValidLink.

private void importValidLink(Map<String, String> properties) throws NodeFactoryException {
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl(properties.get(StudyConstant.TITLE), SOURCE_SPIRE, null, properties.get(StudyConstant.DESCRIPTION)));
    try {
        Specimen predator = createSpecimen(properties.get(PREDATOR_NAME), study);
        String locality = properties.get(LOCALITY_ORIGINAL);
        LatLng latLng = getGeoNamesService().findLatLng(locality);
        if (latLng == null) {
            getLogger().warn(study, "failed to find location for county [" + locality + "]");
        } else {
            Location location = nodeFactory.getOrCreateLocation(new LocationImpl(latLng.getLat(), latLng.getLng(), null, null));
            predator.caughtIn(location);
            String habitat = properties.get(OF_HABITAT);
            if (StringUtils.isNotBlank(habitat)) {
                addEnvironment(location, "SPIRE:" + habitat, habitat);
            }
        }
        Specimen prey = createSpecimen(properties.get(PREY_NAME), study);
        predator.ate(prey);
    } catch (NodeFactoryException e) {
        getLogger().warn(study, "failed to import trophic link with properties [" + properties + "]: " + e.getMessage());
    } catch (IOException e) {
        getLogger().warn(study, "failed to import trophic link with properties [" + properties + "]: " + e.getMessage());
    }
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StudyImpl(org.eol.globi.domain.StudyImpl) LocationImpl(org.eol.globi.domain.LocationImpl) LatLng(org.eol.globi.geo.LatLng) IOException(java.io.IOException) Location(org.eol.globi.domain.Location)

Example 7 with Study

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

the class StudyImporterForWrast method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    String citation = "Wrast JL. Spatiotemporal And Habitat-mediated Food Web Dynamics in Lavaca Bay, Texas. 2008. Master Thesis.";
    StudyImpl study1 = new StudyImpl("Wrast 2008", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, null, citation);
    study1.setExternalId("http://www.fisheries.tamucc.edu/people_files/FINAL%20WRAST%20THESIS.pdf");
    Study study = nodeFactory.getOrCreateStudy(study1);
    try {
        LabeledCSVParser csvParser = parserFactory.createParser(LAVACA_BAY_DATA_SOURCE, CharsetConstant.UTF8);
        LengthParser parser = new LengthParserImpl(COLUMN_MAPPER.get(LENGTH_IN_MM));
        getPredatorSpecimenMap().clear();
        while (csvParser.getLine() != null) {
            addNextRecordToStudy(csvParser, study, COLUMN_MAPPER, parser);
        }
    } catch (IOException e) {
        throw new StudyImporterException("failed to create study [" + LAVACA_BAY_DATA_SOURCE + "]", e);
    } finally {
        getPredatorSpecimenMap().clear();
    }
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException)

Example 8 with Study

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

the class StudyImporterForGoMexSI2IT method assertThatSomeDataIsImported.

private static void assertThatSomeDataIsImported(NodeFactory nodeFactory, TaxonIndex taxonIndex) throws StudyImporterException, NodeFactoryException {
    Study study = nodeFactory.findStudy("Divita et al 1983");
    assertSpecimenProperties(((NodeBacked) study).getUnderlyingNode().getGraphDatabase());
    assertNotNull(study);
    assertThat(study.getTitle(), is("Divita et al 1983"));
    assertThat(study.getExternalId(), is(ExternalIdUtil.urlForExternalId("GAME:2689")));
    assertThat(study.getCitation(), is("Regina Divita, Mischelle Creel, Peter Sheridan. 1983. Foods of coastal fishes during brown shrimp Penaeus aztecus, migration from Texas estuaries (June - July 1981)."));
    assertNotNull(nodeFactory.findStudy("Beaumariage 1973"));
    assertNotNull(nodeFactory.findStudy("Baughman, 1943"));
    assertNotNull(taxonIndex.findTaxonByName("Chloroscombrus chrysurus"));
    assertNotNull(taxonIndex.findTaxonByName("Micropogonias undulatus"));
    assertNotNull(taxonIndex.findTaxonByName("Amphipoda"));
    assertNotNull(taxonIndex.findTaxonByName("Crustacea"));
    Taxon taxon = taxonIndex.findTaxonByName("Scomberomorus cavalla");
    List<String> preyList = new ArrayList<String>();
    final List<String> titles = new ArrayList<String>();
    Iterable<Relationship> classifiedAsRels = ((NodeBacked) taxon).getUnderlyingNode().getRelationships(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS));
    int count = 0;
    for (Relationship classifiedAsRel : classifiedAsRels) {
        Node predatorSpecimen = classifiedAsRel.getStartNode();
        Specimen predator = new SpecimenNode(predatorSpecimen);
        Iterable<Relationship> stomachContents = NodeUtil.getStomachContents(predator);
        for (Relationship prey : stomachContents) {
            Relationship singleRelationship = prey.getEndNode().getSingleRelationship(NodeUtil.asNeo4j(RelTypes.CLASSIFIED_AS), Direction.OUTGOING);
            preyList.add((String) singleRelationship.getEndNode().getProperty("name"));
        }
        count++;
        Relationship collectedBy = predatorSpecimen.getSingleRelationship(NodeUtil.asNeo4j(RelTypes.COLLECTED), Direction.INCOMING);
        assertThat(collectedBy, is(notNullValue()));
        String title = (String) collectedBy.getStartNode().getProperty("title");
        titles.add(title);
    }
    assertThat(count > 7, is(true));
    assertThat(preyList, hasItem("Organic matter"));
    assertThat(preyList, hasItem("Triglidae"));
    assertThat(preyList, hasItem("Sparidae"));
    assertThat(titles, hasItem("Beaumariage 1973"));
    assertThat(titles, hasItem("Blanton et al 1972"));
    assertNotNull(taxon);
    final String footprintWKT = WKT_FOOTPRINT2;
    LocationImpl expectedLocation = new LocationImpl(29.346953, -92.980614, -13.641, footprintWKT);
    expectedLocation.setLocality("Louisiana inner continental shelf");
    Location location = nodeFactory.findLocation(expectedLocation);
    assertThat(location, is(notNullValue()));
    assertThat(location.getFootprintWKT(), is(footprintWKT));
    assertThat(location.getLocality(), is("Louisiana inner continental shelf"));
    assertNotNull(location);
    List<Environment> environments = location.getEnvironments();
    assertThat(environments.size(), not(is(0)));
    assertThat(environments.get(0).getExternalId(), is("http://cmecscatalog.org/classification/aquaticSetting/13"));
    assertThat(environments.get(0).getName(), is("Marine Nearshore Subtidal"));
    assertNotNull(nodeFactory.findStudy("GoMexSI"));
}
Also used : Study(org.eol.globi.domain.Study) Taxon(org.eol.globi.domain.Taxon) JsonNode(org.codehaus.jackson.JsonNode) Node(org.neo4j.graphdb.Node) SpecimenNode(org.eol.globi.domain.SpecimenNode) ArrayList(java.util.ArrayList) SpecimenNode(org.eol.globi.domain.SpecimenNode) Specimen(org.eol.globi.domain.Specimen) NodeBacked(org.eol.globi.domain.NodeBacked) Relationship(org.neo4j.graphdb.Relationship) LocationImpl(org.eol.globi.domain.LocationImpl) Environment(org.eol.globi.domain.Environment) Location(org.eol.globi.domain.Location)

Example 9 with Study

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

the class StudyImporterForGitHubDataIT method importGoMexSI.

@Test
public void importGoMexSI() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    importer.importData("gomexsi/interaction-data");
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    for (Study study : allStudies) {
        assertThat(study.getSource(), is(Matchers.notNullValue()));
    }
}
Also used : Study(org.eol.globi.domain.Study) Test(org.junit.Test)

Example 10 with Study

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

the class StudyImporterForGitHubDataIT method importSmithsonian.

@Test
public void importSmithsonian() throws StudyImporterException {
    StudyImporterForGitHubData importer = createImporter();
    importer.importData("millerse/Smithsonian-Repository-Interactions");
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    Map<String, String> citationDOIs = new TreeMap<String, String>();
    for (Study study : allStudies) {
        citationDOIs.put(study.getCitation(), study.getDOI());
    }
    String citation = "Raboy, Becky E., and James M. Dietz. Diet, Foraging, and Use of Space in Wild Golden-headed Lion Tamarins. American Journal of Primatology, 63(1):, 2004, 1-15. Accessed April 20, 2015. http://hdl.handle.net/10088/4251.";
    assertThat(citationDOIs.keySet(), hasItem(citation));
    String doi = citationDOIs.get(citation);
    assertThat(doi, startsWith("doi:Raboy"));
    assertThat(allStudies.get(0).getSource(), containsString("Miller"));
    assertThat(taxonIndex.findTaxonByName("Leontopithecus chrysomelas"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) Matchers.containsString(org.hamcrest.Matchers.containsString) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

Study (org.eol.globi.domain.Study)141 Test (org.junit.Test)84 StudyImpl (org.eol.globi.domain.StudyImpl)61 Specimen (org.eol.globi.domain.Specimen)38 Relationship (org.neo4j.graphdb.Relationship)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)32 IOException (java.io.IOException)30 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)24 Location (org.eol.globi.domain.Location)24 StringWriter (java.io.StringWriter)21 LocationImpl (org.eol.globi.domain.LocationImpl)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 Taxon (org.eol.globi.domain.Taxon)16 SpecimenNode (org.eol.globi.domain.SpecimenNode)14 Date (java.util.Date)13 DatasetImpl (org.eol.globi.service.DatasetImpl)13 Node (org.neo4j.graphdb.Node)12 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)10 InteractType (org.eol.globi.domain.InteractType)9