Search in sources :

Example 51 with Expression

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));
                    });
                });
        }
    });
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 52 with Expression

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;
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 53 with Expression

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));
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 54 with Expression

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;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 55 with Expression

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));
        }
    }
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)75 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)41 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)29 Test (org.junit.Test)27 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)26 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)26 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)25 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)14 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)11 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 ArrayList (java.util.ArrayList)8 Context (org.kie.workbench.common.dmn.api.definition.model.Context)8 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)8 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)7 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)7 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7