use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText in project kie-wb-common by kiegroup.
the class AddRuleAnnotationClauseCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
decisionTable.getComponentWidths().add(uiColumnIndex, null);
final int clauseIndex = getClauseIndex();
decisionTable.getAnnotations().add(clauseIndex, ruleAnnotationClause);
ruleAnnotationClause.getName().setValue(getName());
decisionTable.getRule().forEach(rule -> {
final RuleAnnotationClauseText ruleAnnotationClauseText = new RuleAnnotationClauseText();
ruleAnnotationClauseText.getText().setValue(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_EXPRESSION_TEXT);
rule.getAnnotationEntry().add(clauseIndex, ruleAnnotationClauseText);
ruleAnnotationClauseText.setParent(rule);
});
ruleAnnotationClause.setParent(decisionTable);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
decisionTable.getComponentWidths().remove(uiColumnIndex);
final int clauseIndex = decisionTable.getAnnotations().indexOf(ruleAnnotationClause);
decisionTable.getRule().forEach(rule -> rule.getAnnotationEntry().remove(clauseIndex));
decisionTable.getAnnotations().remove(ruleAnnotationClause);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText in project kie-wb-common by kiegroup.
the class DeleteRuleAnnotationClauseCommand 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) {
getDecisionTable().getComponentWidths().remove(getUiColumnIndex());
final int clauseIndex = getRuleAnnotationClauseIndex();
getDecisionTable().getRule().forEach(row -> row.getAnnotationEntry().remove(clauseIndex));
getDecisionTable().getAnnotations().remove(clauseIndex);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
getDecisionTable().getComponentWidths().add(getUiColumnIndex(), getOldUiModelColumn().getWidth());
final int clauseIndex = getRuleAnnotationClauseIndex();
getDecisionTable().getAnnotations().add(clauseIndex, getOldRuleClause());
IntStream.range(0, getDecisionTable().getRule().size()).forEach(rowIndex -> {
final RuleAnnotationClauseText value = getOldColumnData().get(rowIndex);
getDecisionTable().getRule().get(rowIndex).getAnnotationEntry().add(clauseIndex, value);
});
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverterTest method createWbRuleAnnotation.
private RuleAnnotationClauseText createWbRuleAnnotation(final String text) {
final RuleAnnotationClauseText annotation = new RuleAnnotationClauseText();
annotation.getText().setValue(text);
return annotation;
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseTextConverterTest method testDmnFromWB.
@Test
public void testDmnFromWB() {
final String text = "text";
final Text textObject = new Text(text);
when(ruleAnnotationClauseText.getText()).thenReturn(textObject);
final RuleAnnotation converted = RuleAnnotationClauseTextConverter.dmnFromWB(ruleAnnotationClauseText);
assertEquals(text, converted.getText());
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseTextConverterTest method testWbFromDMN.
@Test
public void testWbFromDMN() {
final String text = "text";
when(ruleAnnotation.getText()).thenReturn(text);
final RuleAnnotationClauseText converted = RuleAnnotationClauseTextConverter.wbFromDMN(ruleAnnotation);
assertEquals(text, converted.getText().getValue());
}
Aggregations