use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class InvocationUIModelMapper method toDMNModel.
@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
dmnModel.get().ifPresent(invocation -> {
switch(columnIndex) {
case ROW_NUMBER_COLUMN_INDEX:
break;
case BINDING_PARAMETER_COLUMN_INDEX:
invocation.getBinding().get(rowIndex).getParameter().getName().setValue(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
break;
case BINDING_EXPRESSION_COLUMN_INDEX:
cell.get().ifPresent(v -> {
final ExpressionCellValue ecv = (ExpressionCellValue) v;
ecv.getValue().ifPresent(beg -> {
beg.getExpression().get().ifPresent(e -> invocation.getBinding().get(rowIndex).setExpression((Expression) e));
});
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ExpressionContainerGrid method getExistingEditor.
Optional<BaseExpressionGrid> getExistingEditor() {
Optional<BaseExpressionGrid> beg = Optional.empty();
final GridCell<?> cell = model.getRow(0).getCells().get(0);
if (cell != null) {
final GridCellValue<?> value = cell.getValue();
if (value instanceof ExpressionCellValue) {
final ExpressionCellValue ecv = (ExpressionCellValue) value;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
if (editor.isPresent()) {
beg = Optional.of(editor.get());
}
}
}
return beg;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
final String uuid = nodeUUID.get();
final GridData uiModel = this.uiModel.get();
final Optional<Expression> expression = dmnModel.get();
final Optional<HasName> hasName = this.hasName.get();
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final HasExpression hasExpression = this.hasExpression.get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(definition -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid);
if (!editor.isPresent()) {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0);
expressionGridCache.get().putExpressionGrid(uuid, oEditor);
editor = oEditor;
}
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor;
uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector));
});
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class BindingPropertyConverter method wbFromDMN.
public static Binding wbFromDMN(final org.kie.dmn.model.api.Binding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (dmn == null) {
return null;
}
final InformationItem convertedParameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
final Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
final Binding result = new Binding();
if (convertedParameter != null) {
convertedParameter.setParent(result);
}
result.setParameter(convertedParameter);
if (convertedExpression != null) {
convertedExpression.setParent(result);
}
result.setExpression(convertedExpression);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method convertContextEntryExpression.
private static void convertContextEntryExpression(final ContextEntry contextEntry) {
final Expression expression = contextEntry.getExpression();
if (expression instanceof LiteralExpression) {
final LiteralExpression le = (LiteralExpression) expression;
final String variableName = contextEntry.getVariable().getName().getValue();
if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, variableName)) {
contextEntry.setExpression(convertLiteralExpressionToPMMLDocument(le));
} else if (Objects.equals(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL, variableName)) {
contextEntry.setExpression(convertLiteralExpressionToPMMLDocumentModel(le));
}
}
}
Aggregations