BPMN diagram import

Package provides functionality for importing from BPMN 2.0 XML to graph representation

class bpmn_python.bpmn_diagram_import.BpmnDiagramGraphImport

Class BPMNDiagramGraphImport provides methods for importing BPMN 2.0 XML file. As a utility class, it only contains static methods. This class is meant to be used from BPMNDiagramGraph class.

staticmethod import_activity_to_graph(diagram_graph, process_id, process_attributes, element)

Method that adds the new element that represents BPMN activity. Should not be used directly, only as a part of method, that imports an element which extends Activity element (task, subprocess etc.)

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML element which extends ‘activity’.
staticmethod import_boundary_event_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN boundary event. Boundary event inherits sequence of eventDefinitionRef from Event type. Separate methods for each event type are required since each of them has different variants (Message, Error, Signal etc.).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘endEvent’ element.
staticmethod import_child_lane_set_element(child_lane_set_element, plane_element)

Method for importing ‘childLaneSet’ element from diagram file.

Parameters:
  • child_lane_set_element – XML document element,
  • plane_element – object representing a BPMN XML ‘plane’ element.
staticmethod import_collaboration_element(diagram_graph, collaboration_element, collaboration_dict)

Method that imports information from ‘collaboration’ element.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • collaboration_element – XML doument element,
  • collaboration_dict – dictionary, that consist all information imported from ‘collaboration’ element. Includes three key-value pairs - ‘id’ which keeps ID of collaboration element, ‘participants’ that keeps information about ‘participant’ elements and ‘message_flows’ that keeps information about message flows.
staticmethod import_complex_gateway_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN complex gateway. In addition to attributes inherited from Gateway type, complex gateway has additional attribute default flow (default value - none).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘complexGateway’ element.
staticmethod import_data_object_to_graph(diagram_graph, process_id, process_attributes, data_object_element)

Adds to graph the new element that represents BPMN data object. Data object inherits attributes from FlowNode. In addition, an attribute ‘isCollection’ is added to the node.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • data_object_element – object representing a BPMN XML ‘dataObject’ element.
staticmethod import_diagram_and_plane_attributes(diagram_attributes, plane_attributes, diagram_element, plane_element)

Adds attributes of BPMN diagram and plane elements to appropriate fields diagram_attributes and plane_attributes. Diagram inner representation contains following diagram element attributes:

  • id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn’t say so,
  • name - optional parameter, empty string by default,

Diagram inner representation contains following plane element attributes:

  • id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn’t say so,
  • bpmnElement - assumed to be required in XML file, even thought BPMN 2.0 schema doesn’t say so,
Parameters:
  • diagram_attributes – dictionary that holds attribute values for imported ‘BPMNDiagram’ element,
  • plane_attributes – dictionary that holds attribute values for imported ‘BPMNPlane’ element,
  • diagram_element – object representing a BPMN XML ‘diagram’ element,
  • plane_element – object representing a BPMN XML ‘plane’ element.
staticmethod import_end_event_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN end event. End event inherits sequence of eventDefinitionRef from Event type. Separate methods for each event type are required since each of them has different variants (Message, Error, Signal etc.).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘endEvent’ element.
staticmethod import_event_based_gateway_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN event based gateway. In addition to attributes inherited from Gateway type, event based gateway has additional attributes - instantiate (boolean type, default value - false) and eventGatewayType (custom type tEventBasedGatewayType, default value - Exclusive).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘eventBasedGateway’ element.
staticmethod import_event_definition_elements(diagram_graph, element, event_definitions)

Helper function, that adds event definition elements (defines special types of events) to corresponding events.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • element – object representing a BPMN XML event element,
  • event_definitions – list of event definitions, that belongs to given event.
staticmethod import_flow_di(diagram_graph, sequence_flows, message_flows, flow_element)

Adds Diagram Interchange information (information about rendering a diagram) to appropriate BPMN sequence flow represented as graph edge. We assume that each BPMNEdge has a list of ‘waypoint’ elements. BPMN 2.0 XML Schema states, that each BPMNEdge must have at least two waypoints.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • sequence_flows – dictionary (associative list) of sequence flows existing in diagram. Key attribute is sequenceFlow ID, value is a dictionary consisting three key-value pairs: “name” (sequence flow name), “sourceRef” (ID of node, that is a flow source) and “targetRef” (ID of node, that is a flow target),
  • message_flows – dictionary (associative list) of message flows existing in diagram. Key attribute is messageFlow ID, value is a dictionary consisting three key-value pairs: “name” (message flow name), “sourceRef” (ID of node, that is a flow source) and “targetRef” (ID of node, that is a flow target),
  • flow_element – object representing a BPMN XML ‘BPMNEdge’ element.
staticmethod import_flow_node_to_graph(bpmn_graph, process_id, process_attributes, flow_node_element)

Adds a new node to graph. Input parameter is object of class xml.dom.Element. Nodes are identified by ID attribute of Element. Method adds basic attributes (shared by all BPMN elements) to node. Those elements are:

  • id - added as key value, we assume that this is a required value,
  • type - tagName of element, used to identify type of BPMN diagram element,
  • name - optional attribute, empty string by default.
Parameters:
  • bpmn_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • flow_node_element – object representing a BPMN XML element corresponding to given flownode,
staticmethod import_gateway_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN gateway. In addition to attributes inherited from FlowNode type, Gateway has additional attribute gatewayDirection (simple type, default value - Unspecified).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML element of Gateway type extension.
staticmethod import_incl_or_excl_gateway_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN inclusive or eclusive gateway. In addition to attributes inherited from Gateway type, inclusive and exclusive gateway have additional attribute default flow (default value - none).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘inclusiveGateway’ or ‘exclusiveGateway’ element.
staticmethod import_intermediate_catch_event_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN intermediate catch event. Intermediate catch event inherits attribute parallelMultiple from CatchEvent type and sequence of eventDefinitionRef from Event type. Separate methods for each event type are required since each of them has different variants (Message, Error, Signal etc.).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘intermediateCatchEvent’ element.
staticmethod import_intermediate_throw_event_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN intermediate throw event. Intermediate throw event inherits sequence of eventDefinitionRef from Event type. Separate methods for each event type are required since each of them has different variants (Message, Error, Signal etc.).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘intermediateThrowEvent’ element.
staticmethod import_lane_element(lane_element, plane_element)

Method for importing ‘laneSet’ element from diagram file.

Parameters:
  • lane_element – XML document element,
  • plane_element – object representing a BPMN XML ‘plane’ element.
staticmethod import_lane_set_element(process_attributes, lane_set_element, plane_element)

Method for importing ‘laneSet’ element from diagram file.

Parameters:
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • lane_set_element – XML document element,
  • plane_element – object representing a BPMN XML ‘plane’ element.
staticmethod import_message_flow_to_graph(diagram_graph, message_flows, flow_element)

Adds a new edge to graph and a record to message flows dictionary. Input parameter is object of class xml.dom.Element. Edges are identified by pair of sourceRef and targetRef attributes of BPMNFlow element. We also provide a dictionary, that maps messageFlow ID attribute with its sourceRef and targetRef. Method adds basic attributes of messageFlow element to edge. Those elements are:

  • id - added as edge attribute, we assume that this is a required value,
  • name - optional attribute, empty string by default.
Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • message_flows – dictionary (associative list) of message flows existing in diagram. Key attribute is messageFlow ID, value is a dictionary consisting three key-value pairs: “name” (message flow name), “sourceRef” (ID of node, that is a flow source) and “targetRef” (ID of node, that is a flow target),
  • flow_element – object representing a BPMN XML ‘messageFlow’ element.
staticmethod import_parallel_gateway_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN parallel gateway. Parallel gateway doesn’t have additional attributes. Separate method is used to improve code readability.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘parallelGateway’.
staticmethod import_participant_element(diagram_graph, participants_dictionary, participant_element)

Adds ‘participant’ element to the collaboration dictionary.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • participants_dictionary – dictionary with participant element attributes. Key is participant ID, value is a dictionary of participant attributes,
  • participant_element – object representing a BPMN XML ‘participant’ element.
staticmethod import_process_element(process_elements_dict, process_element)

Adds attributes of BPMN process element to appropriate field process_attributes. Diagram inner representation contains following process attributes:

  • id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn’t say so,
  • isClosed - optional parameter, default value ‘false’,
  • isExecutable - optional parameter, default value ‘false’,
  • processType - optional parameter, default value ‘None’,
  • node_ids - list of flow nodes IDs, associated with given process.
Parameters:
  • process_elements_dict – dictionary that holds attribute values for imported ‘process’ element. Key is process ID, value is a dictionary of attributes,
  • process_element – object representing a BPMN XML ‘process’ element.
staticmethod import_process_elements(document, diagram_graph, sequence_flows, process_elements_dict, plane_element)

Method for importing all ‘process’ elements in diagram.

Parameters:
  • document – XML document,
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • sequence_flows – a list of sequence flows existing in diagram,
  • process_elements_dict – dictionary that holds attribute values for imported ‘process’ elements. Key is an ID of process, value - a dictionary of process attributes,
  • plane_element – object representing a BPMN XML ‘plane’ element.
staticmethod import_sequence_flow_to_graph(diagram_graph, sequence_flows, process_id, flow_element)

Adds a new edge to graph and a record to sequence_flows dictionary. Input parameter is object of class xml.dom.Element. Edges are identified by pair of sourceRef and targetRef attributes of BPMNFlow element. We also provide a dictionary, that maps sequenceFlow ID attribute with its sourceRef and targetRef. Method adds basic attributes of sequenceFlow element to edge. Those elements are:

  • id - added as edge attribute, we assume that this is a required value,
  • name - optional attribute, empty string by default.
Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • sequence_flows – dictionary (associative list) of sequence flows existing in diagram. Key attribute is sequenceFlow ID, value is a dictionary consisting three key-value pairs: “name” (sequence flow name), “sourceRef” (ID of node, that is a flow source) and “targetRef” (ID of node, that is a flow target),
  • process_id – string object, representing an ID of process element,
  • flow_element – object representing a BPMN XML ‘sequenceFlow’ element.
staticmethod import_shape_di(participants_dict, diagram_graph, shape_element)

Adds Diagram Interchange information (information about rendering a diagram) to appropriate BPMN diagram element in graph node. We assume that those attributes are required for each BPMNShape:

  • width - width of BPMNShape,
  • height - height of BPMNShape,
  • x - first coordinate of BPMNShape,
  • y - second coordinate of BPMNShape.
Parameters:
  • participants_dict – dictionary with ‘participant’ elements attributes,
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • shape_element – object representing a BPMN XML ‘BPMNShape’ element.
staticmethod import_start_event_to_graph(diagram_graph, process_id, process_attributes, element)

Adds to graph the new element that represents BPMN start event. Start event inherits attribute parallelMultiple from CatchEvent type and sequence of eventDefinitionRef from Event type. Separate methods for each event type are required since each of them has different variants (Message, Error, Signal etc.).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • element – object representing a BPMN XML ‘startEvent’ element.
staticmethod import_subprocess_to_graph(diagram_graph, sequence_flows, process_id, process_attributes, subprocess_element)

Adds to graph the new element that represents BPMN subprocess. In addition to attributes inherited from FlowNode type, SubProcess has additional attribute tiggeredByEvent (boolean type, default value - false).

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • sequence_flows – a list of sequence flows existing in diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • subprocess_element – object representing a BPMN XML ‘subprocess’ element
staticmethod import_task_to_graph(diagram_graph, process_id, process_attributes, task_element)

Adds to graph the new element that represents BPMN task. In our representation tasks have only basic attributes and elements, inherited from Activity type, so this method only needs to call add_flownode_to_graph.

Parameters:
  • diagram_graph – NetworkX graph representing a BPMN process diagram,
  • process_id – string object, representing an ID of process element,
  • process_attributes – dictionary that holds attribute values of ‘process’ element, which is parent of imported flow node,
  • task_element – object representing a BPMN XML ‘task’ element.
staticmethod load_diagram_from_xml(filepath, bpmn_diagram)

Reads an XML file from given filepath and maps it into inner representation of BPMN diagram. Returns an instance of BPMNDiagramGraph class.

Parameters:
  • filepath – string with output filepath,
  • bpmn_diagram – an instance of BpmnDiagramGraph class.
staticmethod read_xml_file(filepath)

Reads BPMN 2.0 XML file from given filepath and returns xml.dom.xminidom.Document object.

Parameters:filepath – filepath of source XML file.