Search in sources :

Example 26 with DecisionRule

use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.

the class DecisionRulePropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.DecisionRule dmnFromWB(final DecisionRule wb) {
    org.kie.dmn.model.v1_1.DecisionRule result = new org.kie.dmn.model.v1_1.DecisionRule();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    for (UnaryTests ie : wb.getInputEntry()) {
        result.getInputEntry().add(UnaryTestsPropertyConverter.dmnFromWB(ie));
    }
    for (LiteralExpression oe : wb.getOutputEntry()) {
        result.getOutputEntry().add(LiteralExpressionPropertyConverter.dmnFromWB(oe));
    }
    return result;
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)

Example 27 with DecisionRule

use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project kie-wb-common by kiegroup.

the class DecisionTablePropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.DecisionTable dmnFromWB(final DecisionTable wb) {
    org.kie.dmn.model.v1_1.DecisionTable result = new org.kie.dmn.model.v1_1.DecisionTable();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (InputClause input : wb.getInput()) {
        result.getInput().add(InputClausePropertyConverter.dmnFromWB(input));
    }
    for (OutputClause input : wb.getOutput()) {
        result.getOutput().add(OutputClausePropertyConverter.dmnFromWB(input));
    }
    for (DecisionRule dr : wb.getRule()) {
        result.getRule().add(DecisionRulePropertyConverter.dmnFromWB(dr));
    }
    if (wb.getHitPolicy() != null) {
        result.setHitPolicy(org.kie.dmn.model.v1_1.HitPolicy.fromValue(wb.getHitPolicy().value()));
    }
    if (wb.getAggregation() != null) {
        result.setAggregation(org.kie.dmn.model.v1_1.BuiltinAggregator.fromValue(wb.getAggregation().value()));
    }
    if (wb.getPreferredOrientation() != null) {
        result.setPreferredOrientation(org.kie.dmn.model.v1_1.DecisionTableOrientation.fromValue(wb.getPreferredOrientation().value()));
    }
    result.setOutputLabel(wb.getOutputLabel());
    return result;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)

Example 28 with DecisionRule

use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule in project drools by kiegroup.

the class DecisionRuleConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DecisionRule dr = (DecisionRule) parent;
    for (UnaryTests ie : dr.getInputEntry()) {
        writeChildrenNode(writer, context, ie, INPUT_ENTRY);
    }
    for (LiteralExpression oe : dr.getOutputEntry()) {
        writeChildrenNode(writer, context, oe, OUTPUT_ENTRY);
    }
}
Also used : LiteralExpression(org.kie.dmn.model.v1_1.LiteralExpression) UnaryTests(org.kie.dmn.model.v1_1.UnaryTests) DecisionRule(org.kie.dmn.model.v1_1.DecisionRule)

Aggregations

DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)25 Test (org.junit.Test)12 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)12 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)12 DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)9 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)6 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)6 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)6 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)6 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)6 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)6 Before (org.junit.Before)5 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)5 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)5 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)3 DecisionTableSection (org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapperHelper.DecisionTableSection)3 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2