Search in sources :

Example 1 with SpecimenNodeWrapper

use of eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper in project cdmlib by cybertaxonomy.

the class OccurrenceDaoHibernateImpl method querySpecimen.

private List<SpecimenNodeWrapper> querySpecimen(Query query, List<UUID> taxonNodeUuids, Integer limit, Integer start) {
    query.setParameterList("taxonNodeUuids", taxonNodeUuids);
    addLimitAndStart(query, limit, start);
    List<SpecimenNodeWrapper> list = new ArrayList<>();
    @SuppressWarnings("unchecked") List<Object[]> result = query.list();
    for (Object[] object : result) {
        SpecimenNodeWrapper wrapper = new SpecimenNodeWrapper(new UuidAndTitleCache<>((UUID) object[0], (Integer) object[1], (String) object[2]), (SpecimenOrObservationType) object[3], new TaxonNodeDto((TaxonNode) object[4]));
        if (object.length > 5) {
            wrapper.setTaxonDescriptionUuid((UUID) object[5]);
        }
        list.add(wrapper);
    }
    return list;
}
Also used : TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) ArrayList(java.util.ArrayList) SpecimenNodeWrapper(eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper) UUID(java.util.UUID) TaxonNodeDto(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto)

Example 2 with SpecimenNodeWrapper

use of eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper in project cdmlib by cybertaxonomy.

the class OccurrenceServiceTest method testListUuidAndTitleCacheByAssociatedTaxon.

@Test
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest-testAllKindsOfSpecimenAssociations.xml")
public void testListUuidAndTitleCacheByAssociatedTaxon() {
    UUID taxonNodeUuid = UUID.fromString("6b8b6ff9-66e4-4496-8e5a-7d03bdf9a076");
    /**
     * Structure is as follows:
     *
     * Taxon ----IndividualsAssociation---> DnaSample
     * Taxon ----TypeDesignation---> Fossil
     * Taxon ----Determination ---> PreservedSpecimenA
     *
     * Taxon ---> Taxon Name ----Determination ---> PreservedSpecimenB
     *
     * Taxon ---> Synonym ---> SynonymName ----Determination---> PreservedSpecimenC
     *
     * Orphan Name (not associated with any taxon) ----Determination ---> PreservedSpecimenD
     */
    // UUIDS
    UUID derivedUnitDeterminationTaxonUuid = UUID.fromString("941b8b22-1925-4b91-8ff8-97114499bb22");
    UUID derivedUnitDeterminationNameUuid = UUID.fromString("0cdc7a57-6f55-45c8-b3e5-523748c381e7");
    UUID derivedUnitDeterminationSynonymNameUuid = UUID.fromString("d940a940-8caf-4a52-b1d8-ba4aad7ddae2");
    UUID derivedUnitDeterminationOrphanNameUuid = UUID.fromString("587b7297-7d59-4f59-8ef3-c7a559cadeca");
    UUID tissueUuidNoAssociationUuid = UUID.fromString("93e94260-5107-4b2c-9ce4-da9e1a4e7cb9");
    UUID dnaSampleUuidIndividualsAssociationUuid = UUID.fromString("1fb53903-c9b9-4078-8297-5b86aec7fe21");
    UUID fossilTypeDesignationUuid = UUID.fromString("42ec8dcf-a923-4256-bbd5-b0d10f4de5e2");
    UUID taxonUuid = UUID.fromString("07cc47a5-1a63-46a1-8366-0d59d2b90d5b");
    /*
         * search for taxon node
         * should retrieve all specimens associated via
         *  - type designations (fossil)
         *  - individuals associations (dnaSample)
         *  - determinations on
         *   - taxon (specimenA)
         *   - taxon name (specimenA, specimenB)
         */
    FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
    config.setAssociatedTaxonUuid(taxonUuid);
    Collection<SpecimenNodeWrapper> specimens = occurrenceService.listUuidAndTitleCacheByAssociatedTaxon(Collections.singletonList(taxonNodeUuid), null, null);
    List<UUID> uuidList = specimens.stream().map(specimen -> specimen.getUuidAndTitleCache().getUuid()).collect(Collectors.toList());
    assertTrue(uuidList.contains(derivedUnitDeterminationNameUuid));
    assertTrue(uuidList.contains(derivedUnitDeterminationTaxonUuid));
    assertFalse(uuidList.contains(derivedUnitDeterminationSynonymNameUuid));
    assertTrue(uuidList.contains(dnaSampleUuidIndividualsAssociationUuid));
    assertTrue(uuidList.contains(fossilTypeDesignationUuid));
    assertFalse(uuidList.contains(tissueUuidNoAssociationUuid));
    assertFalse(uuidList.contains(derivedUnitDeterminationOrphanNameUuid));
    assertEquals("Wrong number of associated specimens", 4, specimens.size());
}
Also used : SpringBeanByType(org.unitils.spring.annotation.SpringBeanByType) Sequence(eu.etaxonomy.cdm.model.molecular.Sequence) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) SynonymType(eu.etaxonomy.cdm.model.taxon.SynonymType) SpecimenTypeDesignation(eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation) Logger(org.apache.log4j.Logger) Classification(eu.etaxonomy.cdm.model.taxon.Classification) TaxonBase(eu.etaxonomy.cdm.model.taxon.TaxonBase) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) DataSet(org.unitils.dbunit.annotation.DataSet) DerivationEventType(eu.etaxonomy.cdm.model.occurrence.DerivationEventType) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) DeterminationEvent(eu.etaxonomy.cdm.model.occurrence.DeterminationEvent) Identifier(eu.etaxonomy.cdm.model.common.Identifier) DescriptionElementBase(eu.etaxonomy.cdm.model.description.DescriptionElementBase) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) DefinedTerm(eu.etaxonomy.cdm.model.term.DefinedTerm) TimePeriod(eu.etaxonomy.cdm.model.common.TimePeriod) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) SpecimenDeleteConfigurator(eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator) List(java.util.List) DerivationEvent(eu.etaxonomy.cdm.model.occurrence.DerivationEvent) Assert.assertFalse(org.junit.Assert.assertFalse) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) Synonym(eu.etaxonomy.cdm.model.taxon.Synonym) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) Person(eu.etaxonomy.cdm.model.agent.Person) IBotanicalName(eu.etaxonomy.cdm.model.name.IBotanicalName) SpecimenDescription(eu.etaxonomy.cdm.model.description.SpecimenDescription) Institution(eu.etaxonomy.cdm.model.agent.Institution) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) IndividualsAssociation(eu.etaxonomy.cdm.model.description.IndividualsAssociation) FindOccurrencesConfigurator(eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator) CleanSweepInsertLoadStrategy(eu.etaxonomy.cdm.test.unitils.CleanSweepInsertLoadStrategy) TaxonNameFactory(eu.etaxonomy.cdm.model.name.TaxonNameFactory) SpecimenNodeWrapper(eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper) DnaSample(eu.etaxonomy.cdm.model.molecular.DnaSample) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) CdmBase(eu.etaxonomy.cdm.model.common.CdmBase) ISequenceService(eu.etaxonomy.cdm.api.service.molecular.ISequenceService) Assert.assertNotNull(org.junit.Assert.assertNotNull) HibernateProxyHelper(eu.etaxonomy.cdm.hibernate.HibernateProxyHelper) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TypeDesignationBase(eu.etaxonomy.cdm.model.name.TypeDesignationBase) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) Assert.assertNull(org.junit.Assert.assertNull) SpecimenOrObservationBaseDTO(eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationBaseDTO) FieldUnit(eu.etaxonomy.cdm.model.occurrence.FieldUnit) AssignmentStatus(eu.etaxonomy.cdm.persistence.query.AssignmentStatus) Feature(eu.etaxonomy.cdm.model.description.Feature) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) FindOccurrencesConfigurator(eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator) SpecimenNodeWrapper(eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper) UUID(java.util.UUID) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) Test(org.junit.Test) DataSet(org.unitils.dbunit.annotation.DataSet)

Aggregations

TaxonNode (eu.etaxonomy.cdm.model.taxon.TaxonNode)2 SpecimenNodeWrapper (eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper)2 FindOccurrencesConfigurator (eu.etaxonomy.cdm.api.service.config.FindOccurrencesConfigurator)1 SpecimenDeleteConfigurator (eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator)1 SpecimenOrObservationBaseDTO (eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationBaseDTO)1 ISequenceService (eu.etaxonomy.cdm.api.service.molecular.ISequenceService)1 HibernateProxyHelper (eu.etaxonomy.cdm.hibernate.HibernateProxyHelper)1 Institution (eu.etaxonomy.cdm.model.agent.Institution)1 Person (eu.etaxonomy.cdm.model.agent.Person)1 CdmBase (eu.etaxonomy.cdm.model.common.CdmBase)1 Identifier (eu.etaxonomy.cdm.model.common.Identifier)1 TimePeriod (eu.etaxonomy.cdm.model.common.TimePeriod)1 DescriptionElementBase (eu.etaxonomy.cdm.model.description.DescriptionElementBase)1 Feature (eu.etaxonomy.cdm.model.description.Feature)1 IndividualsAssociation (eu.etaxonomy.cdm.model.description.IndividualsAssociation)1 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)1 TaxonDescription (eu.etaxonomy.cdm.model.description.TaxonDescription)1 DnaSample (eu.etaxonomy.cdm.model.molecular.DnaSample)1 Sequence (eu.etaxonomy.cdm.model.molecular.Sequence)1 IBotanicalName (eu.etaxonomy.cdm.model.name.IBotanicalName)1