use of org.kie.dmn.core.ast.DMNIteratorEvaluator in project drools by kiegroup.
the class DMNEvaluatorCompiler method compileIterator.
private DMNExpressionEvaluator compileIterator(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, String exprName, Iterator expression) {
if (expression.getIteratorVariable() == null || expression.getIteratorVariable().isEmpty()) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, node.getSource(), model, null, null, Msg.MISSING_EXPRESSION_FOR_ITERATOR, expression.getTypeRef().toString().toLowerCase(), node.getIdentifierString());
return null;
}
DMNExpressionEvaluator inEvaluator = null;
DMNExpressionEvaluator returnEvaluator = null;
inEvaluator = compileExpression(ctx, model, node, exprName + " [in]", expression.getIn().getExpression());
try {
ctx.enterFrame();
DMNType outputType = compiler.resolveTypeRef(model, null, node.getSource(), expression.getTypeRef());
DMNType elementType = compiler.resolveTypeRefUsingString(model, null, node.getSource(), expression.getIn().getTypeRef());
if (elementType != null && elementType.isCollection() && elementType instanceof BaseDMNTypeImpl) {
elementType = extractOrSynthesizeGeneric(model, (BaseDMNTypeImpl) elementType);
}
ctx.setVariable(expression.getIteratorVariable(), elementType != null ? elementType : model.getTypeRegistry().unknown());
ctx.setVariable("partial", outputType != null ? outputType : model.getTypeRegistry().unknown());
returnEvaluator = compileExpression(ctx, model, node, exprName + " [return]", expression instanceof For ? ((For) expression).getReturn().getExpression() : ((Quantified) expression).getSatisfies().getExpression());
} finally {
ctx.exitFrame();
}
if (inEvaluator == null) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, node.getSource(), model, null, null, Msg.MISSING_EXPRESSION_FOR_ITERATOR, "in", node.getIdentifierString());
return null;
}
if (returnEvaluator == null) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, node.getSource(), model, null, null, Msg.MISSING_EXPRESSION_FOR_ITERATOR, expression instanceof For ? "return" : "satisfies", node.getIdentifierString());
return null;
}
return new DMNIteratorEvaluator(exprName, node.getSource(), expression, expression.getIteratorVariable(), inEvaluator, returnEvaluator);
}
Aggregations