Search in sources :

Example 16 with Invocation

use of org.kie.workbench.common.dmn.api.definition.v1_1.Invocation 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)

Aggregations

Invocation (org.kie.workbench.common.dmn.api.definition.v1_1.Invocation)9 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)7 Before (org.junit.Before)5 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 Optional (java.util.Optional)4 Binding (org.kie.dmn.model.v1_1.Binding)3 Invocation (org.kie.dmn.model.v1_1.Invocation)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)3 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)3 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)3 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)3 Test (org.junit.Test)2 DMNInvocationEvaluator (org.kie.dmn.core.ast.DMNInvocationEvaluator)2 LiteralExpression (org.kie.dmn.model.v1_1.LiteralExpression)2 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)2 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)2 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)2 ArrayList (java.util.ArrayList)1