Ejemplo n.º 1
0
        protected internal virtual void assertEventShapeProperties(string id)
        {
            BpmnShape bpmnShapeEvent = findBpmnShape(id);

            assertNotNull(bpmnShapeEvent);
            assertEventSize(bpmnShapeEvent);
        }
Ejemplo n.º 2
0
        protected internal virtual void assertGatewayShapeProperties(string id)
        {
            BpmnShape bpmnShapeGateway = findBpmnShape(id);

            assertNotNull(bpmnShapeGateway);
            assertGatewaySize(bpmnShapeGateway);
        }
Ejemplo n.º 3
0
        public void BPMNShape_Populate()
        {
            BpmnShape shape = new BpmnShape
            {
                BPMNLabel                    = new BpmnLabel(),
                BpmnElement                  = XmlQualifiedName.Empty,
                IsHorizontal                 = false,
                IsHorizontalSpecified        = false,
                IsExpanded                   = false,
                IsExpandedSpecified          = false,
                IsMarkerVisible              = false,
                IsMarkerVisibleSpecified     = false,
                IsMessageVisible             = false,
                IsMessageVisibleSpecified    = false,
                ParticipantBandKind          = ParticipantBandKind.bottom_initiating,
                ParticipantBandKindSpecified = false,
                ChoreographyActivityShape    = XmlQualifiedName.Empty
            };

            Assert.NotNull(shape.BPMNLabel);
            Assert.NotNull(shape.BpmnElement);
            Assert.False(shape.IsHorizontal);
            Assert.False(shape.IsHorizontalSpecified);
            Assert.False(shape.IsExpanded);
            Assert.False(shape.IsExpandedSpecified);
            Assert.False(shape.IsMarkerVisible);
            Assert.False(shape.IsMarkerVisibleSpecified);
            Assert.False(shape.IsMessageVisible);
            Assert.False(shape.IsMessageVisibleSpecified);
            Assert.Equal(ParticipantBandKind.bottom_initiating, shape.ParticipantBandKind);
            Assert.False(shape.ParticipantBandKindSpecified);
            Assert.NotNull(shape.ChoreographyActivityShape);
        }
Ejemplo n.º 4
0
        protected internal virtual void assertTaskShapeProperties(string id)
        {
            BpmnShape bpmnShapeTask = findBpmnShape(id);

            assertNotNull(bpmnShapeTask);
            assertActivitySize(bpmnShapeTask);
        }
Ejemplo n.º 5
0
        public virtual StartEventBuilder startEvent(string id)
        {
            StartEvent start     = createChild(typeof(StartEvent), id);
            BpmnShape  bpmnShape = createBpmnShape(start);

            Coordinates = bpmnShape;
            return(start.builder());
        }
Ejemplo n.º 6
0
        protected internal virtual void resizeSubProcess(BpmnShape innerShape)
        {
            BaseElement innerElement     = innerShape.BpmnElement;
            Bounds      innerShapeBounds = innerShape.Bounds;

            ModelElementInstance parent = innerElement.ParentElement;

            while (parent is SubProcess)
            {
                BpmnShape subProcessShape = findBpmnShape((SubProcess)parent);

                if (subProcessShape != null)
                {
                    Bounds subProcessBounds = subProcessShape.Bounds;
                    double innerX           = innerShapeBounds.getX().Value;
                    double innerWidth       = innerShapeBounds.getWidth().Value;
                    double innerY           = innerShapeBounds.getY().Value;
                    double innerHeight      = innerShapeBounds.getHeight().Value;

                    double subProcessY      = subProcessBounds.getY().Value;
                    double subProcessHeight = subProcessBounds.getHeight().Value;
                    double subProcessX      = subProcessBounds.getX().Value;
                    double subProcessWidth  = subProcessBounds.getWidth().Value;

                    double tmpWidth  = innerX + innerWidth + SPACE;
                    double tmpHeight = innerY + innerHeight + SPACE;

                    if (innerY == subProcessY)
                    {
                        subProcessBounds.setY(subProcessY - SPACE);
                        subProcessBounds.setHeight(subProcessHeight + SPACE);
                    }

                    if (tmpWidth >= subProcessX + subProcessWidth)
                    {
                        double newWidth = tmpWidth - subProcessX;
                        subProcessBounds.setWidth(newWidth);
                    }

                    if (tmpHeight >= subProcessY + subProcessHeight)
                    {
                        double newHeight = tmpHeight - subProcessY;
                        subProcessBounds.setHeight(newHeight);
                    }

                    innerElement     = (SubProcess)parent;
                    innerShapeBounds = subProcessBounds;
                    parent           = innerElement.ParentElement;
                }
                else
                {
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        public virtual BoundaryEventBuilder boundaryEvent(string id)
        {
            BoundaryEvent boundaryEvent = createSibling(typeof(BoundaryEvent), id);

            boundaryEvent.AttachedTo = element;

            BpmnShape boundaryEventBpmnShape = createBpmnShape(boundaryEvent);

            BoundaryEventCoordinates = boundaryEventBpmnShape;

            return(boundaryEvent.builder());
        }
Ejemplo n.º 8
0
        protected internal virtual T createTarget <T>(Type typeClass, string identifier) where T : FlowNode
        {
            typeClass = typeof(T);
            T target = createSibling(typeClass, identifier);

            BpmnShape targetBpmnShape = createBpmnShape(target);

            Coordinates = targetBpmnShape;
            connectTarget(target);
            resizeSubProcess(targetBpmnShape);
            return(target);
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBpmnLabel()
        public virtual void testBpmnLabel()
        {
            BpmnShape shape = startEvent.DiagramElement;

            assertThat(shape.BpmnElement).isEqualTo(startEvent);
            assertThat(shape.BpmnLabel).NotNull;

            BpmnLabel label = shape.BpmnLabel;

            assertThat(label.LabelStyle).Null;
            assertThat(label.Bounds).NotNull;
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testBpmnShape()
        public virtual void testBpmnShape()
        {
            BpmnShape shape = serviceTask.DiagramElement;

            assertThat(shape.BpmnElement).isEqualTo(serviceTask);
            assertThat(shape.BpmnLabel).Null;
            assertThat(shape.Expanded).False;
            assertThat(shape.Horizontal).False;
            assertThat(shape.MarkerVisible).False;
            assertThat(shape.MessageVisible).False;
            assertThat(shape.ParticipantBandKind).Null;
            assertThat(shape.ChoreographyActivityShape).Null;
        }
Ejemplo n.º 11
0
        protected internal virtual double calculateXCoordinate(Bounds boundaryEventBounds)
        {
            BpmnShape attachedToElement = findBpmnShape(element);

            double x = 0;

            if (attachedToElement != null)
            {
                Bounds attachedToBounds = attachedToElement.Bounds;

                ICollection <BoundaryEvent> boundaryEvents         = element.ParentElement.getChildElementsByType(typeof(BoundaryEvent));
                ICollection <BoundaryEvent> attachedBoundaryEvents = new List <BoundaryEvent>();

                IEnumerator <BoundaryEvent> iterator = boundaryEvents.GetEnumerator();
                while (iterator.MoveNext())
                {
                    BoundaryEvent tmp = iterator.Current;
                    if (tmp.AttachedTo.Equals(element))
                    {
                        attachedBoundaryEvents.Add(tmp);
                    }
                }

                double attachedToX     = attachedToBounds.getX().Value;
                double attachedToWidth = attachedToBounds.getWidth().Value;
                double boundaryWidth   = boundaryEventBounds.getWidth().Value;

                switch (attachedBoundaryEvents.Count)
                {
                case 2:
                {
                    x = attachedToX + attachedToWidth / 2 + boundaryWidth / 2;
                    break;
                }

                case 3:
                {
                    x = attachedToX + attachedToWidth / 2 - 1.5 * boundaryWidth;
                    break;
                }

                default:
                {
                    x = attachedToX + attachedToWidth / 2 - boundaryWidth / 2;
                    break;
                }
                }
            }

            return(x);
        }
Ejemplo n.º 12
0
        protected internal virtual void setWaypointsWithSourceAndTarget(BpmnEdge edge, FlowNode edgeSource, FlowNode edgeTarget)
        {
            BpmnShape source = findBpmnShape(edgeSource);
            BpmnShape target = findBpmnShape(edgeTarget);

            if (source != null && target != null)
            {
                Bounds sourceBounds = source.Bounds;
                Bounds targetBounds = target.Bounds;

                double sourceX      = sourceBounds.getX().Value;
                double sourceY      = sourceBounds.getY().Value;
                double sourceWidth  = sourceBounds.getWidth().Value;
                double sourceHeight = sourceBounds.getHeight().Value;

                double targetX      = targetBounds.getX().Value;
                double targetY      = targetBounds.getY().Value;
                double targetHeight = targetBounds.getHeight().Value;

                Waypoint w1 = createInstance(typeof(Waypoint));

                if (edgeSource.Outgoing.Count == 1)
                {
                    w1.X = sourceX + sourceWidth;
                    w1.Y = sourceY + sourceHeight / 2;

                    edge.addChildElement(w1);
                }
                else
                {
                    w1.X = sourceX + sourceWidth / 2;
                    w1.Y = sourceY + sourceHeight;

                    edge.addChildElement(w1);

                    Waypoint w2 = createInstance(typeof(Waypoint));
                    w2.X = sourceX + sourceWidth / 2;
                    w2.Y = targetY + targetHeight / 2;

                    edge.addChildElement(w2);
                }

                Waypoint w3 = createInstance(typeof(Waypoint));
                w3.X = targetX;
                w3.Y = targetY + targetHeight / 2;

                edge.addChildElement(w3);
            }
        }
Ejemplo n.º 13
0
        protected internal virtual BpmnShape findBpmnShape(string id)
        {
            ICollection <BpmnShape> allShapes = instance.getModelElementsByType(typeof(BpmnShape));

            IEnumerator <BpmnShape> iterator = allShapes.GetEnumerator();

            while (iterator.MoveNext())
            {
                BpmnShape shape = iterator.Current;
                if (shape.BpmnElement.Id.Equals(id))
                {
                    return(shape);
                }
            }
            return(null);
        }
Ejemplo n.º 14
0
        public virtual BpmnShape createBpmnShape(FlowNode node)
        {
            BpmnPlane bpmnPlane = findBpmnPlane();

            if (bpmnPlane != null)
            {
                BpmnShape bpmnShape = createInstance(typeof(BpmnShape));
                bpmnShape.BpmnElement = node;
                Bounds nodeBounds = createInstance(typeof(Bounds));

                if (node is SubProcess)
                {
                    bpmnShape.Expanded = true;
                    nodeBounds.setWidth(350);
                    nodeBounds.setHeight(200);
                }
                else if (node is Activity)
                {
                    nodeBounds.setWidth(100);
                    nodeBounds.setHeight(80);
                }
                else if (node is Event)
                {
                    nodeBounds.setWidth(36);
                    nodeBounds.setHeight(36);
                }
                else if (node is Gateway)
                {
                    nodeBounds.setWidth(50);
                    nodeBounds.setHeight(50);
                    if (node is ExclusiveGateway)
                    {
                        bpmnShape.MarkerVisible = true;
                    }
                }

                nodeBounds.setX(0);
                nodeBounds.setY(0);

                bpmnShape.addChildElement(nodeBounds);
                bpmnPlane.addChildElement(bpmnShape);

                return(bpmnShape);
            }
            return(null);
        }
Ejemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateShapeForExclusiveGateway()
        public virtual void shouldGenerateShapeForExclusiveGateway()
        {
            // given
            ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

            // when
            instance = processBuilder.startEvent(START_EVENT_ID).exclusiveGateway("or").endEvent(END_EVENT_ID).done();

            // then
            ICollection <BpmnShape> allShapes = instance.getModelElementsByType(typeof(BpmnShape));

            assertEquals(3, allShapes.Count);

            assertGatewayShapeProperties("or");
            BpmnShape bpmnShape = findBpmnShape("or");

            assertTrue(bpmnShape.MarkerVisible);
        }
Ejemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateShapeForBlankSubProcess()
        public virtual void shouldGenerateShapeForBlankSubProcess()
        {
            // given
            ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

            // when
            instance = processBuilder.startEvent(START_EVENT_ID).subProcess(SUB_PROCESS_ID).endEvent(END_EVENT_ID).done();

            // then
            ICollection <BpmnShape> allShapes = instance.getModelElementsByType(typeof(BpmnShape));

            assertEquals(3, allShapes.Count);

            BpmnShape bpmnShapeSubProcess = findBpmnShape(SUB_PROCESS_ID);

            assertNotNull(bpmnShapeSubProcess);
            assertSubProcessSize(bpmnShapeSubProcess);
            assertTrue(bpmnShapeSubProcess.Expanded);
        }
Ejemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateShapeForEventSubProcess()
        public virtual void shouldGenerateShapeForEventSubProcess()
        {
            // given
            ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

            // when
            instance = processBuilder.startEvent(START_EVENT_ID).endEvent(END_EVENT_ID).subProcess(SUB_PROCESS_ID).triggerByEvent().embeddedSubProcess().startEvent("innerStartEvent").endEvent("innerEndEvent").subProcessDone().done();

            // then
            ICollection <BpmnShape> allShapes = instance.getModelElementsByType(typeof(BpmnShape));

            assertEquals(5, allShapes.Count);

            assertEventShapeProperties("innerStartEvent");
            assertEventShapeProperties("innerEndEvent");

            BpmnShape bpmnShapeEventSubProcess = findBpmnShape(SUB_PROCESS_ID);

            assertNotNull(bpmnShapeEventSubProcess);
            assertTrue(bpmnShapeEventSubProcess.Expanded);
        }
Ejemplo n.º 18
0
        public virtual EventSubProcessBuilder eventSubProcess(string id)
        {
            // Create a subprocess, triggered by an event, and add it to modelInstance
            SubProcess subProcess = createChild(typeof(SubProcess), id);

            subProcess.TriggeredByEvent = true;

            // Create Bpmn shape so subprocess will be drawn
            BpmnShape targetBpmnShape = createBpmnShape(subProcess);

            //find the lowest shape in the process
            // place event sub process underneath
            EventSubProcessCoordinates = targetBpmnShape;

            resizeSubProcess(targetBpmnShape);

            // Return the eventSubProcessBuilder
            EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(modelInstance, subProcess);

            return(eventSubProcessBuilder);
        }
Ejemplo n.º 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateShapeForTransaction()
        public virtual void shouldGenerateShapeForTransaction()
        {
            // given
            ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

            // when
            instance = processBuilder.startEvent(START_EVENT_ID).transaction(TRANSACTION_ID).embeddedSubProcess().startEvent("innerStartEvent").userTask("innerUserTask").endEvent("innerEndEvent").transactionDone().endEvent(END_EVENT_ID).done();

            // then
            ICollection <BpmnShape> allShapes = instance.getModelElementsByType(typeof(BpmnShape));

            assertEquals(6, allShapes.Count);

            assertEventShapeProperties("innerStartEvent");
            assertTaskShapeProperties("innerUserTask");
            assertEventShapeProperties("innerEndEvent");

            BpmnShape bpmnShapeSubProcess = findBpmnShape(TRANSACTION_ID);

            assertNotNull(bpmnShapeSubProcess);
            assertTrue(bpmnShapeSubProcess.Expanded);
        }
Ejemplo n.º 20
0
        public virtual StartEventBuilder startEvent(string id)
        {
            StartEvent start = createChild(typeof(StartEvent), id);

            BpmnShape startShape      = createBpmnShape(start);
            BpmnShape subProcessShape = findBpmnShape(Element);

            if (subProcessShape != null)
            {
                Bounds subProcessBounds = subProcessShape.Bounds;
                Bounds startBounds      = startShape.Bounds;

                double subProcessX      = subProcessBounds.getX().Value;
                double subProcessY      = subProcessBounds.getY().Value;
                double subProcessHeight = subProcessBounds.getHeight().Value;
                double startHeight      = startBounds.getHeight().Value;

                startBounds.setX(subProcessX + SPACE);
                startBounds.setY(subProcessY + subProcessHeight / 2 - startHeight / 2);
            }

            return(start.builder());
        }
Ejemplo n.º 21
0
 protected internal virtual void assertEventSize(BpmnShape shape)
 {
     assertSize(shape, 36, 36);
 }
Ejemplo n.º 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateValidBpmnDi()
        public virtual void shouldCreateValidBpmnDi()
        {
            modelInstance = Bpmn.createProcess("process").startEvent("start").sequenceFlowId("flow").endEvent("end").done();

            process      = modelInstance.getModelElementById("process");
            startEvent   = modelInstance.getModelElementById("start");
            sequenceFlow = modelInstance.getModelElementById("flow");
            endEvent     = modelInstance.getModelElementById("end");

            // create bpmn diagram
            BpmnDiagram bpmnDiagram = modelInstance.newInstance(typeof(BpmnDiagram));

            bpmnDiagram.Id            = "diagram";
            bpmnDiagram.Name          = "diagram";
            bpmnDiagram.Documentation = "bpmn diagram element";
            bpmnDiagram.Resolution    = 120.0;
            modelInstance.Definitions.addChildElement(bpmnDiagram);

            // create plane for process
            BpmnPlane processPlane = modelInstance.newInstance(typeof(BpmnPlane));

            processPlane.Id          = "plane";
            processPlane.BpmnElement = process;
            bpmnDiagram.BpmnPlane    = processPlane;

            // create shape for start event
            BpmnShape startEventShape = modelInstance.newInstance(typeof(BpmnShape));

            startEventShape.Id          = "startShape";
            startEventShape.BpmnElement = startEvent;
            processPlane.DiagramElements.Add(startEventShape);

            // create bounds for start event shape
            Bounds startEventBounds = modelInstance.newInstance(typeof(Bounds));

            startEventBounds.setHeight(36.0);
            startEventBounds.setWidth(36.0);
            startEventBounds.setX(632.0);
            startEventBounds.setY(312.0);
            startEventShape.Bounds = startEventBounds;

            // create shape for end event
            BpmnShape endEventShape = modelInstance.newInstance(typeof(BpmnShape));

            endEventShape.Id          = "endShape";
            endEventShape.BpmnElement = endEvent;
            processPlane.DiagramElements.Add(endEventShape);

            // create bounds for end event shape
            Bounds endEventBounds = modelInstance.newInstance(typeof(Bounds));

            endEventBounds.setHeight(36.0);
            endEventBounds.setWidth(36.0);
            endEventBounds.setX(718.0);
            endEventBounds.setY(312.0);
            endEventShape.Bounds = endEventBounds;

            // create edge for sequence flow
            BpmnEdge flowEdge = modelInstance.newInstance(typeof(BpmnEdge));

            flowEdge.Id            = "flowEdge";
            flowEdge.BpmnElement   = sequenceFlow;
            flowEdge.SourceElement = startEventShape;
            flowEdge.TargetElement = endEventShape;
            processPlane.DiagramElements.Add(flowEdge);

            // create waypoints for sequence flow edge
            Waypoint startWaypoint = modelInstance.newInstance(typeof(Waypoint));

            startWaypoint.X = 668.0;
            startWaypoint.Y = 330.0;
            flowEdge.Waypoints.add(startWaypoint);

            Waypoint endWaypoint = modelInstance.newInstance(typeof(Waypoint));

            endWaypoint.X = 718.0;
            endWaypoint.Y = 330.0;
            flowEdge.Waypoints.add(endWaypoint);
        }
Ejemplo n.º 23
0
 protected internal virtual void assertGatewaySize(BpmnShape shape)
 {
     assertSize(shape, 50, 50);
 }
Ejemplo n.º 24
0
 protected internal virtual void assertSubProcessSize(BpmnShape shape)
 {
     assertSize(shape, 200, 350);
 }
Ejemplo n.º 25
0
 protected internal virtual void assertSize(BpmnShape shape, int height, int width)
 {
     assertThat(shape.Bounds.Height).isEqualTo(height);
     assertThat(shape.Bounds.Width).isEqualTo(width);
 }
Ejemplo n.º 26
0
 protected internal virtual void assertActivitySize(BpmnShape shape)
 {
     assertSize(shape, 80, 100);
 }