Revision 3ed10837
Added by Katja Luther over 2 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/description/DescriptiveDataSetDao.java | ||
---|---|---|
30 | 30 |
import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonNodeDao; |
31 | 31 |
import eu.etaxonomy.cdm.persistence.dao.term.IDefinedTermDao; |
32 | 32 |
import eu.etaxonomy.cdm.persistence.dao.term.ITermTreeDao; |
33 |
import eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto; |
|
34 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
35 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
36 |
import eu.etaxonomy.cdm.persistence.dto.TermTreeDto; |
|
33 | 37 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
34 | 38 |
|
35 | 39 |
@Repository |
... | ... | |
264 | 268 |
|
265 | 269 |
|
266 | 270 |
|
267 |
// @Override
|
|
268 |
// public DescriptiveDataSetBaseDto getDescriptiveDataSetDtoByUuid(UUID uuid) {
|
|
269 |
// String queryString = DescriptiveDataSetBaseDto.getDescriptiveDataSetDtoSelect()
|
|
270 |
// + " WHERE a.uuid = :uuid"
|
|
271 |
// + " ORDER BY a.titleCache";
|
|
272 |
// Query query = getSession().createQuery(queryString);
|
|
273 |
// query.setParameter("uuid", uuid);
|
|
274 |
// |
|
275 |
// @SuppressWarnings("unchecked")
|
|
276 |
// List<Object[]> result = query.list();
|
|
277 |
// |
|
278 |
// List<DescriptiveDataSetBaseDto> list = DescriptiveDataSetBaseDto.descriptiveDataSetBaseDtoListFrom(result);
|
|
279 |
// UUID descriptiveSystemUuid = null;
|
|
280 |
// UUID minRankUuid = null;
|
|
281 |
// UUID maxRankUuid = null;
|
|
282 |
// if (result != null && !result.isEmpty()){
|
|
283 |
// Object[] descriptiveDataSetResult = result.get(0);
|
|
284 |
// descriptiveSystemUuid = (UUID)descriptiveDataSetResult[4];
|
|
285 |
// minRankUuid = (UUID)descriptiveDataSetResult[5];
|
|
286 |
// maxRankUuid = (UUID)descriptiveDataSetResult[6];
|
|
287 |
// }else{
|
|
288 |
// return null;
|
|
289 |
// }
|
|
290 |
// //get descriptiveSystem
|
|
291 |
// DescriptiveDataSetBaseDto dto = list.get(0);
|
|
292 |
// if (descriptiveSystemUuid != null){
|
|
293 |
// TermTreeDto treeDto = termTreeDao.getTermTreeDtosByUuid(descriptiveSystemUuid);
|
|
294 |
// dto.setDescriptiveSystem(treeDto);
|
|
295 |
// }
|
|
296 |
// //get taxon nodes
|
|
297 |
// List<UUID> nodeUuids = getNodeUuidsForDescriptiveDataSet(uuid);
|
|
298 |
// List<TaxonNodeDto> nodeDtos = nodeDao.getTaxonNodeDtos(nodeUuids);
|
|
299 |
// Set<TaxonNodeDto> nodeSet = new HashSet<>(nodeDtos);
|
|
300 |
// dto.setSubTreeFilter(nodeSet);
|
|
301 |
// |
|
302 |
// List<UUID> descriptionUuidList = getDescriptionUuidsForDescriptiveDataSet(uuid);
|
|
303 |
// Set<UUID> descriptionUuids = new HashSet<>(descriptionUuidList);
|
|
304 |
// dto.setDescriptionUuids(descriptionUuids);
|
|
305 |
// |
|
306 |
// TermDto minRank = termDao.getTermDto(minRankUuid);
|
|
307 |
// TermDto maxRank = termDao.getTermDto(maxRankUuid);
|
|
308 |
// dto.setMaxRank(maxRank);
|
|
309 |
// dto.setMinRank(minRank);
|
|
310 |
// return dto;
|
|
311 |
// }
|
|
271 |
@Override |
|
272 |
public DescriptiveDataSetBaseDto getDescriptiveDataSetDtoByUuid(UUID uuid) { |
|
273 |
String queryString = DescriptiveDataSetBaseDto.getDescriptiveDataSetDtoSelect() |
|
274 |
+ " WHERE a.uuid = :uuid" |
|
275 |
+ " ORDER BY a.titleCache"; |
|
276 |
Query query = getSession().createQuery(queryString); |
|
277 |
query.setParameter("uuid", uuid); |
|
278 |
|
|
279 |
@SuppressWarnings("unchecked") |
|
280 |
List<Object[]> result = query.list(); |
|
281 |
|
|
282 |
List<DescriptiveDataSetBaseDto> list = DescriptiveDataSetBaseDto.descriptiveDataSetBaseDtoListFrom(result); |
|
283 |
UUID descriptiveSystemUuid = null; |
|
284 |
UUID minRankUuid = null; |
|
285 |
UUID maxRankUuid = null; |
|
286 |
if (result != null && !result.isEmpty()){ |
|
287 |
Object[] descriptiveDataSetResult = result.get(0); |
|
288 |
descriptiveSystemUuid = (UUID)descriptiveDataSetResult[4]; |
|
289 |
minRankUuid = (UUID)descriptiveDataSetResult[5]; |
|
290 |
maxRankUuid = (UUID)descriptiveDataSetResult[6]; |
|
291 |
}else{ |
|
292 |
return null; |
|
293 |
} |
|
294 |
//get descriptiveSystem |
|
295 |
DescriptiveDataSetBaseDto dto = list.get(0); |
|
296 |
if (descriptiveSystemUuid != null){ |
|
297 |
TermTreeDto treeDto = termTreeDao.getTermTreeDtosByUuid(descriptiveSystemUuid); |
|
298 |
dto.setDescriptiveSystem(treeDto); |
|
299 |
} |
|
300 |
//get taxon nodes |
|
301 |
List<UUID> nodeUuids = getNodeUuidsForDescriptiveDataSet(uuid); |
|
302 |
List<TaxonNodeDto> nodeDtos = nodeDao.getTaxonNodeDtos(nodeUuids); |
|
303 |
Set<TaxonNodeDto> nodeSet = new HashSet<>(nodeDtos); |
|
304 |
dto.setSubTreeFilter(nodeSet); |
|
305 |
|
|
306 |
List<UUID> descriptionUuidList = getDescriptionUuidsForDescriptiveDataSet(uuid); |
|
307 |
Set<UUID> descriptionUuids = new HashSet<>(descriptionUuidList); |
|
308 |
dto.setDescriptionUuids(descriptionUuids); |
|
309 |
|
|
310 |
TermDto minRank = termDao.getTermDto(minRankUuid); |
|
311 |
TermDto maxRank = termDao.getTermDto(maxRankUuid); |
|
312 |
dto.setMaxRank(maxRank); |
|
313 |
dto.setMinRank(minRank); |
|
314 |
return dto; |
|
315 |
} |
|
312 | 316 |
} |
Also available in: Unified diff
ref #9772: code cleaning - move hql code to persistence