Search in sources :

Example 26 with DecisionTable

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

the class DecisionTableGrid method initialiseUiColumns.

@Override
public void initialiseUiColumns() {
    int uiColumnIndex = 0;
    if (getExpression().get().isPresent()) {
        final DecisionTable e = getExpression().get().get();
        model.appendColumn(new DecisionTableRowNumberColumn(e::getHitPolicy, e::getAggregation, cellEditorControls, hitPolicyEditor, getAndSetInitialWidth(uiColumnIndex++, DecisionTableRowNumberColumn.DEFAULT_WIDTH), this));
        for (int index = 0; index < e.getInput().size(); index++) {
            model.appendColumn(makeInputClauseColumn(uiColumnIndex++, e.getInput().get(index)));
        }
        for (int index = 0; index < e.getOutput().size(); index++) {
            model.appendColumn(makeOutputClauseColumn(uiColumnIndex++, e.getOutput().get(index)));
        }
        for (int index = 0; index < e.getAnnotations().size(); index++) {
            model.appendColumn(makeRuleAnnotationClauseColumn(uiColumnIndex++, e.getAnnotations().get(index)));
        }
    }
    getRenderer().setColumnRenderConstraint((isSelectionLayer, gridColumn) -> !isSelectionLayer);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable)

Example 27 with DecisionTable

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

the class DecisionTablePropertyConverterTest method testConverterWhenJSITOutputTypeRefIsNullThenDecisionTableOutputTypeRefIsUndefined.

@Test
public void testConverterWhenJSITOutputTypeRefIsNullThenDecisionTableOutputTypeRefIsUndefined() {
    when(jsitDecisionTable.getOutput()).thenReturn(jsitOutput);
    when(jsitOutput.size()).thenReturn(1);
    when(jsitOutput.get(0)).thenReturn(jsitOutputItem);
    final DecisionTable decisionTable = DecisionTablePropertyConverter.wbFromDMN(jsitDecisionTable);
    assertNotNull(decisionTable);
    assertNotNull(decisionTable.getOutput());
    assertEquals(1, decisionTable.getOutput().size());
    assertEquals(BuiltInType.UNDEFINED.asQName(), decisionTable.getOutput().get(0).getTypeRef());
}
Also used : JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 28 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable 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)

Example 29 with DecisionTable

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

the class DecisionTablePropertyConverterTest method testWBFromDMNMultipleOutputClauseTypeRef.

@Test
public void testWBFromDMNMultipleOutputClauseTypeRef() {
    final org.kie.dmn.model.api.DecisionTable dmn = new TDecisionTable();
    final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = new TOutputClause();
    final org.kie.dmn.model.api.OutputClause dmnOutputClause2 = new TOutputClause();
    dmn.setId(UUID);
    dmn.setDescription(DESCRIPTION);
    dmn.setTypeRef(new QName(QNAME_LOCALPART));
    dmnOutputClause1.setName(NAME + "-oc1");
    dmnOutputClause2.setName(NAME + "-oc2");
    dmnOutputClause1.setTypeRef(new QName(QNAME_LOCALPART + "-oc1"));
    dmnOutputClause2.setTypeRef(new QName(QNAME_LOCALPART + "-oc2"));
    dmn.getOutput().add(dmnOutputClause1);
    dmn.getOutput().add(dmnOutputClause2);
    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(2);
    final OutputClause wbOutputClause1 = wb.getOutput().get(0);
    final OutputClause wbOutputClause2 = wb.getOutput().get(1);
    assertThat(wbOutputClause1.getName()).isEqualTo(NAME + "-oc1");
    assertThat(wbOutputClause2.getName()).isEqualTo(NAME + "-oc2");
    assertThat(wbOutputClause1.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc1");
    assertThat(wbOutputClause2.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc2");
}
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)

Example 30 with DecisionTable

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

the class DecisionTablePropertyConverterTest method testDMNFromWBSingleOutputClauseTypeRef.

@Test
public void testDMNFromWBSingleOutputClauseTypeRef() {
    final DecisionTable wb = new DecisionTable();
    final OutputClause outputClause1 = new OutputClause();
    wb.getId().setValue(UUID);
    wb.getDescription().setValue(DESCRIPTION);
    wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(NULL_NS_URI, QNAME_LOCALPART));
    outputClause1.setName(NAME);
    outputClause1.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(NULL_NS_URI, QNAME_LOCALPART + "-oc1"));
    wb.getOutput().add(outputClause1);
    final org.kie.dmn.model.api.DecisionTable dmn = DecisionTablePropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(UUID);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(DESCRIPTION);
    assertThat(dmn.getTypeRef()).isNotNull();
    assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART);
    assertThat(dmn.getOutput()).hasSize(1);
    final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = dmn.getOutput().get(0);
    assertThat(dmnOutputClause1.getName()).isNull();
    assertThat(dmnOutputClause1.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) Test(org.junit.Test)

Aggregations

DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)56 Test (org.junit.Test)32 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)22 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)17 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)15 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)12 Before (org.junit.Before)11 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)10 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)9 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)8 Context (org.kie.workbench.common.dmn.api.definition.model.Context)7 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)7 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)7 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6 TDecisionTable (org.kie.dmn.model.v1_2.TDecisionTable)5 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)5