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;
}
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());
}
Aggregations