use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method addDatasetToStudy.
@Test
public void addDatasetToStudy() throws NodeFactoryException, IOException {
StudyImpl study1 = new StudyImpl("my title", SOME_DOI, "some citation");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
dataset.setConfig(objectNode);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
Dataset origDataset = study.getOriginatingDataset();
assertThat(origDataset, is(notNullValue()));
assertThat(origDataset.getArchiveURI().toString(), is("some:uri"));
assertThat(origDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"), is("false"));
String expectedConfig = new ObjectMapper().writeValueAsString(objectNode);
assertThat(new ObjectMapper().writeValueAsString(origDataset.getConfig()), is(expectedConfig));
Node datasetNode = NodeUtil.getDataSetForStudy(study);
assertThat(datasetNode.getProperty(DatasetConstant.NAMESPACE), is("some/namespace"));
assertThat(datasetNode.getProperty("archiveURI"), is("some:uri"));
assertThat(datasetNode.getProperty(DatasetConstant.SHOULD_RESOLVE_REFERENCES), is("false"));
StudyImpl otherStudy = new StudyImpl("my other title", SOME_DOI, "some citation");
otherStudy.setOriginatingDataset(dataset);
StudyNode studySameDataset = getNodeFactory().getOrCreateStudy(otherStudy);
Node datasetNodeOther = NodeUtil.getDataSetForStudy(studySameDataset);
assertThat(datasetNode.getId(), is(datasetNodeOther.getId()));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method assertDataset.
protected void assertDataset(String citationKey) {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
objectNode.put(citationKey, "some citation");
dataset.setConfig(objectNode);
Dataset origDataset = getNodeFactory().getOrCreateDataset(dataset);
assertThat(origDataset, is(notNullValue()));
assertThat(origDataset.getArchiveURI().toString(), is("some:uri"));
assertThat(origDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"), is("false"));
assertThat(origDataset.getOrDefault(DatasetConstant.CITATION, "no citation"), is("some citation"));
assertThat(origDataset.getCitation(), is("some citation"));
assertThat(origDataset.getOrDefault(DatasetConstant.LAST_SEEN_AT, "1"), is(not("1")));
Dataset datasetAnother = getNodeFactory().getOrCreateDataset(dataset);
assertThat(((DatasetNode) datasetAnother).getNodeID(), is(((DatasetNode) origDataset).getNodeID()));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForSzoboszlaiTest method importShapes2.
@Test
public void importShapes2() throws IOException {
Dataset testDataset = getTestDataset();
ParserFactory parserFactory = new ParserFactoryForDataset(testDataset);
DatasetImporterForSzoboszlai studyImporterForSzoboszlai = new DatasetImporterForSzoboszlai(parserFactory, nodeFactory);
studyImporterForSzoboszlai.setDataset(testDataset);
Map<Integer, LatLng> localityMap = studyImporterForSzoboszlai.importShapes2();
assertLocalityMap(localityMap);
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForSzoboszlaiTest method getTestDataset.
private Dataset getTestDataset() throws IOException {
JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Szoboszlai AI, Thayer JA, Wood SA, Sydeman WJ, Koehn LE (2015) Data from: Forage species in predator diets: synthesis of data from the California Current. Dryad Digital Repository. https://doi.org/10.5061/dryad.nv5d2\",\n" + " \"doi\": \"https://doi.org/10.5061/dryad.nv5d2\",\n" + " \"format\": \"szoboszlai\",\n" + " \"resources\": {\n" + " \"links\": \"szoboszlai/CCPDDlinkdata_v2.csv\",\n" + " \"shapes\": \"szoboszlai/CCPDDlocationdata_test.zip\"\n" + " }\n" + "}");
Dataset dataset = new DatasetLocal(inStream -> inStream);
dataset.setConfig(config);
return dataset;
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class CmdGenerateReportTest method generateCollectionReport.
@Test
public void generateCollectionReport() throws NodeFactoryException {
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
Dataset originatingDatasetNode = nodeFactory.getOrCreateDataset(originatingDataset);
StudyImpl study1 = new StudyImpl("a title", null, "citation");
study1.setOriginatingDataset(originatingDatasetNode);
createStudy(study1);
StudyImpl study2 = new StudyImpl("another title", null, "citation");
study2.setOriginatingDataset(originatingDatasetNode);
createStudy(study2);
resolveNames();
new CmdGenerateReport(getGraphDb(), cacheService).generateReportForCollection();
IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query("*", "*");
assertThat(reports.size(), is(1));
Node reportNode = reports.getSingle();
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Aggregations