Search in sources :

Example 1 with DatasetFactory

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

the class DatasetImporterFactoryImplIT method jsonldImporterCached.

@Test
public void jsonldImporterCached() throws StudyImporterException, DatasetRegistryException {
    final DatasetRegistry datasetRegistry = new DatasetRegistryWithCache(new DatasetRegistryGitHubArchive(inStream -> inStream), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), "target/datasets", inStream -> inStream));
    Dataset dataset = new DatasetFactory(datasetRegistry).datasetFor("globalbioticinteractions/jsonld-template-dataset");
    DatasetImporter importer = new StudyImporterFactoryImpl(null).createImporter(dataset);
    assertThat(importer, is(notNullValue()));
    assertThat(importer, is(instanceOf(DatasetImporterForJSONLD.class)));
}
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) Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) DatasetRegistryWithCache(org.globalbioticinteractions.dataset.DatasetRegistryWithCache) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory) DatasetRegistryGitHubArchive(org.globalbioticinteractions.dataset.DatasetRegistryGitHubArchive) Test(org.junit.Test)

Example 2 with DatasetFactory

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

the class DatasetImporterFactoryImplIT method createHafner.

@Test
public void createHafner() throws StudyImporterException, DatasetRegistryException, IOException {
    final DatasetRegistry datasetRegistryGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
    Dataset dataset = new DatasetFactory(datasetRegistryGitHubRemote).datasetFor("globalbioticinteractions/hafner");
    DatasetImporter importer = new StudyImporterFactoryImpl(null).createImporter(dataset);
    assertThat(importer, is(notNullValue()));
    DatasetImporterForHafner haftnerImporter = (DatasetImporterForHafner) importer;
    assertThat(haftnerImporter.getDataset().retrieve(URI.create("hafner/gopher_lice_int.csv")), is(notNullValue()));
}
Also used : DatasetRegistryGitHubRemote(org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote) Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) DatasetImporterForHafner(org.eol.globi.data.DatasetImporterForHafner) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory) Test(org.junit.Test)

Example 3 with DatasetFactory

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

the class DatasetImporterFactoryImplIT method getTemplateImporter.

DatasetImporter getTemplateImporter(DatasetRegistry datasetRegistry, String repo) throws DatasetRegistryException, StudyImporterException {
    Dataset dataset = new DatasetFactory(datasetRegistry).datasetFor(repo);
    DatasetImporter importer = new StudyImporterFactoryImpl(null).createImporter(dataset);
    assertThat(importer, is(notNullValue()));
    assertThat(importer, is(instanceOf(DatasetImporterForTSV.class)));
    return importer;
}
Also used : Dataset(org.globalbioticinteractions.dataset.Dataset) BaseDatasetImporter(org.eol.globi.data.BaseDatasetImporter) DatasetImporter(org.eol.globi.data.DatasetImporter) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory)

Example 4 with DatasetFactory

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

the class DatasetImporterForRegistry method importData.

private void importData(String namespace) throws StudyImporterException {
    try {
        LOG.info("[" + namespace + "] checking status...");
        Dataset dataset = new DatasetFactory(getRegistry()).datasetFor(namespace);
        if (datasetFilter.test(dataset)) {
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            LOG.info("[" + namespace + "] is active, importing...");
            getNodeFactory().getOrCreateDataset(dataset);
            importData(dataset);
            stopWatch.stop();
            LOG.info("[" + namespace + "] imported in " + stopWatch.getTime(TimeUnit.SECONDS) + "s");
        } else {
            LOG.info("[" + namespace + "] is deprecated, not importing.");
        }
    } catch (StudyImporterException | DatasetRegistryException ex) {
        String msg = "failed to import data from repo [" + namespace + "]";
        LOG.error(msg, ex);
        throw new StudyImporterException(msg, ex);
    }
}
Also used : DatasetRegistryException(org.globalbioticinteractions.dataset.DatasetRegistryException) Dataset(org.globalbioticinteractions.dataset.Dataset) DatasetFactory(org.globalbioticinteractions.dataset.DatasetFactory) StopWatch(org.apache.commons.lang3.time.StopWatch)

Aggregations

Dataset (org.globalbioticinteractions.dataset.Dataset)4 DatasetFactory (org.globalbioticinteractions.dataset.DatasetFactory)4 BaseDatasetImporter (org.eol.globi.data.BaseDatasetImporter)3 DatasetImporter (org.eol.globi.data.DatasetImporter)3 DatasetImporterForHafner (org.eol.globi.data.DatasetImporterForHafner)2 DatasetRegistry (org.globalbioticinteractions.dataset.DatasetRegistry)2 DatasetRegistryException (org.globalbioticinteractions.dataset.DatasetRegistryException)2 DatasetRegistryGitHubRemote (org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 DatasetImporterForCoetzer (org.eol.globi.data.DatasetImporterForCoetzer)1 DatasetImporterForGoMexSI2 (org.eol.globi.data.DatasetImporterForGoMexSI2)1 DatasetImporterForHurlbert (org.eol.globi.data.DatasetImporterForHurlbert)1 DatasetImporterForJSONLD (org.eol.globi.data.DatasetImporterForJSONLD)1 DatasetImporterForMetaTable (org.eol.globi.data.DatasetImporterForMetaTable)1 DatasetImporterForPlanque (org.eol.globi.data.DatasetImporterForPlanque)1