use of org.kie.dmn.core.ast.DMNRelationEvaluator in project drools by kiegroup.
the class DMNEvaluatorCompiler method compileRelation.
private DMNExpressionEvaluator compileRelation(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, String relationName, Relation expression) {
Relation relationDef = expression;
DMNRelationEvaluator relationEval = new DMNRelationEvaluator(node.getName(), node.getSource(), relationDef);
for (InformationItem col : relationDef.getColumn()) {
DMNCompilerHelper.checkVariableName(model, col, col.getName());
relationEval.addColumn(col.getName());
}
for (org.kie.dmn.model.api.List row : relationDef.getRow()) {
java.util.List<DMNExpressionEvaluator> values = new ArrayList<>();
for (Expression expr : row.getExpression()) {
if (expr instanceof LiteralExpression) {
// DROOLS-2439
LiteralExpression literalExpression = (LiteralExpression) expr;
if (literalExpression.getText() == null || literalExpression.getText().isEmpty()) {
LiteralExpression nullProxy = (literalExpression instanceof org.kie.dmn.model.v1_1.TLiteralExpression) ? new org.kie.dmn.model.v1_1.TLiteralExpression() : new org.kie.dmn.model.v1_2.TLiteralExpression();
nullProxy.setText("null");
nullProxy.setImportedValues(literalExpression.getImportedValues());
nullProxy.setExpressionLanguage(literalExpression.getExpressionLanguage());
nullProxy.setTypeRef(literalExpression.getTypeRef());
nullProxy.setId(literalExpression.getId());
nullProxy.setLabel(literalExpression.getLabel());
nullProxy.setDescription(literalExpression.getDescription());
nullProxy.setExtensionElements(literalExpression.getExtensionElements());
nullProxy.setParent(literalExpression.getParent());
nullProxy.getNsContext().putAll(literalExpression.getNsContext());
nullProxy.setAdditionalAttributes(literalExpression.getAdditionalAttributes());
nullProxy.setLocation(literalExpression.getLocation());
// do not add `temp` as child of parent.
expr = nullProxy;
}
}
values.add(compileExpression(ctx, model, node, relationName, expr));
}
relationEval.addRow(values);
}
return relationEval;
}
Aggregations