use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method nonInteractionRecordMessage.
@Test
public void nonInteractionRecordMessage() throws StudyImporterException, URISyntaxException {
List<String> msgs = new ArrayList<>();
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/mcz-adjusted/meta.xml");
URI archiveRoot = new File(resource.toURI()).getParentFile().toURI();
AtomicInteger recordCounter = new AtomicInteger(0);
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setLogger(new NullImportLogger() {
@Override
public void info(LogContext ctx, String message) {
msgs.add(message);
}
});
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", archiveRoot, inStream -> inStream));
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/ResourceRelationship | http://rs.tdwg.org/dwc/terms/Occurrence"));
recordCounter.incrementAndGet();
}
});
studyImporterForDwCA.importStudy();
assertThat(recordCounter.get(), is(0));
String joinedMsgs = StringUtils.join(msgs, "\n");
assertThat(joinedMsgs, containsString("]: indexing interaction records"));
assertThat(joinedMsgs, containsString("]: scanned [1] record(s)"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importTaxonDescriptionsFromDirNoInteractionType.
@Test
public void importTaxonDescriptionsFromDirNoInteractionType() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/coetzer-no-interaction-type/meta.xml");
URI archiveRoot = new File(resource.toURI()).getParentFile().toURI();
List<Map<String, String>> links = new ArrayList<>();
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 {
assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/ResourceRelationship | http://rs.tdwg.org/dwc/terms/Occurrence"));
links.add(interaction);
}
});
studyImporterForDwCA.importStudy();
assertThat(links.size(), is(0));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importRecordsFromUnresolvedResourceRelationshipArchive.
@Test
public void importRecordsFromUnresolvedResourceRelationshipArchive() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("fmnh-rr-unresolved-targetid-test.zip");
AtomicInteger recordCounter = new AtomicInteger(0);
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
studyImporterForDwCA.setDataset(new DatasetImpl("some/namespace", resource.toURI(), inStream -> inStream));
studyImporterForDwCA.setInteractionListener(interaction -> {
if (interaction.get(TARGET_OCCURRENCE_ID) != null) {
assertNull(interaction.get(TARGET_TAXON_NAME));
assertThat(interaction.get(TARGET_OCCURRENCE_ID), is("http://n2t.net/ark:/65665/37d63a454-d948-4b1d-89db-89809887ef41"));
recordCounter.incrementAndGet();
}
assertThat(interaction.get(DatasetImporterForTSV.RESOURCE_TYPES), is("http://rs.tdwg.org/dwc/terms/ResourceRelationship | http://rs.tdwg.org/dwc/terms/Occurrence"));
});
studyImporterForDwCA.importStudy();
assertThat(recordCounter.get(), greaterThan(0));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImplTest method useCitationFromTableDefinition.
@Test
public void useCitationFromTableDefinition() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree(getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi-default-external-schema.json")));
assertThat(dataset.getCitation(), is("Seltzer, Carrie; Wysocki, William; Palacios, Melissa; Eickhoff, Anna; Pilla, Hannah; Aungst, Jordan; Mercer, Aaron; Quicho, Jamie; Voss, Neil; Xu, Man; J. Ndangalasi, Henry; C. Lovett, Jon; J. Cordeiro, Norbert (2015): Plant-animal interactions from Africa. figshare. https://dx.doi.org/10.6084/m9.figshare.1526128"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImplTest method useCitationFromMultipleTableDefinitionsWithDifferentCitations.
@Test
public void useCitationFromMultipleTableDefinitionsWithDifferentCitations() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree(getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi-default-external-schemas-different-citations.json")));
assertThat(dataset.getCitation(), is("a citation; other citation"));
}
Aggregations