Search in sources :

Example 1 with TARGET_BODY_PART_ID

use of org.eol.globi.data.DatasetImporterForTSV.TARGET_BODY_PART_ID in project eol-globi-data by jhpoelen.

the class InteractionImporterTest method importBlankCitation.

@Test
public void importBlankCitation() throws StudyImporterException {
    final InteractionListener listener = new InteractionImporter(nodeFactory, (GeoNamesService) null, null);
    final TreeMap<String, String> link = new TreeMap<String, String>();
    link.put(SOURCE_OCCURRENCE_ID, "123");
    link.put(SOURCE_CATALOG_NUMBER, "catalogNumber123");
    link.put(SOURCE_COLLECTION_CODE, "collectionCode123");
    link.put(SOURCE_COLLECTION_ID, "collectionId123");
    link.put(SOURCE_INSTITUTION_CODE, "institutionCode123");
    link.put(TARGET_OCCURRENCE_ID, "456");
    link.put(TARGET_CATALOG_NUMBER, "targetCatalogNumber123");
    link.put(TARGET_COLLECTION_CODE, "targetCollectionCode123");
    link.put(TARGET_COLLECTION_ID, "targetCollectionId123");
    link.put(TARGET_INSTITUTION_CODE, "targetInstitutionCode123");
    link.put(SOURCE_TAXON_NAME, "donald");
    link.put(SOURCE_TAXON_ID, "duck");
    link.put(SOURCE_BODY_PART_ID, "bla:123");
    link.put(SOURCE_BODY_PART_NAME, "snout");
    link.put(SOURCE_LIFE_STAGE_ID, "some:stage");
    link.put(SOURCE_LIFE_STAGE_NAME, "stage");
    link.put(TARGET_TAXON_NAME, "mini");
    link.put(TARGET_TAXON_ID, "mouse");
    link.put(TARGET_BODY_PART_ID, "bla:345");
    link.put(TARGET_BODY_PART_NAME, "tail");
    link.put(DatasetImporterForMetaTable.EVENT_DATE, "20160404T21:31:40Z");
    link.put(DatasetImporterForMetaTable.LATITUDE, "12.1");
    link.put(DatasetImporterForMetaTable.LONGITUDE, "13.2");
    link.put(DatasetImporterForTSV.INTERACTION_TYPE_ID, "http://purl.obolibrary.org/obo/RO_0002470");
    link.put(REFERENCE_ID, "123");
    link.put(DATASET_CITATION, "some source ref");
    link.put(REFERENCE_CITATION, "");
    link.put(REFERENCE_DOI, "doi:1234");
    listener.on(link);
    final AtomicBoolean foundPair = new AtomicBoolean(false);
    RelationshipListener relationshipListener = relationship -> {
        final SpecimenNode predator = new SpecimenNode(relationship.getEndNode());
        for (Relationship stomachRel : NodeUtil.getStomachContents(predator)) {
            final SpecimenNode prey = new SpecimenNode(stomachRel.getEndNode());
            final TaxonNode preyTaxon = getOrigTaxon(prey);
            final TaxonNode predTaxon = getOrigTaxon(predator);
            assertThat(preyTaxon.getName(), is("mini"));
            assertThat(preyTaxon.getExternalId(), is("mouse"));
            assertThat(predTaxon.getName(), is("donald"));
            assertThat(predTaxon.getExternalId(), is("duck"));
            assertLocation(predator.getSampleLocation());
            assertLocation(prey.getSampleLocation());
            assertThat(predator.getExternalId(), is("123"));
            assertThat(prey.getExternalId(), is("456"));
            assertThat(predator.getLifeStage().getId(), is("some:stage"));
            assertThat(predator.getLifeStage().getName(), is("stage"));
            assertThat(predator.getProperty(OCCURRENCE_ID), is("123"));
            assertThat(predator.getProperty(CATALOG_NUMBER), is("catalogNumber123"));
            assertThat(predator.getProperty(COLLECTION_CODE), is("collectionCode123"));
            assertThat(predator.getProperty(COLLECTION_ID), is("collectionId123"));
            assertThat(predator.getProperty(INSTITUTION_CODE), is("institutionCode123"));
            assertThat(prey.getProperty(OCCURRENCE_ID), is("456"));
            assertThat(prey.getProperty(CATALOG_NUMBER), is("targetCatalogNumber123"));
            assertThat(prey.getProperty(COLLECTION_CODE), is("targetCollectionCode123"));
            assertThat(prey.getProperty(COLLECTION_ID), is("targetCollectionId123"));
            assertThat(prey.getProperty(INSTITUTION_CODE), is("targetInstitutionCode123"));
            foundPair.set(true);
            assertThat(relationship.getProperty(SpecimenConstant.EVENT_DATE), is(notNullValue()));
            List<SpecimenNode> specimens = Arrays.asList(predator, prey);
            for (SpecimenNode specimen : specimens) {
                assertThat(specimen.getBodyPart().getId(), is(notNullValue()));
                assertThat(specimen.getBodyPart().getName(), is(notNullValue()));
            }
        }
    };
    handleRelations(relationshipListener, RelTypes.COLLECTED);
    assertThat(foundPair.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) TaxonNode(org.eol.globi.domain.TaxonNode) Relationship(org.neo4j.graphdb.Relationship) List(java.util.List) ArrayList(java.util.ArrayList) 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)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DatasetImporterForMetaTable (org.eol.globi.data.DatasetImporterForMetaTable)1 DatasetImporterForTSV (org.eol.globi.data.DatasetImporterForTSV)1 ARGUMENT_TYPE_ID (org.eol.globi.data.DatasetImporterForTSV.ARGUMENT_TYPE_ID)1 DATASET_CITATION (org.eol.globi.data.DatasetImporterForTSV.DATASET_CITATION)1 DECIMAL_LATITUDE (org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LATITUDE)1 DECIMAL_LONGITUDE (org.eol.globi.data.DatasetImporterForTSV.DECIMAL_LONGITUDE)1 LOCALITY_ID (org.eol.globi.data.DatasetImporterForTSV.LOCALITY_ID)1 LOCALITY_NAME (org.eol.globi.data.DatasetImporterForTSV.LOCALITY_NAME)1 REFERENCE_CITATION (org.eol.globi.data.DatasetImporterForTSV.REFERENCE_CITATION)1 REFERENCE_DOI (org.eol.globi.data.DatasetImporterForTSV.REFERENCE_DOI)1 REFERENCE_ID (org.eol.globi.data.DatasetImporterForTSV.REFERENCE_ID)1 SOURCE_BODY_PART_ID (org.eol.globi.data.DatasetImporterForTSV.SOURCE_BODY_PART_ID)1