use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.
the class StudyImporterFactoryImpl method createImporter.
public static DatasetImporter createImporter(Dataset dataset, final NodeFactory nodeFactory) throws StudyImporterException {
Class<? extends DatasetImporter> anImporter = findImporterFor(dataset);
try {
Constructor<? extends DatasetImporter> constructor = anImporter.getConstructor(ParserFactory.class, NodeFactory.class);
ParserFactoryForDataset parserFactory = new ParserFactoryForDataset(dataset);
DatasetImporter datasetImporter = constructor.newInstance(parserFactory, new NodeFactoryWithDatasetContext(nodeFactory, dataset));
datasetImporter.setDataset(dataset);
return datasetImporter;
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
throw new StudyImporterException("failed to instantiate importer for [" + dataset.getNamespace() + "]", e);
}
}
use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method createHurlbert.
@Test
public void createHurlbert() throws StudyImporterException, DatasetRegistryException {
final DatasetRegistryGitHubRemote datasetFinderGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
DatasetImporter importer = importerFor(datasetFinderGitHubRemote, "hurlbertlab/dietdatabase");
assertThat(importer, is(notNullValue()));
assertThat(importer, is(instanceOf(DatasetImporterForHurlbert.class)));
final JsonNode config = ((BaseDatasetImporter) importer).getDataset().getConfig();
assertThat(config, is(notNullValue()));
}
use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method createMetaTable.
@Test
public void createMetaTable() throws DatasetRegistryException, StudyImporterException {
final DatasetRegistryGitHubRemote datasetFinderGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
DatasetImporter importer = importerFor(datasetFinderGitHubRemote, "globalbioticinteractions/AfricaTreeDatabase");
assertThat(importer, is(notNullValue()));
assertThat(importer, is(instanceOf(DatasetImporterForMetaTable.class)));
assertThat(((DatasetImporterForMetaTable) importer).getConfig(), is(notNullValue()));
assertThat(((DatasetImporterForMetaTable) importer).getBaseUrl(), startsWith("https://raw.githubusercontent.com/globalbioticinteractions/AfricaTreeDatabase/"));
}
use of org.eol.globi.data.DatasetImporter in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method createPlanque.
@Test
public void createPlanque() throws StudyImporterException, DatasetRegistryException, IOException {
final DatasetRegistryGitHubRemote datasetFinderGitHubRemote = new DatasetRegistryGitHubRemote(inStream -> inStream);
DatasetImporter importer = importerFor(datasetFinderGitHubRemote, "globalbioticinteractions/planque2014");
assertThat(importer, is(notNullValue()));
assertThat(importer, is(instanceOf(DatasetImporterForPlanque.class)));
DatasetImporterForPlanque importerz = (DatasetImporterForPlanque) importer;
assertThat(importerz.getSourceCitation(), containsString("Planque"));
}
use of org.eol.globi.data.DatasetImporter 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)));
}
Aggregations