use of org.hisp.dhis.datavalue.DeflatedDataValue in project dhis2-core by dhis2.
the class DeflatedDataValueRowMapper method mapRow.
@Override
public DeflatedDataValue mapRow(ResultSet resultSet) throws SQLException {
final DeflatedDataValue value = new DeflatedDataValue();
value.setDataElementId(resultSet.getInt("dataelementid"));
value.setPeriodId(resultSet.getInt("periodid"));
value.setSourceId(resultSet.getInt("sourceid"));
value.setCategoryOptionComboId(resultSet.getInt("categoryoptioncomboid"));
value.setValue(resultSet.getString("value"));
value.setStoredBy(resultSet.getString("storedby"));
value.setCreated(resultSet.getTimestamp("created"));
value.setLastUpdated(resultSet.getTimestamp("lastupdated"));
value.setComment(resultSet.getString("comment"));
return value;
}
use of org.hisp.dhis.datavalue.DeflatedDataValue in project dhis2-core by dhis2.
the class ValidationAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit(ou);
DataSet dataSet = dataSetService.getDataSet(ds);
Period selectedPeriod = PeriodType.getPeriodFromIsoString(pe);
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(cc, cp, false);
if (attributeOptionCombo == null) {
attributeOptionCombo = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo();
}
if (selectedPeriod == null || orgUnit == null || (multiOu && !orgUnit.hasChild())) {
return SUCCESS;
}
Period period = periodService.getPeriod(selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedPeriod.getPeriodType());
List<OrganisationUnit> organisationUnits = new ArrayList<>();
if (!multiOu) {
organisationUnits.add(orgUnit);
} else {
organisationUnits.addAll(orgUnit.getChildren());
}
Collections.sort(organisationUnits);
Date from = new DateTime(period.getStartDate()).minusYears(2).toDate();
for (OrganisationUnit organisationUnit : organisationUnits) {
List<DeflatedDataValue> values = new ArrayList<>(minMaxOutlierAnalysisService.analyse(Sets.newHashSet(organisationUnit), dataSet.getDataElements(), Sets.newHashSet(period), null, from));
if (!values.isEmpty()) {
dataValues.put(organisationUnit.getUid(), values);
}
List<ValidationResult> results = new ArrayList<>(validationService.startInteractiveValidationAnalysis(dataSet, period, organisationUnit, attributeOptionCombo));
if (!results.isEmpty()) {
validationResults.put(organisationUnit.getUid(), results);
}
List<DataElementOperand> violations = validationService.validateRequiredComments(dataSet, period, organisationUnit, attributeOptionCombo);
if (!violations.isEmpty()) {
commentViolations.put(organisationUnit.getUid(), violations);
}
}
return dataValues.isEmpty() && validationResults.isEmpty() && commentViolations.isEmpty() ? SUCCESS : INPUT;
}
Aggregations