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;
}
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");
}
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));
}
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));
}
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());
}
Aggregations