Search in sources :

Example 71 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 JSITBinding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    final InformationItem parameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
    Expression expression = null;
    final JSITExpression jsiWrapped = dmn.getExpression();
    if (Objects.nonNull(jsiWrapped)) {
        final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
        expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
    }
    final Binding result = new Binding();
    if (Objects.nonNull(parameter)) {
        parameter.setParent(result);
    }
    result.setParameter(parameter);
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
    }
    result.setExpression(expression);
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 72 with Expression

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

the class BaseGrid method getAndSetInitialWidth.

protected double getAndSetInitialWidth(final int uiColumnIndex, final double initialWidth) {
    if (getExpression().get().isPresent()) {
        final Expression e = getExpression().get().get();
        final List<Double> componentWidths = e.getComponentWidths();
        if (Objects.isNull(componentWidths.get(uiColumnIndex))) {
            componentWidths.set(uiColumnIndex, initialWidth);
        }
        return componentWidths.get(uiColumnIndex);
    }
    throw new IllegalStateException("Unable to initialise column width if Expression has not been set.");
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression)

Example 73 with Expression

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

the class ExpressionEditorViewImplTest method testSetExpressionDoesUpdateExpressionTypeTextWhenHasExpressionIsNotEmpty.

@Test
public void testSetExpressionDoesUpdateExpressionTypeTextWhenHasExpressionIsNotEmpty() {
    final Expression expression = new LiteralExpression();
    final Optional<HasName> hasName = Optional.empty();
    when(hasExpression.getExpression()).thenReturn(expression);
    view.setExpression(NODE_UUID, hasExpression, hasName, false);
    verify(expressionType).setTextContent(eq(LITERAL_EXPRESSION_DEFINITION_NAME));
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Test(org.junit.Test)

Example 74 with Expression

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

the class ObserverBuilderControlTest method testUpdateExpressionFromDefinition.

@Test
public void testUpdateExpressionFromDefinition() {
    final Element element = mock(Element.class);
    final View elementContent = mock(View.class);
    final HasExpression newHasExpression = mock(HasExpression.class);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Expression expression = mock(Expression.class);
    when(element.getContent()).thenReturn(elementContent);
    when(elementContent.getDefinition()).thenReturn(newHasExpression);
    when(hasExpression.getExpression()).thenReturn(expression);
    observerBuilderControl.updateElementFromDefinition(element, hasExpression);
    verify(newHasExpression).setExpression(expression);
}
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) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Element(org.kie.workbench.common.stunner.core.graph.Element) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 75 with Expression

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

the class RelationEditorDefinitionTest method testEditor.

@Test
public void testEditor() {
    when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
    assertThat(oEditor).isPresent();
    final GridWidget editor = oEditor.get();
    assertThat(editor).isInstanceOf(RelationGrid.class);
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) 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) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

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