Search in sources :

Example 1 with ValidationSummary

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;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ValidationSummary(org.hisp.dhis.validation.ValidationSummary) DataSet(org.hisp.dhis.dataset.DataSet) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) Period(org.hisp.dhis.period.Period) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Aggregations

DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)1 DataSet (org.hisp.dhis.dataset.DataSet)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Period (org.hisp.dhis.period.Period)1 ValidationSummary (org.hisp.dhis.validation.ValidationSummary)1