Revision bce2d0e5
Added by Katja Luther 9 months ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java | ||
---|---|---|
1184 | 1184 |
|
1185 | 1185 |
public String getTaxonNodeDtoQueryWithoutParent() { |
1186 | 1186 |
String queryString = "SELECT new " + SortableTaxonNodeQueryResult.class.getName() + "(" |
1187 |
+ "tn.uuid, tn.id, t.titleCache"// rank " |
|
1188 |
|
|
1189 |
// + "tn.uuid, tn.id, t.uuid, t.titleCache, name.titleCache, rank, cl.uuid, t.publish, tn.status, note " |
|
1187 |
+ "tn.uuid, tn.id, t.uuid, t.titleCache"// rank " |
|
1190 | 1188 |
+ ") " |
1191 | 1189 |
+ " FROM TaxonNode tn " |
1192 | 1190 |
+ " LEFT JOIN tn.taxon AS t " ; |
1193 |
// + " LEFT JOIN t.name AS name " |
|
1194 |
// + " INNER JOIN tn.classification AS cl "; |
|
1195 |
// + " LEFT OUTER JOIN tn.statusNote as note "; |
|
1196 |
// + " LEFT OUTER JOIN name.rank AS rank "; |
|
1191 |
|
|
1197 | 1192 |
return queryString; |
1198 | 1193 |
} |
1199 | 1194 |
|
... | ... | |
1256 | 1251 |
List<TaxonNodeDto> nodeDtos = new ArrayList<>(); |
1257 | 1252 |
Collections.sort(result, new SortableTaxonNodeQueryResultComparator()); |
1258 | 1253 |
for(SortableTaxonNodeQueryResult queryDTO : result){ |
1259 |
TaxonNodeDto nodeDto = new TaxonNodeDto(queryDTO.getTaxonNodeUuid(), queryDTO.getTaxonNodeId(), queryDTO.getTreeIndex(), queryDTO.getNameTitleCache(), queryDTO.getTaxonTitleCache(), queryDTO.getNameRank()!= null? queryDTO.getNameRank().getOrderIndex(): null, queryDTO.getParentNodeUuid(), queryDTO.getSortIndex(), queryDTO.getClassificationUuid(), queryDTO.isTaxonIsPublish(), queryDTO.getStatus(), queryDTO.getStatusNote()); |
|
1254 |
TaxonNodeDto nodeDto = new TaxonNodeDto(queryDTO.getTaxonNodeUuid(), queryDTO.getTaxonNodeId(), queryDTO.getTaxonUuid(), queryDTO.getTreeIndex(), queryDTO.getNameTitleCache(), queryDTO.getTaxonTitleCache(), queryDTO.getNameRank()!= null? queryDTO.getNameRank().getOrderIndex(): null, queryDTO.getParentNodeUuid(), queryDTO.getSortIndex(), queryDTO.getClassificationUuid(), queryDTO.isTaxonIsPublish(), queryDTO.getStatus(), queryDTO.getStatusNote());
|
|
1260 | 1255 |
nodeDtos.add(nodeDto); |
1261 | 1256 |
} |
1262 | 1257 |
return nodeDtos; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TaxonNodeDto.java | ||
---|---|---|
92 | 92 |
super(uuid, id, nameTitleCache, taxonTitleCache); |
93 | 93 |
|
94 | 94 |
} |
95 |
public TaxonNodeDto(UUID uuid, Integer id, String treeIndex, String nameTitleCache, String taxonTitleCache, Integer rankOrderIndex, UUID parentUuid, Integer sortIndex, UUID classificationUuid, Boolean taxonIsPublished, TaxonNodeStatus status, List<LanguageString> statusNote){ |
|
95 |
public TaxonNodeDto(UUID uuid, Integer id, UUID taxonUuid, String treeIndex, String nameTitleCache, String taxonTitleCache, Integer rankOrderIndex, UUID parentUuid, Integer sortIndex, UUID classificationUuid, Boolean taxonIsPublished, TaxonNodeStatus status, List<LanguageString> statusNote){
|
|
96 | 96 |
this(uuid, id, treeIndex, nameTitleCache, taxonTitleCache, rankOrderIndex, parentUuid, sortIndex, classificationUuid); |
97 | 97 |
this.status = status; |
98 | 98 |
this.taxonIsPublish = taxonIsPublished; |
99 | 99 |
for (LanguageString str: statusNote) { |
100 | 100 |
this.statusNote.put(str.getLanguage(), str.getText()); |
101 | 101 |
} |
102 |
this.taxonUuid = taxonUuid; |
|
102 | 103 |
} |
103 | 104 |
|
104 | 105 |
public TaxonNodeDto(UUID uuid, Integer id, String treeIndex, String nameTitleCache, String taxonTitleCache, Integer rankOrderIndex, UUID parentUuid, Integer sortIndex, UUID classificationUuid) { |
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