use of org.kie.dmn.core.ast.DMNFilterEvaluator in project drools by kiegroup.
the class DMNEvaluatorCompiler method compileFilter.
private DMNExpressionEvaluator compileFilter(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, String exprName, Filter expression) {
DMNExpressionEvaluator inEvaluator = compileExpression(ctx, model, node, exprName + " [in]", expression.getIn().getExpression());
DMNExpressionEvaluator filterEvaluator;
try {
ctx.enterFrame();
DMNType outputType = compiler.resolveTypeRef(model, null, node.getSource(), expression.getTypeRef());
DMNType elementType = outputType;
if (elementType != null && elementType.isCollection() && elementType instanceof BaseDMNTypeImpl) {
elementType = extractOrSynthesizeGeneric(model, (BaseDMNTypeImpl) elementType);
}
ctx.setVariable("item", elementType != null ? elementType : model.getTypeRegistry().unknown());
if (elementType != null && elementType.isComposite()) {
elementType.getFields().forEach((k, v) -> ctx.setVariable(k, v != null ? v : model.getTypeRegistry().unknown()));
}
filterEvaluator = compileExpression(ctx, model, node, exprName + " [filter]", expression.getMatch().getExpression());
} finally {
ctx.exitFrame();
}
if (inEvaluator == null) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, node.getSource(), model, null, null, Msg.MISSING_EXPRESSION_FOR_FILTER, "in", node.getIdentifierString());
return null;
}
if (filterEvaluator == null) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, node.getSource(), model, null, null, Msg.MISSING_EXPRESSION_FOR_FILTER, "filter", node.getIdentifierString());
return null;
}
return new DMNFilterEvaluator(exprName, node.getSource(), inEvaluator, filterEvaluator);
}
Aggregations