@@ -243,28 +243,57 @@ def _add_sub_element(self, parent: ET.Element, bpmn_element: str, shape: Any):
243243 )
244244
245245 # *** Generate bpmn:outgoing and bpmn:incoming elements ***
246- if shape .connection_to is not None :
247- for connection in shape .connection_to :
248- # Check if connection is of type Connection
249- if isinstance (connection , Connection ):
250- # Use the bpmn_id of the target as the target is a Connection which references a different shape
251- if connection .target is not None :
252- ET .SubElement (element , "bpmn:outgoing" ).text = connection .target .bpmn_id
253- else :
254- # The bpmn_id can be used directly as the target is one of:
255- # Activity, Event or Gateway
256- ET .SubElement (element , "bpmn:outgoing" ).text = connection .bpmn_id
257- if shape .connection_from is not None :
258- for connection in shape .connection_from :
259- # Check if connection is of type Connection
260- if isinstance (connection , Connection ):
261- # Use the bpmn_id of the source as the source is a Connection which references a different shape
262- if connection .source is not None :
263- ET .SubElement (element , "bpmn:incoming" ).text = connection .source .bpmn_id
264- else :
265- # The bpmn_id can be used directly as the source is one of:
266- # Activity, Event or Gateway
267- ET .SubElement (element , "bpmn:incoming" ).text = connection .bpmn_id
246+ #
247+ # The following shapes are considered:
248+ # - startEvent
249+ # - endEvent
250+ # - intermediateCatchEvent
251+ # - task
252+ # - subProcess
253+ # - serviceTask
254+ # - exclusiveGateway
255+ # - inclusiveGateway
256+ # - parallelGateway
257+ #
258+ # The following shapes are ignored:
259+ # - timerEventDefinition (nested under startEvent, intermediateCatchEvent or endEvent)
260+ # - messageEventDefinition (nested under startEvent, intermediateCatchEvent or endEvent)
261+ # - signalEventDefinition (nested under startEvent, intermediateCatchEvent or endEvent)
262+ # - conditionalEventDefinition (nested under startEvent, intermediateCatchEvent or endEvent)
263+ # - linkEventDefinition (nested under startEvent, intermediateCatchEvent or endEvent)
264+ if (
265+ isinstance (shape , Start )
266+ or isinstance (shape , End )
267+ or isinstance (shape , Intermediate )
268+ or isinstance (shape , Task )
269+ or isinstance (shape , Subprocess )
270+ or isinstance (shape , ServiceTask )
271+ or isinstance (shape , Exclusive )
272+ or isinstance (shape , Inclusive )
273+ or isinstance (shape , Parallel )
274+ ):
275+ if shape .connection_to is not None :
276+ for connection in shape .connection_to :
277+ # Check if connection is of type Connection
278+ if isinstance (connection , Connection ):
279+ # Use the bpmn_id of the target as the target is a Connection which references a different shape
280+ if connection .target is not None :
281+ ET .SubElement (element , "bpmn:outgoing" ).text = connection .target .bpmn_id
282+ else :
283+ # The bpmn_id can be used directly as the target is one of:
284+ # Activity, Event or Gateway
285+ ET .SubElement (element , "bpmn:outgoing" ).text = connection .bpmn_id
286+ if shape .connection_from is not None :
287+ for connection in shape .connection_from :
288+ # Check if connection is of type Connection
289+ if isinstance (connection , Connection ):
290+ # Use the bpmn_id of the source as the source is a Connection which references a different shape
291+ if connection .source is not None :
292+ ET .SubElement (element , "bpmn:incoming" ).text = connection .source .bpmn_id
293+ else :
294+ # The bpmn_id can be used directly as the source is one of:
295+ # Activity, Event or Gateway
296+ ET .SubElement (element , "bpmn:incoming" ).text = connection .bpmn_id
268297 return element
269298 else :
270299 return ET .SubElement (parent , bpmn_element , {"id" : Helper .get_uuid ()})
0 commit comments