use of org.openforis.idm.metamodel.expression.ExpressionValidator.ExpressionValidationResult in project collect by openforis.
the class FormValidator method validateExpression.
protected boolean validateExpression(ValidationContext ctx, ExpressionType type, String field, NodeDefinition contextNodeDef, NodeDefinition thisNodeDef, String epression) {
if (StringUtils.isNotBlank(epression)) {
ExpressionValidator expressionValidator = getExpressionValidator(ctx);
ExpressionValidationResult result = expressionValidator.validateExpression(type, contextNodeDef, thisNodeDef, epression);
if (result.isError()) {
addInvalidMessage(ctx, field, generateErrorMessageLabel(result, INVALID_EXPRESSION_MESSAGE_KEY));
return false;
}
ExpressionValidationResult circularReferenceValidationResult = expressionValidator.validateCircularReferenceAbsence(contextNodeDef, thisNodeDef, epression);
if (circularReferenceValidationResult.isError()) {
addInvalidMessage(ctx, field, generateErrorMessageLabel(circularReferenceValidationResult, CIRCULAR_REFERENCE_IN_EXPRESSION_MESSAGE_KEY));
return false;
}
}
return true;
}
use of org.openforis.idm.metamodel.expression.ExpressionValidator.ExpressionValidationResult in project collect by openforis.
the class ModelJXPathCompiledExpression method validateOperations.
private ExpressionValidationResult validateOperations(OperationVaildator operationValidator) {
Deque<Expression> stack = new LinkedList<Expression>();
stack.push(getExpression());
while (!stack.isEmpty()) {
Expression expression = stack.pop();
if (expression instanceof Operation) {
Operation op = (Operation) expression;
ExpressionValidationResult result = operationValidator.validate(op);
if (result.isError()) {
return result;
} else {
Expression[] args = op.getArguments();
if (args != null) {
stack.addAll(Arrays.asList(args));
}
}
}
}
return new ExpressionValidationResult();
}
Aggregations