Search in sources :

Example 1 with Relation

use of org.kie.dmn.model.api.Relation in project drools by kiegroup.

the class RelationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Relation r = (Relation) parent;
    for (InformationItem c : r.getColumn()) {
        writeChildrenNode(writer, context, c, COLUMN);
    }
    for (org.kie.dmn.model.api.List row : r.getRow()) {
        writeChildrenNode(writer, context, row, ROW);
    }
}
Also used : Relation(org.kie.dmn.model.api.Relation) TRelation(org.kie.dmn.model.v1_3.TRelation) InformationItem(org.kie.dmn.model.api.InformationItem)

Example 2 with Relation

use of org.kie.dmn.model.api.Relation in project drools by kiegroup.

the class RelationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Relation r = (Relation) parent;
    for (InformationItem c : r.getColumn()) {
        writeChildrenNode(writer, context, c, COLUMN);
    }
    for (org.kie.dmn.model.api.List row : r.getRow()) {
        writeChildrenNode(writer, context, row, ROW);
    }
}
Also used : TRelation(org.kie.dmn.model.v1_1.TRelation) Relation(org.kie.dmn.model.api.Relation) InformationItem(org.kie.dmn.model.api.InformationItem)

Example 3 with Relation

use of org.kie.dmn.model.api.Relation in project drools by kiegroup.

the class RelationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Relation r = (Relation) parent;
    for (InformationItem c : r.getColumn()) {
        writeChildrenNode(writer, context, c, COLUMN);
    }
    for (org.kie.dmn.model.api.List row : r.getRow()) {
        writeChildrenNode(writer, context, row, ROW);
    }
}
Also used : TRelation(org.kie.dmn.model.v1_2.TRelation) Relation(org.kie.dmn.model.api.Relation) InformationItem(org.kie.dmn.model.api.InformationItem)

Example 4 with Relation

use of org.kie.dmn.model.api.Relation 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;
}
Also used : DMNExpressionEvaluator(org.kie.dmn.core.api.DMNExpressionEvaluator) LiteralExpression(org.kie.dmn.model.api.LiteralExpression) ArrayList(java.util.ArrayList) InformationItem(org.kie.dmn.model.api.InformationItem) Relation(org.kie.dmn.model.api.Relation) LiteralExpression(org.kie.dmn.model.api.LiteralExpression) CompiledExpression(org.kie.dmn.feel.lang.CompiledExpression) Expression(org.kie.dmn.model.api.Expression) DMNRelationEvaluator(org.kie.dmn.core.ast.DMNRelationEvaluator)

Example 5 with Relation

use of org.kie.dmn.model.api.Relation in project drools by kiegroup.

the class RelationConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Relation r = (Relation) parent;
    for (InformationItem c : r.getColumn()) {
        writeChildrenNode(writer, context, c, COLUMN);
    }
    for (org.kie.dmn.model.api.List row : r.getRow()) {
        writeChildrenNode(writer, context, row, ROW);
    }
}
Also used : TRelation(org.kie.dmn.model.v1_4.TRelation) Relation(org.kie.dmn.model.api.Relation) InformationItem(org.kie.dmn.model.api.InformationItem)

Aggregations

InformationItem (org.kie.dmn.model.api.InformationItem)5 Relation (org.kie.dmn.model.api.Relation)5 ArrayList (java.util.ArrayList)1 DMNExpressionEvaluator (org.kie.dmn.core.api.DMNExpressionEvaluator)1 DMNRelationEvaluator (org.kie.dmn.core.ast.DMNRelationEvaluator)1 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)1 Expression (org.kie.dmn.model.api.Expression)1 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)1 TRelation (org.kie.dmn.model.v1_1.TRelation)1 TRelation (org.kie.dmn.model.v1_2.TRelation)1 TRelation (org.kie.dmn.model.v1_3.TRelation)1 TRelation (org.kie.dmn.model.v1_4.TRelation)1