Search in sources :

Example 6 with DatasetLocal

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

the class StudyImporterForSPIRETest method createImporter.

private StudyImporterForSPIRE createImporter() {
    StudyImporterForSPIRE studyImporterForSPIRE = new StudyImporterForSPIRE(null, nodeFactory);
    studyImporterForSPIRE.setDataset(new DatasetLocal());
    studyImporterForSPIRE.setGeoNamesService(new GeoNamesService() {

        @Override
        public boolean hasTermForLocale(String locality) {
            return "something".equals(locality);
        }

        @Override
        public LatLng findLatLng(String locality) throws IOException {
            return hasTermForLocale(locality) ? new LatLng(1.0, 2.0) : null;
        }
    });
    return studyImporterForSPIRE;
}
Also used : GeoNamesService(org.eol.globi.service.GeoNamesService) IOException(java.io.IOException) LatLng(org.eol.globi.geo.LatLng) DatasetLocal(org.eol.globi.service.DatasetLocal)

Example 7 with DatasetLocal

use of org.eol.globi.service.DatasetLocal 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 8 with DatasetLocal

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

the class StudyImporterTestFactory method instantiateImporter.

public StudyImporter instantiateImporter(Class<? extends StudyImporter> clazz) throws StudyImporterException {
    try {
        Constructor<? extends StudyImporter> aConstructor = clazz.getConstructor(ParserFactory.class, NodeFactory.class);
        StudyImporter studyImporter = aConstructor.newInstance(parserFactory, nodeFactory);
        studyImporter.setDataset(new DatasetLocal());
        return studyImporter;
    } catch (Exception ex) {
        throw new StudyImporterException("failed to create study importer for [" + clazz.toString() + "]", ex);
    }
}
Also used : DatasetLocal(org.eol.globi.service.DatasetLocal)

Example 9 with DatasetLocal

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

the class StudyImporterForSzoboszlaiTest method getTestDataset.

private Dataset getTestDataset() throws IOException {
    JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Szoboszlai AI, Thayer JA, Wood SA, Sydeman WJ, Koehn LE (2015) Data from: Forage species in predator diets: synthesis of data from the California Current. Dryad Digital Repository. http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + "  \"doi\": \"http://dx.doi.org/10.5061/dryad.nv5d2\",\n" + "  \"format\": \"szoboszlai\",\n" + "  \"resources\": {\n" + "    \"links\": \"szoboszlai/CCPDDlinkdata_v2.csv\",\n" + "    \"shapes\": \"szoboszlai/CCPDDlocationdata_test.zip\"\n" + "  }\n" + "}");
    Dataset dataset = new DatasetLocal();
    dataset.setConfig(config);
    return dataset;
}
Also used : Dataset(org.eol.globi.service.Dataset) JsonNode(org.codehaus.jackson.JsonNode) DatasetLocal(org.eol.globi.service.DatasetLocal) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 10 with DatasetLocal

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

the class StudyImporterForWebOfLifeTest method importSome.

@Test
public void importSome() throws StudyImporterException, IOException {
    StudyImporterForWebOfLife importer = new StudyImporterForWebOfLife(null, nodeFactory);
    importer.setDataset(new DatasetLocal());
    importer.importNetworks("weboflife/web-of-life_2016-01-15_192434.zip", "Web of Life. " + CitationUtil.createLastAccessedString("http://www.web-of-life.es/"));
    resolveNames();
    List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
    List<String> references = new ArrayList<>();
    for (Study allStudy : allStudies) {
        assertThat(allStudy.getSource(), startsWith("Web of Life. Accessed at <http://www.web-of-life.es/>"));
        references.add(allStudy.getCitation());
    }
    assertThat(references, hasItem("Arroyo, M.T.K., R. Primack & J.J. Armesto. 1982. Community studies in pollination ecology in the high temperate Andes of central Chile. I. Pollination mechanisms and altitudinal variation. Amer. J. Bot. 69:82-97."));
    assertThat(taxonIndex.findTaxonByName("Diplopterys pubipetala"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Juniperus communis"), is(notNullValue()));
    assertThat(taxonIndex.findTaxonByName("Turdus torquatus"), is(notNullValue()));
}
Also used : Study(org.eol.globi.domain.Study) ArrayList(java.util.ArrayList) DatasetLocal(org.eol.globi.service.DatasetLocal) Test(org.junit.Test)

Aggregations

DatasetLocal (org.eol.globi.service.DatasetLocal)16 Test (org.junit.Test)11 Study (org.eol.globi.domain.Study)7 IOException (java.io.IOException)4 JsonNode (org.codehaus.jackson.JsonNode)4 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Relationship (org.neo4j.graphdb.Relationship)3 Specimen (org.eol.globi.domain.Specimen)2 Taxon (org.eol.globi.domain.Taxon)2 LatLng (org.eol.globi.geo.LatLng)2 GeoNamesService (org.eol.globi.service.GeoNamesService)2 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)2 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)1 Query (com.hp.hpl.jena.query.Query)1 QueryExecution (com.hp.hpl.jena.query.QueryExecution)1 QuerySolution (com.hp.hpl.jena.query.QuerySolution)1 ResultSet (com.hp.hpl.jena.query.ResultSet)1 Model (com.hp.hpl.jena.rdf.model.Model)1