use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method buildOutputClausesByDataType.
void buildOutputClausesByDataType(final HasExpression hasExpression, final DecisionTable dTable, final DecisionRule decisionRule) {
final HasTypeRef hasTypeRef = getHasTypeRef(hasExpression, dTable);
final QName typeRef = !Objects.isNull(hasTypeRef) ? hasTypeRef.getTypeRef() : BuiltInType.UNDEFINED.asQName();
final String name = DecisionTableDefaultValueUtilities.getNewOutputClauseName(dTable);
final List<ClauseRequirement> outputClausesRequirement = generateOutputClauseRequirements(dmnGraphUtils.getModelDefinitions(), typeRef, name);
if (outputClausesRequirement.isEmpty()) {
dTable.getOutput().add(buildOutputClause(dTable, typeRef, name));
populateOutputEntries(decisionRule);
} else {
outputClausesRequirement.stream().sorted(Comparator.comparing(outputClauseRequirement -> outputClauseRequirement.text)).map(outputClauseRequirement -> buildOutputClause(dTable, outputClauseRequirement.typeRef, outputClauseRequirement.text)).forEach(outputClause -> {
dTable.getOutput().add(outputClause);
populateOutputEntries(decisionRule);
});
}
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableGrid method doAfterSelectionChange.
@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
return;
}
if (getExpression().get().isPresent()) {
final DecisionTable dtable = getExpression().get().get();
final DecisionTableUIModelMapperHelper.DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, uiColumnIndex);
switch(section) {
case INPUT_CLAUSES:
final int icIndex = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, uiColumnIndex);
final UnaryTests unaryTests = dtable.getRule().get(uiRowIndex).getInputEntry().get(icIndex);
fireDomainObjectSelectionEvent(unaryTests);
return;
case OUTPUT_CLAUSES:
final int ocIndex = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, uiColumnIndex);
final LiteralExpression literalExpression = dtable.getRule().get(uiRowIndex).getOutputEntry().get(ocIndex);
fireDomainObjectSelectionEvent(literalExpression);
return;
}
}
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method wbFromDMN.
public static Expression wbFromDMN(final org.kie.dmn.model.api.Expression dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (dmn instanceof org.kie.dmn.model.api.LiteralExpression) {
final LiteralExpression e = LiteralExpressionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.LiteralExpression) dmn);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Context) {
final Context e = ContextPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Context) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Relation) {
final Relation e = RelationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Relation) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.List) {
final List e = ListPropertyConverter.wbFromDMN((org.kie.dmn.model.api.List) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Invocation) {
final Invocation e = InvocationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Invocation) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.FunctionDefinition) {
final FunctionDefinition e = FunctionDefinitionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.FunctionDefinition) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.DecisionTable) {
final DecisionTable e = DecisionTablePropertyConverter.wbFromDMN((org.kie.dmn.model.api.DecisionTable) dmn);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testGetLabel.
@Test
public void testGetLabel() {
final DecisionTable expression = new DecisionTable();
when(boxedExpressionHelper.getExpression(node)).thenReturn(expression);
final String actualLabel = factory.getLabel(node);
assertEquals(DECISION_TABLE_DEFINITION_NAME, actualLabel);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testGetType.
@Test
public void testGetType() {
final DecisionTable expression = new DecisionTable();
final DecisionNavigatorItem.Type expectedType = DECISION_TABLE;
when(boxedExpressionHelper.getExpression(node)).thenReturn(expression);
final DecisionNavigatorItem.Type actualType = factory.getType(node);
assertEquals(expectedType, actualType);
}
Aggregations