Search in sources :

Example 21 with Expression

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

the class UndefinedExpressionUIModelMapper method toDMNModel.

@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    cell.get().ifPresent(v -> {
        final ExpressionCellValue ecv = (ExpressionCellValue) v;
        ecv.getValue().ifPresent(beg -> hasExpression.setExpression((Expression) beg.getExpression().orElse(null)));
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 22 with Expression

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

the class DeleteRelationColumnCommand method newGraphCommand.

@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
    return new AbstractGraphCommand() {

        @Override
        protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
            final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
            relation.getRow().forEach(row -> row.getExpression().remove(iiIndex));
            relation.getColumn().remove(iiIndex);
            return GraphCommandResultBuilder.SUCCESS;
        }

        @Override
        public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
            final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
            relation.getColumn().add(iiIndex, oldInformationItem);
            IntStream.range(0, relation.getRow().size()).forEach(rowIndex -> {
                final Expression value = oldColumnData.get(rowIndex);
                relation.getRow().get(rowIndex).getExpression().add(iiIndex, value);
            });
            return GraphCommandResultBuilder.SUCCESS;
        }
    };
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation)

Example 23 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 setUp.

@Before
public void setUp() throws Exception {
    tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
    definition = new RelationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    expression = definition.getModelClass();
    doReturn(canvasHandler).when(dmnClientFullSession).getCanvasHandler();
    doReturn(dmnClientFullSession).when(sessionManager).getCurrentSession();
    doReturn(parentGridData).when(parentGridWidget).getModel();
    doReturn(Collections.singletonList(parentGridColumn)).when(parentGridData).getColumns();
    parent = spy(new GridCellTuple(0, 0, parentGridWidget));
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 24 with Expression

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

the class BaseExpressionGridCacheTest method getGrid.

@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parentCell, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, cacheResult, renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return mapper;
        }

        @Override
        protected void initialiseUiColumns() {
            model.appendColumn(uiColumn);
        }

        @Override
        protected void initialiseUiModel() {
            model.appendRow(uiRow);
        }

        @Override
        protected boolean isHeaderHidden() {
            return false;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)

Example 25 with Expression

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

the class BaseExpressionGridGeneralTest method getGrid.

@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parentCell, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return mapper;
        }

        @Override
        protected void initialiseUiColumns() {
        // Nothing for this test
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return false;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

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