use of org.eol.globi.service.DatasetFinder in project eol-globi-data by jhpoelen.
the class DatasetFinderLocal method datasetFor.
@Override
public Dataset datasetFor(String namespace) throws DatasetFinderException {
Dataset dataset;
try {
final URI sourceURI = findLastCachedDatasetURI(namespace);
dataset = sourceURI == null ? null : DatasetFactory.datasetFor(namespace, new DatasetFinder() {
@Override
public Collection<String> findNamespaces() throws DatasetFinderException {
return Collections.singletonList(namespace);
}
@Override
public Dataset datasetFor(String s) throws DatasetFinderException {
Dataset dataset = new DatasetImpl(namespace, sourceURI);
return new DatasetWithCache(dataset, cacheFactory.cacheFor(dataset));
}
});
} catch (IOException e) {
throw new DatasetFinderException("failed to access [" + namespace + "]", e);
}
if (dataset == null) {
throw new DatasetFinderException("failed to retrieve/cache dataset in namespace [" + namespace + "]");
}
return dataset;
}
use of org.eol.globi.service.DatasetFinder in project eol-globi-data by jhpoelen.
the class DatasetFinderWithCacheIT method hafnerTest.
@Test
public void hafnerTest() throws DatasetFinderException, IOException {
DatasetFinder finder = new DatasetFinderWithCache(new DatasetFinderGitHubArchive(), cachePath);
Dataset dataset = DatasetFactory.datasetFor("globalbioticinteractions/hafner", finder);
assertNotNull(dataset.getResource("hafner/gopher_lice_int.csv"));
}
use of org.eol.globi.service.DatasetFinder in project eol-globi-data by jhpoelen.
the class DatasetFinderWithCacheIT method gitHubTest.
@Test
public void gitHubTest() throws DatasetFinderException {
DatasetFinder finder = new DatasetFinderWithCache(new DatasetFinderGitHubArchive(), cachePath);
Dataset dataset = DatasetFactory.datasetFor("globalbioticinteractions/Catalogue-of-Afrotropical-Bees", finder);
assertThat(dataset.getArchiveURI().toString(), containsString("github.com"));
assertThat(dataset.getResourceURI("globi.json").toString(), startsWith("jar:file:/"));
assertThat(dataset.getCitation(), startsWith("Shan Kothari, Pers. Comm. 2014."));
}
use of org.eol.globi.service.DatasetFinder in project eol-globi-data by jhpoelen.
the class DatasetFinderWithCacheIT method assertTemplateDataset.
private void assertTemplateDataset(String expectedURIFragment, DatasetFinder datasetFinder, String expectedCitation) throws DatasetFinderException, IOException {
DatasetFinder finder = new DatasetFinderWithCache(datasetFinder, cachePath);
Dataset dataset = DatasetFactory.datasetFor("globalbioticinteractions/template-dataset", finder);
assertThat(dataset.getArchiveURI().toString(), containsString(expectedURIFragment));
assertThat(dataset.getResourceURI("globi.json").toString(), startsWith("jar:file:/"));
assertThat(dataset.getCitation(), startsWith(expectedCitation));
}
use of org.eol.globi.service.DatasetFinder 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();
}
}
Aggregations