use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method datasetWithNamespace.
private DatasetImpl datasetWithNamespace(String namespace) {
DatasetImpl dataset = new DatasetImpl(namespace, URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
dataset.setConfig(objectNode);
return dataset;
}
use of org.globalbioticinteractions.dataset.DatasetImpl 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));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4jTest method addDatasetToStudyNulls2.
@Test
public void addDatasetToStudyNulls2() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("my title", SOME_DOI, "some citation");
DatasetImpl dataset = new DatasetImpl("some/namespace", null, inStream -> inStream);
study1.setOriginatingDataset(dataset);
StudyNode study = getNodeFactory().getOrCreateStudy(study1);
Node datasetNode = NodeUtil.getDataSetForStudy(study);
assertThat(datasetNode.getProperty(DatasetConstant.NAMESPACE), is("some/namespace"));
assertThat(datasetNode.hasProperty(DatasetConstant.ARCHIVE_URI), is(false));
assertThat(datasetNode.getProperty(DatasetConstant.SHOULD_RESOLVE_REFERENCES), is("true"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDunneIT 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/main/nodes.tsv\",\n" + " \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/main/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"), inStream -> inStream);
dunne2016.setConfig(new ObjectMapper().readTree(configJson));
ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
DatasetImporterForDunne importer = new DatasetImporterForDunne(parserFactory, nodeFactory);
importer.setDataset(dunne2016);
importStudy(importer);
StudyNode study = getStudySingleton(getGraphDb());
assertThat(study, is(notNullValue()));
assertThat(study.getCitation(), is(notNullValue()));
assertThat(getSpecimenCount(study), is(6774 * 2));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForSzoboszlaiIT method importAll.
@Test
public void importAll() throws StudyImporterException, 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\": \"http://datadryad.org/bitstream/handle/10255/dryad.94536/CCPDDlinkdata_v1.csv\",\n" + " \"shapes\": \"http://datadryad.org/bitstream/handle/10255/dryad.94535/CCPDDlocationdata_v1.zip\"\n" + " }\n" + "}");
DatasetImpl dataset = new DatasetImpl("someRepo", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(config);
ParserFactory parserFactory = new ParserFactoryForDataset(dataset);
DatasetImporterForSzoboszlai importer = new DatasetImporterForSzoboszlai(parserFactory, nodeFactory);
importer.setDataset(dataset);
importStudy(importer);
NodeUtil.handleCollectedRelationships(new NodeTypeDirection(getStudySingleton(getGraphDb()).getUnderlyingNode()), relationship -> {
Specimen specimenNode = new SpecimenNode(relationship.getEndNode());
Location sampleLocation = specimenNode.getSampleLocation();
assertThat(sampleLocation, is(notNullValue()));
assertThat(sampleLocation.getLatitude(), is(notNullValue()));
assertThat(sampleLocation.getLongitude(), is(notNullValue()));
});
assertThat(taxonIndex.findTaxonByName("Thunnus thynnus"), is(notNullValue()));
assertThat(nodeFactory.findLocation(new LocationImpl(34.00824202376044, -120.72716166720323, null, null)), is(notNullValue()));
}
Aggregations