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