Search in sources :

Example 11 with OutputClause

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

the class DeleteOutputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.outputClause = new OutputClause();
    this.dtable.getOutput().add(outputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiRuleAnnotationClauseColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size());
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiOutputClauseColumn).getIndex();
    doReturn(2).when(uiRuleAnnotationClauseColumn).getIndex();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 12 with OutputClause

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

the class DeleteOutputClauseCommandTest method testGraphCommandExecuteRemoveMiddle.

@Test
public void testGraphCommandExecuteRemoveMiddle() {
    final OutputClause firstOutput = mock(OutputClause.class);
    final OutputClause lastOutput = mock(OutputClause.class);
    dtable.getOutput().add(0, firstOutput);
    dtable.getOutput().add(lastOutput);
    final LiteralExpression outputOneValue = mock(LiteralExpression.class);
    final LiteralExpression outputTwoValue = mock(LiteralExpression.class);
    final LiteralExpression outputThreeValue = mock(LiteralExpression.class);
    final DecisionRule rule = new DecisionRule();
    rule.getOutputEntry().add(outputOneValue);
    rule.getOutputEntry().add(outputTwoValue);
    rule.getOutputEntry().add(outputThreeValue);
    dtable.getRule().add(rule);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size() + 1);
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
    assertEquals(2, dtable.getOutput().size());
    assertEquals(firstOutput, dtable.getOutput().get(0));
    assertEquals(lastOutput, dtable.getOutput().get(1));
    assertEquals(2, dtable.getRule().get(0).getOutputEntry().size());
    assertEquals(outputOneValue, dtable.getRule().get(0).getOutputEntry().get(0));
    assertEquals(outputThreeValue, dtable.getRule().get(0).getOutputEntry().get(1));
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Example 13 with OutputClause

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

the class DecisionTableGrid method addOutputClause.

void addOutputClause(final int index) {
    getExpression().get().ifPresent(dtable -> {
        final OutputClause clause = new OutputClause();
        final CommandResult<CanvasViolation> result = sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddOutputClauseCommand(dtable, clause, model, () -> makeOutputClauseColumn(index, clause), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING), () -> resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM)));
        if (!CommandUtils.isError(result)) {
            selectHeaderCell(1, index, false, false);
            CellContextUtilities.editSelectedCell(this);
        }
    });
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AddOutputClauseCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddOutputClauseCommand)

Example 14 with OutputClause

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

the class DecisionTableGrid method doAfterHeaderOutputClauseSelectionChange.

protected void doAfterHeaderOutputClauseSelectionChange(final DecisionTable dtable, final int uiHeaderRowIndex, final int uiHeaderColumnIndex) {
    final List<GridColumn.HeaderMetaData> headerMetaData = model.getColumns().get(uiHeaderColumnIndex).getHeaderMetaData();
    if (uiHeaderRowIndex == 0 && headerMetaData.size() > 1) {
        if (doFireDomainObjectSelectionEventForHasExpression()) {
            return;
        }
    }
    final int ocIndex = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, uiHeaderColumnIndex);
    final OutputClause outputClause = dtable.getOutput().get(ocIndex);
    fireDomainObjectSelectionEvent(outputClause);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause)

Example 15 with OutputClause

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

the class DecisionTablePropertyConverterTest method testWBFromDMNSingleOutputClauseTypeRef.

@Test
public void testWBFromDMNSingleOutputClauseTypeRef() {
    final org.kie.dmn.model.api.DecisionTable dmn = new TDecisionTable();
    final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = new TOutputClause();
    dmn.setId(UUID);
    dmn.setDescription(DESCRIPTION);
    dmn.setTypeRef(new QName(QNAME_LOCALPART));
    dmnOutputClause1.setName(NAME);
    dmnOutputClause1.setTypeRef(new QName(QNAME_LOCALPART + "-oc1"));
    dmn.getOutput().add(dmnOutputClause1);
    final DecisionTable wb = DecisionTablePropertyConverter.wbFromDMN(dmn);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(UUID);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(DESCRIPTION);
    assertThat(wb.getTypeRef()).isNotNull();
    assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART);
    assertThat(wb.getOutput()).hasSize(1);
    final OutputClause wbOutputClause1 = wb.getOutput().get(0);
    assertThat(wbOutputClause1.getName()).isNull();
    assertThat(wbOutputClause1.getTypeRef()).isNull();
}
Also used : TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) QName(javax.xml.namespace.QName) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) Test(org.junit.Test)

Aggregations

OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)40 Test (org.junit.Test)24 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)21 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)14 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)12 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)10 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)7 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)7 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)7 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)6 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)6 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)5 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)5 Before (org.junit.Before)4 TDecisionTable (org.kie.dmn.model.v1_2.TDecisionTable)4 TOutputClause (org.kie.dmn.model.v1_2.TOutputClause)4 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)4