Search in sources :

Example 1 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression 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 2 with HasExpression

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

Example 3 with HasExpression

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

the class ExpressionContainerUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    uiModel = new BaseGridData();
    uiModel.appendRow(new DMNGridRow());
    uiModel.appendColumn(uiExpressionColumn);
    doReturn(0).when(uiExpressionColumn).getIndex();
    doReturn(MINIMUM_COLUMN_WIDTH).when(uiExpressionColumn).getMinimumWidth();
    parent = new GridCellTuple(0, 0, expressionContainerGrid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), expressionEditorDefinitionsSupplier, listSelector);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 4 with HasExpression

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

the class ListPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
    final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (HasExpression hasExpression : wb.getExpression()) {
        final Expression e = hasExpression.getExpression();
        final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer);
        if (Objects.nonNull(eConverted)) {
            eConverted.setParent(result);
        }
        result.getExpression().add(eConverted);
    }
    return result;
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression)

Example 5 with HasExpression

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

the class ListPropertyConverter method wbFromDMN.

public static List wbFromDMN(final org.kie.dmn.model.api.List dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final java.util.List<HasExpression> expression = new ArrayList<>();
    final List result = new List(id, description, typeRef, expression);
    for (org.kie.dmn.model.api.Expression e : dmn.getExpression()) {
        final Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e, hasComponentWidthsConsumer);
        final HasExpression hasExpression = HasExpression.wrap(result, eConverted);
        expression.add(hasExpression);
    }
    for (HasExpression hasExpression : expression) {
        final Expression e = hasExpression.getExpression();
        if (Objects.nonNull(e)) {
            e.setParent(result);
        }
    }
    return result;
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) List(org.kie.workbench.common.dmn.api.definition.model.List) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Aggregations

HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)78 Test (org.junit.Test)41 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)30 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 HasName (org.kie.workbench.common.dmn.api.definition.HasName)18 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)15 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)15 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)15 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)15 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)13 Optional (java.util.Optional)12 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)10 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)10 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)8 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)8 ArrayList (java.util.ArrayList)7 EditExpressionEvent (org.kie.workbench.common.dmn.client.events.EditExpressionEvent)6 Before (org.junit.Before)5