use of org.hisp.dhis.dataset.DataSetElement in project dhis2-core by dhis2.
the class DefaultDataElementCategoryService method getOperands.
@Override
public List<DataElementOperand> getOperands(DataSet dataSet, boolean includeTotals) {
List<DataElementOperand> operands = Lists.newArrayList();
for (DataSetElement element : dataSet.getDataSetElements()) {
DataElementCategoryCombo categoryCombo = element.getResolvedCategoryCombo();
if (includeTotals && !categoryCombo.isDefault()) {
operands.add(new DataElementOperand(element.getDataElement()));
}
operands.addAll(getOperands(element.getDataElement(), element.getResolvedCategoryCombo()));
}
return operands;
}
use of org.hisp.dhis.dataset.DataSetElement in project dhis2-core by dhis2.
the class PreheatServiceTest method testPreheatWithDataSetElements.
@Test
void testPreheatWithDataSetElements() {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = new HashMap<>();
DataElement de1 = createDataElement('A');
DataElement de2 = createDataElement('B');
DataElement de3 = createDataElement('C');
manager.save(de1);
manager.save(de2);
manager.save(de3);
DataSet dataSet = createDataSet('A');
dataSet.setAutoFields();
dataSet.getDataSetElements().add(new DataSetElement(dataSet, de1));
dataSet.getDataSetElements().add(new DataSetElement(dataSet, de2));
dataSet.getDataSetElements().add(new DataSetElement(dataSet, de3));
metadata.put(DataSet.class, new ArrayList<>());
metadata.get(DataSet.class).add(dataSet);
PreheatParams params = new PreheatParams();
params.setPreheatIdentifier(PreheatIdentifier.UID);
params.setPreheatMode(PreheatMode.REFERENCE);
params.setObjects(metadata);
preheatService.validate(params);
Preheat preheat = preheatService.preheat(params);
assertEquals(3, preheat.getIdentifierKeyCount(PreheatIdentifier.UID, DataElement.class));
}
use of org.hisp.dhis.dataset.DataSetElement in project dhis2-core by dhis2.
the class DefaultCategoryService method getOperands.
@Override
@Transactional(readOnly = true)
public List<DataElementOperand> getOperands(DataSet dataSet, boolean includeTotals) {
List<DataElementOperand> operands = Lists.newArrayList();
for (DataSetElement element : dataSet.getDataSetElements()) {
CategoryCombo categoryCombo = element.getResolvedCategoryCombo();
if (includeTotals && !categoryCombo.isDefault()) {
operands.add(new DataElementOperand(element.getDataElement()));
}
operands.addAll(getOperands(element.getDataElement(), element.getResolvedCategoryCombo()));
}
return operands;
}
use of org.hisp.dhis.dataset.DataSetElement in project dhis2-core by dhis2.
the class DataElementDeletionHandler method deleteDataSet.
private void deleteDataSet(DataSet dataSet) {
Iterator<DataSetElement> elements = dataSet.getDataSetElements().iterator();
while (elements.hasNext()) {
DataSetElement element = elements.next();
elements.remove();
dataSet.removeDataSetElement(element);
idObjectManager.updateNoAcl(element.getDataElement());
}
}
use of org.hisp.dhis.dataset.DataSetElement in project dhis2-core by dhis2.
the class DefaultDataSetReportService method getDefaultDataSetReport.
private List<Grid> getDefaultDataSetReport(DataSet dataSet, List<Period> periods, OrganisationUnit unit, Set<String> filters, boolean selectedUnitOnly) {
ListMap<CategoryCombo, DataElement> map = new ListMap<>();
for (DataSetElement element : dataSet.getDataSetElements()) {
map.putValue(element.getResolvedCategoryCombo(), element.getDataElement());
}
DataSet tmpDataSet = new DataSet(dataSet.getName(), dataSet.getShortName(), dataSet.getPeriodType());
tmpDataSet.setDataSetElements(dataSet.getDataSetElements());
for (CategoryCombo categoryCombo : map.keySet()) {
List<DataElement> dataElements = map.get(categoryCombo);
String name = categoryCombo.isDefault() ? dataSet.getName() : categoryCombo.getName();
Section section = new Section(name, dataSet, dataElements, null);
tmpDataSet.getSections().add(section);
}
return getSectionDataSetReport(tmpDataSet, periods, unit, filters, selectedUnitOnly);
}
Aggregations