Search in sources :

Example 36 with DatasetImpl

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 37 with DatasetImpl

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));
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) Test(org.junit.Test)

Example 38 with DatasetImpl

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"));
}
Also used : LocationNode(org.eol.globi.domain.LocationNode) EnvironmentNode(org.eol.globi.domain.EnvironmentNode) SpecimenNode(org.eol.globi.domain.SpecimenNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Node(org.neo4j.graphdb.Node) DatasetNode(org.eol.globi.domain.DatasetNode) StudyNode(org.eol.globi.domain.StudyNode) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 39 with DatasetImpl

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));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 40 with DatasetImpl

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()));
}
Also used : Specimen(org.eol.globi.domain.Specimen) NodeTypeDirection(org.eol.globi.util.NodeTypeDirection) LocationImpl(org.eol.globi.domain.LocationImpl) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) SpecimenNode(org.eol.globi.domain.SpecimenNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Location(org.eol.globi.domain.Location) Test(org.junit.Test)

Aggregations

DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)83 Test (org.junit.Test)73 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)50 URI (java.net.URI)32 JsonNode (com.fasterxml.jackson.databind.JsonNode)31 Dataset (org.globalbioticinteractions.dataset.Dataset)25 ArrayList (java.util.ArrayList)22 IOException (java.io.IOException)21 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)21 InteractionListener (org.eol.globi.process.InteractionListener)19 URL (java.net.URL)18 Map (java.util.Map)17 StudyNode (org.eol.globi.domain.StudyNode)17 HashMap (java.util.HashMap)16 Is.is (org.hamcrest.core.Is.is)16 List (java.util.List)15 StudyImpl (org.eol.globi.domain.StudyImpl)15 StringUtils (org.apache.commons.lang3.StringUtils)14 CoreMatchers.nullValue (org.hamcrest.CoreMatchers.nullValue)14 Is (org.hamcrest.core.Is)14