use of org.kie.dmn.model.api.Invocation in project drools by kiegroup.
the class InvocationConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Invocation i = (Invocation) parent;
if (i.getExpression() != null)
writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(i.getExpression()));
for (Binding b : i.getBinding()) {
writeChildrenNode(writer, context, b, BINDING);
}
}
use of org.kie.dmn.model.api.Invocation in project drools by kiegroup.
the class InvocationConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Invocation i = (Invocation) parent;
if (i.getExpression() != null)
writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, i.getExpression()));
for (Binding b : i.getBinding()) {
writeChildrenNode(writer, context, b, BINDING);
}
}
use of org.kie.dmn.model.api.Invocation in project drools by kiegroup.
the class InvocationConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Invocation i = (Invocation) parent;
if (i.getExpression() != null)
writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(xstream, i.getExpression()));
for (Binding b : i.getBinding()) {
writeChildrenNode(writer, context, b, BINDING);
}
}
use of org.kie.dmn.model.api.Invocation in project drools by kiegroup.
the class InvocationConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Invocation i = (Invocation) parent;
if (i.getExpression() != null)
writeChildrenNode(writer, context, i.getExpression(), MarshallingUtils.defineExpressionNodeName(i.getExpression()));
for (Binding b : i.getBinding()) {
writeChildrenNode(writer, context, b, BINDING);
}
}
use of org.kie.dmn.model.api.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
if (invocation.getExpression() == null || ((LiteralExpression) invocation.getExpression()).getText().isEmpty()) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, invocation, model, null, null, Msg.MISSING_EXPRESSION_FOR_INVOCATION, node.getIdentifierString());
return null;
}
String functionName = ((LiteralExpression) invocation.getExpression()).getText();
String[] fnameParts = functionName.split("\\.");
Optional<DMNNode> findAsDep = Optional.empty();
if (fnameParts.length > 1) {
findAsDep = node.getDependencies().values().stream().filter(dmnNode -> dmnNode.getModelImportAliasFor(dmnNode.getModelNamespace(), dmnNode.getModelName()).map(alias -> Objects.equals(functionName, alias + "." + dmnNode.getName())).orElse(false)).findFirst();
} else {
findAsDep = node.getDependencies().values().stream().filter(d -> d.getName().equals(functionName)).findAny();
}
boolean findAsBuiltin = RootExecutionFrame.INSTANCE.getValue(functionName) != null;
boolean findAsCustomFunction = ctx.getFeelHelper().newCompilerContext().getFEELFunctions().stream().anyMatch(f -> f.getName().equals(functionName));
boolean findInContext = ctx.getVariables().get(functionName) != null;
if (!findAsDep.isPresent() && !findAsBuiltin && !findAsCustomFunction && !findInContext) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.WARN, invocation, model, null, null, Msg.EXPRESSION_FOR_INVOCATION_NOT_RESOLVED, functionName, node.getIdentifierString(), node.getDependencies().values().stream().map(DMNNode::getName).collect(Collectors.toList()));
}
DMNInvocationEvaluator invEval = new DMNInvocationEvaluator(node.getName(), node.getSource(), functionName, invocation, null, ctx.getFeelHelper().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.WARN, binding, model, null, null, Msg.MISSING_EXPRESSION_FOR_PARAM_OF_INVOCATION, binding.getParameter().getIdentifierString(), node.getIdentifierString());
return null;
}
invEval.addParameter(binding.getParameter().getName(), compiler.resolveTypeRef(model, binding.getParameter(), binding.getParameter(), binding.getParameter().getTypeRef()), compileExpression(ctx, model, node, binding.getParameter().getName(), binding.getExpression()));
}
return invEval;
}
Aggregations