Search in sources :

Example 1 with TARGET_TAXON_NAME

use of org.eol.globi.service.TaxonUtil.TARGET_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"));
}
Also used : TaxonUtil(org.eol.globi.service.TaxonUtil) Arrays(java.util.Arrays) INTERACTION_TYPE_NAME(org.eol.globi.data.DatasetImporterForTSV.INTERACTION_TYPE_NAME) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) INTERACTION_TYPE_ID(org.eol.globi.data.DatasetImporterForTSV.INTERACTION_TYPE_ID) InteractionListener(org.eol.globi.process.InteractionListener) StringUtils(org.apache.commons.lang3.StringUtils) NullImportLogger(org.eol.globi.tool.NullImportLogger) InteractType(org.eol.globi.domain.InteractType) Is(org.hamcrest.core.Is) REFERENCE_URL(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_URL) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) SOURCE_LIFE_STAGE_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) DatasetImporterForDwCA.parseAssociatedSequences(org.eol.globi.data.DatasetImporterForDwCA.parseAssociatedSequences) DatasetImporterForDwCA.importAssociatedTaxaExtension(org.eol.globi.data.DatasetImporterForDwCA.importAssociatedTaxaExtension) DatasetImporterForDwCA.mapReferenceInfo(org.eol.globi.data.DatasetImporterForDwCA.mapReferenceInfo) TARGET_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID) EXTENSION_RESOURCE_RELATIONSHIP(org.eol.globi.data.DatasetImporterForDwCA.EXTENSION_RESOURCE_RELATIONSHIP) SOURCE_TAXON_NAME(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME) DwcTerm(org.gbif.dwc.terms.DwcTerm) IsNot.not(org.hamcrest.core.IsNot.not) TARGET_FIELD_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_FIELD_NUMBER) DatasetImporterForDwCA.importResourceRelationshipExtension(org.eol.globi.data.DatasetImporterForDwCA.importResourceRelationshipExtension) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) REFERENCE_ID(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID) Record(org.gbif.dwc.record.Record) Set(java.util.Set) TestCase.assertNull(junit.framework.TestCase.assertNull) Matchers.startsWith(org.hamcrest.Matchers.startsWith) DatasetImporterForDwCA.parseDynamicPropertiesForInteractionsOnly(org.eol.globi.data.DatasetImporterForDwCA.parseDynamicPropertiesForInteractionsOnly) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) EXTENSION_ASSOCIATED_TAXA(org.eol.globi.data.DatasetImporterForDwCA.EXTENSION_ASSOCIATED_TAXA) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) TARGET_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME) DATASET_CITATION(org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION) CoreMatchers.anyOf(org.hamcrest.CoreMatchers.anyOf) LogContext(org.eol.globi.domain.LogContext) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) TARGET_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER) DwcTerm.relatedResourceID(org.gbif.dwc.terms.DwcTerm.relatedResourceID) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SOURCE_TAXON_FAMILY(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_FAMILY) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) RESOURCE_TYPES(org.eol.globi.data.DatasetImporterForTSV.RESOURCE_TYPES) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) SOURCE_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Term(org.gbif.dwc.terms.Term) MapUtils(org.apache.commons.collections4.MapUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) Archive(org.gbif.dwc.Archive) DwCAUtil(org.globalbioticinteractions.dataset.DwCAUtil) Test(org.junit.Test) IOException(java.io.IOException) TARGET_TAXON_NAME(org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME) File(java.io.File) DatasetImporterForDwCA.parseAssociatedOccurrences(org.eol.globi.data.DatasetImporterForDwCA.parseAssociatedOccurrences) TARGET_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME) TreeMap(java.util.TreeMap) DcTerm(org.gbif.dwc.terms.DcTerm) REFERENCE_CITATION(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION) ArrayList(java.util.ArrayList) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) URI(java.net.URI) URL(java.net.URL) REFERENCE_URL(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_URL) InteractionListener(org.eol.globi.process.InteractionListener) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 2 with TARGET_TAXON_NAME

use of org.eol.globi.service.TaxonUtil.TARGET_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));
}
Also used : TaxonUtil(org.eol.globi.service.TaxonUtil) Arrays(java.util.Arrays) INTERACTION_TYPE_NAME(org.eol.globi.data.DatasetImporterForTSV.INTERACTION_TYPE_NAME) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) INTERACTION_TYPE_ID(org.eol.globi.data.DatasetImporterForTSV.INTERACTION_TYPE_ID) InteractionListener(org.eol.globi.process.InteractionListener) StringUtils(org.apache.commons.lang3.StringUtils) NullImportLogger(org.eol.globi.tool.NullImportLogger) InteractType(org.eol.globi.domain.InteractType) Is(org.hamcrest.core.Is) REFERENCE_URL(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_URL) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Is.is(org.hamcrest.core.Is.is) SOURCE_LIFE_STAGE_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME) JsonNode(com.fasterxml.jackson.databind.JsonNode) URI(java.net.URI) DatasetImporterForDwCA.parseAssociatedSequences(org.eol.globi.data.DatasetImporterForDwCA.parseAssociatedSequences) DatasetImporterForDwCA.importAssociatedTaxaExtension(org.eol.globi.data.DatasetImporterForDwCA.importAssociatedTaxaExtension) DatasetImporterForDwCA.mapReferenceInfo(org.eol.globi.data.DatasetImporterForDwCA.mapReferenceInfo) TARGET_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID) EXTENSION_RESOURCE_RELATIONSHIP(org.eol.globi.data.DatasetImporterForDwCA.EXTENSION_RESOURCE_RELATIONSHIP) SOURCE_TAXON_NAME(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME) DwcTerm(org.gbif.dwc.terms.DwcTerm) IsNot.not(org.hamcrest.core.IsNot.not) TARGET_FIELD_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_FIELD_NUMBER) DatasetImporterForDwCA.importResourceRelationshipExtension(org.eol.globi.data.DatasetImporterForDwCA.importResourceRelationshipExtension) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) REFERENCE_ID(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID) Record(org.gbif.dwc.record.Record) Set(java.util.Set) TestCase.assertNull(junit.framework.TestCase.assertNull) Matchers.startsWith(org.hamcrest.Matchers.startsWith) DatasetImporterForDwCA.parseDynamicPropertiesForInteractionsOnly(org.eol.globi.data.DatasetImporterForDwCA.parseDynamicPropertiesForInteractionsOnly) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) EXTENSION_ASSOCIATED_TAXA(org.eol.globi.data.DatasetImporterForDwCA.EXTENSION_ASSOCIATED_TAXA) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) TARGET_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME) DATASET_CITATION(org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION) CoreMatchers.anyOf(org.hamcrest.CoreMatchers.anyOf) LogContext(org.eol.globi.domain.LogContext) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) TARGET_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER) DwcTerm.relatedResourceID(org.gbif.dwc.terms.DwcTerm.relatedResourceID) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SOURCE_TAXON_FAMILY(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_FAMILY) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) RESOURCE_TYPES(org.eol.globi.data.DatasetImporterForTSV.RESOURCE_TYPES) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) SOURCE_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Term(org.gbif.dwc.terms.Term) MapUtils(org.apache.commons.collections4.MapUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) Archive(org.gbif.dwc.Archive) DwCAUtil(org.globalbioticinteractions.dataset.DwCAUtil) Test(org.junit.Test) IOException(java.io.IOException) TARGET_TAXON_NAME(org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME) File(java.io.File) DatasetImporterForDwCA.parseAssociatedOccurrences(org.eol.globi.data.DatasetImporterForDwCA.parseAssociatedOccurrences) TARGET_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME) TreeMap(java.util.TreeMap) DcTerm(org.gbif.dwc.terms.DcTerm) REFERENCE_CITATION(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DatasetImpl(org.globalbioticinteractions.dataset.DatasetImpl) URL(java.net.URL) REFERENCE_URL(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_URL) Test(org.junit.Test)

Example 3 with TARGET_TAXON_NAME

use of org.eol.globi.service.TaxonUtil.TARGET_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));
}
Also used : Arrays(java.util.Arrays) NodeUtil(org.eol.globi.util.NodeUtil) SOURCE_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_ID) Date(java.util.Date) Direction(org.neo4j.graphdb.Direction) TARGET_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_ID) DatasetImporterForMetaTable(org.eol.globi.data.DatasetImporterForMetaTable) NullImportLogger(org.eol.globi.tool.NullImportLogger) InteractType(org.eol.globi.domain.InteractType) TARGET_TAXON_RANK(org.eol.globi.service.TaxonUtil.TARGET_TAXON_RANK) StudyImporterException(org.eol.globi.data.StudyImporterException) TARGET_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.TARGET_TAXON_PATH_IDS) RelationshipListener(org.eol.globi.util.RelationshipListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DECIMAL_LONGITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LONGITUDE) COLLECTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_CODE) TARGET_TAXON_ID(org.eol.globi.service.TaxonUtil.TARGET_TAXON_ID) SOURCE_TAXON_ID(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_ID) Is.is(org.hamcrest.core.Is.is) SOURCE_LIFE_STAGE_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME) LatLng(org.eol.globi.geo.LatLng) Assert.fail(org.junit.Assert.fail) GraphDBTestCase(org.eol.globi.data.GraphDBTestCase) TARGET_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID) SOURCE_TAXON_NAME(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME) TARGET_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_INSTITUTION_CODE) LOCALITY_NAME(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_NAME) REFERENCE_ID(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID) SOURCE_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_CODE) LocationNode(org.eol.globi.domain.LocationNode) NodeTypeDirection(org.eol.globi.util.NodeTypeDirection) List(java.util.List) SOURCE_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_ID) SOURCE_TAXON_SPECIFIC_EPITHET(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_SPECIFIC_EPITHET) Assert.assertFalse(org.junit.Assert.assertFalse) SOURCE_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.SOURCE_CATALOG_NUMBER) SOURCE_TAXON_PATH(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH) TARGET_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_CODE) SpecimenConstant(org.eol.globi.domain.SpecimenConstant) SpecimenNode(org.eol.globi.domain.SpecimenNode) TARGET_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME) DATASET_CITATION(org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION) SOURCE_TAXON_RANK(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_RANK) DateUtil(org.eol.globi.util.DateUtil) LogContext(org.eol.globi.domain.LogContext) COLLECTION_ID(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_ID) OCCURRENCE_ID(org.eol.globi.domain.PropertyAndValueDictionary.OCCURRENCE_ID) TARGET_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RelTypes(org.eol.globi.domain.RelTypes) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) SOURCE_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_NAME) SOURCE_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_NAME) SOURCE_TAXON_PATH_NAMES(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_NAMES) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CATALOG_NUMBER(org.eol.globi.domain.PropertyAndValueDictionary.CATALOG_NUMBER) StringStartsWith.startsWith(org.hamcrest.core.StringStartsWith.startsWith) SOURCE_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID) ARGUMENT_TYPE_ID(org.eol.globi.data.DatasetImporterForTSV.ARGUMENT_TYPE_ID) SOURCE_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_INSTITUTION_CODE) SOURCE_LIFE_STAGE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_ID) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) StudyNode(org.eol.globi.domain.StudyNode) TARGET_TAXON_NAME(org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME) TARGET_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_ID) INSTITUTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.INSTITUTION_CODE) SOURCE_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_IDS) LOCALITY_ID(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_ID) SOURCE_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_ID) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) GeoNamesService(org.eol.globi.service.GeoNamesService) TARGET_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME) Relationship(org.neo4j.graphdb.Relationship) TreeMap(java.util.TreeMap) NodeFactoryException(org.eol.globi.data.NodeFactoryException) DECIMAL_LATITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LATITUDE) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) REFERENCE_DOI(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_DOI) TARGET_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_ID) TaxonNode(org.eol.globi.domain.TaxonNode) REFERENCE_CITATION(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LocationNode(org.eol.globi.domain.LocationNode) TreeMap(java.util.TreeMap) SpecimenNode(org.eol.globi.domain.SpecimenNode) RelationshipListener(org.eol.globi.util.RelationshipListener) Test(org.junit.Test)

Example 4 with TARGET_TAXON_NAME

use of org.eol.globi.service.TaxonUtil.TARGET_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));
}
Also used : Arrays(java.util.Arrays) NodeUtil(org.eol.globi.util.NodeUtil) SOURCE_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_ID) Date(java.util.Date) Direction(org.neo4j.graphdb.Direction) TARGET_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_ID) DatasetImporterForMetaTable(org.eol.globi.data.DatasetImporterForMetaTable) NullImportLogger(org.eol.globi.tool.NullImportLogger) InteractType(org.eol.globi.domain.InteractType) TARGET_TAXON_RANK(org.eol.globi.service.TaxonUtil.TARGET_TAXON_RANK) StudyImporterException(org.eol.globi.data.StudyImporterException) TARGET_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.TARGET_TAXON_PATH_IDS) RelationshipListener(org.eol.globi.util.RelationshipListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DECIMAL_LONGITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LONGITUDE) COLLECTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_CODE) TARGET_TAXON_ID(org.eol.globi.service.TaxonUtil.TARGET_TAXON_ID) SOURCE_TAXON_ID(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_ID) Is.is(org.hamcrest.core.Is.is) SOURCE_LIFE_STAGE_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME) LatLng(org.eol.globi.geo.LatLng) Assert.fail(org.junit.Assert.fail) GraphDBTestCase(org.eol.globi.data.GraphDBTestCase) TARGET_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID) SOURCE_TAXON_NAME(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME) TARGET_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_INSTITUTION_CODE) LOCALITY_NAME(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_NAME) REFERENCE_ID(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID) SOURCE_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_CODE) LocationNode(org.eol.globi.domain.LocationNode) NodeTypeDirection(org.eol.globi.util.NodeTypeDirection) List(java.util.List) SOURCE_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_ID) SOURCE_TAXON_SPECIFIC_EPITHET(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_SPECIFIC_EPITHET) Assert.assertFalse(org.junit.Assert.assertFalse) SOURCE_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.SOURCE_CATALOG_NUMBER) SOURCE_TAXON_PATH(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH) TARGET_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_CODE) SpecimenConstant(org.eol.globi.domain.SpecimenConstant) SpecimenNode(org.eol.globi.domain.SpecimenNode) TARGET_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME) DATASET_CITATION(org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION) SOURCE_TAXON_RANK(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_RANK) DateUtil(org.eol.globi.util.DateUtil) LogContext(org.eol.globi.domain.LogContext) COLLECTION_ID(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_ID) OCCURRENCE_ID(org.eol.globi.domain.PropertyAndValueDictionary.OCCURRENCE_ID) TARGET_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RelTypes(org.eol.globi.domain.RelTypes) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) SOURCE_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_NAME) SOURCE_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_NAME) SOURCE_TAXON_PATH_NAMES(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_NAMES) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CATALOG_NUMBER(org.eol.globi.domain.PropertyAndValueDictionary.CATALOG_NUMBER) StringStartsWith.startsWith(org.hamcrest.core.StringStartsWith.startsWith) SOURCE_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID) ARGUMENT_TYPE_ID(org.eol.globi.data.DatasetImporterForTSV.ARGUMENT_TYPE_ID) SOURCE_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_INSTITUTION_CODE) SOURCE_LIFE_STAGE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_ID) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) StudyNode(org.eol.globi.domain.StudyNode) TARGET_TAXON_NAME(org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME) TARGET_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_ID) INSTITUTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.INSTITUTION_CODE) SOURCE_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_IDS) LOCALITY_ID(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_ID) SOURCE_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_ID) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) GeoNamesService(org.eol.globi.service.GeoNamesService) TARGET_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME) Relationship(org.neo4j.graphdb.Relationship) TreeMap(java.util.TreeMap) NodeFactoryException(org.eol.globi.data.NodeFactoryException) DECIMAL_LATITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LATITUDE) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) REFERENCE_DOI(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_DOI) TARGET_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_ID) TaxonNode(org.eol.globi.domain.TaxonNode) REFERENCE_CITATION(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TreeMap(java.util.TreeMap) SpecimenNode(org.eol.globi.domain.SpecimenNode) RelationshipListener(org.eol.globi.util.RelationshipListener) Test(org.junit.Test)

Example 5 with TARGET_TAXON_NAME

use of org.eol.globi.service.TaxonUtil.TARGET_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));
}
Also used : Arrays(java.util.Arrays) NodeUtil(org.eol.globi.util.NodeUtil) SOURCE_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_ID) Date(java.util.Date) Direction(org.neo4j.graphdb.Direction) TARGET_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_ID) DatasetImporterForMetaTable(org.eol.globi.data.DatasetImporterForMetaTable) NullImportLogger(org.eol.globi.tool.NullImportLogger) InteractType(org.eol.globi.domain.InteractType) TARGET_TAXON_RANK(org.eol.globi.service.TaxonUtil.TARGET_TAXON_RANK) StudyImporterException(org.eol.globi.data.StudyImporterException) TARGET_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.TARGET_TAXON_PATH_IDS) RelationshipListener(org.eol.globi.util.RelationshipListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DECIMAL_LONGITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LONGITUDE) COLLECTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_CODE) TARGET_TAXON_ID(org.eol.globi.service.TaxonUtil.TARGET_TAXON_ID) SOURCE_TAXON_ID(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_ID) Is.is(org.hamcrest.core.Is.is) SOURCE_LIFE_STAGE_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME) LatLng(org.eol.globi.geo.LatLng) Assert.fail(org.junit.Assert.fail) GraphDBTestCase(org.eol.globi.data.GraphDBTestCase) TARGET_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID) SOURCE_TAXON_NAME(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME) TARGET_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_INSTITUTION_CODE) LOCALITY_NAME(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_NAME) REFERENCE_ID(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID) SOURCE_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_CODE) LocationNode(org.eol.globi.domain.LocationNode) NodeTypeDirection(org.eol.globi.util.NodeTypeDirection) List(java.util.List) SOURCE_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_COLLECTION_ID) SOURCE_TAXON_SPECIFIC_EPITHET(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_SPECIFIC_EPITHET) Assert.assertFalse(org.junit.Assert.assertFalse) SOURCE_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.SOURCE_CATALOG_NUMBER) SOURCE_TAXON_PATH(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH) TARGET_COLLECTION_CODE(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_CODE) SpecimenConstant(org.eol.globi.domain.SpecimenConstant) SpecimenNode(org.eol.globi.domain.SpecimenNode) TARGET_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME) DATASET_CITATION(org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION) SOURCE_TAXON_RANK(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_RANK) DateUtil(org.eol.globi.util.DateUtil) LogContext(org.eol.globi.domain.LogContext) COLLECTION_ID(org.eol.globi.domain.PropertyAndValueDictionary.COLLECTION_ID) OCCURRENCE_ID(org.eol.globi.domain.PropertyAndValueDictionary.OCCURRENCE_ID) TARGET_CATALOG_NUMBER(org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RelTypes(org.eol.globi.domain.RelTypes) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) SOURCE_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_NAME) SOURCE_BODY_PART_NAME(org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_NAME) SOURCE_TAXON_PATH_NAMES(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_NAMES) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CATALOG_NUMBER(org.eol.globi.domain.PropertyAndValueDictionary.CATALOG_NUMBER) StringStartsWith.startsWith(org.hamcrest.core.StringStartsWith.startsWith) SOURCE_OCCURRENCE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID) ARGUMENT_TYPE_ID(org.eol.globi.data.DatasetImporterForTSV.ARGUMENT_TYPE_ID) SOURCE_INSTITUTION_CODE(org.eol.globi.data.DatasetImporterForTSV.SOURCE_INSTITUTION_CODE) SOURCE_LIFE_STAGE_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_ID) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) StudyNode(org.eol.globi.domain.StudyNode) TARGET_TAXON_NAME(org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME) TARGET_COLLECTION_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_COLLECTION_ID) INSTITUTION_CODE(org.eol.globi.domain.PropertyAndValueDictionary.INSTITUTION_CODE) SOURCE_TAXON_PATH_IDS(org.eol.globi.service.TaxonUtil.SOURCE_TAXON_PATH_IDS) LOCALITY_ID(org.eol.globi.data.DatasetImporterForTSV.LOCALITY_ID) SOURCE_SEX_ID(org.eol.globi.data.DatasetImporterForTSV.SOURCE_SEX_ID) DatasetImporterForTSV(org.eol.globi.data.DatasetImporterForTSV) GeoNamesService(org.eol.globi.service.GeoNamesService) TARGET_SEX_NAME(org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME) Relationship(org.neo4j.graphdb.Relationship) TreeMap(java.util.TreeMap) NodeFactoryException(org.eol.globi.data.NodeFactoryException) DECIMAL_LATITUDE(org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LATITUDE) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) REFERENCE_DOI(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_DOI) TARGET_BODY_PART_ID(org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_ID) TaxonNode(org.eol.globi.domain.TaxonNode) REFERENCE_CITATION(org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TreeMap(java.util.TreeMap) SpecimenNode(org.eol.globi.domain.SpecimenNode) RelationshipListener(org.eol.globi.util.RelationshipListener) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 Arrays (java.util.Arrays)10 List (java.util.List)10 TreeMap (java.util.TreeMap)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 DATASET_CITATION (org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION)10 REFERENCE_CITATION (org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION)10 REFERENCE_ID (org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID)10 SOURCE_LIFE_STAGE_NAME (org.eol.globi.data.DatasetImporterForTSV.SOURCE_LIFE_STAGE_NAME)10 SOURCE_OCCURRENCE_ID (org.eol.globi.data.DatasetImporterForTSV.SOURCE_OCCURRENCE_ID)10 TARGET_BODY_PART_NAME (org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_NAME)10 TARGET_CATALOG_NUMBER (org.eol.globi.data.DatasetImporterForTSV.TARGET_CATALOG_NUMBER)10 TARGET_OCCURRENCE_ID (org.eol.globi.data.DatasetImporterForTSV.TARGET_OCCURRENCE_ID)10 TARGET_SEX_NAME (org.eol.globi.data.DatasetImporterForTSV.TARGET_SEX_NAME)10 InteractType (org.eol.globi.domain.InteractType)10 SOURCE_TAXON_NAME (org.eol.globi.service.TaxonUtil.SOURCE_TAXON_NAME)10 TARGET_TAXON_NAME (org.eol.globi.service.TaxonUtil.TARGET_TAXON_NAME)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 LogContext (org.eol.globi.domain.LogContext)9