use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationUIModelMapper method toDMNModel.
@Override
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
dmnModel.get().ifPresent(relation -> {
final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
switch(section) {
case ROW_INDEX:
break;
case INFORMATION_ITEM:
final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
final Expression e = row.getExpression().get(iiIndex);
final Optional<Expression> expression = Optional.ofNullable(e);
expression.ifPresent(ex -> {
// Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
// to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
// the simplification has been made for the benefit of USERS.
final LiteralExpression le = (LiteralExpression) ex;
le.setText(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class RelationUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(relation -> {
final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
switch(section) {
case ROW_INDEX:
uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case INFORMATION_ITEM:
final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
final Expression e = row.getExpression().get(iiIndex);
final Optional<Expression> expression = Optional.ofNullable(e);
expression.ifPresent(ex -> {
// Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
// to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
// the simplification has been made for the benefit of USERS.
final LiteralExpression le = (LiteralExpression) ex;
uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(le.getText()), listSelector));
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverter method wbFromDMN.
public static LiteralExpression wbFromDMN(final org.kie.dmn.model.v1_1.LiteralExpression dmn) {
if (dmn == null) {
return null;
}
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
String text = dmn.getText();
String expressionLanguage = dmn.getExpressionLanguage();
ImportedValues importedValues = ImportedValuesConverter.wbFromDMN(dmn.getImportedValues());
LiteralExpression result = new LiteralExpression(id, description, typeRef, text, importedValues, expressionLanguage);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression 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.LiteralExpression in project kie-wb-common by kiegroup.
the class ContextEditorDefinition method getModelClass.
@Override
public Optional<Context> getModelClass() {
// Add one ContextEntry for the User to start with
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
contextEntry.setVariable(new InformationItem());
context.getContextEntry().add(contextEntry);
// Add (default) "result" entry
final ContextEntry resultEntry = new ContextEntry();
resultEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(resultEntry);
return Optional.of(context);
}
Aggregations