use of org.globalbioticinteractions.dataset.DatasetRegistryException 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.DatasetRegistryException in project eol-globi-data by jhpoelen.
the class DatasetImporterFactoryImplIT method defaultTSVImporterCachedZenodo.
@Test
public void defaultTSVImporterCachedZenodo() throws StudyImporterException, DatasetRegistryException {
final DatasetRegistry datasetRegistry = new DatasetRegistryWithCache(new DatasetRegistryZenodo(inStream -> inStream), dataset -> CacheUtil.cacheFor(dataset.getNamespace(), "target/datasets", inStream -> inStream));
DatasetImporter importer = getTemplateImporter(datasetRegistry, "globalbioticinteractions/template-dataset");
DatasetImporterForTSV importerTSV = (DatasetImporterForTSV) importer;
assertThat(importerTSV.getSourceCitation(), containsString("doi.org"));
}
use of org.globalbioticinteractions.dataset.DatasetRegistryException in project eol-globi-data by jhpoelen.
the class DatasetImporterForRegistryTest method filteredDatasets.
@Test
public void filteredDatasets() throws StudyImporterException {
DatasetImporterForRegistry importer = new DatasetImporterForRegistry(null, null, new DatasetRegistry() {
@Override
public Collection<String> findNamespaces() throws DatasetRegistryException {
return Collections.singletonList("some/namespace");
}
@Override
public Dataset datasetFor(String namespace) throws DatasetRegistryException {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), in -> in) {
@Override
public InputStream retrieve(URI resource) throws IOException {
if (!StringUtils.endsWith(resource.toString(), "globi.json")) {
throw new IOException();
}
return IOUtils.toInputStream("{\"some\":\"thing\"}", StandardCharsets.UTF_8);
}
};
return dataset;
}
});
importer.setDatasetFilter(x -> false);
importer.importStudy();
}
use of org.globalbioticinteractions.dataset.DatasetRegistryException in project eol-globi-data by jhpoelen.
the class ProvenanceLog method parseProvenanceStream.
public static void parseProvenanceStream(InputStream is, ProvenanceEntryListener listener) throws DatasetRegistryException {
try (InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
BufferedReader bufferedReader = IOUtils.toBufferedReader(reader);
String line;
while ((line = bufferedReader.readLine()) != null) {
listener.onValues(CSVTSVUtil.splitTSV(line));
}
} catch (IOException e) {
throw new DatasetRegistryException("failed to read ", e);
}
}
use of org.globalbioticinteractions.dataset.DatasetRegistryException in project eol-globi-data by jhpoelen.
the class IndexerDataset method indexDatasets.
private static void indexDatasets(DatasetRegistry registry, NodeFactory nodeFactory) {
try {
final Collection<String> namespaces = registry.findNamespaces();
String namespacelist = StringUtils.join(namespaces, CharsetConstant.SEPARATOR);
LOG.info("found dataset namespaces: {" + namespacelist + "}");
DatasetImporterForRegistry importer = new DatasetImporterForRegistry(new ParserFactoryLocal(), nodeFactory, registry);
importer.setDatasetFilter(x -> !DatasetUtil.isDeprecated(x));
importer.setDataset(new DatasetLocal(inStream -> inStream));
importer.setLogger(new NullImportLogger());
importer.importStudy();
} catch (DatasetRegistryException | StudyImporterException e) {
LOG.error("problem encountered while importing [" + DatasetImporterForRegistry.class.getName() + "]", e);
}
}
Aggregations