use of eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO in project cdmlib by cybertaxonomy.
the class ClassificationServiceImpl method groupTaxaByMarkedParents.
@Override
public List<GroupedTaxonDTO> groupTaxaByMarkedParents(List<UUID> originalTaxonUuids, UUID classificationUuid, MarkerType markerType, Boolean flag) {
List<GroupedTaxonDTO> result = new ArrayList<>();
// get treeindex for each taxonUUID
Map<UUID, TreeIndex> taxonIdTreeIndexMap = dao.treeIndexForTaxonUuids(classificationUuid, originalTaxonUuids);
// get all marked tree indexes
Set<TreeIndex> markedTreeIndexes = dao.getMarkedTreeIndexes(markerType, flag);
Map<TreeIndex, TreeIndex> groupedMap = TreeIndex.group(markedTreeIndexes, taxonIdTreeIndexMap.values());
Set<TreeIndex> notNullGroups = new HashSet<>(groupedMap.values());
notNullGroups.remove(null);
// get taxonInfo for treeIndexes
Map<TreeIndex, UuidAndTitleCache<?>> treeIndexTaxonIdMap = taxonNodeDao.taxonUuidsForTreeIndexes(notNullGroups);
// fill result list
for (UUID originalTaxonUuid : originalTaxonUuids) {
GroupedTaxonDTO item = new GroupedTaxonDTO();
result.add(item);
item.setTaxonUuid(originalTaxonUuid);
TreeIndex toBeGroupedTreeIndex = taxonIdTreeIndexMap.get(originalTaxonUuid);
TreeIndex groupTreeIndex = groupedMap.get(toBeGroupedTreeIndex);
UuidAndTitleCache<?> uuidAndLabel = treeIndexTaxonIdMap.get(groupTreeIndex);
if (uuidAndLabel != null) {
item.setGroupTaxonUuid(uuidAndLabel.getUuid());
item.setGroupTaxonName(uuidAndLabel.getTitleCache());
}
}
return result;
}
Aggregations