use of org.hisp.dhis.validation.ValidationSummary in project dhis2-core by dhis2.
the class ValidationController method validate.
@RequestMapping(value = "/dataSet/{ds}", method = RequestMethod.GET)
@ResponseBody
public ValidationSummary validate(@PathVariable String ds, @RequestParam String pe, @RequestParam String ou, @RequestParam(required = false) String aoc, HttpServletResponse response, Model model) throws WebMessageException {
DataSet dataSet = dataSetService.getDataSet(ds);
if (dataSet == null) {
throw new WebMessageException(WebMessageUtils.conflict("Data set does not exist: " + ds));
}
Period period = PeriodType.getPeriodFromIsoString(pe);
if (period == null) {
throw new WebMessageException(WebMessageUtils.conflict("Period does not exist: " + pe));
}
OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit(ou);
if (orgUnit == null) {
throw new WebMessageException(WebMessageUtils.conflict("Organisation unit does not exist: " + ou));
}
DataElementCategoryOptionCombo attributeOptionCombo = categoryService.getDataElementCategoryOptionCombo(aoc);
if (attributeOptionCombo == null) {
attributeOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
}
ValidationSummary summary = new ValidationSummary();
summary.setValidationRuleViolations(new ArrayList<>(validationService.startInteractiveValidationAnalysis(dataSet, period, orgUnit, attributeOptionCombo)));
summary.setCommentRequiredViolations(validationService.validateRequiredComments(dataSet, period, orgUnit, attributeOptionCombo));
return summary;
}
Aggregations