Search in sources :

Example 46 with DatasetImpl

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

the class DatasetImporterForJSONLDTest method importStatic.

@Test
public void importStatic() throws StudyImporterException, URISyntaxException {
    DatasetImporter importer = new DatasetImporterForJSONLD(null, nodeFactory);
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
    dataset.setConfigURI(URI.create("classpath:/org/eol/globi/data/globi-jsonld/globi-dataset.jsonld"));
    importer.setDataset(dataset);
    importStudy(importer);
    List<StudyNode> allStudies = NodeUtil.findAllStudies(getGraphDb());
    for (Study study : allStudies) {
        assertThat(study.getExternalId(), is("http://arctos.database.museum/guid/CUMV:Bird:25225"));
        assertThat(study.getCitation(), is("http://arctos.database.museum/guid/CUMV:Bird:25225"));
    }
    assertThat(taxonIndex.findTaxonById("NCBI:8782"), not(is(nullValue())));
}
Also used : Study(org.eol.globi.domain.Study) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 47 with DatasetImpl

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

the class DatasetImporterForCoetzerTest method importSome.

@Test
public void importSome() throws StudyImporterException, IOException {
    DatasetImporterForCoetzer importer = new DatasetImporterForCoetzer(null, nodeFactory);
    DatasetImpl dataset = new DatasetLocal(inStream -> inStream);
    JsonNode config = new ObjectMapper().readTree("{\"citation\": \"source citation\", \"resources\": {\"archive\": \"coetzer/CatalogOfAfrotropicalBees.zip\"}}");
    dataset.setConfig(config);
    importer.setDataset(dataset);
    importStudy(importer);
    List<StudyNode> allStudies = NodeUtil.findAllStudies(getGraphDb());
    for (Study allStudy : allStudies) {
        assertThat(allStudy.getCitation(), is(notNullValue()));
    }
    assertThat(taxonIndex.findTaxonByName("Agrostis tremula"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Coelioxys erythrura"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Patellapis namaquensis"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) DatasetLocal(org.eol.globi.service.DatasetLocal) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 48 with DatasetImpl

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

the class DatasetImporterForHurlbertTest method doImport.

public DatasetImporter doImport(final String namespace) throws StudyImporterException {
    DatasetImporter importer = new DatasetImporterForHurlbert(null, nodeFactory);
    Dataset dataset = new DatasetImpl(namespace, URI.create("some:uri"), inStream -> inStream) {

        @Override
        public InputStream retrieve(URI name) {
            return DatasetImporterForHurlbertTest.getResource();
        }
    };
    importer.setDataset(dataset);
    importStudy(importer);
    return importer;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URI(java.net.URI)

Example 49 with DatasetImpl

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

the class DatasetImporterForDunneIT method importStudy.

@Test
public void importStudy() throws StudyImporterException, IOException {
    String configJson = "{ \"citation\": \"blabla\",\n" + "  \"format\": \"dunne\",\n" + "  \"resources\": {\n" + "    \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/main/nodes.tsv\",\n" + "    \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/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" + "}";
    JsonNode jsonNode = new ObjectMapper().readTree(configJson);
    DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"), inStream -> inStream);
    dunne2016.setConfig(jsonNode);
    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(getSpecimenCount(study), is(1804 * 2));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) 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 50 with DatasetImpl

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

the class DatasetImporterForGrayTest method createImporter.

static DatasetImporterForGray createImporter(NodeFactory nodeFactory) throws IOException {
    DatasetImporterForGray gray = new DatasetImporterForGray(new ParserFactoryLocal(), nodeFactory);
    JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. https://doi.org/10.5281/zenodo.13751\",\n" + "  \"doi\": \"https://doi.org/10.5281/zenodo.13751\",\n" + "  \"format\": \"gray\",\n" + "  \"resources\": {\n" + "    \"links\": \"https://zenodo.org/record/13751/files/trophic.links.2014-11-10.csv\"  \n" + "  }\n" + "}");
    DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
    dataset.setConfig(config);
    gray.setDataset(dataset);
    return gray;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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