Search in sources :

Example 21 with Expression

use of org.kie.dmn.model.v1_1.Expression in project drools by kiegroup.

the class DMNEvaluatorCompiler method compileInvocation.

private DMNExpressionEvaluator compileInvocation(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, Invocation expression) {
    Invocation invocation = expression;
    // expression must be a literal text with the name of the function
    String functionName = ((LiteralExpression) invocation.getExpression()).getText();
    DMNInvocationEvaluator invEval = new DMNInvocationEvaluator(node.getName(), node.getSource(), functionName, invocation, null, feel.newFEELInstance());
    for (Binding binding : invocation.getBinding()) {
        if (binding.getParameter() == null) {
            // error, missing binding parameter
            MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, binding, model, null, null, Msg.MISSING_PARAMETER_FOR_INVOCATION, node.getIdentifierString());
            return null;
        }
        if (binding.getExpression() == null) {
            MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, binding, model, null, null, Msg.MISSING_PARAMETER_FOR_INVOCATION, node.getIdentifierString());
            return null;
        }
        invEval.addParameter(binding.getParameter().getName(), compiler.resolveTypeRef(model, node, binding.getParameter(), binding.getParameter(), binding.getParameter().getTypeRef()), compileExpression(ctx, model, node, binding.getParameter().getName(), binding.getExpression()));
    }
    return invEval;
}
Also used : Binding(org.kie.dmn.model.v1_1.Binding) Invocation(org.kie.dmn.model.v1_1.Invocation) LiteralExpression(org.kie.dmn.model.v1_1.LiteralExpression) DMNInvocationEvaluator(org.kie.dmn.core.ast.DMNInvocationEvaluator)

Example 22 with Expression

use of org.kie.dmn.model.v1_1.Expression in project drools by kiegroup.

the class ExpressionConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    super.writeAttributes(writer, parent);
    Expression e = (Expression) parent;
    if (e.getTypeRef() != null)
        writer.addAttribute(TYPE_REF, MarshallingUtils.formatQName(e.getTypeRef()));
}
Also used : Expression(org.kie.dmn.model.v1_1.Expression)

Aggregations

ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 Expression (org.apache.commons.jexl2.Expression)6 MapContext (org.apache.commons.jexl2.MapContext)6 JexlContext (org.apache.commons.jexl2.JexlContext)5 Expression (org.kie.dmn.model.v1_1.Expression)5 LiteralExpression (org.kie.dmn.model.v1_1.LiteralExpression)4 HashMap (java.util.HashMap)3 JexlEngine (org.apache.commons.jexl2.JexlEngine)3 DMNExpressionEvaluator (org.kie.dmn.core.api.DMNExpressionEvaluator)3 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)3 ArrayList (java.util.ArrayList)2 DMNType (org.kie.dmn.api.core.DMNType)2 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)2 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)2 EvaluatorResult (org.kie.dmn.core.api.EvaluatorResult)2 DMNContextEvaluator (org.kie.dmn.core.ast.DMNContextEvaluator)2 DMNInvocationEvaluator (org.kie.dmn.core.ast.DMNInvocationEvaluator)2 DMNRelationEvaluator (org.kie.dmn.core.ast.DMNRelationEvaluator)2 Binding (org.kie.dmn.model.v1_1.Binding)2