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)));
}
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()));
}
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;
}
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);
}
}
Aggregations