Search in sources :

Example 56 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.

the class RelationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    final Optional<Relation> expression = definition.getModelClass();
    final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, expression, hasName, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(RelationGrid.class);
}
Also used : Relation(org.kie.workbench.common.dmn.api.definition.v1_1.Relation) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Test(org.junit.Test)

Example 57 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.

the class RelationGridTest method testInitialiseUiColumns.

@Test
public void testInitialiseUiColumns() throws Exception {
    final String columnHeader = "first column";
    relation.getColumn().add(new InformationItem() {

        {
            getName().setValue(columnHeader);
        }
    });
    expression = Optional.of(relation);
    setupGrid(0);
    assertEquals(2, grid.getModel().getColumns().size());
    assertTrue(grid.getModel().getColumns().get(0) instanceof RowNumberColumn);
    assertEquals(columnHeader, grid.getModel().getColumns().get(1).getHeaderMetaData().get(0).getTitle());
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 58 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.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 59 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.Expression in project kie-wb-common by kiegroup.

the class InvocationPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.Invocation dmnFromWB(final Invocation wb) {
    if (wb == null) {
        return null;
    }
    org.kie.dmn.model.v1_1.Invocation result = new org.kie.dmn.model.v1_1.Invocation();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    org.kie.dmn.model.v1_1.Expression convertedExpression = ExpressionPropertyConverter.dmnFromWB(wb.getExpression());
    result.setExpression(convertedExpression);
    for (Binding b : wb.getBinding()) {
        org.kie.dmn.model.v1_1.Binding bConverted = BindingPropertyConverter.dmnFromWB(b);
        result.getBinding().add(bConverted);
    }
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation)

Example 60 with Expression

use of org.kie.workbench.common.dmn.api.definition.v1_1.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)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)19 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)15 Expression (org.apache.commons.jexl2.Expression)14 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)13 JexlContext (org.apache.commons.jexl2.JexlContext)12 Test (org.junit.Test)12 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)11 HasName (org.kie.workbench.common.dmn.api.definition.HasName)10 JexlEngine (org.apache.commons.jexl2.JexlEngine)9 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)9 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)9 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)9 MapContext (org.apache.commons.jexl2.MapContext)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 Optional (java.util.Optional)6 Before (org.junit.Before)6 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6