use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class DeleteInputClauseCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
dtable.getComponentWidths().remove(uiColumnIndex);
final int clauseIndex = getInputClauseIndex();
dtable.getRule().forEach(row -> row.getInputEntry().remove(clauseIndex));
dtable.getInput().remove(clauseIndex);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth());
final int clauseIndex = getInputClauseIndex();
dtable.getInput().add(clauseIndex, oldInputClause);
IntStream.range(0, dtable.getRule().size()).forEach(rowIndex -> {
final UnaryTests value = oldColumnData.get(rowIndex);
dtable.getRule().get(rowIndex).getInputEntry().add(clauseIndex, value);
});
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testSetUnaryTestsWhenUnaryTestsIsNotNull.
@Test
public void testSetUnaryTestsWhenUnaryTestsIsNotNull() {
final ItemDefinition wb = mock(ItemDefinition.class);
final ArgumentCaptor<UnaryTests> argument = ArgumentCaptor.forClass(UnaryTests.class);
final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
final org.kie.dmn.model.api.UnaryTests dmnAllowedValues = mock(org.kie.dmn.model.api.UnaryTests.class);
when(dmn.getAllowedValues()).thenReturn(dmnAllowedValues);
setUnaryTests(wb, dmn);
verify(wb).setAllowedValues(argument.capture());
assertEquals(wb, argument.getValue().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class DecisionRuleFactory method duplicateDecisionRule.
public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) {
final DecisionRule rule = new DecisionRule();
final DecisionRule source = dtable.getRule().get(index);
for (UnaryTests ie : source.getInputEntry()) {
final UnaryTests ut = new UnaryTests();
ut.getText().setValue(ie.getText().getValue());
ut.setConstraintType(ie.getConstraintType());
rule.getInputEntry().add(ut);
ut.setParent(rule);
}
for (LiteralExpression oe : source.getOutputEntry()) {
final LiteralExpression le = new LiteralExpression();
le.getText().setValue(oe.getText().getValue());
rule.getOutputEntry().add(le);
le.setParent(rule);
}
for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) {
final RuleAnnotationClauseText copy = new RuleAnnotationClauseText();
copy.getText().setValue(text.getText().getValue());
copy.setParent(rule);
rule.getAnnotationEntry().add(copy);
}
rule.setParent(dtable);
return rule;
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests 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.UnaryTests in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.DecisionRule dmnFromWB(final DecisionRule wb) {
final org.kie.dmn.model.api.DecisionRule result = new org.kie.dmn.model.v1_2.TDecisionRule();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
for (final RuleAnnotationClauseText ruleAnnotationClauseText : wb.getAnnotationEntry()) {
final org.kie.dmn.model.api.RuleAnnotation ruleAnnotation = RuleAnnotationClauseTextConverter.dmnFromWB(ruleAnnotationClauseText);
if (ruleAnnotation != null) {
ruleAnnotation.setParent(result);
}
result.getAnnotationEntry().add(ruleAnnotation);
}
for (final UnaryTests ie : wb.getInputEntry()) {
final org.kie.dmn.model.api.UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.dmnFromWB(ie);
if (inputEntryConverted != null) {
inputEntryConverted.setParent(result);
}
result.getInputEntry().add(inputEntryConverted);
}
for (final LiteralExpression oe : wb.getOutputEntry()) {
final org.kie.dmn.model.api.LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.dmnFromWB(oe);
if (outputEntryConverted != null) {
outputEntryConverted.setParent(result);
}
result.getOutputEntry().add(outputEntryConverted);
}
return result;
}
Aggregations