Search in sources :

Example 6 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class BPMNProcessVariableDeleteHandler method isVariableBoundToNode.

private boolean isVariableBoundToNode(Node node, String propertyId) {
    Object content = node.getContent();
    if (content instanceof Definition) {
        Object nodeDefinition = ((Definition) content).getDefinition();
        Collection<String> variablesName = new ArrayList();
        if (nodeDefinition instanceof UserTask) {
            UserTask userTask = (UserTask) nodeDefinition;
            final String userTaskAssignmentsinfo = userTask.getExecutionSet().getAssignmentsinfo().getValue();
            variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
            variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
        }
        if ((nodeDefinition instanceof BusinessRuleTask)) {
            BusinessRuleTask businessRuleTaskTask = (BusinessRuleTask) nodeDefinition;
            final String businessRuleTaskAssignmentsinfo = businessRuleTaskTask.getDataIOSet().getAssignmentsinfo().getValue();
            variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
            variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
        }
        return variablesName.stream().filter(id -> propertyId.equals(id)).findAny().isPresent();
    }
    return false;
}
Also used : Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)

Example 7 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testIsAllowedWhenIsNotDecisionService.

@Test
public void testIsAllowedWhenIsNotDecisionService() {
    final Node node = mock(Node.class);
    final Definition content = mock(Definition.class);
    final Object def = mock(Object.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(def);
    doReturn(false).when(tested).superIsAllowed(canvasHandler, node);
    final boolean actual = tested.isAllowed(canvasHandler, node);
    assertFalse(actual);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 8 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testIsAllowed.

@Test
public void testIsAllowed() {
    final Node node = mock(Node.class);
    final Definition content = mock(Definition.class);
    final DecisionService decisionService = mock(DecisionService.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decisionService);
    final boolean actual = tested.isAllowed(canvasHandler, node);
    assertTrue(actual);
    verify(tested, never()).superIsAllowed(canvasHandler, node);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 9 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testAddEditBusinessKnowledgeModelAction.

@Test
public void testAddEditBusinessKnowledgeModelAction() {
    final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
    final Element element = mock(Element.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final BusinessKnowledgeModel bkm = mock(BusinessKnowledgeModel.class);
    when(element.asNode()).thenReturn(node);
    when(element.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(bkm);
    tested.addEditAction(element, actions);
    assertEquals(1, actions.size());
    assertTrue(DMNEditBusinessKnowledgeModelToolboxAction.class.isInstance(actions.get(0)));
}
Also used : ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) DeleteNodeToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.DeleteNodeToolboxAction) Element(org.kie.workbench.common.stunner.core.graph.Element) Node(org.kie.workbench.common.stunner.core.graph.Node) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) ArrayList(java.util.ArrayList) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Test(org.junit.Test)

Example 10 with Definition

use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.

the class DMNCommonActionsToolboxFactoryTest method testAddEditDecisionAction.

@Test
public void testAddEditDecisionAction() {
    final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
    final Element element = mock(Element.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final Decision decision = mock(Decision.class);
    when(element.asNode()).thenReturn(node);
    when(element.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(decision);
    tested.addEditAction(element, actions);
    assertEquals(1, actions.size());
    assertTrue(DMNEditDecisionToolboxAction.class.isInstance(actions.get(0)));
}
Also used : ToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.ToolboxAction) DeleteNodeToolboxAction(org.kie.workbench.common.stunner.core.client.components.toolbox.actions.DeleteNodeToolboxAction) Element(org.kie.workbench.common.stunner.core.graph.Element) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Aggregations

Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)111 Node (org.kie.workbench.common.stunner.core.graph.Node)61 Test (org.junit.Test)46 Element (org.kie.workbench.common.stunner.core.graph.Element)31 Edge (org.kie.workbench.common.stunner.core.graph.Edge)25 Graph (org.kie.workbench.common.stunner.core.graph.Graph)20 ArrayList (java.util.ArrayList)16 Optional (java.util.Optional)14 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)12 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)11 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 List (java.util.List)9 Before (org.junit.Before)9 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)9 HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)9 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)9 Stream (java.util.stream.Stream)8