Search in sources :

Example 11 with Expression

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

the class NamedExpressionConverter method assignChildElement.

@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
    NamedExpression namedExp = (NamedExpression) parent;
    if (child instanceof Expression) {
        namedExp.setExpression((Expression) child);
        namedExp.setName(nodeName);
    } else
        super.assignChildElement(parent, nodeName, child);
}
Also used : Expression(org.kie.dmn.model.api.Expression) TNamedExpression(org.kie.dmn.trisotech.model.v1_3.TNamedExpression) NamedExpression(org.kie.dmn.trisotech.model.api.NamedExpression) TNamedExpression(org.kie.dmn.trisotech.model.v1_3.TNamedExpression) NamedExpression(org.kie.dmn.trisotech.model.api.NamedExpression)

Example 12 with Expression

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

the class IteratorConverter method assignChildElement.

@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
    Iterator filter = (Iterator) parent;
    if (IN.equals(nodeName)) {
        Expression expression = ((NamedExpression) child).getExpression();
        if (((NamedExpression) child).getTypeRef() != null) {
            expression.setTypeRef(((NamedExpression) child).getTypeRef());
        }
        filter.setIn(expression);
    } else if (RETURN.equals(nodeName)) {
        filter.setReturn(((NamedExpression) child).getExpression());
    } else {
        super.assignChildElement(parent, nodeName, child);
    }
}
Also used : Expression(org.kie.dmn.model.api.Expression) TNamedExpression(org.kie.dmn.trisotech.model.v1_3.TNamedExpression) NamedExpression(org.kie.dmn.trisotech.model.api.NamedExpression) TNamedExpression(org.kie.dmn.trisotech.model.v1_3.TNamedExpression) NamedExpression(org.kie.dmn.trisotech.model.api.NamedExpression) Iterator(org.kie.dmn.trisotech.model.api.Iterator) TIterator(org.kie.dmn.trisotech.model.v1_3.TIterator)

Example 13 with Expression

use of org.kie.dmn.model.api.Expression 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 14 with Expression

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

the class ExpressionConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    super.writeAttributes(writer, parent);
    Expression e = (Expression) parent;
    if (!(e instanceof UnaryTests) && e.getTypeRef() != null) {
        writer.addAttribute(TYPE_REF, MarshallingUtils.formatQName(e.getTypeRef()));
    }
}
Also used : Expression(org.kie.dmn.model.api.Expression) UnaryTests(org.kie.dmn.model.api.UnaryTests)

Example 15 with Expression

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

the class DecisionConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Decision dec = (Decision) parent;
    if (dec.getQuestion() != null)
        writeChildrenNodeAsValue(writer, context, dec.getQuestion(), QUESTION);
    if (dec.getAllowedAnswers() != null)
        writeChildrenNodeAsValue(writer, context, dec.getAllowedAnswers(), ALLOWED_ANSWERS);
    if (dec.getVariable() != null)
        writeChildrenNode(writer, context, dec.getVariable(), VARIABLE);
    for (InformationRequirement ir : dec.getInformationRequirement()) {
        writeChildrenNode(writer, context, ir, INFORMATION_REQUIREMENT);
    }
    for (KnowledgeRequirement kr : dec.getKnowledgeRequirement()) {
        writeChildrenNode(writer, context, kr, KNOWLEDGE_REQUIREMENT);
    }
    for (AuthorityRequirement ar : dec.getAuthorityRequirement()) {
        writeChildrenNode(writer, context, ar, AUTHORITY_REQUIREMENT);
    }
    for (DMNElementReference so : dec.getSupportedObjective()) {
        writeChildrenNode(writer, context, so, SUPPORTED_OBJECTIVE);
    }
    for (DMNElementReference ipi : dec.getImpactedPerformanceIndicator()) {
        writeChildrenNode(writer, context, ipi, IMPACTED_PERFORMANCE_INDICATOR);
    }
    for (DMNElementReference dm : dec.getDecisionMaker()) {
        writeChildrenNode(writer, context, dm, DECISION_MAKER);
    }
    for (DMNElementReference downer : dec.getDecisionOwner()) {
        writeChildrenNode(writer, context, downer, DECISION_OWNER);
    }
    for (DMNElementReference up : dec.getUsingProcess()) {
        writeChildrenNode(writer, context, up, USING_PROCESS);
    }
    for (DMNElementReference ut : dec.getUsingTask()) {
        writeChildrenNode(writer, context, ut, USING_TASK);
    }
    if (dec.getExpression() != null) {
        Expression e = dec.getExpression();
        String nodeName = MarshallingUtils.defineExpressionNodeName(xstream, e);
        writeChildrenNode(writer, context, e, nodeName);
    }
}
Also used : KnowledgeRequirement(org.kie.dmn.model.api.KnowledgeRequirement) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) InformationRequirement(org.kie.dmn.model.api.InformationRequirement) Expression(org.kie.dmn.model.api.Expression) AuthorityRequirement(org.kie.dmn.model.api.AuthorityRequirement) Decision(org.kie.dmn.model.api.Decision) TDecision(org.kie.dmn.model.v1_4.TDecision)

Aggregations

Expression (org.kie.dmn.model.api.Expression)16 AuthorityRequirement (org.kie.dmn.model.api.AuthorityRequirement)4 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)4 Decision (org.kie.dmn.model.api.Decision)4 InformationRequirement (org.kie.dmn.model.api.InformationRequirement)4 KnowledgeRequirement (org.kie.dmn.model.api.KnowledgeRequirement)4 List (org.kie.dmn.model.api.List)4 UnaryTests (org.kie.dmn.model.api.UnaryTests)4 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)2 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)2 NamedExpression (org.kie.dmn.trisotech.model.api.NamedExpression)2 TNamedExpression (org.kie.dmn.trisotech.model.v1_3.TNamedExpression)2 ArrayList (java.util.ArrayList)1 DMNExpressionEvaluator (org.kie.dmn.core.api.DMNExpressionEvaluator)1 DMNListEvaluator (org.kie.dmn.core.ast.DMNListEvaluator)1 DMNRelationEvaluator (org.kie.dmn.core.ast.DMNRelationEvaluator)1 InformationItem (org.kie.dmn.model.api.InformationItem)1 Relation (org.kie.dmn.model.api.Relation)1 TDecision (org.kie.dmn.model.v1_1.TDecision)1 TList (org.kie.dmn.model.v1_1.TList)1