Search in sources :

Example 36 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class ContextUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(context -> {
        final boolean isLastRow = isLastRow(rowIndex);
        final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
        switch(section) {
            case ROW_INDEX:
                if (!isLastRow) {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                } else {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
                }
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case NAME:
                if (!isLastRow) {
                    final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemNameCell(() -> variable, listSelector));
                } else {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>(DEFAULT_ROW_CAPTION)));
                }
                break;
            case EXPRESSION:
                final ContextEntry ce = context.getContextEntry().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(ce.getExpression());
                final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
                expressionEditorDefinition.ifPresent(ed -> {
                    final Optional<BaseExpressionGrid> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), ce, expression, Optional.ofNullable(ce.getVariable()), nesting + 1);
                    if (!isLastRow) {
                        uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
                    } else {
                        uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new ExpressionCellValue(editor)));
                    }
                });
        }
    });
}
Also used : ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 37 with Expression

use of org.eclipse.bpmn2.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().ifPresent(e -> invocation.getBinding().get(rowIndex).setExpression((Expression) e));
                    });
                });
        }
    });
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.v1_1.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 38 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class InvocationPropertyConverter method wbFromDMN.

public static Invocation wbFromDMN(final org.kie.dmn.model.v1_1.Invocation dmn) {
    if (dmn == null) {
        return null;
    }
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    Invocation result = new Invocation();
    result.setId(id);
    result.setDescription(description);
    result.setTypeRef(typeRef);
    Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression());
    result.setExpression(convertedExpression);
    for (org.kie.dmn.model.v1_1.Binding b : dmn.getBinding()) {
        Binding bConverted = BindingPropertyConverter.wbFromDMN(b);
        result.getBinding().add(bConverted);
    }
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 39 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class ListPropertyConverter method wbFromDMN.

public static List wbFromDMN(final org.kie.dmn.model.v1_1.List dmn) {
    Id id = new Id(dmn.getId());
    Description description = new Description(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    java.util.List<Expression> expression = new ArrayList<>();
    for (org.kie.dmn.model.v1_1.Expression e : dmn.getExpression()) {
        Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e);
        expression.add(eConverted);
    }
    List result = new List(id, description, typeRef, expression);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 40 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class ListPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.List dmnFromWB(final List wb) {
    org.kie.dmn.model.v1_1.List result = new org.kie.dmn.model.v1_1.List();
    result.setId(wb.getId().getValue());
    result.setDescription(wb.getDescription().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (Expression e : wb.getExpression()) {
        org.kie.dmn.model.v1_1.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e);
        result.getExpression().add(eConverted);
    }
    return result;
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) List(org.kie.workbench.common.dmn.api.definition.v1_1.List) ArrayList(java.util.ArrayList)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)19 Expression (org.apache.commons.jexl2.Expression)14 JexlContext (org.apache.commons.jexl2.JexlContext)12 JexlEngine (org.apache.commons.jexl2.JexlEngine)9 MapContext (org.apache.commons.jexl2.MapContext)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)7 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)6 ArrayList (java.util.ArrayList)5 Expression (org.kie.dmn.model.v1_1.Expression)5 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)5 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)4 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)4 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)3 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)3 HashMap (java.util.HashMap)2