Search in sources :

Example 16 with StudyImporter

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

the class GitHubImporterFactoryIT method defaultTSVImporterCachedZenodo.

@Test
public void defaultTSVImporterCachedZenodo() throws StudyImporterException, DatasetFinderException {
    final DatasetFinder datasetFinder = new DatasetFinderWithCache(new DatasetFinderZenodo());
    StudyImporter importer = getTemplateImporter(datasetFinder, "globalbioticinteractions/template-dataset");
    StudyImporterForTSV importerTSV = (StudyImporterForTSV) importer;
    assertThat(importerTSV.getSourceCitation(), containsString("doi.org"));
}
Also used : StudyImporterForTSV(org.eol.globi.data.StudyImporterForTSV) BaseStudyImporter(org.eol.globi.data.BaseStudyImporter) StudyImporter(org.eol.globi.data.StudyImporter) DatasetFinderWithCache(org.globalbioticinteractions.dataset.DatasetFinderWithCache) Test(org.junit.Test)

Example 17 with StudyImporter

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

the class GitHubImporterFactoryIT method createHurlbert.

@Test
public void createHurlbert() throws StudyImporterException, DatasetFinderException {
    final DatasetFinderGitHubRemote datasetFinderGitHubRemote = new DatasetFinderGitHubRemote();
    StudyImporter importer = importerFor(datasetFinderGitHubRemote, "hurlbertlab/dietdatabase");
    assertThat(importer, is(notNullValue()));
    assertThat(importer, is(instanceOf(StudyImporterForHurlbert.class)));
    final JsonNode config = ((BaseStudyImporter) importer).getDataset().getConfig();
    assertThat(config, is(notNullValue()));
}
Also used : JsonNode(org.codehaus.jackson.JsonNode) BaseStudyImporter(org.eol.globi.data.BaseStudyImporter) StudyImporter(org.eol.globi.data.StudyImporter) Test(org.junit.Test)

Example 18 with StudyImporter

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

the class Normalizer method importData.

void importData(GraphDatabaseService graphService, String cacheDir) {
    NodeFactoryNeo4j factory = new NodeFactoryNeo4j(graphService);
    factory.setEcoregionFinder(getEcoregionFinder());
    factory.setDoiResolver(new DOIResolverImpl());
    try {
        CacheFactory cacheFactory = dataset -> new CacheLocalReadonly(dataset.getNamespace(), cacheDir);
        DatasetFinder finder = new DatasetFinderLocal(cacheDir, cacheFactory);
        StudyImporter importer = new StudyImporterForGitHubData(new ParserFactoryLocal(), factory, finder);
        importer.setDataset(new DatasetLocal());
        importer.setLogger(new StudyImportLogger());
        importer.importStudy();
    } catch (StudyImporterException e) {
        LOG.error("problem encountered while importing [" + StudyImporterForGitHubData.class.getName() + "]", e);
    }
    EcoregionFinder regionFinder = getEcoregionFinder();
    if (regionFinder != null) {
        regionFinder.shutdown();
    }
}
Also used : OpenTreeTaxonIndex(org.eol.globi.opentree.OpenTreeTaxonIndex) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) EcoregionFinder(org.eol.globi.geo.EcoregionFinder) DatasetFinderLocal(org.globalbioticinteractions.dataset.DatasetFinderLocal) URISyntaxException(java.net.URISyntaxException) Options(org.apache.commons.cli.Options) TaxonCacheService(org.eol.globi.taxon.TaxonCacheService) DOIResolverCache(org.eol.globi.service.DOIResolverCache) ResolvingTaxonIndex(org.eol.globi.taxon.ResolvingTaxonIndex) HelpFormatter(org.apache.commons.cli.HelpFormatter) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) StudyImporterException(org.eol.globi.data.StudyImporterException) EcoregionFinderProxy(org.eol.globi.service.EcoregionFinderProxy) ParserFactoryLocal(org.eol.globi.data.ParserFactoryLocal) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) BasicParser(org.apache.commons.cli.BasicParser) CommandLine(org.apache.commons.cli.CommandLine) GraphService(org.eol.globi.db.GraphService) URI(java.net.URI) EcoregionFinderFactoryImpl(org.eol.globi.geo.EcoregionFinderFactoryImpl) HttpUtil(org.eol.globi.util.HttpUtil) Option(org.apache.commons.cli.Option) Taxon(org.eol.globi.domain.Taxon) CommandLineParser(org.apache.commons.cli.CommandLineParser) MalformedURLException(java.net.MalformedURLException) CacheLocalReadonly(org.globalbioticinteractions.cache.CacheLocalReadonly) DatasetFinder(org.eol.globi.service.DatasetFinder) DatasetLocal(org.eol.globi.service.DatasetLocal) StudyImporterForGitHubData(org.eol.globi.data.StudyImporterForGitHubData) DOIResolverImpl(org.eol.globi.service.DOIResolverImpl) NodeFactoryNeo4j(org.eol.globi.data.NodeFactoryNeo4j) List(java.util.List) StudyImporter(org.eol.globi.data.StudyImporter) ParseException(org.apache.commons.cli.ParseException) GraphExporterImpl(org.eol.globi.export.GraphExporterImpl) Version(org.eol.globi.Version) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) CacheFactory(org.globalbioticinteractions.cache.CacheFactory) EcoregionFinder(org.eol.globi.geo.EcoregionFinder) StudyImporterForGitHubData(org.eol.globi.data.StudyImporterForGitHubData) DOIResolverImpl(org.eol.globi.service.DOIResolverImpl) NodeFactoryNeo4j(org.eol.globi.data.NodeFactoryNeo4j) DatasetLocal(org.eol.globi.service.DatasetLocal) StudyImporter(org.eol.globi.data.StudyImporter) CacheLocalReadonly(org.globalbioticinteractions.cache.CacheLocalReadonly) StudyImporterException(org.eol.globi.data.StudyImporterException) DatasetFinder(org.eol.globi.service.DatasetFinder) CacheFactory(org.globalbioticinteractions.cache.CacheFactory) DatasetFinderLocal(org.globalbioticinteractions.dataset.DatasetFinderLocal) ParserFactoryLocal(org.eol.globi.data.ParserFactoryLocal)

Example 19 with StudyImporter

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

the class NormalizerTest method createStudyImporter.

private static StudyImporter createStudyImporter(Class<? extends StudyImporter> studyImporter, NodeFactoryNeo4j factory) throws StudyImporterException {
    StudyImporter importer = new StudyImporterTestFactory(factory).instantiateImporter(studyImporter);
    importer.setLogger(new StudyImportLogger());
    return importer;
}
Also used : StudyImporterTestFactory(org.eol.globi.data.StudyImporterTestFactory) StudyImporter(org.eol.globi.data.StudyImporter)

Example 20 with StudyImporter

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

the class GitHubImporterFactory method createImporter.

public StudyImporter createImporter(Dataset dataset, final NodeFactory nodeFactory) throws StudyImporterException {
    Class<? extends StudyImporter> anImporter = findImporterFor(dataset);
    try {
        Constructor<? extends StudyImporter> constructor = anImporter.getConstructor(ParserFactory.class, NodeFactory.class);
        ParserFactoryForDataset parserFactory = new ParserFactoryForDataset(dataset);
        StudyImporter studyImporter = constructor.newInstance(parserFactory, new NodeFactoryWithDatasetContext(nodeFactory, dataset));
        studyImporter.setDataset(dataset);
        return studyImporter;
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
        throw new StudyImporterException("failed to instantiate importer for [" + dataset.getNamespace() + "]", e);
    }
}
Also used : StudyImporterException(org.eol.globi.data.StudyImporterException) ParserFactoryForDataset(org.eol.globi.data.ParserFactoryForDataset) NodeFactoryWithDatasetContext(org.eol.globi.data.NodeFactoryWithDatasetContext) StudyImporter(org.eol.globi.data.StudyImporter) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

StudyImporter (org.eol.globi.data.StudyImporter)20 BaseStudyImporter (org.eol.globi.data.BaseStudyImporter)16 Test (org.junit.Test)15 JsonNode (org.codehaus.jackson.JsonNode)3 StudyImporterForTSV (org.eol.globi.data.StudyImporterForTSV)3 DatasetFinderWithCache (org.globalbioticinteractions.dataset.DatasetFinderWithCache)3 StringContains.containsString (org.junit.internal.matchers.StringContains.containsString)3 StudyImporterException (org.eol.globi.data.StudyImporterException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BasicParser (org.apache.commons.cli.BasicParser)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Option (org.apache.commons.cli.Option)1 Options (org.apache.commons.cli.Options)1