Search in sources :

Example 6 with DatasetRegistry

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

the class IndexerDataset method indexDatasets.

private static void indexDatasets(DatasetRegistry registry, NodeFactory nodeFactory) {
    try {
        final Collection<String> namespaces = registry.findNamespaces();
        String namespacelist = StringUtils.join(namespaces, CharsetConstant.SEPARATOR);
        LOG.info("found dataset namespaces: {" + namespacelist + "}");
        DatasetImporterForRegistry importer = new DatasetImporterForRegistry(new ParserFactoryLocal(), nodeFactory, registry);
        importer.setDatasetFilter(x -> !DatasetUtil.isDeprecated(x));
        importer.setDataset(new DatasetLocal(inStream -> inStream));
        importer.setLogger(new NullImportLogger());
        importer.importStudy();
    } catch (DatasetRegistryException | StudyImporterException e) {
        LOG.error("problem encountered while importing [" + DatasetImporterForRegistry.class.getName() + "]", e);
    }
}
Also used : DatasetRegistryException(org.globalbioticinteractions.dataset.DatasetRegistryException) Logger(org.slf4j.Logger) Collection(java.util.Collection) NodeFactory(org.eol.globi.data.NodeFactory) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) DatasetLocal(org.eol.globi.service.DatasetLocal) StudyImporterException(org.eol.globi.data.StudyImporterException) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) ParserFactoryLocal(org.eol.globi.data.ParserFactoryLocal) GraphServiceFactory(org.eol.globi.db.GraphServiceFactory) DatasetImporterForRegistry(org.eol.globi.data.DatasetImporterForRegistry) DatasetUtil(org.globalbioticinteractions.dataset.DatasetUtil) Transaction(org.neo4j.graphdb.Transaction) CharsetConstant(org.eol.globi.data.CharsetConstant) DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry) DatasetImporterForRegistry(org.eol.globi.data.DatasetImporterForRegistry) DatasetRegistryException(org.globalbioticinteractions.dataset.DatasetRegistryException) StudyImporterException(org.eol.globi.data.StudyImporterException) ParserFactoryLocal(org.eol.globi.data.ParserFactoryLocal) DatasetLocal(org.eol.globi.service.DatasetLocal)

Example 7 with DatasetRegistry

use of org.globalbioticinteractions.dataset.DatasetRegistry 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)

Example 8 with DatasetRegistry

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

the class CmdImportDatasets method run.

@Override
public void run() throws StudyImporterException {
    DatasetRegistry registry = DatasetRegistryUtil.getDatasetRegistry(datasetDir);
    new IndexerDataset(registry, nodeFactoryFactory, graphServiceFactory).index();
}
Also used : DatasetRegistry(org.globalbioticinteractions.dataset.DatasetRegistry)

Aggregations

DatasetRegistry (org.globalbioticinteractions.dataset.DatasetRegistry)8 InputStream (java.io.InputStream)5 BaseDatasetImporter (org.eol.globi.data.BaseDatasetImporter)5 DatasetImporter (org.eol.globi.data.DatasetImporter)5 Dataset (org.globalbioticinteractions.dataset.Dataset)5 DatasetRegistryException (org.globalbioticinteractions.dataset.DatasetRegistryException)5 DatasetRegistryGitHubRemote (org.globalbioticinteractions.dataset.DatasetRegistryGitHubRemote)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 URI (java.net.URI)4 DatasetImporterForHafner (org.eol.globi.data.DatasetImporterForHafner)4 StudyImporterException (org.eol.globi.data.StudyImporterException)4 DatasetFactory (org.globalbioticinteractions.dataset.DatasetFactory)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 DatasetImporterForCoetzer (org.eol.globi.data.DatasetImporterForCoetzer)3 DatasetImporterForGoMexSI2 (org.eol.globi.data.DatasetImporterForGoMexSI2)3 DatasetImporterForHurlbert (org.eol.globi.data.DatasetImporterForHurlbert)3 DatasetImporterForJSONLD (org.eol.globi.data.DatasetImporterForJSONLD)3 DatasetImporterForMetaTable (org.eol.globi.data.DatasetImporterForMetaTable)3