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;
}
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;
}
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;
}
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);
}
Aggregations