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);
}
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());
}
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();
}
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");
}
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();
}
Aggregations