use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImportUtil method importDatasets.
public static void importDatasets(Map<Pair<String, String>, Map<String, String>> interactionsWithUnresolvedOccurrenceIds, List<Dataset> datasets, ImportLogger logger, NodeFactory nodeFactory) throws StudyImporterException {
for (Dataset dataset : datasets) {
try {
importDataset(studyImporter -> {
if (studyImporter instanceof DatasetImporterWithListener) {
final InteractionListenerResolving interactionListener = new InteractionListenerResolving(interactionsWithUnresolvedOccurrenceIds, ((DatasetImporterWithListener) studyImporter).getInteractionListener());
((DatasetImporterWithListener) studyImporter).setInteractionListener(interactionListener);
}
}, dataset, nodeFactory, logger);
} catch (StudyImporterException | IllegalStateException ex) {
LogUtil.logError(logger, ex);
}
}
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j2 method getOrCreateDatasetNoTx.
@Override
protected Dataset getOrCreateDatasetNoTx(Dataset originatingDataset) {
Dataset datasetCreated = null;
if (originatingDataset != null && StringUtils.isNotBlank(originatingDataset.getNamespace())) {
IndexHits<Node> datasetHits = datasets.get(DatasetConstant.NAMESPACE, originatingDataset.getNamespace());
Node datasetNode = datasetHits.hasNext() ? datasetHits.next() : createDatasetNode(originatingDataset);
datasetCreated = new DatasetNode(datasetNode);
}
return datasetCreated;
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class InteractionListenerImplTest method processMessageWithOIgnoredInteractionType.
@Test
public void processMessageWithOIgnoredInteractionType() throws StudyImporterException, IOException {
ResourceService resourceService = Mockito.mock(ResourceService.class);
when(resourceService.retrieve(URI.create("interaction_types_ignored.csv"))).thenReturn(IOUtils.toInputStream("provided_interaction_type_id\nshouldBeIgnored", StandardCharsets.UTF_8)).thenReturn(IOUtils.toInputStream("provided_interaction_type_id\nshouldBeIgnored", StandardCharsets.UTF_8));
when(resourceService.retrieve(URI.create("interaction_types_mapping.csv"))).thenReturn(IOUtils.toInputStream(getTestMap(), StandardCharsets.UTF_8));
Dataset dataset = new DatasetImpl("bla", resourceService, URI.create("foo:bar"));
InteractionListenerImpl interactionListener = new InteractionListenerImpl(nodeFactory, null, null, dataset);
HashMap<String, String> interaction = new HashMap<>();
interaction.put(SOURCE_TAXON_NAME, "sourceName");
interaction.put(DatasetImporterForTSV.INTERACTION_TYPE_NAME, "shouldBeIgnored");
interaction.put(TARGET_TAXON_NAME, "targetName");
interaction.put(REFERENCE_ID, "citation");
assertStudyCount(0L);
interactionListener.on(interaction);
assertStudyCount(0L);
}
use of org.globalbioticinteractions.dataset.Dataset 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.Dataset 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()));
}
Aggregations