Search in sources :

Example 6 with Invocation

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

the class DeleteParameterBindingCommandTest method setup.

@Before
public void setup() {
    this.invocation = new Invocation();
    this.binding = makeBinding("p" + invocation.getBinding().size());
    this.invocation.getBinding().add(binding);
    this.uiModel = new BaseGridData(false);
    this.uiGridRow = new BaseGridRow();
    this.uiModel.appendRow(uiGridRow);
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 7 with Invocation

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

the class InvocationEditorDefinitionTest method testModelDefinition.

@Test
public void testModelDefinition() {
    final Optional<Invocation> oModel = definition.getModelClass();
    assertTrue(oModel.isPresent());
    final Invocation model = oModel.get();
    assertNotNull(model.getExpression());
    assertTrue(model.getExpression() instanceof LiteralExpression);
    assertEquals(1, model.getBinding().size());
    assertNotNull(model.getBinding().get(0).getParameter());
    assertEquals("p0", model.getBinding().get(0).getParameter().getName().getValue());
    assertNull(model.getBinding().get(0).getExpression());
    assertNotNull(model.getId());
}
Also used : Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Test(org.junit.Test)

Example 8 with Invocation

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

the class InvocationGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
    definition = new InvocationEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, expressionEditorDefinitionsSupplier);
    expression = definition.getModelClass();
    expression.ifPresent(invocation -> ((LiteralExpression) invocation.getExpression()).setText("invocation-expression"));
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
    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());
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    doReturn(graphContext).when(canvasHandler).getGraphExecutionContext();
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(anyString())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(anyString());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Optional(java.util.Optional) Element(org.kie.workbench.common.stunner.core.graph.Element) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) UndefinedExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.undefined.UndefinedExpressionEditorDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Before(org.junit.Before)

Example 9 with Invocation

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

the class InvocationEditorDefinition method getModelClass.

@Override
public Optional<Invocation> getModelClass() {
    final Invocation invocation = new Invocation();
    invocation.setExpression(new LiteralExpression());
    final InformationItem parameter = new InformationItem();
    parameter.setName(new Name("p0"));
    final Binding binding = new Binding();
    binding.setParameter(parameter);
    invocation.getBinding().add(binding);
    return Optional.of(invocation);
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Example 10 with Invocation

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

the class InvocationGrid method addParameterBinding.

void addParameterBinding(final int index) {
    expression.ifPresent(invocation -> {
        final Binding binding = new Binding();
        final InformationItem parameter = new InformationItem();
        parameter.setName(new Name("p" + invocation.getBinding().size()));
        binding.setParameter(parameter);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterBindingCommand(invocation, binding, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) AddParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.AddParameterBindingCommand) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Aggregations

Invocation (org.kie.workbench.common.dmn.api.definition.v1_1.Invocation)9 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)7 Before (org.junit.Before)5 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 Optional (java.util.Optional)4 Binding (org.kie.dmn.model.v1_1.Binding)3 Invocation (org.kie.dmn.model.v1_1.Invocation)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)3 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)3 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)3 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)3 Test (org.junit.Test)2 DMNInvocationEvaluator (org.kie.dmn.core.ast.DMNInvocationEvaluator)2 LiteralExpression (org.kie.dmn.model.v1_1.LiteralExpression)2 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)2 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)2 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)2 ArrayList (java.util.ArrayList)1