use of org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method wbFromDMN.
public static UnaryTests wbFromDMN(final org.kie.dmn.model.v1_1.UnaryTests dmn) {
if (dmn == null) {
return null;
}
Id id = new Id(dmn.getId());
Description description = new Description(dmn.getDescription());
UnaryTests result = new UnaryTests(id, description, dmn.getText(), dmn.getExpressionLanguage());
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommand 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) {
dtable.getRule().add(uiRowIndex, rule);
for (int ie = 0; ie < dtable.getInput().size(); ie++) {
final UnaryTests ut = new UnaryTests();
ut.setText(AddInputClauseCommand.INPUT_CLAUSE_DEFAULT_VALUE);
rule.getInputEntry().add(ut);
}
for (int oe = 0; oe < dtable.getOutput().size(); oe++) {
final LiteralExpression le = new LiteralExpression();
le.setText(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE);
rule.getOutputEntry().add(le);
}
final Description d = new Description();
d.setValue(DESCRIPTION_DEFAULT_VALUE);
rule.setDescription(d);
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
dtable.getRule().remove(rule);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests in project kie-wb-common by kiegroup.
the class AddInputClauseCommand 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) {
final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
dtable.getInput().add(clauseIndex, inputClause);
dtable.getRule().forEach(rule -> {
final UnaryTests ut = new UnaryTests();
ut.setText(INPUT_CLAUSE_DEFAULT_VALUE);
rule.getInputEntry().add(clauseIndex, ut);
});
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
final int clauseIndex = dtable.getInput().indexOf(inputClause);
dtable.getRule().forEach(rule -> rule.getInputEntry().remove(clauseIndex));
dtable.getInput().remove(inputClause);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClauseOne);
dtable.getInput().add(inputClauseTwo);
dtable.getInput().add(inputClauseThree);
dtable.getOutput().add(outputClauseOne);
dtable.getOutput().add(outputClauseTwo);
dtable.getOutput().add(outputClauseThree);
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
}
});
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumnOne);
uiModel.appendColumn(uiInputClauseColumnTwo);
uiModel.appendColumn(uiInputClauseColumnThree);
uiModel.appendColumn(uiOutputClauseColumnOne);
uiModel.appendColumn(uiOutputClauseColumnTwo);
uiModel.appendColumn(uiOutputClauseColumnThree);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumnOne).getIndex();
doReturn(2).when(uiInputClauseColumnTwo).getIndex();
doReturn(3).when(uiInputClauseColumnThree).getIndex();
doReturn(4).when(uiOutputClauseColumnOne).getIndex();
doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
doReturn(6).when(uiOutputClauseColumnThree).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests in project kie-wb-common by kiegroup.
the class OutputClausePropertyConverter method wbFromDMN.
public static OutputClause wbFromDMN(final org.kie.dmn.model.v1_1.OutputClause dmn) {
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
UnaryTests outputValues = UnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
LiteralExpression defaultOutputEntry = LiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
OutputClause result = new OutputClause();
result.setId(id);
result.setName(dmn.getName());
result.setDescription(description);
result.setOutputValues(outputValues);
result.setDefaultOutputEntry(defaultOutputEntry);
result.setTypeRef(typeRef);
return result;
}
Aggregations