use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class LinkerDOITest method createStudyDOIlookupCitationDisabled.
@Test
public void createStudyDOIlookupCitationDisabled() throws NodeFactoryException {
StudyImpl study1 = new StudyImpl("title", null, "some citation");
study1.setExternalId("some:id");
DatasetImpl originatingDataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
ObjectNode objectNode = new ObjectMapper().createObjectNode();
objectNode.put(DatasetConstant.SHOULD_RESOLVE_REFERENCES, false);
originatingDataset.setConfig(objectNode);
study1.setOriginatingDataset(originatingDataset);
Study study = getNodeFactory().getOrCreateStudy(study1);
assertThat(study.getDOI(), is(nullValue()));
assertThat(study.getCitation(), is("some citation"));
assertThat(study.getTitle(), is("title"));
assertThat(study.getExternalId(), is("some:id"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForMetaTableTest method assertExpectedColumnCount.
public void assertExpectedColumnCount(String metaTableDef) throws IOException {
final Class<DatasetImporterForMetaTable> clazz = DatasetImporterForMetaTable.class;
final URL resource = clazz.getResource(metaTableDef);
assertNotNull(resource);
final InputStream inputStream = clazz.getResourceAsStream(metaTableDef);
final JsonNode config = new ObjectMapper().readTree(inputStream);
String baseUrl = resource.toExternalForm().replaceFirst(metaTableDef + "$", "");
List<DatasetImporterForMetaTable.Column> columnNames = DatasetImporterForMetaTable.columnsFromExternalSchema(config.get("tableSchema"), new DatasetImpl(null, URI.create(baseUrl), inStream -> inStream));
assertThat(columnNames.size(), is(40));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importTaxonDescriptionsFromDirUnsupportedDescriptionType.
@Test
public void importTaxonDescriptionsFromDirUnsupportedDescriptionType() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/coetzer-unsupported-description-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 importRecordsFromZip.
@Test
public void importRecordsFromZip() throws StudyImporterException, IOException {
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/dwca.zip");
DatasetImporterForDwCA studyImporterForDwCA = new DatasetImporterForDwCA(null, null);
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("file:///some/path/data.zip"), inStream -> inStream);
JsonNode jsonNode = new ObjectMapper().readTree("{ " + "\"interactionTypeId\": \"http://purl.obolibrary.org/obo/RO_0002437\"," + "\"url\": \"" + resource.toExternalForm() + "\"" + "}");
dataset.setConfig(jsonNode);
studyImporterForDwCA.setDataset(dataset);
String expectedCitation = dataset.getCitation();
AtomicBoolean someRecords = new AtomicBoolean(false);
Set<String> resourceTypes = new TreeSet<>();
studyImporterForDwCA.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
String associatedTaxa = interaction.get("http://rs.tdwg.org/dwc/terms/associatedTaxa");
String dynamicProperties = interaction.get("http://rs.tdwg.org/dwc/terms/dynamicProperties");
assertThat(StringUtils.isNotBlank(associatedTaxa) || StringUtils.isNotBlank(dynamicProperties), is(true));
assertThat(interaction.get(SOURCE_TAXON_NAME), is(not(nullValue())));
assertThat(interaction.get(TaxonUtil.TARGET_TAXON_NAME), is(not(nullValue())));
assertThat(interaction.get(INTERACTION_TYPE_NAME), is(not(nullValue())));
assertThat(interaction.get(DatasetImporterForTSV.DATASET_CITATION), containsString(expectedCitation));
assertThat(interaction.get(REFERENCE_ID), startsWith("https://symbiota.ccber.ucsb.edu:443/collections/individual/index.php?occid"));
assertThat(interaction.get(DatasetImporterForTSV.REFERENCE_CITATION), startsWith("https://symbiota.ccber.ucsb.edu:443/collections/individual/index.php?occid"));
assertThat(interaction.get(REFERENCE_URL), startsWith("https://symbiota.ccber.ucsb.edu:443/collections/individual/index.php?occid"));
resourceTypes.addAll(Arrays.asList(splitByPipes(interaction.get(RESOURCE_TYPES))));
someRecords.set(true);
}
});
studyImporterForDwCA.importStudy();
assertThat(someRecords.get(), is(true));
assertThat(resourceTypes, containsInAnyOrder("http://rs.tdwg.org/dwc/terms/dynamicProperties", "http://rs.tdwg.org/dwc/terms/Occurrence", "http://rs.tdwg.org/dwc/terms/associatedTaxa"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importTaxonDescriptionsFromDir.
@Test
public void importTaxonDescriptionsFromDir() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("/org/globalbioticinteractions/dataset/coetzer/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 {
links.add(interaction);
}
});
studyImporterForDwCA.importStudy();
assertThat(links.size() > 0, is(true));
assertThat(links.get(0).get(DATASET_CITATION), containsString("org/globalbioticinteractions/dataset/coetzer/"));
assertThat(links.get(0).get(REFERENCE_CITATION), is("Cockerell, T.D.A. 1937. African bees of the genera Ceratina, Halictus and Megachile. 254 pp. William Clowes and Sons, London"));
assertThat(links.get(0).get(TARGET_TAXON_NAME), is("Chaetodactylus leleupi"));
assertThat(links.get(0).get(SOURCE_TAXON_NAME), is("Ceratina ruwenzorica Cockerell, 1937"));
assertThat(links.get(0).get(INTERACTION_TYPE_NAME), is("Parasite"));
assertThat(links.get(0).get(RESOURCE_TYPES), is("http://rs.gbif.org/terms/1.0/Reference"));
}
Aggregations