BPMN diagram representation¶
Package with BPMNDiagramGraph - graph representation of BPMN diagram
-
class
bpmn_python.bpmn_diagram_rep.BpmnDiagramGraph¶ Class BPMNDiagramGraph implements simple inner representation of BPMN 2.0 diagram, based on NetworkX graph implementation
Fields:
- diagram_graph - networkx.Graph object, stores elements of BPMN diagram as nodes. Each edge of graph represents
- sequenceFlow element. Edges are identified by IDs of nodes connected by edge. IDs are passed as edge parameters,
- 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),
- collaboration - a dictionary that contains two dictionaries:
- “messageFlows” - 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),
- “participants” - dictionary (associative list) of participants existing in diagram. Key attribute is
- participant ID, value is a dictionary consisting participant attributes,
- process_elements_dictionary - dictionary that holds attribute values for imported ‘process’ elements.
- Key is an ID of process, value is a dictionary of all process attributes,
- diagram_attributes - dictionary that contains BPMN diagram element attributes,
- plane_attributes - dictionary that contains BPMN plane element attributes.
Default constructor, initializes object fields with new instances.
-
add_end_event_to_diagram(process_id, end_event_name='', end_event_definition=None, node_id=None)¶ Adds an EndEvent element to BPMN diagram. User-defined attributes:
- name
- event definition (creates a special type of end event). Supported event definitions
- terminate: ‘terminateEventDefinition’,
- signal: ‘signalEventDefinition’,
- error: ‘errorEventDefinition’,
- escalation: ‘escalationEventDefinition’,
- message: ‘messageEventDefinition’,
- compensate: ‘compensateEventDefinition’.
Parameters: - process_id – string object. ID of parent process,
- end_event_name – string object. Name of end event,
- end_event_definition – list of event definitions. By default - empty.
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is endEvent ID, second a reference to created object,
-
staticmethod
add_event_definition_element(event_type, event_definitions)¶ Helper function, that creates event definition element (special type of event) from given parameters.
Parameters: - event_type – string object. Short name of required event definition,
- event_definitions – dictionary of event definitions. Key is a short name of event definition, value is a full name of event definition, as defined in BPMN 2.0 XML Schema.
-
add_exclusive_gateway_to_diagram(process_id, gateway_name='', gateway_direction='Unspecified', default=None, node_id=None)¶ Adds an exclusiveGateway element to BPMN diagram.
Parameters: - process_id – string object. ID of parent process,
- gateway_name – string object. Name of exclusive gateway,
- gateway_direction – string object. Accepted values - “Unspecified”, “Converging”, “Diverging”, “Mixed”. Default value - “Unspecified”.
- default – string object. ID of flow node, target of gateway default path. Default value - None,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is exculusiveGateway ID, second a reference to created object.
-
add_flow_node_to_diagram(process_id, node_type, name, node_id=None)¶ Helper function that adds a new Flow Node to diagram. It is used to add a new node of specified type. Adds a basic information inherited from Flow Node type.
Parameters: - process_id – string object. ID of parent process,
- node_type – string object. Represents type of BPMN node passed to method,
- name – string object. Name of the node,
- node_id – string object. ID of node. Default value - None.
-
add_gateway_to_diagram(process_id, gateway_type, gateway_name='', gateway_direction='Unspecified', node_id=None)¶ Adds an exclusiveGateway element to BPMN diagram.
Parameters: - process_id – string object. ID of parent process,
- gateway_type – string object. Type of gateway to be added.
- gateway_name – string object. Name of exclusive gateway,
- gateway_direction – string object. Accepted values - “Unspecified”, “Converging”, “Diverging”, “Mixed”. Default value - “Unspecified”,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is gateway ID, second a reference to created object.
-
add_inclusive_gateway_to_diagram(process_id, gateway_name='', gateway_direction='Unspecified', default=None, node_id=None)¶ Adds an inclusiveGateway element to BPMN diagram.
Parameters: - process_id – string object. ID of parent process,
- gateway_name – string object. Name of inclusive gateway,
- gateway_direction – string object. Accepted values - “Unspecified”, “Converging”, “Diverging”, “Mixed”. Default value - “Unspecified”,
- default – string object. ID of flow node, target of gateway default path. Default value - None,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is inclusiveGateway ID, second a reference to created object.
-
add_parallel_gateway_to_diagram(process_id, gateway_name='', gateway_direction='Unspecified', node_id=None)¶ Adds an parallelGateway element to BPMN diagram.
Parameters: - process_id – string object. ID of parent process,
- gateway_name – string object. Name of inclusive gateway,
- gateway_direction – string object. Accepted values - “Unspecified”, “Converging”, “Diverging”, “Mixed”. Default value - “Unspecified”,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is parallelGateway ID, second a reference to created object.
-
add_process_to_diagram(process_name='', process_is_closed=False, process_is_executable=False, process_type='None')¶ - Adds a new process to diagram and corresponding participant
- process, diagram and plane
Accepts a user-defined values for following attributes: (Process element) - isClosed - default value false, - isExecutable - default value false, - processType - default value None.
Parameters: - process_name – string obejct, process name. Default value - empty string,
- process_is_closed – boolean type. Represents a user-defined value of ‘process’ element attribute ‘isClosed’. Default value false,
- process_is_executable – boolean type. Represents a user-defined value of ‘process’ element attribute ‘isExecutable’. Default value false,
- process_type – string type. Represents a user-defined value of ‘process’ element attribute ‘procesType’. Default value “None”,
-
add_sequence_flow_to_diagram(process_id, source_ref_id, target_ref_id, sequence_flow_name='')¶ Adds a SequenceFlow element to BPMN diagram. Requires that user passes a sourceRef and targetRef as parameters. User-defined attributes:
- name
Parameters: - process_id – string object. ID of parent process,
- source_ref_id – string object. ID of source node,
- target_ref_id – string object. ID of target node,
- sequence_flow_name – string object. Name of sequence flow.
Returns: a tuple, where first value is sequenceFlow ID, second a reference to created object.
-
add_start_event_to_diagram(process_id, start_event_name='', start_event_definition=None, parallel_multiple=False, is_interrupting=True, node_id=None)¶ Adds a StartEvent element to BPMN diagram.
User-defined attributes:
- name
- parallel_multiple
- is_interrupting
- event definition (creates a special type of start event). Supported event definitions -
- ‘message’: ‘messageEventDefinition’,
- ‘timer’: ‘timerEventDefinition’,
- ‘signal’: ‘signalEventDefinition’,
- ‘conditional’: ‘conditionalEventDefinition’,
- ‘escalation’: ‘escalationEventDefinition’.
Parameters: - process_id – string object. ID of parent process,
- start_event_name – string object. Name of start event,
- start_event_definition – list of event definitions. By default - empty,
- parallel_multiple – boolean value for attribute “parallelMultiple”,
- is_interrupting – boolean value for attribute “isInterrupting,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is startEvent ID, second a reference to created object.
-
add_subprocess_to_diagram(process_id, subprocess_name, is_expanded=False, triggered_by_event=False, node_id=None)¶ Adds a SubProcess element to BPMN diagram. User-defined attributes:
- name
- triggered_by_event
Parameters: - process_id – string object. ID of parent process,
- subprocess_name – string object. Name of subprocess,
- is_expanded – boolean value for attribute “isExpanded”. Default value false,
- triggered_by_event – boolean value for attribute “triggeredByEvent”. Default value false,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is subProcess ID, second a reference to created object.
-
add_task_to_diagram(process_id, task_name='', node_id=None)¶ Adds a Task element to BPMN diagram. User-defined attributes:
- name
Parameters: - process_id – string object. ID of parent process,
- task_name – string object. Name of task,
- node_id – string object. ID of node. Default value - None.
Returns: a tuple, where first value is task ID, second a reference to created object.
-
create_new_diagram_graph(diagram_name='')¶ Initializes a new BPMN diagram and sets up a basic diagram attributes. Accepts a user-defined values for following attributes: (Diagram element)
- name - default value empty string.
Parameters: diagram_name – string type. Represents a user-defined value of ‘BPMNDiagram’ element attribute ‘name’. Default value - empty string.
-
export_csv_file(directory, filename)¶ Exports diagram inner graph to BPMN 2.0 XML file (with Diagram Interchange data).
Parameters: - directory – strings representing output directory,
- filename – string representing output file name.
-
export_xml_file(directory, filename)¶ Exports diagram inner graph to BPMN 2.0 XML file (with Diagram Interchange data).
Parameters: - directory – strings representing output directory,
- filename – string representing output file name.
-
export_xml_file_no_di(directory, filename)¶ Exports diagram inner graph to BPMN 2.0 XML file (without Diagram Interchange data).
Parameters: - directory – strings representing output directory,
- filename – string representing output file name.
-
get_flow_by_id(flow_id)¶ Gets an edge (flow) with requested ID. Returns a tuple, where first value is node ID, second - a dictionary of all node attributes.
Parameters: flow_id – string with edge ID.
-
get_flows()¶ Gets all graph edges (process flows). Returns a two-dimensional dictionary, where keys are IDs of nodes connected by edge and values are a dictionary of all edge attributes.
-
get_flows_list_by_process_id(process_id)¶ Gets an edge (flow) with requested ID. Returns a tuple, where first value is node ID, second - a dictionary of all node attributes.
Parameters: process_id – string object, representing an ID of parent process element.
-
get_node_by_id(node_id)¶ Gets a node with requested ID. Returns a tuple, where first value is node ID, second - a dictionary of all node attributes.
Parameters: node_id – string with ID of node.
-
get_nodes(node_type='')¶ Gets all nodes of requested type. If no type is provided by user, all nodes in BPMN diagram graph are returned. Returns a dictionary, where key is an ID of node, value is a dictionary of all node attributes.
Parameters: node_type – string with valid BPMN XML tag name (e.g. ‘task’, ‘sequenceFlow’).
-
get_nodes_id_list_by_type(node_type)¶ Get a list of node’s id by requested type. Returns a list of ids
Parameters: node_type – string with valid BPMN XML tag name (e.g. ‘task’, ‘sequenceFlow’).
-
get_nodes_list_by_process_id(process_id)¶ Gets all nodes of requested type. If no type is provided by user, all nodes in BPMN diagram graph are returned. Returns a dictionary, where key is an ID of node, value is a dictionary of all node attributes.
Parameters: process_id – string object, representing an ID of parent process element.
-
get_nodes_positions()¶ Getter method for nodes positions.
Returns: A dictionary with nodes as keys and positions as values
-
load_diagram_from_csv_file(filepath)¶ Reads an CSV 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.
-
load_diagram_from_xml_file(filepath)¶ 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.