use of org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME 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"));
}
use of org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME in project eol-globi-data by jhpoelen.
the class DatasetImporterForDwCATest method importRecordsFromResourceRelationshipArchiveRemarksOnly.
@Test
public void importRecordsFromResourceRelationshipArchiveRemarksOnly() throws StudyImporterException, URISyntaxException {
URL resource = getClass().getResource("fmnh-rr-8278596f-4d3f-4f82-8cd1-b5070fe1bc7c.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 -> {
assertThat(interaction.get(TARGET_TAXON_NAME), is("Glaucomys volans"));
assertThat(interaction.get(TARGET_OCCURRENCE_ID), is(nullValue()));
assertThat(interaction.get(SOURCE_TAXON_NAME), is("Orchopeas fulleri Traub, 1950"));
assertThat(interaction.get(SOURCE_OCCURRENCE_ID), is("8278596f-4d3f-4f82-8cd1-b5070fe1bc7c"));
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.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method importWithLocalityAndLatLng.
@Test
public void importWithLocalityAndLatLng() throws StudyImporterException {
final InteractionListener listener = getAssertingInteractionImporter();
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(SOURCE_TAXON_ID, "duck");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
link.put(TARGET_TAXON_NAME, "mini");
link.put(TARGET_TAXON_ID, "mouse");
link.put(LOCALITY_ID, "back:yard");
link.put(LOCALITY_NAME, "my back yard");
link.put(DECIMAL_LATITUDE, "12.2");
link.put(DECIMAL_LONGITUDE, "13.2");
link.put(REFERENCE_ID, "123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_CITATION, "");
link.put(REFERENCE_DOI, "doi:10.12/34");
listener.on(link);
AtomicBoolean foundSpecimen = new AtomicBoolean(false);
RelationshipListener someListener = relationship -> {
final SpecimenNode someSpecimen = new SpecimenNode(relationship.getEndNode());
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.COLLECTED)));
LocationNode sampleLocation = someSpecimen.getSampleLocation();
assertThat(sampleLocation.getLatitude(), is(12.2d));
assertThat(sampleLocation.getLongitude(), is(13.2d));
assertThat(sampleLocation.getLocality(), is("my back yard"));
assertThat(sampleLocation.getLocalityId(), is("back:yard"));
foundSpecimen.set(true);
};
handleRelations(someListener, RelTypes.COLLECTED);
assertThat(foundSpecimen.get(), is(true));
}
use of org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method importRefutingClaim.
@Test
public void importRefutingClaim() throws StudyImporterException {
final InteractionListener listener = getAssertingInteractionImporter();
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(SOURCE_TAXON_ID, "duck");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
link.put(TARGET_TAXON_NAME, "mini");
link.put(TARGET_TAXON_ID, "mouse");
link.put(ARGUMENT_TYPE_ID, "https://en.wiktionary.org/wiki/refute");
link.put(REFERENCE_ID, "123");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_CITATION, "");
link.put(REFERENCE_DOI, "doi:10.12/34");
listener.on(link);
AtomicBoolean foundSpecimen = new AtomicBoolean(false);
RelationshipListener relHandler = relationship -> {
final SpecimenNode someSpecimen = new SpecimenNode(relationship.getEndNode());
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.REFUTES)));
assertFalse(someSpecimen.getUnderlyingNode().hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.COLLECTED)));
foundSpecimen.set(true);
};
handleRelations(relHandler, RelTypes.REFUTES);
assertThat(foundSpecimen.get(), is(true));
}
use of org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME in project eol-globi-data by jhpoelen.
the class InteractionImporterTest method importWithSex.
@Test
public void importWithSex() throws StudyImporterException {
final InteractionListener listener = getAssertingInteractionImporter();
final TreeMap<String, String> link = new TreeMap<>();
link.put(SOURCE_TAXON_NAME, "donald");
link.put(SOURCE_SEX_NAME, "female");
link.put(SOURCE_SEX_ID, "some:female");
link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, InteractType.ATE.getIRI());
link.put(TARGET_TAXON_NAME, "mini");
link.put(TARGET_SEX_NAME, "male");
link.put(TARGET_SEX_ID, "some:male");
link.put(DATASET_CITATION, "some source ref");
link.put(REFERENCE_ID, "123");
link.put(REFERENCE_CITATION, "");
listener.on(link);
AtomicInteger foundSpecimen = new AtomicInteger(0);
RelationshipListener someListener = relationship -> {
final SpecimenNode someSpecimen = new SpecimenNode(relationship.getEndNode());
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(Direction.INCOMING, NodeUtil.asNeo4j(RelTypes.COLLECTED)));
assertTrue(someSpecimen.getUnderlyingNode().hasRelationship(NodeUtil.asNeo4j(InteractType.ATE)));
if (someSpecimen.getUnderlyingNode().hasRelationship(Direction.OUTGOING, NodeUtil.asNeo4j(InteractType.ATE))) {
assertThat(someSpecimen.getSex().getName(), is("female"));
assertThat(someSpecimen.getSex().getId(), is("some:female"));
} else {
assertThat(someSpecimen.getSex().getName(), is("male"));
assertThat(someSpecimen.getSex().getId(), is("some:male"));
}
foundSpecimen.incrementAndGet();
};
handleRelations(someListener, RelTypes.COLLECTED);
assertThat(foundSpecimen.get(), is(2));
}
Aggregations