use of com.agiletec.aps.system.common.entity.model.attribute.util.OgnlValidationRule in project entando-core by entando.
the class EntityAttributeOgnlValidationDto method buildAttributeOgnlValidation.
public void buildAttributeOgnlValidation(String typeCode, AttributeInterface attribute, BindingResult bindingResult) {
IAttributeValidationRules validationRules = attribute.getValidationRules();
if (!StringUtils.isEmpty(this.getOgnlExpression())) {
// to check into validator
OgnlValidationRule ognlValidationRule = new OgnlValidationRule();
if (StringUtils.isEmpty(this.getErrorMessage()) && StringUtils.isEmpty(this.getKeyForErrorMessage())) {
this.addError(EntityTypeValidator.ERRCODE_INVALID_OGNL_ERROR, bindingResult, new String[] { typeCode, attribute.getName() }, "entityType.attribute.ognl.missingErrorMessage");
}
if (StringUtils.isEmpty(this.getHelpMessage()) && StringUtils.isEmpty(this.getKeyForHelpMessage())) {
this.addError(EntityTypeValidator.ERRCODE_INVALID_OGNL_HELP, bindingResult, new String[] { typeCode, attribute.getName() }, "entityType.attribute.ognl.missingHelpMessage");
}
ognlValidationRule.setErrorMessage(this.getErrorMessage());
ognlValidationRule.setErrorMessageKey(this.getKeyForErrorMessage());
ognlValidationRule.setEvalExpressionOnValuedAttribute(this.isApplyOnlyToFilledAttr());
ognlValidationRule.setExpression(this.getOgnlExpression());
ognlValidationRule.setHelpMessage(this.getHelpMessage());
ognlValidationRule.setHelpMessageKey(this.getKeyForHelpMessage());
validationRules.setOgnlValidationRule(ognlValidationRule);
}
}
Aggregations