Search in sources :

Example 11 with DatasetImporter

use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.

the class DatasetImporterFactoryImplIT method defaultTSVImporterNotCached.

@Test
public void defaultTSVImporterNotCached() throws StudyImporterException, DatasetRegistryException, IOException {
    final DatasetRegistry datasetRegistry = new DatasetRegistryGitHubRemote(inStream -> inStream);
    DatasetImporter importer = getTemplateImporter(datasetRegistry, "globalbioticinteractions/template-dataset");
    assertThat(((DatasetImporterForTSV) importer).getBaseUrl(), startsWith("https://raw.githubusercontent.com/globalbioticinteractions/template-dataset/"));
    InputStream actual = ((DatasetImporterForTSV) importer).getDataset().retrieve(URI.create("globi.json"));
    assertThat(actual, is(notNullValue()));
}
Also used : DatasetRegistryGitHubRemote(org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote) InputStream(java.io.InputStream) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) Test(org.junit.Test)

Example 12 with DatasetImporter

use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.

the class DatasetImporterFactoryImplTest method createImporter.

@Test
public void createImporter() throws StudyImporterException {
    DatasetImporter someImporter = new StudyImporterFactoryImpl(null).createImporter(new DatasetImpl("namespace", URI.create("some:uri"), is -> is));
    assertThat(someImporter, instanceOf(DatasetImporterForTSV.class));
}
Also used : StudyImporterException(org.eol.globi.data.StudyImporterException) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) IsNull.nullValue(org.hamcrest.core.IsNull.nullValue) CoreMatchers.not(org.hamcrest.CoreMatchers.not) DatasetImporter(org.eol.globi.data.DatasetImporter) Test(org.junit.Test) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assert(org.junit.Assert) Is(org.hamcrest.core.Is) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) DatasetImporter(org.eol.globi.data.DatasetImporter) Test(org.junit.Test)

Example 13 with DatasetImporter

use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.

the class DatasetImportUtil method importDataset.

public static void importDataset(StudyImporterConfigurator studyImporterConfigurator, Dataset dataset, NodeFactory nodeFactory, ImportLogger logger, GeoNamesService geoNamesService) throws StudyImporterException {
    nodeFactory.getOrCreateDataset(dataset);
    NodeFactory nodeFactoryForDataset = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
    DatasetImporter datasetImporter = new StudyImporterFactoryImpl(nodeFactoryForDataset).createImporter(dataset);
    datasetImporter.setDataset(dataset);
    if (studyImporterConfigurator != null) {
        studyImporterConfigurator.configure(datasetImporter);
    }
    if (logger != null) {
        datasetImporter.setLogger(logger);
    }
    if (geoNamesService != null) {
        datasetImporter.setGeoNamesService(geoNamesService);
    }
    datasetImporter.importStudy();
}
Also used : NodeFactory(org.eol.globi.data.NodeFactory) DatasetImporter(org.eol.globi.data.DatasetImporter) NodeFactoryWithDatasetContext(org.eol.globi.data.NodeFactoryWithDatasetContext) StudyImporterFactoryImpl(org.eol.globi.service.StudyImporterFactoryImpl)

Example 14 with DatasetImporter

use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.

the class DatasetImporterFactoryImplIT method createSIAD.

@Test
public void createSIAD() throws StudyImporterException, DatasetRegistryException {
    final DatasetRegistryGitHubRemote datasetFinderGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
    DatasetImporter importer = importerFor(datasetFinderGitHubRemote, "globalbioticinteractions/siad");
    assertThat(importer, is(notNullValue()));
    Dataset dataset = ((BaseDatasetImporter) importer).getDataset();
    final JsonNode config = dataset.getConfig();
    assertThat(config, is(notNullValue()));
    assertThat(dataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "donald"), is("false"));
}
Also used : DatasetRegistryGitHubRemote(org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote) Dataset(org.globalbioticinteractions.dataset.Dataset) JsonNode(com.fasterxml.jackson.databind.JsonNode) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) Test(org.junit.Test)

Example 15 with DatasetImporter

use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.

the class DatasetImporterFactoryImplIT method defaultTSVImporterCached.

@Test
public void defaultTSVImporterCached() throws StudyImporterException, DatasetRegistryException, IOException {
    final DatasetRegistry datasetRegistry = new DatasetRegistryWithCache(new DatasetRegistryGitHubArchive(inStream -> inStream), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), "target/datasets", inStream -> inStream));
    DatasetImporter importer = getTemplateImporter(datasetRegistry, "globalbioticinteractions/template-dataset");
    DatasetImporterForTSV importerTSV = (DatasetImporterForTSV) importer;
    assertThat(importerTSV.getBaseUrl(), startsWith("https://github.com/globalbioticinteractions/template-dataset/"));
    assertThat(importerTSV.getDataset().retrieve(URI.create("globi.json")), is(notNullValue()));
}
Also used : CacheUtil(org.globalbioticinteractions.cache.CacheUtil) DatasetImporterForGoMexSI2(org.eol.globi.data.DatasetImporterForGoMexSI2) DatasetRegistryGitHubRemote(org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote) IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) DatasetImporterForHurlbert(org.eol.globi.data.DatasetImporterForHurlbert) DatasetConstant(org.globalbioticinteractions.dataset.DatasetConstant) DatasetImporterForMetaTable(org.eol.globi.data.DatasetImporterForMetaTable) DatasetImporterForHafner(org.eol.globi.data.DatasetImporterForHafner) DatasetImporterForSzoboszlai(org.eol.globi.data.DatasetImporterForSzoboszlai) StudyImporterException(org.eol.globi.data.StudyImporterException) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) Is.is(org.hamcrest.core.Is.is) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetImporter(org.eol.globi.data.DatasetImporter) DatasetImporterForJSONLD(org.eol.globi.data.DatasetImporterForJSONLD) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) StringStartsWith.startsWith(org.hamcrest.core.StringStartsWith.startsWith) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) DatasetRegistryZenodo(org.globalbioticinteractions.dataset.DatasetRegistryZenodo) DatasetRegistryException(org.globalbioticinteractions.dataset.DatasetRegistryException) Assert.assertNotNull(org.junit.Assert.assertNotNull) Test(org.junit.Test) IOException(java.io.IOException) DatasetImporterForCoetzer(org.eol.globi.data.DatasetImporterForCoetzer) DatasetRegistryGitHubArchive(org.globalbioticinteractions.dataset.DatasetRegistryGitHubArchive) DatasetImporterForPlanque(org.eol.globi.data.DatasetImporterForPlanque) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory) Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetImporterForRSS(org.eol.globi.data.DatasetImporterForRSS) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) DatasetImporterForWood(org.eol.globi.data.DatasetImporterForWood) DatasetRegistryWithCache(org.globalbioticinteractions.dataset.DatasetRegistryWithCache) Matchers.containsString(org.hamcrest.Matchers.containsString) InputStream(java.io.InputStream) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) DatasetRegistryWithCache(org.globalbioticinteractions.dataset.DatasetRegistryWithCache) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) DatasetRegistryGitHubArchive(org.globalbioticinteractions.dataset.DatasetRegistryGitHubArchive) Test(org.junit.Test)

Aggregations

DatasetImporter (org.eol.globi.data.DatasetImporter)21 BaseDatasetImporter (org.eol.globi.data.BaseDatasetImporter)16 Test (org.junit.Test)16 DatasetRegistryGitHubRemote (org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 Dataset (org.globalbioticinteractions.dataset.Dataset)6 StudyImporterException (org.eol.globi.data.StudyImporterException)5 DatasetFactory (org.globalbioticinteractions.dataset.DatasetFactory)5 DatasetRegistry (org.globalbioticinteractions.dataset.DatasetRegistry)5 InputStream (java.io.InputStream)4 URI (java.net.URI)4 DatasetImporterForCoetzer (org.eol.globi.data.DatasetImporterForCoetzer)4 DatasetImporterForGoMexSI2 (org.eol.globi.data.DatasetImporterForGoMexSI2)4 DatasetImporterForHafner (org.eol.globi.data.DatasetImporterForHafner)4 DatasetImporterForMetaTable (org.eol.globi.data.DatasetImporterForMetaTable)4 DatasetImporterForPlanque (org.eol.globi.data.DatasetImporterForPlanque)4 DatasetImporterForSzoboszlai (org.eol.globi.data.DatasetImporterForSzoboszlai)4 DatasetImporterForTSV (org.eol.globi.data.DatasetImporterForTSV)4 DatasetImporterForWood (org.eol.globi.data.DatasetImporterForWood)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4