Search in sources :

Example 6 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest 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) 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 : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) 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) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 7 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallXorGateway.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallXorGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_XORGATEWAY);
    assertDiagram(diagram, 7);
    assertEquals(diagram.getMetadata().getTitle(), "XORGateway");
    Graph graph = diagram.getGraph();
    Node<? extends Definition, ?> gatewayNode = graph.getNode("_877EA035-1A14-42E9-8CAA-43E9BF908C70");
    ExclusiveGateway xorGateway = (ExclusiveGateway) gatewayNode.getContent().getDefinition();
    assertEquals("AgeSplit", xorGateway.getGeneral().getName().getValue());
    assertEquals("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD", xorGateway.getExecutionSet().getDefaultRoute().getValue());
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    List<Edge> outEdges = (List<Edge>) gatewayNode.getOutEdges();
    if (outEdges != null) {
        for (Edge edge : outEdges) {
            if ("_C72E00C3-70DC-4BC9-A08E-761B4263A239".equals(edge.getUUID())) {
                sequenceFlow1 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            } else if ("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD".equals(edge.getUUID())) {
                sequenceFlow2 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertEquals("10 and over", sequenceFlow1.getGeneral().getName().getValue());
    assertNotNull(sequenceFlow2);
    assertEquals("under 10", sequenceFlow2.getGeneral().getName().getValue());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 8 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class ExclusiveGatewayTest method testExclusiveDatabasedGatewayNameEmpty.

@Test
public void testExclusiveDatabasedGatewayNameEmpty() {
    ExclusiveGateway exclusiveGateway = new ExclusiveGateway.ExclusiveGatewayBuilder().build();
    exclusiveGateway.getGeneral().setName(new Name(""));
    Set<ConstraintViolation<ExclusiveGateway>> violations = this.validator.validate(exclusiveGateway);
    assertTrue(violations.isEmpty());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) ConstraintViolation(javax.validation.ConstraintViolation) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) Test(org.junit.Test)

Example 9 with ExclusiveGateway

use of org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway in project kie-wb-common by kiegroup.

the class GatewayConverter method exclusive.

private PropertyWriter exclusive(Node<View<ExclusiveGateway>, ?> n) {
    org.eclipse.bpmn2.ExclusiveGateway gateway = bpmn2.createExclusiveGateway();
    GatewayPropertyWriter p = propertyWriterFactory.of(gateway);
    gateway.setId(n.getUUID());
    ExclusiveGateway definition = n.getContent().getDefinition();
    p.setGatewayDirection(n);
    BPMNGeneralSet general = definition.getGeneral();
    p.setName(general.getName().getValue());
    p.setDocumentation(general.getDocumentation().getValue());
    GatewayExecutionSet executionSet = definition.getExecutionSet();
    p.setDefaultRoute(executionSet.getDefaultRoute().getValue());
    p.setBounds(n.getContent().getBounds());
    return p;
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) GatewayPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.GatewayPropertyWriter) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) GatewayExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.gateway.GatewayExecutionSet)

Aggregations

ExclusiveGateway (org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway)9 Test (org.junit.Test)6 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)4 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)4 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)4 Graph (org.kie.workbench.common.stunner.core.graph.Graph)4 ArrayList (java.util.ArrayList)3 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 List (java.util.List)2 ConstraintViolation (javax.validation.ConstraintViolation)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 GatewayExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.gateway.GatewayExecutionSet)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 LinkedList (java.util.LinkedList)1