use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class ExportFlatInteractionsTest method init.
@Before
public void init() throws IOException {
super.startGraphDb();
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
factory = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForWoodTest method createImporter.
static DatasetImporterForWood createImporter(NodeFactory nodeFactory) throws IOException {
JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Wood SA, Russell R, Hanson D, Williams RJ, Dunne JA (2015) Data from: Effects of spatial scale of sampling on food web structure. Dryad Digital Repository. https://doi.org/10.5061/dryad.g1qr6\",\n" + " \"doi\": \"https://doi.org/10.5061/dryad.g1qr6\",\n" + " \"format\": \"wood\",\n" + " \"resources\": {\n" + " \"links\": \"http://datadryad.org/bitstream/handle/10255/dryad.93018/WoodEtal_Append1_v2.csv\" \n" + " },\n" + " \"location\": {\n" + " \"locality\": {\n" + " \"id\": \"GEONAMES:5873327\",\n" + " \"name\": \"Sanak Island, Alaska, USA\"\n" + " },\n" + " \"latitude\": 54.42972,\n" + " \"longitude\": -162.70889\n" + " }\n" + "}");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(config);
DatasetImporterForWood wood = new DatasetImporterForWood(new ParserFactoryForDataset(dataset), nodeFactory);
wood.setDataset(dataset);
return wood;
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class InteractionListenerImplTest method processMessageWithTranslatedInteractionType.
@Test
public void processMessageWithTranslatedInteractionType() 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, "shouldBeMapped");
interaction.put(TARGET_TAXON_NAME, "targetName");
interaction.put(REFERENCE_ID, "citation");
assertStudyCount(0L);
interactionListener.on(interaction);
assertStudyCount(1L);
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationEnabled.
@Test
public void createStudyDOIlookupCitationEnabled() throws NodeFactoryException {
StudyImpl title = new StudyImpl("title", null, "some citation");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, true);
originatingDataset.setConfig(objectNode);
title.setOriginatingDataset(originatingDataset);
StudyNode study = getNodeFactory().getOrCreateStudy(title);
LinkerDOI.linkStudy(new TestDOIResolver(), study);
assertThat(study.getDOI().toString(), is("10.some/some citation"));
assertThat(study.getExternalId(), is("https://doi.org/10.some/some%20citation"));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method assertImportsSomethingOfType.
private void assertImportsSomethingOfType(URI archiveRoot, AtomicInteger recordCounter, String defaultResourceType, String... expectedProperties) throws StudyImporterException {
final Set<String> resourceTypes = new TreeSet<>();
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", archiveRoot, inStream -> inStream));
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
for (String expectedProperty : expectedProperties) {
assertThat("no [" + expectedProperty + "] found in " + interaction, interaction.containsKey(expectedProperty), is(true));
assertThat("no value of [" + expectedProperty + "] found in " + interaction, interaction.get(expectedProperty), is(notNullValue()));
}
assertThat(interaction.get(RESOURCE_TYPES), is(notNullValue()));
String[] types = splitByPipes(interaction.get(RESOURCE_TYPES));
resourceTypes.addAll(Arrays.asList(types));
recordCounter.incrementAndGet();
}
});
studyImporterForDwCA.importStudy();
assertThat(recordCounter.get(), greaterThan(0));
String[] items = splitByPipes(defaultResourceType);
assertThat(resourceTypes, containsInAnyOrder(items));
assertThat(recordCounter.get(), greaterThan(0));
}
Aggregations