use of org.hisp.dhis.completeness.DataSetCompletenessService in project dhis2-core by dhis2.
the class GetDataCompletenessAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
Grid _grid = (Grid) SessionUtils.getSessionVar(KEY_DATA_COMPLETENESS);
if (_grid != null && type != null && !type.equals(DEFAULT_TYPE)) {
grid = _grid;
return type;
} else {
OrganisationUnit selectedUnit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
if (periodId == null || selectedUnit == null || criteria == null) {
return INPUT;
} else {
Period period = periodService.reloadPeriod(PeriodType.getPeriodFromIsoString(periodId));
Integer _periodId = period.getId();
DataSet dataSet = null;
List<DataSetCompletenessResult> mainResults = new ArrayList<>();
List<DataSetCompletenessResult> footerResults = new ArrayList<>();
DataSetCompletenessService completenessService = serviceProvider.provide(criteria);
if (// One ds for one ou
dataSetId != null && dataSetId != 0) {
mainResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, getIdentifiers(selectedUnit.getChildren()), dataSetId, groupId));
footerResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, Arrays.asList(selectedUnit.getId()), dataSetId, groupId));
dataSet = dataSetService.getDataSet(dataSetId);
} else // All ds for children of one ou
{
mainResults = new ArrayList<>(completenessService.getDataSetCompleteness(_periodId, selectedUnit.getId(), groupId));
}
grid = getGrid(mainResults, footerResults, selectedUnit, dataSet, period);
SessionUtils.setSessionVar(KEY_DATA_COMPLETENESS, grid);
}
return type != null ? type : DEFAULT_TYPE;
}
}
Aggregations