@Override public String allowDeleteDataElementCategoryCombo(DataElementCategoryCombo categoryCombo) { Collection<CaseAggregationCondition> conditions = aggregationConditionService.getAllCaseAggregationCondition(); for (CaseAggregationCondition condition : conditions) { if (categoryCombo.getOptionCombos().contains(condition.getOptionCombo())) { return ERROR; } } return null; }
@Override public String execute() { if (dataElementGroupId > 0) { DataElementGroup group = dataElementService.getDataElementGroup(dataElementGroupId.intValue()); dataElements = new ArrayList<>(group.getMembers()); } else { dataElements = new ArrayList<>(dataElementService.getAllDataElements()); } Collections.sort(dataElements, new IdentifiableObjectNameComparator()); for (DataElement dataElement : dataElements) { DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo(); Set<DataElementCategoryOptionCombo> optionCombos = categoryCombo.getOptionCombos(); if (optionCombos.size() > 1) { for (DataElementCategoryOptionCombo optionCombo : optionCombos) { DataElementOperand operand = new DataElementOperand( dataElement.getUid(), optionCombo.getUid(), dataElement.getName() + optionCombo.getName()); operands.add(operand); } } else { DataElementOperand operand = new DataElementOperand( dataElement.getUid(), optionCombos.iterator().next().getUid(), dataElement.getName()); operands.add(operand); } } return SUCCESS; }
@Override public int compare(DataElementCategoryCombo o1, DataElementCategoryCombo o2) { return o1.getOptionCombos().size() - o2.getOptionCombos().size(); }