Search in sources :

Example 81 with Edge

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

the class BPMNDiagramMarshallerTest method testUnmarshallSequenceFlow.

@Test
public void testUnmarshallSequenceFlow() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof ExclusiveGateway) {
                List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
                for (Edge edge : outEdges) {
                    SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) ((EdgeImpl) edge).getContent()).getDefinition();
                    if ("route1".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow1 = flow;
                    }
                    if ("route2".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow2 = flow;
                    }
                }
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertNotNull(sequenceFlow1.getExecutionSet());
    assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow1.getGeneral());
    assertNotNull(sequenceFlow1.getGeneral().getName());
    assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
    assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
    assertNotNull(sequenceFlow2);
    assertNotNull(sequenceFlow2.getExecutionSet());
    assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow2.getGeneral());
    assertNotNull(sequenceFlow2.getGeneral().getName());
    assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
    assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 82 with Edge

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

the class BPMNDiagramMarshallerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    // Work Items.
    workItemDefinitionMockRegistry = new WorkItemDefinitionMockRegistry();
    // Graph utils.
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.registry()).thenReturn(adapterRegistry);
    definitionUtils = new DefinitionUtils(definitionManager, applicationFactoryManager);
    testScopeModelFactory = new BPMNTestScopeModelFactory(new BPMNDefinitionSet.BPMNDefinitionSetBuilder().build(), workItemDefinitionMockRegistry);
    // Definition manager.
    final BackendDefinitionAdapter definitionAdapter = new BackendDefinitionAdapter(definitionUtils);
    final BackendDefinitionSetAdapter definitionSetAdapter = new BackendDefinitionSetAdapter(definitionAdapter);
    final BackendPropertySetAdapter propertySetAdapter = new BackendPropertySetAdapter();
    final BackendPropertyAdapter propertyAdapter = new BackendPropertyAdapter();
    when(adapterManager.forDefinitionSet()).thenReturn(definitionSetAdapter);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
    when(adapterManager.forPropertySet()).thenReturn(propertySetAdapter);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(adapterRegistry.getDefinitionSetAdapter(any(Class.class))).thenReturn(definitionSetAdapter);
    when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(definitionAdapter);
    when(adapterRegistry.getPropertySetAdapter(any(Class.class))).thenReturn(propertySetAdapter);
    when(adapterRegistry.getPropertyAdapter(any(Class.class))).thenReturn(propertyAdapter);
    commandManager = new GraphCommandManagerImpl(null, null, null);
    commandFactory = new GraphCommandFactory();
    connectionEdgeFactory = new EdgeFactoryImpl(definitionManager);
    viewNodeFactory = new NodeFactoryImpl(definitionUtils);
    bpmnGraphFactory = new GraphFactoryImpl(definitionManager);
    doAnswer(invocationOnMock -> {
        String id = (String) invocationOnMock.getArguments()[0];
        return testScopeModelFactory.build(id);
    }).when(applicationFactoryManager).newDefinition(anyString());
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        String id = (String) invocationOnMock.getArguments()[1];
        if (BPMNDefinitionSet.class.getName().equals(id)) {
            Graph graph = (Graph) bpmnGraphFactory.build(uuid, BPMN_DEF_SET_ID);
            return graph;
        }
        Object model = testScopeModelFactory.accepts(id) ? testScopeModelFactory.build(id) : null;
        if (null != model) {
            Class<? extends ElementFactory> element = BackendDefinitionAdapter.getGraphFactory(model.getClass());
            if (element.isAssignableFrom(NodeFactory.class)) {
                Node node = viewNodeFactory.build(uuid, model);
                return node;
            } else if (element.isAssignableFrom(EdgeFactory.class)) {
                Edge edge = connectionEdgeFactory.build(uuid, model);
                return edge;
            }
        }
        return null;
    }).when(applicationFactoryManager).newElement(anyString(), anyString());
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        Class type = (Class) invocationOnMock.getArguments()[1];
        String id = BindableAdapterUtils.getGenericClassName(type);
        if (BPMNDefinitionSet.class.equals(type)) {
            Graph graph = (Graph) bpmnGraphFactory.build(uuid, BPMN_DEF_SET_ID);
            return graph;
        }
        Object model = testScopeModelFactory.accepts(id) ? testScopeModelFactory.build(id) : null;
        if (null != model) {
            Class<? extends ElementFactory> element = BackendDefinitionAdapter.getGraphFactory(model.getClass());
            if (element.isAssignableFrom(NodeFactory.class)) {
                Node node = viewNodeFactory.build(uuid, model);
                return node;
            } else if (element.isAssignableFrom(EdgeFactory.class)) {
                Edge edge = connectionEdgeFactory.build(uuid, model);
                return edge;
            }
        }
        return null;
    }).when(applicationFactoryManager).newElement(anyString(), any(Class.class));
    doAnswer(invocationOnMock -> {
        String uuid = (String) invocationOnMock.getArguments()[0];
        String defSetId = (String) invocationOnMock.getArguments()[1];
        final Graph graph = (Graph) applicationFactoryManager.newElement(uuid, defSetId);
        final DiagramImpl result = new DiagramImpl(uuid, new MetadataImpl.MetadataImplBuilder(defSetId).build());
        result.setGraph(graph);
        return result;
    }).when(applicationFactoryManager).newDiagram(anyString(), anyString(), any(Metadata.class));
    // Bpmn 2 oryx stuff.
    oryxIdMappings = new Bpmn2OryxIdMappings(definitionManager, () -> workItemDefinitionMockRegistry);
    StringTypeSerializer stringTypeSerializer = new StringTypeSerializer();
    BooleanTypeSerializer booleanTypeSerializer = new BooleanTypeSerializer();
    ColorTypeSerializer colorTypeSerializer = new ColorTypeSerializer();
    DoubleTypeSerializer doubleTypeSerializer = new DoubleTypeSerializer();
    IntegerTypeSerializer integerTypeSerializer = new IntegerTypeSerializer();
    EnumTypeSerializer enumTypeSerializer = new EnumTypeSerializer(definitionUtils);
    AssignmentsTypeSerializer assignmentsTypeSerializer = new AssignmentsTypeSerializer();
    VariablesTypeSerializer variablesTypeSerializer = new VariablesTypeSerializer();
    TimerSettingsTypeSerializer timerSettingsTypeSerializer = new TimerSettingsTypeSerializer();
    ScriptTypeTypeSerializer scriptTypeTypeSerializer = new ScriptTypeTypeSerializer();
    ScriptTypeListTypeSerializer scriptTypeListTypeSerializer = new ScriptTypeListTypeSerializer();
    TaskTypeSerializer taskTypeSerializer = new TaskTypeSerializer(definitionUtils, enumTypeSerializer);
    List<Bpmn2OryxPropertySerializer<?>> propertySerializers = new LinkedList<>();
    propertySerializers.add(stringTypeSerializer);
    propertySerializers.add(booleanTypeSerializer);
    propertySerializers.add(colorTypeSerializer);
    propertySerializers.add(doubleTypeSerializer);
    propertySerializers.add(integerTypeSerializer);
    propertySerializers.add(enumTypeSerializer);
    propertySerializers.add(assignmentsTypeSerializer);
    propertySerializers.add(variablesTypeSerializer);
    propertySerializers.add(timerSettingsTypeSerializer);
    propertySerializers.add(scriptTypeTypeSerializer);
    propertySerializers.add(scriptTypeListTypeSerializer);
    propertySerializers.add(taskTypeSerializer);
    oryxPropertyManager = new Bpmn2OryxPropertyManager(propertySerializers);
    oryxManager = new Bpmn2OryxManager(oryxIdMappings, oryxPropertyManager);
    oryxManager.init();
    // Marshalling factories.
    objectBuilderFactory = new BPMNGraphObjectBuilderFactory(definitionManager, oryxManager, () -> workItemDefinitionMockRegistry);
    taskMorphDefinition = new TaskTypeMorphDefinition();
    Collection<MorphDefinition> morphDefinitions = new ArrayList<MorphDefinition>() {

        {
            add(taskMorphDefinition);
        }
    };
    BackendBindableMorphAdapter<Object> morphAdapter = new BackendBindableMorphAdapter(definitionUtils, applicationFactoryManager, cloneManager, morphDefinitions);
    when(adapterRegistry.getMorphAdapter(eq(UserTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(NoneTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(ScriptTask.class))).thenReturn(morphAdapter);
    when(adapterRegistry.getMorphAdapter(eq(BusinessRuleTask.class))).thenReturn(morphAdapter);
    GraphIndexBuilder<?> indexBuilder = new MapIndexBuilder();
    when(rulesManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(new DefaultRuleViolations());
    // The work item definition registry.
    WorkItemDefinitionBackendRegistry widRegistry = mock(WorkItemDefinitionBackendRegistry.class);
    when(widRegistry.getRegistry()).thenReturn(workItemDefinitionMockRegistry);
    when(widRegistry.items()).thenReturn(workItemDefinitionMockRegistry.items());
    when(widRegistry.load(any(Metadata.class))).thenReturn(widRegistry);
    doAnswer(invocationOnMock -> workItemDefinitionMockRegistry.get((String) invocationOnMock.getArguments()[0])).when(widRegistry).get(anyString());
    // The tested BPMN marshaller.
    tested = new BPMNDiagramMarshaller(new XMLEncoderDiagramMetadataMarshaller(), objectBuilderFactory, definitionManager, indexBuilder, oryxManager, applicationFactoryManager, rulesManager, commandManager, commandFactory, widRegistry);
}
Also used : BackendPropertyAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertyAdapter) NodeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.NodeFactoryImpl) BackendDefinitionAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionAdapter) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) GraphFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.GraphFactoryImpl) Matchers.anyString(org.mockito.Matchers.anyString) BackendBindableMorphAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.bind.BackendBindableMorphAdapter) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) BackendPropertySetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendPropertySetAdapter) Bpmn2OryxPropertyManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertyManager) RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) MorphDefinition(org.kie.workbench.common.stunner.core.definition.morph.MorphDefinition) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) LinkedList(java.util.LinkedList) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) Bpmn2OryxPropertySerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.Bpmn2OryxPropertySerializer) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) BPMNGraphObjectBuilderFactory(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.builder.BPMNGraphObjectBuilderFactory) EdgeFactoryImpl(org.kie.workbench.common.stunner.core.factory.impl.EdgeFactoryImpl) EdgeFactory(org.kie.workbench.common.stunner.core.factory.graph.EdgeFactory) TaskTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TaskTypeSerializer) Bpmn2OryxManager(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxManager) DoubleTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.DoubleTypeSerializer) ColorTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ColorTypeSerializer) MapIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) WorkItemDefinitionBackendRegistry(org.kie.workbench.common.stunner.bpmn.backend.workitem.WorkItemDefinitionBackendRegistry) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) Bpmn2OryxIdMappings(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.Bpmn2OryxIdMappings) ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) TimerSettingsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.TimerSettingsTypeSerializer) EnumTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.EnumTypeSerializer) BackendDefinitionSetAdapter(org.kie.workbench.common.stunner.core.backend.definition.adapter.reflect.BackendDefinitionSetAdapter) StringTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.StringTypeSerializer) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) GraphCommandManagerImpl(org.kie.workbench.common.stunner.core.graph.command.GraphCommandManagerImpl) IntegerTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.IntegerTypeSerializer) AssignmentsTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.AssignmentsTypeSerializer) VariablesTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.VariablesTypeSerializer) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) BPMNDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDiagramMarshaller) BooleanTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.BooleanTypeSerializer) RuleEvaluationContext(org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext) DefaultRuleViolations(org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Before(org.junit.Before)

Example 83 with Edge

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

the class BPMNDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
    assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
    assertDiagram(diagram, 6);
    // Assert than the intermediate event is connected using a view connector,
    // so not boundary to the task ( not docked ).
    Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
    List<Edge> inEdges = event.getInEdges();
    boolean foundViewConnector = false;
    for (Edge e : inEdges) {
        if (e.getContent() instanceof ViewConnector) {
            foundViewConnector = true;
        }
    }
    assertTrue(foundViewConnector);
    // Assert absolute position as the node is not docked.
    Bounds bounds = ((View) event.getContent()).getBounds();
    Bounds.Bound ul = bounds.getUpperLeft();
    Bounds.Bound lr = bounds.getLowerRight();
    assertEquals(305, ul.getX(), 0);
    assertEquals(300, ul.getY(), 0);
    assertEquals(335, lr.getX(), 0);
    assertEquals(330, lr.getY(), 0);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 84 with Edge

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

the class AbstractNodeBuilder method afterNodeBuild.

@SuppressWarnings("unchecked")
protected void afterNodeBuild(final BuilderContext context, final T node) {
    // Outgoing connections.
    if (outgoingResourceIds != null && !outgoingResourceIds.isEmpty()) {
        for (String outgoingNodeId : outgoingResourceIds) {
            GraphObjectBuilder<?, ?> outgoingBuilder = getBuilder(context, outgoingNodeId);
            if (outgoingBuilder == null) {
                throw new RuntimeException("No outgoing edge builder for " + outgoingNodeId);
            }
            final List<Command<GraphCommandExecutionContext, RuleViolation>> commands = new LinkedList<>();
            // If outgoing element it's a node means that it's docked.
            if (outgoingBuilder instanceof AbstractNodeBuilder) {
                // Command - Create the docked node.
                Node docked = (Node) outgoingBuilder.build(context);
                commands.add(context.getCommandFactory().addDockedNode(node, docked));
                // Obtain docked position and use those for the docked node.
                final List<Double[]> dockers = ((AbstractNodeBuilder) outgoingBuilder).dockers;
                if (!dockers.isEmpty()) {
                    // TODO: Use not only first docker coordinates?
                    Double[] dCoords = dockers.get(0);
                    double x = dCoords[0];
                    double y = dCoords[1];
                    commands.add(context.getCommandFactory().updatePosition(docked, new Point2D(x, y)));
                }
            } else {
                // Create the outgoing edge.
                AbstractEdgeBuilder edgeBuilder = (AbstractEdgeBuilder) outgoingBuilder;
                Edge edge = (Edge) edgeBuilder.build(context);
                if (edge != null) {
                    // Command - Execute the graph command to set the node as the edge connection's source..
                    Double[] sourceDocker = null;
                    final List<Double[]> dockers = ((AbstractEdgeBuilder) outgoingBuilder).dockers;
                    if (dockers != null && dockers.size() > 1) {
                        sourceDocker = dockers.get(0);
                    }
                    Connection sourceConnection = null;
                    if (null != sourceDocker) {
                        sourceConnection = MagnetConnection.Builder.at(sourceDocker[0], sourceDocker[1]).setAuto(edgeBuilder.isSourceAutoConnection());
                    }
                    commands.add(context.getCommandFactory().setSourceNode(node, edge, sourceConnection));
                }
            }
            if (!commands.isEmpty()) {
                for (Command<GraphCommandExecutionContext, RuleViolation> command : commands) {
                    doExecuteCommand(context, command);
                }
            }
        }
    }
    // Children connections.
    if (childNodeIds != null && !childNodeIds.isEmpty()) {
        for (String childNodeId : childNodeIds) {
            GraphObjectBuilder<?, ?> childNodeBuilder = getBuilder(context, childNodeId);
            if (childNodeBuilder == null) {
                throw new RuntimeException("No child node builder for " + childNodeId);
            }
            Command<GraphCommandExecutionContext, RuleViolation> command = null;
            if (childNodeBuilder instanceof NodeObjectBuilder) {
                // Command - Create the child node and the parent-child relationship.
                Node childNode = (Node) childNodeBuilder.build(context);
                command = context.getCommandFactory().addChildNode(node, childNode);
            }
            if (null != command) {
                doExecuteCommand(context, command);
            }
        }
    }
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) LinkedList(java.util.LinkedList) Command(org.kie.workbench.common.stunner.core.command.Command) AddNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 85 with Edge

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

the class BPMNGraphGenerator method createGraph.

public Graph<DefinitionSet, Node> createGraph() {
    Graph<DefinitionSet, Node> graph = (Graph<DefinitionSet, Node>) factoryManager.newElement(UUID.uuid(), diagramDefinitionSetClass);
    // TODO: Where are the BPMN diagram bounds in the Oryx json structure? Exist?
    if (null == graph.getContent().getBounds()) {
        graph.getContent().setBounds(new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(BPMNGraphFactory.GRAPH_DEFAULT_WIDTH, BPMNGraphFactory.GRAPH_DEFAULT_HEIGHT)));
    }
    builderContext.init(graph).execute(builderContext.getCommandFactory().clearGraph());
    NodeObjectBuilder diagramBuilder = getDiagramBuilder(builderContext);
    if (diagramBuilder == null) {
        throw new RuntimeException("No diagrams found!");
    }
    Node<View<BPMNDefinition>, Edge> diagramNode = (Node<View<BPMNDefinition>, Edge>) diagramBuilder.build(builderContext);
    graph.addNode(diagramNode);
    logBuilders();
    return graph;
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) TreeNode(com.fasterxml.jackson.core.TreeNode) Node(org.kie.workbench.common.stunner.core.graph.Node) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Aggregations

Edge (org.kie.workbench.common.stunner.core.graph.Edge)154 View (org.kie.workbench.common.stunner.core.graph.content.view.View)101 Node (org.kie.workbench.common.stunner.core.graph.Node)84 Test (org.junit.Test)45 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)30 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)30 Graph (org.kie.workbench.common.stunner.core.graph.Graph)28 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)25 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)25 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)19 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)19 List (java.util.List)17 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)16 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)16 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)13 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 ArrayList (java.util.ArrayList)11