Search in sources :

Example 6 with IdmInterpretationError

use of org.openforis.idm.metamodel.IdmInterpretationError in project collect by openforis.

the class ComparisonCheck method evaluate.

@Override
public ValidationResultFlag evaluate(Attribute<?, ?> node) {
    Record record = node.getRecord();
    SurveyContext recordContext = record.getSurveyContext();
    ExpressionEvaluator expressionEvaluator = recordContext.getExpressionEvaluator();
    String expr = getExpression();
    try {
        boolean valid = expressionEvaluator.evaluateBoolean(node.getParent(), node, expr, true);
        return ValidationResultFlag.valueOf(valid, this.getFlag());
    } catch (InvalidExpressionException e) {
        throw new IdmInterpretationError("Error evaluating comparison check", e);
    }
}
Also used : IdmInterpretationError(org.openforis.idm.metamodel.IdmInterpretationError) InvalidExpressionException(org.openforis.idm.model.expression.InvalidExpressionException) Record(org.openforis.idm.model.Record) ExpressionEvaluator(org.openforis.idm.model.expression.ExpressionEvaluator) SurveyContext(org.openforis.idm.metamodel.SurveyContext)

Aggregations

IdmInterpretationError (org.openforis.idm.metamodel.IdmInterpretationError)6 InvalidExpressionException (org.openforis.idm.model.expression.InvalidExpressionException)6 ExpressionEvaluator (org.openforis.idm.model.expression.ExpressionEvaluator)5 SurveyContext (org.openforis.idm.metamodel.SurveyContext)4 Matcher (java.util.regex.Matcher)1 Survey (org.openforis.idm.metamodel.Survey)1 Attribute (org.openforis.idm.model.Attribute)1 Node (org.openforis.idm.model.Node)1 Record (org.openforis.idm.model.Record)1 Value (org.openforis.idm.model.Value)1