Search in sources :

Example 26 with DatasetImpl

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

the class StudyImporterForWoodTest method createImporter.

static StudyImporterForWood createImporter(NodeFactory nodeFactory) throws IOException {
    JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Wood SA, Russell R, Hanson D, Williams RJ, Dunne JA (2015) Data from: Effects of spatial scale of sampling on food web structure. Dryad Digital Repository. http://dx.doi.org/10.5061/dryad.g1qr6\",\n" + "  \"doi\": \"http://dx.doi.org/10.5061/dryad.g1qr6\",\n" + "  \"format\": \"wood\",\n" + "  \"resources\": {\n" + "    \"links\": \"http://datadryad.org/bitstream/handle/10255/dryad.93018/WoodEtal_Append1_v2.csv\"  \n" + "  },\n" + "  \"location\": {\n" + "    \"locality\": {\n" + "      \"id\": \"GEONAMES:5873327\",\n" + "      \"name\": \"Sanak Island, Alaska, USA\"\n" + "    },\n" + "    \"latitude\": 54.42972,\n" + "    \"longitude\": -162.70889\n" + "  }\n" + "}");
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
    dataset.setConfig(config);
    StudyImporterForWood wood = new StudyImporterForWood(new ParserFactoryForDataset(dataset), nodeFactory);
    wood.setDataset(dataset);
    return wood;
}
Also used : JsonNode(org.codehaus.jackson.JsonNode) DatasetImpl(org.eol.globi.service.DatasetImpl) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 27 with DatasetImpl

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

the class StudyImporterForTSVTest method importFewLines.

@Test
public void importFewLines() throws StudyImporterException {
    StudyImporterForTSV importer = new StudyImporterForTSV(new TestParserFactory(firstFewLines), nodeFactory);
    importer.setDataset(new DatasetImpl("someRepo", URI.create("http://example.com")));
    importStudy(importer);
    assertExists("Leptoconchus incycloseris");
    assertExists("Sandalolitha dentata");
    assertStudyTitles("someRepodoi:10.1007/s13127-011-0039-1");
}
Also used : DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 28 with DatasetImpl

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

the class LinkerTrustyNanoPubsTest method dataOutput.

@Test
public void dataOutput() throws NodeFactoryException, OpenRDFException, IOException, MalformedNanopubException, TrustyUriException {
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com/dataset"));
    populateDataset(dataset);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    LinkerTrustyNanoPubs linker = new LinkerTrustyNanoPubs(getGraphDb(), new NanopubOutputStreamFactory() {

        @Override
        public OutputStream outputStreamFor(Nanopub nanopub) {
            try {
                return new GZIPOutputStream(byteArrayOutputStream);
            } catch (IOException e) {
                throw new RuntimeException("kaboom!");
            }
        }
    });
    linker.link();
    String actualTrig = toTrigString(new GZIPInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())));
    String expectedTrig = toTrigString(getClass().getResourceAsStream("trusty.nanopub.trig"));
    assertThat(actualTrig, is(expectedTrig));
}
Also used : Nanopub(org.nanopub.Nanopub) MakeTrustyNanopub(org.nanopub.trusty.MakeTrustyNanopub) GZIPOutputStream(java.util.zip.GZIPOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) DatasetImpl(org.eol.globi.service.DatasetImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) GZIPInputStream(java.util.zip.GZIPInputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 29 with DatasetImpl

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

the class ReportGeneratorTest method generateCollectionReport.

@Test
public void generateCollectionReport() throws NodeFactoryException {
    DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
    StudyImpl study1 = new StudyImpl("a title", "source", null, "citation");
    study1.setOriginatingDataset(originatingDataset);
    createStudy(study1);
    StudyImpl study2 = new StudyImpl("another title", "another source", null, "citation");
    study2.setOriginatingDataset(originatingDataset);
    createStudy(study2);
    resolveNames();
    new ReportGenerator(getGraphDb()).generateReportForCollection();
    IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query("*:*");
    assertThat(reports.size(), is(1));
    Node reportNode = reports.getSingle();
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Also used : Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) Test(org.junit.Test)

Example 30 with DatasetImpl

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

the class NodeFactoryWithDatasetContextTest method createStudy.

@Test
public void createStudy() {
    NodeFactory factory = Mockito.mock(NodeFactory.class);
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
    NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
    StudyImpl study = new StudyImpl("some title", "some source", "some doi", "some citation");
    study.setExternalId("some:id");
    factoryWithDS.createStudy(study);
    ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
    verify(factory).createStudy(argument.capture());
    assertEquals("globi:some/namespace", argument.getValue().getSourceId());
    assertEquals("some title", argument.getValue().getTitle());
    assertEquals("some citation", argument.getValue().getCitation());
    assertEquals("some doi", argument.getValue().getDOI());
    assertEquals("some:id", argument.getValue().getExternalId());
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.eol.globi.service.DatasetImpl) 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