Search in sources :

Example 6 with DatasetImpl

use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method sourceCitationDatasetNoConfig.

@Test
public void sourceCitationDatasetNoConfig() {
    String citation = CitationUtil.sourceCitationLastAccessed(new DatasetImpl("some/namespace", URI.create("http://example")));
    assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
Also used : DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 7 with DatasetImpl

use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.

the class ReferenceUtilTest method sourceCitationDataset.

@Test
public void sourceCitationDataset() throws IOException {
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example"));
    JsonNode config = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"archive.zip\" } }");
    dataset.setConfig(config);
    String citation = CitationUtil.sourceCitationLastAccessed(dataset);
    assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
Also used : JsonNode(org.codehaus.jackson.JsonNode) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 8 with DatasetImpl

use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.

the class StudyImporterForDunneTest method importStudy.

@Test
public void importStudy() throws StudyImporterException, IOException {
    String configJson = "{ \"citation\": \"blabla\",\n" + "  \"format\": \"dunne\",\n" + "  \"resources\": {\n" + "    \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/nodes.tsv\",\n" + "    \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/links.tsv\"\n" + "  },\n" + "  \"location\": {\n" + "    \"locality\": {\n" + "      \"id\": \"GEONAMES:5873327\",\n" + "      \"name\": \"Sanak Island, Alaska, USA\"\n" + "    },\n" + "    \"latitude\": 60,\n" + "    \"longitude\": 60\n" + "  }\n" + "}";
    JsonNode jsonNode = new ObjectMapper().readTree(configJson);
    DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
    dunne2016.setConfig(jsonNode);
    ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
    StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
    importer.setDataset(dunne2016);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    assertThat(study, is(notNullValue()));
    Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
    int count = 0;
    for (Relationship specimen : specimens) {
        count++;
    }
    assertThat(count, is(1804 * 2));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) JsonNode(org.codehaus.jackson.JsonNode) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 9 with DatasetImpl

use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.

the class StudyImporterForDunneTest method importStudy2.

@Test
public void importStudy2() throws StudyImporterException, IOException {
    String configJson = "{ \"citation\": \"blabla\",\n" + "  \"format\": \"dunne\",\n" + "  \"resources\": {\n" + "    \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/nodes.tsv\",\n" + "    \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/links.tsv\"\n" + "  },\n" + "  \"location\": {\n" + "    \"locality\": {\n" + "      \"id\": \"GEONAMES:5873327\",\n" + "      \"name\": \"Sanak Island, Alaska, USA\"\n" + "    },\n" + "    \"latitude\": 60,\n" + "    \"longitude\": 60\n" + "  }\n" + "}";
    DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
    dunne2016.setConfig(new ObjectMapper().readTree(configJson));
    ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
    StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
    importer.setDataset(dunne2016);
    importStudy(importer);
    Study study = getStudySingleton(getGraphDb());
    assertThat(study, is(notNullValue()));
    assertThat(study.getSource(), containsString("Accessed at "));
    Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
    int count = 0;
    for (Relationship specimen : specimens) {
        count++;
    }
    assertThat(count, is(6774 * 2));
}
Also used : Study(org.eol.globi.domain.Study) Relationship(org.neo4j.graphdb.Relationship) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 10 with DatasetImpl

use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.

the class StudyImporterForCoetzerTest method importSome.

@Test
public void importSome() throws StudyImporterException, IOException {
    StudyImporterForCoetzer importer = new StudyImporterForCoetzer(null, nodeFactory);
    DatasetImpl dataset = new DatasetLocal();
    JsonNode config = new ObjectMapper().readTree("{\"citation\": \"source citation\", \"resources\": {\"archive\": \"coetzer/CatalogOfAfrotropicalBees.zip\"}}");
    dataset.setConfig(config);
    importer.setDataset(dataset);
    importStudy(importer);
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    for (Study allStudy : allStudies) {
        assertThat(allStudy.getSource(), startsWith("source citation"));
        assertThat(allStudy.getSource(), containsString("Accessed at"));
    }
    assertThat(taxonIndex.findTaxonByName("Agrostis tremula"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Coelioxys erythrura"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Patellapis namaquensis"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) JsonNode(org.codehaus.jackson.JsonNode) DatasetImpl(org.eol.globi.service.DatasetImpl) DatasetLocal(org.eol.globi.service.DatasetLocal) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Aggregations

DatasetImpl (org.eol.globi.service.DatasetImpl)45 Test (org.junit.Test)31 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)24 JsonNode (org.codehaus.jackson.JsonNode)16 Study (org.eol.globi.domain.Study)13 Relationship (org.neo4j.graphdb.Relationship)9 ArrayList (java.util.ArrayList)6 ObjectNode (org.codehaus.jackson.node.ObjectNode)6 StudyImpl (org.eol.globi.domain.StudyImpl)6 Dataset (org.eol.globi.service.Dataset)6 Node (org.neo4j.graphdb.Node)5 InputStream (java.io.InputStream)4 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)4 NodeFactoryWithDatasetContext (org.eol.globi.data.NodeFactoryWithDatasetContext)3 LogContext (org.eol.globi.domain.LogContext)3 Specimen (org.eol.globi.domain.Specimen)3 Taxon (org.eol.globi.domain.Taxon)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2