Revision bce2d0e5
Added by Katja Luther almost 2 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java | ||
---|---|---|
144 | 144 |
} |
145 | 145 |
DescriptionBaseDto descDto = descriptionService.loadDto(description); |
146 | 146 |
RowWrapperDTO<?> rowWrapper = null; |
147 |
if (descDto.getTaxonDto() != null && |
|
147 |
if (descDto != null && descDto.getTaxonDto() != null &&
|
|
148 | 148 |
(descDto.getTypes().contains(DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION) |
149 | 149 |
|| descDto.getTypes().contains(DescriptionType.AGGREGATED_STRUC_DESC) |
150 | 150 |
|| descDto.getTypes().contains(DescriptionType.SECONDARY_DATA) |
151 | 151 |
)){ |
152 | 152 |
rowWrapper = createTaxonRowWrapper(descDto, datasetDto.getUuid()); |
153 | 153 |
} |
154 |
else if (descDto.getSpecimenDto() != null && (descDto.getTypes() == null || |
|
154 |
else if (descDto != null &&descDto.getSpecimenDto() != null && (descDto.getTypes() == null ||
|
|
155 | 155 |
!descDto.getTypes().contains(DescriptionType.CLONE_FOR_SOURCE))){ |
156 | 156 |
rowWrapper = createSpecimenRowWrapper(descDto, descriptiveDataSetUuid); |
157 | 157 |
} |
... | ... | |
207 | 207 |
private DescriptionBaseDto recurseDefaultDescription(TaxonNodeDto node, DescriptiveDataSetBaseDto dataSet){ |
208 | 208 |
DescriptionBaseDto defaultDescription = null; |
209 | 209 |
if(node!=null && node.getTaxonUuid()!=null){ |
210 |
defaultDescription = getTaxonDescriptionForDescriptiveDataSetAndType(dataSet, node.getUuid(), DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION); |
|
210 |
defaultDescription = getTaxonDescriptionForDescriptiveDataSetAndType(dataSet, node.getTaxonUuid(), DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION);
|
|
211 | 211 |
if(defaultDescription==null && node.getParentUUID()!=null){ |
212 | 212 |
defaultDescription = recurseDefaultDescription(taxonNodeService.dto(node.getParentUUID()), dataSet); |
213 | 213 |
} |
... | ... | |
491 | 491 |
@Override |
492 | 492 |
public DescriptionBaseDto getTaxonDescriptionForDescriptiveDataSetAndType(DescriptiveDataSetBaseDto dataSet, UUID taxonUuid, DescriptionType descriptionType){ |
493 | 493 |
Session session = getSession(); |
494 |
String queryString = "SELECT d.uuid FROM DescriptiveDataSet a JOIN a.descriptions as d JOIN d.taxon t WHERE t.uuid = :taxonuuid AND a.uuid = :dataSetUuid and d.type = :descriptionType"; |
|
494 |
String queryString = "SELECT d.uuid FROM DescriptiveDataSet a JOIN a.descriptions as d JOIN d.taxon t WHERE t.uuid = :taxonuuid AND a.uuid = :dataSetUuid";// and d.type = :descriptionType";
|
|
495 | 495 |
|
496 | 496 |
Query query; |
497 | 497 |
query = session.createQuery(queryString); |
498 | 498 |
query.setParameter("taxonuuid", taxonUuid); |
499 | 499 |
query.setParameter("dataSetUuid", dataSet.getUuid()); |
500 |
query.setParameter("descriptionType", descriptionType); |
|
500 |
// query.setParameter("descriptionType", descriptionType);
|
|
501 | 501 |
|
502 | 502 |
@SuppressWarnings("unchecked") |
503 | 503 |
List<UUID> result = query.list(); |
504 | 504 |
List<DescriptionBaseDto> list = new ArrayList<>(); |
505 | 505 |
list.addAll(descriptionService.loadDtos(new HashSet(result))); |
506 |
|
|
506 | 507 |
if (list.isEmpty()){ |
507 | 508 |
return null; |
509 |
}else { |
|
510 |
List<DescriptionBaseDto> correctTypeOnly = new ArrayList<>(); |
|
511 |
for (DescriptionBaseDto dto: list) { |
|
512 |
if (dto.getTypes().contains(descriptionType)) { |
|
513 |
correctTypeOnly.add(dto); |
|
514 |
} |
|
515 |
} |
|
516 |
if (correctTypeOnly.isEmpty()) { |
|
517 |
return null; |
|
518 |
}else { |
|
519 |
return correctTypeOnly.get(0); |
|
520 |
} |
|
508 | 521 |
} |
509 |
return list.get(0); |
|
522 |
|
|
523 |
// return list.get(0); |
|
510 | 524 |
} |
511 | 525 |
|
512 | 526 |
@Override |
Also available in: Unified diff
fix 10084: fix problem with missing taxonuuid in dto