Search in sources :

Example 6 with UnaryTests

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

the class UnaryTestsPropertyConverter method wbFromDMN.

public static UnaryTests wbFromDMN(final org.kie.dmn.model.v1_1.UnaryTests dmn) {
    if (dmn == null) {
        return null;
    }
    Id id = new Id(dmn.getId());
    Description description = new Description(dmn.getDescription());
    UnaryTests result = new UnaryTests(id, description, dmn.getText(), dmn.getExpressionLanguage());
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)

Example 7 with UnaryTests

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

the class AddDecisionRuleCommand method newGraphCommand.

@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) {
    return new AbstractGraphCommand() {

        @Override
        protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
            dtable.getRule().add(uiRowIndex, rule);
            for (int ie = 0; ie < dtable.getInput().size(); ie++) {
                final UnaryTests ut = new UnaryTests();
                ut.setText(AddInputClauseCommand.INPUT_CLAUSE_DEFAULT_VALUE);
                rule.getInputEntry().add(ut);
            }
            for (int oe = 0; oe < dtable.getOutput().size(); oe++) {
                final LiteralExpression le = new LiteralExpression();
                le.setText(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE);
                rule.getOutputEntry().add(le);
            }
            final Description d = new Description();
            d.setValue(DESCRIPTION_DEFAULT_VALUE);
            rule.setDescription(d);
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
            dtable.getRule().remove(rule);
            return GraphCommandResultBuilder.SUCCESS;
        }
    };
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)

Example 8 with UnaryTests

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

the class AddInputClauseCommand method newGraphCommand.

@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) {
    return new AbstractGraphCommand() {

        @Override
        protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
            final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
            dtable.getInput().add(clauseIndex, inputClause);
            dtable.getRule().forEach(rule -> {
                final UnaryTests ut = new UnaryTests();
                ut.setText(INPUT_CLAUSE_DEFAULT_VALUE);
                rule.getInputEntry().add(clauseIndex, ut);
            });
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
            final int clauseIndex = dtable.getInput().indexOf(inputClause);
            dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex));
            dtable.getInput().remove(inputClause);
            return GraphCommandResultBuilder.SUCCESS;
        }
    };
}
Also used : AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)

Example 9 with UnaryTests

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

the class MoveColumnsCommandTest method setUp.

@Before
public void setUp() throws Exception {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    dtable.getInput().add(inputClauseOne);
    dtable.getInput().add(inputClauseTwo);
    dtable.getInput().add(inputClauseThree);
    dtable.getOutput().add(outputClauseOne);
    dtable.getOutput().add(outputClauseTwo);
    dtable.getOutput().add(outputClauseThree);
    dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getInputEntry().add(new UnaryTests());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
            getOutputEntry().add(new LiteralExpression());
        }
    });
    uiModel.appendColumn(uiRowNumberColumn);
    uiModel.appendColumn(uiInputClauseColumnOne);
    uiModel.appendColumn(uiInputClauseColumnTwo);
    uiModel.appendColumn(uiInputClauseColumnThree);
    uiModel.appendColumn(uiOutputClauseColumnOne);
    uiModel.appendColumn(uiOutputClauseColumnTwo);
    uiModel.appendColumn(uiOutputClauseColumnThree);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumnOne).getIndex();
    doReturn(2).when(uiInputClauseColumnTwo).getIndex();
    doReturn(3).when(uiInputClauseColumnThree).getIndex();
    doReturn(4).when(uiOutputClauseColumnOne).getIndex();
    doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
    doReturn(6).when(uiOutputClauseColumnThree).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Before(org.junit.Before)

Example 10 with UnaryTests

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

the class OutputClausePropertyConverter method wbFromDMN.

public static OutputClause wbFromDMN(final org.kie.dmn.model.v1_1.OutputClause dmn) {
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    UnaryTests outputValues = UnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
    LiteralExpression defaultOutputEntry = LiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    OutputClause result = new OutputClause();
    result.setId(id);
    result.setName(dmn.getName());
    result.setDescription(description);
    result.setOutputValues(outputValues);
    result.setDefaultOutputEntry(defaultOutputEntry);
    result.setTypeRef(typeRef);
    return result;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)

Aggregations

UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)14 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)8 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)7 UnaryTests (org.kie.dmn.model.v1_1.UnaryTests)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)5 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 AbstractGraphCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand)4 DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)3 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Before (org.junit.Before)2 DMNType (org.kie.dmn.api.core.DMNType)2 BaseDMNTypeImpl (org.kie.dmn.core.impl.BaseDMNTypeImpl)2 UnaryTest (org.kie.dmn.feel.runtime.UnaryTest)2