christophevg / bpmn-tools

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

UserTask throwing error inside the Process #3

Closed sgupta1007 closed 10 months ago

sgupta1007 commented 10 months ago

Describe the bug I am trying to add task type instead of simple tag in Branch inside a process .Code instead of producing correct diagram is producing bug

Code Code using BPMN to produce the bug


from bpmn_tools.builder.process import Process, Task, Branch, BranchKind, If
from bpmn_tools import flow
from bpmn_tools.flow import UserTask
from bpmn_tools.colors import Green, Blue, Red, Orange
from bpmn_tools.util import model2xml

process=Process([
Task(name='Help'),
Branch([Task(name='Branch one a'),Task(name='Branch one b')],kind=BranchKind.AND),
Branch([Task(name='Branch nested before'),Branch([UserTask(name='Inside nested branch')],kind=BranchKind.XOR),Task(name='Branch nested after')],kind=BranchKind.OR)
],name='Some random process',starts=True,ends=True)

model=process.render()

definations=model2xml(model)

Expected behavior I am expecting this diagram

bpmn_bug_new_1

Original behavior

bpmn_bug_new_2
christophevg commented 10 months ago

The API of Process Builder doesn't accept flow.Element, it accepts Process Builder Tasks, and such task has a cls argument, which allows you to specify the flow.Element, e.g. UserTask so just change:

UserTask(name='Inside nested branch')

into

Task(name='Inside nested branch', cls=UserTask)

and you get:

image