christophevg / bpmn-tools

A collection of tools to work with BPMN
MIT License
8 stars 3 forks source link

Message flows arrows generation bug #2

Open sgupta1007 opened 10 months ago

sgupta1007 commented 10 months ago

Message flows arrows are not being correctly generated between empty and non-empty process.

Expected behavior

bpmn_bug5

Original Behavior

bpmn_bug4

To Reproduce

  1. I have placed the code below to generate the Original Behavior Diagram
  2. I have purposely commented the message flow lines. Uncommenting them leads to compiling error.
Code:
from` bpmn_tools.flow import Process, Flow, Lane,LaneSet
from bpmn_tools.flow import End,Start, ScriptTask, SendTask,Task,ExclusiveGateway,IntermediateCatch,IntermediateThrow,BoundaryEvent, MessageEventDefinition
from bpmn_tools.collaboration import Collaboration, Participant
from bpmn_tools.notation import Definitions
from bpmn_tools.diagrams import Diagram, Plane
from bpmn_tools.layout import simple
from bpmn_tools.util import model2xml

#creating activities gateways 
a=SendTask('A')
b=ScriptTask('B')
decision=ExclusiveGateway("Decision")
decision2=ExclusiveGateway("Decision2")
decision3=ExclusiveGateway("Decision3")
c=SendTask('C')
d=Task('D')
e=Task('E') 
f=End('F')
g=Task('G')
h=Task('H')
i=End('I')

#creating events
message1=MessageEventDefinition(id="message1")
message2=MessageEventDefinition(id="message2")
message3=MessageEventDefinition(id="message3")

a1=Start(id="event1",definition=message1,name="a1")
a2=IntermediateThrow(id="event2",definition=message2,name="a2")
a3=IntermediateThrow(id="event3",definition=message3,name="a3")

#creating lanes 
lane1=Lane('Department 1')
lane2=Lane('Department 2')

#appending activities gateways and events to the lanes
lane1.append(a1).append(a).append(c).append(d).append(e).append(decision2).append(h).append(g).append(a3).append(i)
lane2.append(b).append(decision).append(a2).append(decision3).append(f)

#creating edges
flow0=Flow(source=a1,target=a)
flow1=Flow(source=a,target=b)
flow2=Flow(source=b,target=decision)
flow3=Flow(source=decision,target=c,name='Yes')
flow4=Flow(source=decision,target=a2,name='No')
flow5=Flow(source=c,target=d)
flow6=Flow(source=d,target=e)
flow7=Flow(source=e,target=decision2)
flow8=Flow(source=decision2,target=g,name='Yes')
flow9=Flow(source=decision2,target=h,name='No')
flow10=Flow(source=g,target=a3)
flow11=Flow(source=decision3,target=f)
flow12=Flow(source=h,target=decision3)

#intermediate events flow
flow13=Flow(source=a2,target=decision3)
flow14=Flow(source=a3,target=i)

#appending lanes flows and activities to the process
process1=Process().append(lane1).append(lane2).append(flow0).append(flow1).append(flow2).append(flow3).append(flow4).append(flow5).append(flow6).append(flow7).append(flow8).append(flow9).append(flow10).append(flow11).append(flow12).append(flow13).append(flow14)
process2=Process()

collaboration=Collaboration(id='Colaboration').extend([
    Participant('Corporation ',process1,id="p1"),
    Participant('External StakeHolder',process2,id="p2")

     #,MessageFlow(source=process2, target=a1),
     #MessageFlow(source=d, target=process2),
     #MessageFlow(source=a2, target=process2)
  ])

definitions = Definitions(id="definitions").extend([
    process1,
    collaboration,
  ])

definitions.append(
    Diagram( id="diagram", plane=Plane(id="plane", element=collaboration) )
  )

simple.layout(definitions)
print(model2xml(definitions))`
christophevg commented 10 months ago

BPMN Tools started out of a personal need, so up to now it has mostly been driven by the features I needed, along with a prototyping approach to find the right API. I always envisaged a redesign/clean up before moving to an actual 1.0 version. With most of my personal features in place and most of the design deemed ok, it's time for that redesign/clean-up.

Adding all missing features, like this one, will go into the code-sweep over the coming time.

Just with respect to this specific case: if I read the specs correctly, it seems that the flow should go to the second participant, not its process. Still, since both are almost interchangeable, maybe supporting both might be an option. To be seen over the coming time.