Search in sources :

Example 1 with ValidationRuleGroup

use of org.hisp.dhis.validation.ValidationRuleGroup in project dhis2-core by dhis2.

the class ValidateValidationRuleGroupAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    ValidationRuleGroup match = validationRuleService.getValidationRuleGroupByName(name);
    if (match != null && (id == null || match.getId() != id)) {
        message = i18n.getString("name_in_use");
        return INPUT;
    }
    message = i18n.getString("valid");
    return SUCCESS;
}
Also used : ValidationRuleGroup(org.hisp.dhis.validation.ValidationRuleGroup)

Example 2 with ValidationRuleGroup

use of org.hisp.dhis.validation.ValidationRuleGroup in project dhis2-core by dhis2.

the class RunValidationAction method execute.

// -------------------------------------------------------------------------
// Execute
// -------------------------------------------------------------------------
@Override
public String execute() {
    organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId);
    List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitWithChildren(organisationUnit.getId());
    ValidationRuleGroup group = validationRuleGroupId == -1 ? null : validationRuleService.getValidationRuleGroup(validationRuleGroupId);
    DataElementCategoryOptionCombo attributeOptionCombo = attributeOptionComboId == null || attributeOptionComboId == -1 ? null : dataElementCategoryService.getDataElementCategoryOptionCombo(attributeOptionComboId);
    log.info("Validating data for " + (group == null ? "all rules" : "group: " + group.getName()));
    validationResults = new ArrayList<>(validationService.startInteractiveValidationAnalysis(format.parseDate(startDate), format.parseDate(endDate), organisationUnits, attributeOptionCombo, group, sendNotifications, format));
    maxExceeded = validationResults.size() > ValidationService.MAX_INTERACTIVE_ALERTS;
    Collections.sort(validationResults, new ValidationResultComparator());
    SessionUtils.setSessionVar(KEY_VALIDATIONRESULT, validationResults);
    computeShowAttributeCombos();
    log.info("Validation done");
    return SUCCESS;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) ValidationRuleGroup(org.hisp.dhis.validation.ValidationRuleGroup) ValidationResultComparator(org.hisp.dhis.validation.comparator.ValidationResultComparator) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 3 with ValidationRuleGroup

use of org.hisp.dhis.validation.ValidationRuleGroup in project dhis2-core by dhis2.

the class DhisConvenienceTest method createValidationRuleGroup.

/**
 * @param uniqueCharacter A unique character to identify the object.
 * @return ValidationRuleGroup
 */
public static ValidationRuleGroup createValidationRuleGroup(char uniqueCharacter) {
    ValidationRuleGroup group = new ValidationRuleGroup();
    group.setAutoFields();
    group.setName("ValidationRuleGroup" + uniqueCharacter);
    group.setDescription("Description" + uniqueCharacter);
    return group;
}
Also used : ValidationRuleGroup(org.hisp.dhis.validation.ValidationRuleGroup)

Example 4 with ValidationRuleGroup

use of org.hisp.dhis.validation.ValidationRuleGroup in project dhis2-core by dhis2.

the class DataAnalysisController method performValidationRulesAnalysis.

@PostMapping(value = "/validationRules", consumes = APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public List<ValidationResultView> performValidationRulesAnalysis(@RequestBody ValidationRulesAnalysisParams validationRulesAnalysisParams, HttpSession session) throws WebMessageException {
    I18nFormat format = i18nManager.getI18nFormat();
    ValidationRuleGroup group = null;
    if (validationRulesAnalysisParams.getVrg() != null) {
        group = validationRuleService.getValidationRuleGroup(validationRulesAnalysisParams.getVrg());
    }
    OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(validationRulesAnalysisParams.getOu());
    if (organisationUnit == null) {
        throw new WebMessageException(badRequest("No organisation unit defined"));
    }
    ValidationAnalysisParams params = validationService.newParamsBuilder(group, organisationUnit, format.parseDate(validationRulesAnalysisParams.getStartDate()), format.parseDate(validationRulesAnalysisParams.getEndDate())).withIncludeOrgUnitDescendants(true).withPersistResults(validationRulesAnalysisParams.isPersist()).withSendNotifications(validationRulesAnalysisParams.isNotification()).withMaxResults(ValidationService.MAX_INTERACTIVE_ALERTS).build();
    List<ValidationResult> validationResults = validationService.validationAnalysis(params);
    validationResults.sort(new ValidationResultComparator());
    session.setAttribute(KEY_VALIDATION_RESULT, validationResults);
    session.setAttribute(KEY_ORG_UNIT, organisationUnit);
    return validationResultsListToResponse(validationResults);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) I18nFormat(org.hisp.dhis.i18n.I18nFormat) ValidationRuleGroup(org.hisp.dhis.validation.ValidationRuleGroup) ValidationAnalysisParams(org.hisp.dhis.validation.ValidationAnalysisParams) ValidationResult(org.hisp.dhis.validation.ValidationResult) ValidationResultComparator(org.hisp.dhis.validation.comparator.ValidationResultComparator) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ValidationRuleGroup (org.hisp.dhis.validation.ValidationRuleGroup)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)2 ValidationResultComparator (org.hisp.dhis.validation.comparator.ValidationResultComparator)2 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)1 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)1 I18nFormat (org.hisp.dhis.i18n.I18nFormat)1 ValidationAnalysisParams (org.hisp.dhis.validation.ValidationAnalysisParams)1 ValidationResult (org.hisp.dhis.validation.ValidationResult)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1