Search in sources :

Example 1 with ValidationCriteria

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

the class UpdateValidationCriteriaAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    ValidationCriteria criteria = validationCriteriaService.getValidationCriteria(id);
    criteria.setName(StringUtils.trimToNull(name));
    criteria.setDescription(StringUtils.trimToNull(description));
    criteria.setProperty(property);
    criteria.setOperator(operator);
    criteria.setValue(StringUtils.trimToNull(value));
    validationCriteriaService.updateValidationCriteria(criteria);
    return SUCCESS;
}
Also used : ValidationCriteria(org.hisp.dhis.validation.ValidationCriteria)

Example 2 with ValidationCriteria

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

the class ValidateValidationCriteriaAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    if (name == null || name.isEmpty()) {
        message = i18n.getString("specify_name");
        return INPUT;
    } else {
        name = name.trim();
        if (name.length() == 0) {
            message = i18n.getString("specify_name");
            return INPUT;
        }
        ValidationCriteria match = validationCriteriaService.getValidationCriteria(name);
        if (match != null && (id == null || match.getId() != id)) {
            message = i18n.getString("name_in_use");
            return INPUT;
        }
    }
    return SUCCESS;
}
Also used : ValidationCriteria(org.hisp.dhis.validation.ValidationCriteria)

Example 3 with ValidationCriteria

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

the class AddValidationCriteriaAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    ValidationCriteria criteria = new ValidationCriteria();
    criteria.setName(StringUtils.trimToNull(name));
    criteria.setDescription(StringUtils.trimToNull(description));
    criteria.setProperty(property);
    criteria.setOperator(operator);
    criteria.setValue(value);
    validationCriteriaService.saveValidationCriteria(criteria);
    Program program = programService.getProgram(programId);
    program.getValidationCriteria().add(criteria);
    programService.updateProgram(program);
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) ValidationCriteria(org.hisp.dhis.validation.ValidationCriteria)

Example 4 with ValidationCriteria

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

the class RemoveValidationCriteriaAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    ValidationCriteria criteria = validationCriteriaService.getValidationCriteria(id);
    validationCriteriaService.deleteValidationCriteria(criteria);
    return SUCCESS;
}
Also used : ValidationCriteria(org.hisp.dhis.validation.ValidationCriteria)

Example 5 with ValidationCriteria

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

the class DhisConvenienceTest method createValidationCriteria.

/**
     * @param uniqueCharacter A unique character to identify the object.
     * @return ValidationCriteria
     */
public static ValidationCriteria createValidationCriteria(char uniqueCharacter, String property, int operator, String value) {
    ValidationCriteria validationCriteria = new ValidationCriteria();
    validationCriteria.setAutoFields();
    validationCriteria.setName("ValidationCriteria" + uniqueCharacter);
    validationCriteria.setDescription("Description" + uniqueCharacter);
    validationCriteria.setProperty(property);
    validationCriteria.setOperator(operator);
    validationCriteria.setValue(value);
    return validationCriteria;
}
Also used : ValidationCriteria(org.hisp.dhis.validation.ValidationCriteria)

Aggregations

ValidationCriteria (org.hisp.dhis.validation.ValidationCriteria)6 Date (java.util.Date)1 ValueType (org.hisp.dhis.common.ValueType)1 Program (org.hisp.dhis.program.Program)1 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)1