Code
stringlengths 103
85.9k
| Summary
sequencelengths 0
94
|
---|---|
Please provide a description of the function:def check_return_type(value, cllable = None, clss = None, caller_level = 0):
return _check_caller_type(True, cllable, value, clss, caller_level+1) | [
"Can be called from within a function or method to apply typechecking to\n the value that is going to be returned. Checking is applied w.r.t.\n type hints of the function or method hosting the call to check_return_type.\n "
] |
Please provide a description of the function:def load_diagram_from_csv(filepath, bpmn_diagram):
sequence_flows = bpmn_diagram.sequence_flows
process_elements_dict = bpmn_diagram.process_elements
diagram_attributes = bpmn_diagram.diagram_attributes
plane_attributes = bpmn_diagram.plane_attributes
process_dict = BpmnDiagramGraphCSVImport.import_csv_file_as_dict(filepath)
BpmnDiagramGraphCSVImport.populate_diagram_elements_dict(diagram_attributes)
BpmnDiagramGraphCSVImport.populate_process_elements_dict(process_elements_dict, process_dict)
BpmnDiagramGraphCSVImport.populate_plane_elements_dict(plane_attributes)
BpmnDiagramGraphCSVImport.import_nodes(process_dict, bpmn_diagram, sequence_flows)
BpmnDiagramGraphCSVImport.representation_adjustment(process_dict, bpmn_diagram, sequence_flows) | [
"\n Reads an CSV file from given filepath and maps it into inner representation of BPMN diagram.\n Returns an instance of BPMNDiagramGraph class.\n\n :param filepath: string with output filepath,\n :param bpmn_diagram: an instance of BpmnDiagramGraph class.\n "
] |
Please provide a description of the function:def set_gateway_direction(self, value):
if value is None or not isinstance(value, str):
raise TypeError("GatewayDirection must be set to a String")
elif value not in Gateway.__gateway_directions_list:
raise ValueError("GatewayDirection must be one of specified values: 'Unspecified', 'Converging', "
"'Diverging', 'Mixed'")
else:
self.__gateway_direction = value | [
"\n Setter for 'gateway_direction' field.\n :param value - a new value of 'gateway_direction' field.\n "
] |
Please provide a description of the function:def set_name(self, value):
if value is None:
self.__name = value
elif not isinstance(value, str):
raise TypeError("Name must be set to a String")
else:
self.__name = value | [
"\n Setter for 'name' field.\n :param value - a new value of 'name' field. Must be either None (name is optional according to BPMN 2.0 XML\n Schema) or String.\n "
] |
Please provide a description of the function:def set_lane_list(self, value):
if value is None or not isinstance(value, list):
raise TypeError("LaneList new value must be a list")
else:
for element in value:
if not isinstance(element, lane.Lane):
raise TypeError("LaneList elements in variable must be of Lane class")
self.__lane_list = value | [
"\n Setter for 'lane_list' field.\n :param value - a new value of 'lane_list' field. Must be a list of Lane objects\n "
] |
Please provide a description of the function:def load_diagram_from_xml(filepath, bpmn_diagram):
diagram_graph = bpmn_diagram.diagram_graph
sequence_flows = bpmn_diagram.sequence_flows
process_elements_dict = bpmn_diagram.process_elements
diagram_attributes = bpmn_diagram.diagram_attributes
plane_attributes = bpmn_diagram.plane_attributes
collaboration = bpmn_diagram.collaboration
document = BpmnDiagramGraphImport.read_xml_file(filepath)
# According to BPMN 2.0 XML Schema, there's only one 'BPMNDiagram' and 'BPMNPlane'
diagram_element = document.getElementsByTagNameNS("*", "BPMNDiagram")[0]
plane_element = diagram_element.getElementsByTagNameNS("*", "BPMNPlane")[0]
BpmnDiagramGraphImport.import_diagram_and_plane_attributes(diagram_attributes, plane_attributes,
diagram_element, plane_element)
BpmnDiagramGraphImport.import_process_elements(document, diagram_graph, sequence_flows, process_elements_dict,
plane_element)
collaboration_element_list = document.getElementsByTagNameNS("*", consts.Consts.collaboration)
if collaboration_element_list is not None and len(collaboration_element_list) > 0:
# Diagram has multiple pools and lanes
collaboration_element = collaboration_element_list[0]
BpmnDiagramGraphImport.import_collaboration_element(diagram_graph, collaboration_element, collaboration)
if consts.Consts.message_flows in collaboration:
message_flows = collaboration[consts.Consts.message_flows]
else:
message_flows = {}
participants = []
if consts.Consts.participants in collaboration:
participants = collaboration[consts.Consts.participants]
for element in utils.BpmnImportUtils.iterate_elements(plane_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.bpmn_shape:
BpmnDiagramGraphImport.import_shape_di(participants, diagram_graph, element)
elif tag_name == consts.Consts.bpmn_edge:
BpmnDiagramGraphImport.import_flow_di(diagram_graph, sequence_flows, message_flows, element) | [
"\n Reads an XML file from given filepath and maps it into inner representation of BPMN diagram.\n Returns an instance of BPMNDiagramGraph class.\n\n :param filepath: string with output filepath,\n :param bpmn_diagram: an instance of BpmnDiagramGraph class.\n "
] |
Please provide a description of the function:def import_collaboration_element(diagram_graph, collaboration_element, collaboration_dict):
collaboration_dict[consts.Consts.id] = collaboration_element.getAttribute(consts.Consts.id)
collaboration_dict[consts.Consts.participants] = {}
participants_dict = collaboration_dict[consts.Consts.participants]
collaboration_dict[consts.Consts.message_flows] = {}
message_flows_dict = collaboration_dict[consts.Consts.message_flows]
for element in utils.BpmnImportUtils.iterate_elements(collaboration_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.participant:
BpmnDiagramGraphImport.import_participant_element(diagram_graph, participants_dict, element)
elif tag_name == consts.Consts.message_flow:
BpmnDiagramGraphImport.import_message_flow_to_graph(diagram_graph, message_flows_dict, element) | [
"\n Method that imports information from 'collaboration' element.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param collaboration_element: XML doument element,\n :param collaboration_dict: dictionary, that consist all information imported from 'collaboration' element.\n Includes three key-value pairs - 'id' which keeps ID of collaboration element, 'participants' that keeps\n information about 'participant' elements and 'message_flows' that keeps information about message flows.\n "
] |
Please provide a description of the function:def import_participant_element(diagram_graph, participants_dictionary, participant_element):
participant_id = participant_element.getAttribute(consts.Consts.id)
name = participant_element.getAttribute(consts.Consts.name)
process_ref = participant_element.getAttribute(consts.Consts.process_ref)
if participant_element.getAttribute(consts.Consts.process_ref) == '':
diagram_graph.add_node(participant_id)
diagram_graph.node[participant_id][consts.Consts.type] = consts.Consts.participant
diagram_graph.node[participant_id][consts.Consts.process] = participant_id
participants_dictionary[participant_id] = {consts.Consts.name: name, consts.Consts.process_ref: process_ref} | [
"\n Adds 'participant' element to the collaboration dictionary.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param participants_dictionary: dictionary with participant element attributes. Key is participant ID, value\n is a dictionary of participant attributes,\n :param participant_element: object representing a BPMN XML 'participant' element.\n "
] |
Please provide a description of the function:def import_diagram_and_plane_attributes(diagram_attributes, plane_attributes, diagram_element, plane_element):
diagram_attributes[consts.Consts.id] = diagram_element.getAttribute(consts.Consts.id)
diagram_attributes[consts.Consts.name] = diagram_element.getAttribute(consts.Consts.name) \
if diagram_element.hasAttribute(consts.Consts.name) else ""
plane_attributes[consts.Consts.id] = plane_element.getAttribute(consts.Consts.id)
plane_attributes[consts.Consts.bpmn_element] = plane_element.getAttribute(consts.Consts.bpmn_element) | [
"\n Adds attributes of BPMN diagram and plane elements to appropriate\n fields diagram_attributes and plane_attributes.\n Diagram inner representation contains following diagram element attributes:\n\n - id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn't say so,\n - name - optional parameter, empty string by default,\n \n Diagram inner representation contains following plane element attributes:\n\n - id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn't say so,\n - bpmnElement - assumed to be required in XML file, even thought BPMN 2.0 schema doesn't say so,\n\n :param diagram_attributes: dictionary that holds attribute values for imported 'BPMNDiagram' element,\n :param plane_attributes: dictionary that holds attribute values for imported 'BPMNPlane' element,\n :param diagram_element: object representing a BPMN XML 'diagram' element,\n :param plane_element: object representing a BPMN XML 'plane' element.\n "
] |
Please provide a description of the function:def import_process_elements(document, diagram_graph, sequence_flows, process_elements_dict, plane_element):
for process_element in document.getElementsByTagNameNS("*", consts.Consts.process):
BpmnDiagramGraphImport.import_process_element(process_elements_dict, process_element)
process_id = process_element.getAttribute(consts.Consts.id)
process_attributes = process_elements_dict[process_id]
lane_set_list = process_element.getElementsByTagNameNS("*", consts.Consts.lane_set)
if lane_set_list is not None and len(lane_set_list) > 0:
# according to BPMN 2.0 XML Schema, there's at most one 'laneSet' element inside 'process'
lane_set = lane_set_list[0]
BpmnDiagramGraphImport.import_lane_set_element(process_attributes, lane_set, plane_element)
for element in utils.BpmnImportUtils.iterate_elements(process_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
BpmnDiagramGraphImport.__import_element_by_tag_name(diagram_graph, sequence_flows, process_id,
process_attributes, element, tag_name)
for flow in utils.BpmnImportUtils.iterate_elements(process_element):
if flow.nodeType != flow.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(flow.tagName)
if tag_name == consts.Consts.sequence_flow:
BpmnDiagramGraphImport.import_sequence_flow_to_graph(diagram_graph, sequence_flows, process_id,
flow) | [
"\n Method for importing all 'process' elements in diagram.\n\n :param document: XML document,\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param sequence_flows: a list of sequence flows existing in diagram,\n :param process_elements_dict: dictionary that holds attribute values for imported 'process' elements. Key is\n an ID of process, value - a dictionary of process attributes,\n :param plane_element: object representing a BPMN XML 'plane' element.\n "
] |
Please provide a description of the function:def import_lane_set_element(process_attributes, lane_set_element, plane_element):
lane_set_id = lane_set_element.getAttribute(consts.Consts.id)
lanes_attr = {}
for element in utils.BpmnImportUtils.iterate_elements(lane_set_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.lane:
lane = element
lane_id = lane.getAttribute(consts.Consts.id)
lane_attr = BpmnDiagramGraphImport.import_lane_element(lane, plane_element)
lanes_attr[lane_id] = lane_attr
lane_set_attr = {consts.Consts.id: lane_set_id, consts.Consts.lanes: lanes_attr}
process_attributes[consts.Consts.lane_set] = lane_set_attr | [
"\n Method for importing 'laneSet' element from diagram file.\n\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param lane_set_element: XML document element,\n :param plane_element: object representing a BPMN XML 'plane' element.\n "
] |
Please provide a description of the function:def import_child_lane_set_element(child_lane_set_element, plane_element):
lane_set_id = child_lane_set_element.getAttribute(consts.Consts.id)
lanes_attr = {}
for element in utils.BpmnImportUtils.iterate_elements(child_lane_set_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.lane:
lane = element
lane_id = lane.getAttribute(consts.Consts.id)
lane_attr = BpmnDiagramGraphImport.import_lane_element(lane, plane_element)
lanes_attr[lane_id] = lane_attr
child_lane_set_attr = {consts.Consts.id: lane_set_id, consts.Consts.lanes: lanes_attr}
return child_lane_set_attr | [
"\n Method for importing 'childLaneSet' element from diagram file.\n\n :param child_lane_set_element: XML document element,\n :param plane_element: object representing a BPMN XML 'plane' element.\n "
] |
Please provide a description of the function:def import_lane_element(lane_element, plane_element):
lane_id = lane_element.getAttribute(consts.Consts.id)
lane_name = lane_element.getAttribute(consts.Consts.name)
child_lane_set_attr = {}
flow_node_refs = []
for element in utils.BpmnImportUtils.iterate_elements(lane_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.child_lane_set:
child_lane_set_attr = BpmnDiagramGraphImport.import_child_lane_set_element(element, plane_element)
elif tag_name == consts.Consts.flow_node_ref:
flow_node_ref_id = element.firstChild.nodeValue
flow_node_refs.append(flow_node_ref_id)
lane_attr = {consts.Consts.id: lane_id, consts.Consts.name: lane_name,
consts.Consts.child_lane_set: child_lane_set_attr,
consts.Consts.flow_node_refs: flow_node_refs}
shape_element = None
for element in utils.BpmnImportUtils.iterate_elements(plane_element):
if element.nodeType != element.TEXT_NODE and element.getAttribute(consts.Consts.bpmn_element) == lane_id:
shape_element = element
if shape_element is not None:
bounds = shape_element.getElementsByTagNameNS("*", "Bounds")[0]
lane_attr[consts.Consts.is_horizontal] = shape_element.getAttribute(consts.Consts.is_horizontal)
lane_attr[consts.Consts.width] = bounds.getAttribute(consts.Consts.width)
lane_attr[consts.Consts.height] = bounds.getAttribute(consts.Consts.height)
lane_attr[consts.Consts.x] = bounds.getAttribute(consts.Consts.x)
lane_attr[consts.Consts.y] = bounds.getAttribute(consts.Consts.y)
return lane_attr | [
"\n Method for importing 'laneSet' element from diagram file.\n\n :param lane_element: XML document element,\n :param plane_element: object representing a BPMN XML 'plane' element.\n "
] |
Please provide a description of the function:def import_process_element(process_elements_dict, process_element):
process_id = process_element.getAttribute(consts.Consts.id)
process_element_attributes = {consts.Consts.id: process_element.getAttribute(consts.Consts.id),
consts.Consts.name: process_element.getAttribute(consts.Consts.name)
if process_element.hasAttribute(consts.Consts.name) else "",
consts.Consts.is_closed: process_element.getAttribute(consts.Consts.is_closed)
if process_element.hasAttribute(consts.Consts.is_closed) else "false",
consts.Consts.is_executable: process_element.getAttribute(
consts.Consts.is_executable)
if process_element.hasAttribute(consts.Consts.is_executable) else "false",
consts.Consts.process_type: process_element.getAttribute(
consts.Consts.process_type)
if process_element.hasAttribute(consts.Consts.process_type) else "None",
consts.Consts.node_ids: []}
process_elements_dict[process_id] = process_element_attributes | [
"\n Adds attributes of BPMN process element to appropriate field process_attributes.\n Diagram inner representation contains following process attributes:\n\n - id - assumed to be required in XML file, even thought BPMN 2.0 schema doesn't say so,\n - isClosed - optional parameter, default value 'false',\n - isExecutable - optional parameter, default value 'false',\n - processType - optional parameter, default value 'None',\n - node_ids - list of flow nodes IDs, associated with given process.\n\n :param process_elements_dict: dictionary that holds attribute values for imported 'process' element. Key is\n process ID, value is a dictionary of attributes,\n :param process_element: object representing a BPMN XML 'process' element.\n "
] |
Please provide a description of the function:def import_flow_node_to_graph(bpmn_graph, process_id, process_attributes, flow_node_element):
element_id = flow_node_element.getAttribute(consts.Consts.id)
bpmn_graph.add_node(element_id)
bpmn_graph.node[element_id][consts.Consts.id] = element_id
bpmn_graph.node[element_id][consts.Consts.type] = \
utils.BpmnImportUtils.remove_namespace_from_tag_name(flow_node_element.tagName)
bpmn_graph.node[element_id][consts.Consts.node_name] = \
flow_node_element.getAttribute(consts.Consts.name) \
if flow_node_element.hasAttribute(consts.Consts.name) \
else ""
bpmn_graph.node[element_id][consts.Consts.process] = process_id
process_attributes[consts.Consts.node_ids].append(element_id)
# add incoming flow node list
incoming_list = []
for tmp_element in utils.BpmnImportUtils.iterate_elements(flow_node_element):
if tmp_element.nodeType != tmp_element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(tmp_element.tagName)
if tag_name == consts.Consts.incoming_flow:
incoming_value = tmp_element.firstChild.nodeValue
incoming_list.append(incoming_value)
bpmn_graph.node[element_id][consts.Consts.incoming_flow] = incoming_list
# add outgoing flow node list
outgoing_list = []
for tmp_element in utils.BpmnImportUtils.iterate_elements(flow_node_element):
if tmp_element.nodeType != tmp_element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(tmp_element.tagName)
if tag_name == consts.Consts.outgoing_flow:
outgoing_value = tmp_element.firstChild.nodeValue
outgoing_list.append(outgoing_value)
bpmn_graph.node[element_id][consts.Consts.outgoing_flow] = outgoing_list | [
"\n Adds a new node to graph.\n Input parameter is object of class xml.dom.Element.\n Nodes are identified by ID attribute of Element.\n Method adds basic attributes (shared by all BPMN elements) to node. Those elements are:\n\n - id - added as key value, we assume that this is a required value,\n - type - tagName of element, used to identify type of BPMN diagram element,\n - name - optional attribute, empty string by default.\n\n :param bpmn_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param flow_node_element: object representing a BPMN XML element corresponding to given flownode,\n "
] |
Please provide a description of the function:def import_task_to_graph(diagram_graph, process_id, process_attributes, task_element):
BpmnDiagramGraphImport.import_activity_to_graph(diagram_graph, process_id, process_attributes, task_element) | [
"\n Adds to graph the new element that represents BPMN task.\n In our representation tasks have only basic attributes and elements, inherited from Activity type,\n so this method only needs to call add_flownode_to_graph.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param task_element: object representing a BPMN XML 'task' element.\n "
] |
Please provide a description of the function:def import_subprocess_to_graph(diagram_graph, sequence_flows, process_id, process_attributes, subprocess_element):
BpmnDiagramGraphImport.import_activity_to_graph(diagram_graph, process_id, process_attributes,
subprocess_element)
subprocess_id = subprocess_element.getAttribute(consts.Consts.id)
diagram_graph.node[subprocess_id][consts.Consts.triggered_by_event] = \
subprocess_element.getAttribute(consts.Consts.triggered_by_event) \
if subprocess_element.hasAttribute(consts.Consts.triggered_by_event) else "false"
subprocess_attributes = diagram_graph.node[subprocess_id]
subprocess_attributes[consts.Consts.node_ids] = []
for element in utils.BpmnImportUtils.iterate_elements(subprocess_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
BpmnDiagramGraphImport.__import_element_by_tag_name(diagram_graph, sequence_flows, subprocess_id,
subprocess_attributes, element, tag_name)
for flow in utils.BpmnImportUtils.iterate_elements(subprocess_element):
if flow.nodeType != flow.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(flow.tagName)
if tag_name == consts.Consts.sequence_flow:
BpmnDiagramGraphImport.import_sequence_flow_to_graph(diagram_graph, sequence_flows, subprocess_id,
flow) | [
"\n Adds to graph the new element that represents BPMN subprocess.\n In addition to attributes inherited from FlowNode type, SubProcess\n has additional attribute tiggeredByEvent (boolean type, default value - false).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param sequence_flows: a list of sequence flows existing in diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param subprocess_element: object representing a BPMN XML 'subprocess' element\n "
] |
Please provide a description of the function:def import_data_object_to_graph(diagram_graph, process_id, process_attributes, data_object_element):
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes,
data_object_element)
data_object_id = data_object_element.getAttribute(consts.Consts.id)
diagram_graph.node[data_object_id][consts.Consts.is_collection] = \
data_object_element.getAttribute(consts.Consts.is_collection) \
if data_object_element.hasAttribute(consts.Consts.is_collection) else "false" | [
"\n Adds to graph the new element that represents BPMN data object.\n Data object inherits attributes from FlowNode. In addition, an attribute 'isCollection' is added to the node.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param data_object_element: object representing a BPMN XML 'dataObject' element.\n "
] |
Please provide a description of the function:def import_activity_to_graph(diagram_graph, process_id, process_attributes, element):
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
element_id = element.getAttribute(consts.Consts.id)
diagram_graph.node[element_id][consts.Consts.default] = element.getAttribute(consts.Consts.default) \
if element.hasAttribute(consts.Consts.default) else None | [
"\n Method that adds the new element that represents BPMN activity.\n Should not be used directly, only as a part of method, that imports an element which extends Activity element\n (task, subprocess etc.)\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML element which extends 'activity'.\n "
] |
Please provide a description of the function:def import_gateway_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.gateway_direction] = \
element.getAttribute(consts.Consts.gateway_direction) \
if element.hasAttribute(consts.Consts.gateway_direction) else "Unspecified" | [
"\n Adds to graph the new element that represents BPMN gateway.\n In addition to attributes inherited from FlowNode type, Gateway\n has additional attribute gatewayDirection (simple type, default value - Unspecified).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML element of Gateway type extension.\n "
] |
Please provide a description of the function:def import_complex_gateway_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
BpmnDiagramGraphImport.import_gateway_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.default] = element.getAttribute(consts.Consts.default) \
if element.hasAttribute(consts.Consts.default) else None | [
"\n Adds to graph the new element that represents BPMN complex gateway.\n In addition to attributes inherited from Gateway type, complex gateway\n has additional attribute default flow (default value - none).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'complexGateway' element.\n "
] |
Please provide a description of the function:def import_event_based_gateway_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
BpmnDiagramGraphImport.import_gateway_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.instantiate] = element.getAttribute(consts.Consts.instantiate) \
if element.hasAttribute(consts.Consts.instantiate) else "false"
diagram_graph.node[element_id][consts.Consts.event_gateway_type] = \
element.getAttribute(consts.Consts.event_gateway_type) \
if element.hasAttribute(consts.Consts.event_gateway_type) else "Exclusive" | [
"\n Adds to graph the new element that represents BPMN event based gateway.\n In addition to attributes inherited from Gateway type, event based gateway has additional\n attributes - instantiate (boolean type, default value - false) and eventGatewayType\n (custom type tEventBasedGatewayType, default value - Exclusive).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'eventBasedGateway' element.\n "
] |
Please provide a description of the function:def import_parallel_gateway_to_graph(diagram_graph, process_id, process_attributes, element):
BpmnDiagramGraphImport.import_gateway_to_graph(diagram_graph, process_id, process_attributes, element) | [
"\n Adds to graph the new element that represents BPMN parallel gateway.\n Parallel gateway doesn't have additional attributes. Separate method is used to improve code readability.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'parallelGateway'.\n "
] |
Please provide a description of the function:def import_event_definition_elements(diagram_graph, element, event_definitions):
element_id = element.getAttribute(consts.Consts.id)
event_def_list = []
for definition_type in event_definitions:
event_def_xml = element.getElementsByTagNameNS("*", definition_type)
for index in range(len(event_def_xml)):
# tuple - definition type, definition id
event_def_tmp = {consts.Consts.id: event_def_xml[index].getAttribute(consts.Consts.id),
consts.Consts.definition_type: definition_type}
event_def_list.append(event_def_tmp)
diagram_graph.node[element_id][consts.Consts.event_definitions] = event_def_list | [
"\n Helper function, that adds event definition elements (defines special types of events) to corresponding events.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param element: object representing a BPMN XML event element,\n :param event_definitions: list of event definitions, that belongs to given event.\n "
] |
Please provide a description of the function:def import_start_event_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
start_event_definitions = {'messageEventDefinition', 'timerEventDefinition', 'conditionalEventDefinition',
'escalationEventDefinition', 'signalEventDefinition'}
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.parallel_multiple] = \
element.getAttribute(consts.Consts.parallel_multiple) \
if element.hasAttribute(consts.Consts.parallel_multiple) else "false"
diagram_graph.node[element_id][consts.Consts.is_interrupting] = \
element.getAttribute(consts.Consts.is_interrupting) \
if element.hasAttribute(consts.Consts.is_interrupting) else "true"
BpmnDiagramGraphImport.import_event_definition_elements(diagram_graph, element, start_event_definitions) | [
"\n Adds to graph the new element that represents BPMN start event.\n Start event inherits attribute parallelMultiple from CatchEvent type\n and sequence of eventDefinitionRef from Event type.\n Separate methods for each event type are required since each of them has different variants\n (Message, Error, Signal etc.).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'startEvent' element.\n "
] |
Please provide a description of the function:def import_intermediate_catch_event_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
intermediate_catch_event_definitions = {'messageEventDefinition', 'timerEventDefinition',
'signalEventDefinition', 'conditionalEventDefinition',
'escalationEventDefinition'}
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.parallel_multiple] = \
element.getAttribute(consts.Consts.parallel_multiple) \
if element.hasAttribute(consts.Consts.parallel_multiple) else "false"
BpmnDiagramGraphImport.import_event_definition_elements(diagram_graph, element,
intermediate_catch_event_definitions) | [
"\n Adds to graph the new element that represents BPMN intermediate catch event.\n Intermediate catch event inherits attribute parallelMultiple from CatchEvent type\n and sequence of eventDefinitionRef from Event type.\n Separate methods for each event type are required since each of them has different variants\n (Message, Error, Signal etc.).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'intermediateCatchEvent' element.\n "
] |
Please provide a description of the function:def import_end_event_to_graph(diagram_graph, process_id, process_attributes, element):
end_event_definitions = {'messageEventDefinition', 'signalEventDefinition', 'escalationEventDefinition',
'errorEventDefinition', 'compensateEventDefinition', 'terminateEventDefinition'}
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
BpmnDiagramGraphImport.import_event_definition_elements(diagram_graph, element, end_event_definitions) | [
"\n Adds to graph the new element that represents BPMN end event.\n End event inherits sequence of eventDefinitionRef from Event type.\n Separate methods for each event type are required since each of them has different variants\n (Message, Error, Signal etc.).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'endEvent' element.\n "
] |
Please provide a description of the function:def import_intermediate_throw_event_to_graph(diagram_graph, process_id, process_attributes, element):
intermediate_throw_event_definitions = {'messageEventDefinition', 'signalEventDefinition',
'escalationEventDefinition', 'compensateEventDefinition'}
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
BpmnDiagramGraphImport.import_event_definition_elements(diagram_graph, element,
intermediate_throw_event_definitions) | [
"\n Adds to graph the new element that represents BPMN intermediate throw event.\n Intermediate throw event inherits sequence of eventDefinitionRef from Event type.\n Separate methods for each event type are required since each of them has different variants\n (Message, Error, Signal etc.).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'intermediateThrowEvent' element.\n "
] |
Please provide a description of the function:def import_boundary_event_to_graph(diagram_graph, process_id, process_attributes, element):
element_id = element.getAttribute(consts.Consts.id)
boundary_event_definitions = {'messageEventDefinition', 'timerEventDefinition', 'signalEventDefinition',
'conditionalEventDefinition', 'escalationEventDefinition', 'errorEventDefinition'}
BpmnDiagramGraphImport.import_flow_node_to_graph(diagram_graph, process_id, process_attributes, element)
diagram_graph.node[element_id][consts.Consts.parallel_multiple] = \
element.getAttribute(consts.Consts.parallel_multiple) \
if element.hasAttribute(consts.Consts.parallel_multiple) else "false"
diagram_graph.node[element_id][consts.Consts.cancel_activity] = \
element.getAttribute(consts.Consts.cancel_activity) \
if element.hasAttribute(consts.Consts.cancel_activity) else "true"
diagram_graph.node[element_id][consts.Consts.attached_to_ref] = \
element.getAttribute(consts.Consts.attached_to_ref)
BpmnDiagramGraphImport.import_event_definition_elements(diagram_graph, element,
boundary_event_definitions) | [
"\n Adds to graph the new element that represents BPMN boundary event.\n Boundary event inherits sequence of eventDefinitionRef from Event type.\n Separate methods for each event type are required since each of them has different variants\n (Message, Error, Signal etc.).\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param process_id: string object, representing an ID of process element,\n :param process_attributes: dictionary that holds attribute values of 'process' element, which is parent of\n imported flow node,\n :param element: object representing a BPMN XML 'endEvent' element.\n "
] |
Please provide a description of the function:def import_sequence_flow_to_graph(diagram_graph, sequence_flows, process_id, flow_element):
flow_id = flow_element.getAttribute(consts.Consts.id)
name = flow_element.getAttribute(consts.Consts.name) if flow_element.hasAttribute(consts.Consts.name) else ""
source_ref = flow_element.getAttribute(consts.Consts.source_ref)
target_ref = flow_element.getAttribute(consts.Consts.target_ref)
sequence_flows[flow_id] = {consts.Consts.name: name, consts.Consts.source_ref: source_ref,
consts.Consts.target_ref: target_ref}
diagram_graph.add_edge(source_ref, target_ref)
diagram_graph[source_ref][target_ref][consts.Consts.id] = flow_id
diagram_graph[source_ref][target_ref][consts.Consts.process] = process_id
diagram_graph[source_ref][target_ref][consts.Consts.name] = name
diagram_graph[source_ref][target_ref][consts.Consts.source_ref] = source_ref
diagram_graph[source_ref][target_ref][consts.Consts.target_ref] = target_ref
for element in utils.BpmnImportUtils.iterate_elements(flow_element):
if element.nodeType != element.TEXT_NODE:
tag_name = utils.BpmnImportUtils.remove_namespace_from_tag_name(element.tagName)
if tag_name == consts.Consts.condition_expression:
condition_expression = element.firstChild.nodeValue
diagram_graph[source_ref][target_ref][consts.Consts.condition_expression] = {
consts.Consts.id: element.getAttribute(consts.Consts.id),
consts.Consts.condition_expression: condition_expression
}
'''
# Add incoming / outgoing nodes to corresponding elements. May be redundant action since this information is
added when processing nodes, but listing incoming / outgoing nodes under node element is optional - this way
we can make sure this info will be imported.
'''
if consts.Consts.outgoing_flow not in diagram_graph.node[source_ref]:
diagram_graph.node[source_ref][consts.Consts.outgoing_flow] = []
outgoing_list = diagram_graph.node[source_ref][consts.Consts.outgoing_flow]
if flow_id not in outgoing_list:
outgoing_list.append(flow_id)
if consts.Consts.incoming_flow not in diagram_graph.node[target_ref]:
diagram_graph.node[target_ref][consts.Consts.incoming_flow] = []
incoming_list = diagram_graph.node[target_ref][consts.Consts.incoming_flow]
if flow_id not in incoming_list:
incoming_list.append(flow_id) | [
"\n Adds a new edge to graph and a record to sequence_flows dictionary.\n Input parameter is object of class xml.dom.Element.\n Edges are identified by pair of sourceRef and targetRef attributes of BPMNFlow element. We also\n provide a dictionary, that maps sequenceFlow ID attribute with its sourceRef and targetRef.\n Method adds basic attributes of sequenceFlow element to edge. Those elements are:\n\n - id - added as edge attribute, we assume that this is a required value,\n - name - optional attribute, empty string by default.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param sequence_flows: dictionary (associative list) of sequence flows existing in diagram.\n Key attribute is sequenceFlow ID, value is a dictionary consisting three key-value pairs: \"name\" (sequence\n flow name), \"sourceRef\" (ID of node, that is a flow source) and \"targetRef\" (ID of node, that is a flow target),\n :param process_id: string object, representing an ID of process element,\n :param flow_element: object representing a BPMN XML 'sequenceFlow' element.\n "
] |
Please provide a description of the function:def import_message_flow_to_graph(diagram_graph, message_flows, flow_element):
flow_id = flow_element.getAttribute(consts.Consts.id)
name = flow_element.getAttribute(consts.Consts.name) if flow_element.hasAttribute(consts.Consts.name) else ""
source_ref = flow_element.getAttribute(consts.Consts.source_ref)
target_ref = flow_element.getAttribute(consts.Consts.target_ref)
message_flows[flow_id] = {consts.Consts.id: flow_id, consts.Consts.name: name,
consts.Consts.source_ref: source_ref,
consts.Consts.target_ref: target_ref}
diagram_graph.add_edge(source_ref, target_ref)
diagram_graph[source_ref][target_ref][consts.Consts.id] = flow_id
diagram_graph[source_ref][target_ref][consts.Consts.name] = name
diagram_graph[source_ref][target_ref][consts.Consts.source_ref] = source_ref
diagram_graph[source_ref][target_ref][consts.Consts.target_ref] = target_ref
'''
# Add incoming / outgoing nodes to corresponding elements. May be redundant action since this information is
added when processing nodes, but listing incoming / outgoing nodes under node element is optional - this way
we can make sure this info will be imported.
'''
if consts.Consts.outgoing_flow not in diagram_graph.node[source_ref]:
diagram_graph.node[source_ref][consts.Consts.outgoing_flow] = []
outgoing_list = diagram_graph.node[source_ref][consts.Consts.outgoing_flow]
if flow_id not in outgoing_list:
outgoing_list.append(flow_id)
if consts.Consts.incoming_flow not in diagram_graph.node[target_ref]:
diagram_graph.node[target_ref][consts.Consts.incoming_flow] = []
incoming_list = diagram_graph.node[target_ref][consts.Consts.incoming_flow]
if flow_id not in incoming_list:
incoming_list.append(flow_id) | [
"\n Adds a new edge to graph and a record to message flows dictionary.\n Input parameter is object of class xml.dom.Element.\n Edges are identified by pair of sourceRef and targetRef attributes of BPMNFlow element. We also\n provide a dictionary, that maps messageFlow ID attribute with its sourceRef and targetRef.\n Method adds basic attributes of messageFlow element to edge. Those elements are:\n\n - id - added as edge attribute, we assume that this is a required value,\n - name - optional attribute, empty string by default.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param message_flows: dictionary (associative list) of message flows existing in diagram.\n Key attribute is messageFlow ID, value is a dictionary consisting three key-value pairs: \"name\" (message\n flow name), \"sourceRef\" (ID of node, that is a flow source) and \"targetRef\" (ID of node, that is a flow target),\n :param flow_element: object representing a BPMN XML 'messageFlow' element.\n "
] |
Please provide a description of the function:def import_shape_di(participants_dict, diagram_graph, shape_element):
element_id = shape_element.getAttribute(consts.Consts.bpmn_element)
bounds = shape_element.getElementsByTagNameNS("*", "Bounds")[0]
if diagram_graph.has_node(element_id):
node = diagram_graph.node[element_id]
node[consts.Consts.width] = bounds.getAttribute(consts.Consts.width)
node[consts.Consts.height] = bounds.getAttribute(consts.Consts.height)
if node[consts.Consts.type] == consts.Consts.subprocess:
node[consts.Consts.is_expanded] = \
shape_element.getAttribute(consts.Consts.is_expanded) \
if shape_element.hasAttribute(consts.Consts.is_expanded) else "false"
node[consts.Consts.x] = bounds.getAttribute(consts.Consts.x)
node[consts.Consts.y] = bounds.getAttribute(consts.Consts.y)
if element_id in participants_dict:
# BPMNShape is either connected with FlowNode or Participant
participant_attr = participants_dict[element_id]
participant_attr[consts.Consts.is_horizontal] = shape_element.getAttribute(consts.Consts.is_horizontal)
participant_attr[consts.Consts.width] = bounds.getAttribute(consts.Consts.width)
participant_attr[consts.Consts.height] = bounds.getAttribute(consts.Consts.height)
participant_attr[consts.Consts.x] = bounds.getAttribute(consts.Consts.x)
participant_attr[consts.Consts.y] = bounds.getAttribute(consts.Consts.y) | [
"\n Adds Diagram Interchange information (information about rendering a diagram) to appropriate\n BPMN diagram element in graph node.\n We assume that those attributes are required for each BPMNShape:\n\n - width - width of BPMNShape,\n - height - height of BPMNShape,\n - x - first coordinate of BPMNShape,\n - y - second coordinate of BPMNShape.\n\n :param participants_dict: dictionary with 'participant' elements attributes,\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param shape_element: object representing a BPMN XML 'BPMNShape' element.\n "
] |
Please provide a description of the function:def import_flow_di(diagram_graph, sequence_flows, message_flows, flow_element):
flow_id = flow_element.getAttribute(consts.Consts.bpmn_element)
waypoints_xml = flow_element.getElementsByTagNameNS("*", consts.Consts.waypoint)
length = len(waypoints_xml)
waypoints = [None] * length
for index in range(length):
waypoint_tmp = (waypoints_xml[index].getAttribute(consts.Consts.x),
waypoints_xml[index].getAttribute(consts.Consts.y))
waypoints[index] = waypoint_tmp
flow_data = None
if flow_id in sequence_flows:
flow_data = sequence_flows[flow_id]
elif flow_id in message_flows:
flow_data = message_flows[flow_id]
if flow_data is not None:
name = flow_data[consts.Consts.name]
source_ref = flow_data[consts.Consts.source_ref]
target_ref = flow_data[consts.Consts.target_ref]
diagram_graph[source_ref][target_ref][consts.Consts.waypoints] = waypoints
diagram_graph[source_ref][target_ref][consts.Consts.name] = name | [
"\n Adds Diagram Interchange information (information about rendering a diagram) to appropriate\n BPMN sequence flow represented as graph edge.\n We assume that each BPMNEdge has a list of 'waypoint' elements. BPMN 2.0 XML Schema states,\n that each BPMNEdge must have at least two waypoints.\n\n :param diagram_graph: NetworkX graph representing a BPMN process diagram,\n :param sequence_flows: dictionary (associative list) of sequence flows existing in diagram.\n Key attribute is sequenceFlow ID, value is a dictionary consisting three key-value pairs: \"name\" (sequence\n flow name), \"sourceRef\" (ID of node, that is a flow source) and \"targetRef\" (ID of node, that is a flow target),\n :param message_flows: dictionary (associative list) of message flows existing in diagram.\n Key attribute is messageFlow ID, value is a dictionary consisting three key-value pairs: \"name\" (message\n flow name), \"sourceRef\" (ID of node, that is a flow source) and \"targetRef\" (ID of node, that is a flow target),\n :param flow_element: object representing a BPMN XML 'BPMNEdge' element.\n "
] |
Please provide a description of the function:def generate_layout(bpmn_graph):
classification = generate_elements_clasification(bpmn_graph)
(sorted_nodes_with_classification, backward_flows) = topological_sort(bpmn_graph, classification[0])
grid = grid_layout(bpmn_graph, sorted_nodes_with_classification)
set_coordinates_for_nodes(bpmn_graph, grid)
set_flows_waypoints(bpmn_graph) | [
"\n :param bpmn_graph: an instance of BPMNDiagramGraph class.\n "
] |
Please provide a description of the function:def generate_elements_clasification(bpmn_graph):
nodes_classification = []
node_param_name = "node"
flow_param_name = "flow"
classification_param_name = "classification"
classification_element = "Element"
classification_join = "Join"
classification_split = "Split"
classification_start_event = "Start Event"
classification_end_event = "End Event"
task_list = bpmn_graph.get_nodes(consts.Consts.task)
for element in task_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
subprocess_list = bpmn_graph.get_nodes(consts.Consts.subprocess)
for element in subprocess_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
complex_gateway_list = bpmn_graph.get_nodes(consts.Consts.complex_gateway)
for element in complex_gateway_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
event_based_gateway_list = bpmn_graph.get_nodes(consts.Consts.event_based_gateway)
for element in event_based_gateway_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
inclusive_gateway_list = bpmn_graph.get_nodes(consts.Consts.inclusive_gateway)
for element in inclusive_gateway_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
exclusive_gateway_list = bpmn_graph.get_nodes(consts.Consts.exclusive_gateway)
for element in exclusive_gateway_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
parallel_gateway_list = bpmn_graph.get_nodes(consts.Consts.parallel_gateway)
for element in parallel_gateway_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
start_event_list = bpmn_graph.get_nodes(consts.Consts.start_event)
for element in start_event_list:
tmp = [classification_element, classification_start_event]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
intermediate_catch_event_list = bpmn_graph.get_nodes(consts.Consts.intermediate_catch_event)
for element in intermediate_catch_event_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
end_event_list = bpmn_graph.get_nodes(consts.Consts.end_event)
for element in end_event_list:
tmp = [classification_element, classification_end_event]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
intermediate_throw_event_list = bpmn_graph.get_nodes(consts.Consts.intermediate_throw_event)
for element in intermediate_throw_event_list:
tmp = [classification_element]
if len(element[1][consts.Consts.incoming_flow]) >= 2:
tmp.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
tmp.append(classification_split)
nodes_classification += [{node_param_name: element, classification_param_name: tmp}]
flows_classification = []
flows_list = bpmn_graph.get_flows()
for flow in flows_list:
flows_classification += [{flow_param_name: flow, classification_param_name: ["Flow"]}]
return nodes_classification, flows_classification | [
"\n :param bpmn_graph:\n :return:\n "
] |
Please provide a description of the function:def topological_sort(bpmn_graph, nodes_with_classification):
node_param_name = "node"
classification_param_name = "classification"
tmp_nodes_with_classification = copy.deepcopy(nodes_with_classification)
sorted_nodes_with_classification = []
no_incoming_flow_nodes = []
backward_flows = []
while tmp_nodes_with_classification:
for node_with_classification in tmp_nodes_with_classification:
incoming_list = node_with_classification[node_param_name][1][consts.Consts.incoming_flow]
if len(incoming_list) == 0:
no_incoming_flow_nodes.append(node_with_classification)
if len(no_incoming_flow_nodes) > 0:
while len(no_incoming_flow_nodes) > 0:
node_with_classification = no_incoming_flow_nodes.pop()
tmp_nodes_with_classification.remove(node_with_classification)
sorted_nodes_with_classification \
.append(next(tmp_node for tmp_node in nodes_with_classification
if tmp_node[node_param_name][0] == node_with_classification[node_param_name][0]))
outgoing_list = list(node_with_classification[node_param_name][1][consts.Consts.outgoing_flow])
tmp_outgoing_list = list(outgoing_list)
for flow_id in tmp_outgoing_list:
'''
- Remove the outgoing flow for source flow node (the one without incoming flows)
- Get the target node
- Remove the incoming flow for target flow node
'''
outgoing_list.remove(flow_id)
node_with_classification[node_param_name][1][consts.Consts.outgoing_flow].remove(flow_id)
flow = bpmn_graph.get_flow_by_id(flow_id)
target_id = flow[2][consts.Consts.target_ref]
target = next(tmp_node[node_param_name]
for tmp_node in tmp_nodes_with_classification
if tmp_node[node_param_name][0] == target_id)
target[1][consts.Consts.incoming_flow].remove(flow_id)
else:
for node_with_classification in tmp_nodes_with_classification:
if "Join" in node_with_classification[classification_param_name]:
incoming_list = list(node_with_classification[node_param_name][1][consts.Consts.incoming_flow])
tmp_incoming_list = list(incoming_list)
for flow_id in tmp_incoming_list:
incoming_list.remove(flow_id)
flow = bpmn_graph.get_flow_by_id(flow_id)
source_id = flow[2][consts.Consts.source_ref]
source = next(tmp_node[node_param_name]
for tmp_node in tmp_nodes_with_classification
if tmp_node[node_param_name][0] == source_id)
source[1][consts.Consts.outgoing_flow].remove(flow_id)
target_id = flow[2][consts.Consts.target_ref]
target = next(tmp_node[node_param_name]
for tmp_node in tmp_nodes_with_classification
if tmp_node[node_param_name][0] == target_id)
target[1][consts.Consts.incoming_flow].remove(flow_id)
backward_flows.append(flow)
return sorted_nodes_with_classification, backward_flows | [
"\n :return:\n "
] |
Please provide a description of the function:def export_task_info(node_params, output_element):
if consts.Consts.default in node_params and node_params[consts.Consts.default] is not None:
output_element.set(consts.Consts.default, node_params[consts.Consts.default]) | [
"\n Adds Task node attributes to exported XML element\n\n :param node_params: dictionary with given task parameters,\n :param output_element: object representing BPMN XML 'task' element.\n "
] |
Please provide a description of the function:def export_subprocess_info(bpmn_diagram, subprocess_params, output_element):
output_element.set(consts.Consts.triggered_by_event, subprocess_params[consts.Consts.triggered_by_event])
if consts.Consts.default in subprocess_params and subprocess_params[consts.Consts.default] is not None:
output_element.set(consts.Consts.default, subprocess_params[consts.Consts.default])
# for each node in graph add correct type of element, its attributes and BPMNShape element
subprocess_id = subprocess_params[consts.Consts.id]
nodes = bpmn_diagram.get_nodes_list_by_process_id(subprocess_id)
for node in nodes:
node_id = node[0]
params = node[1]
BpmnDiagramGraphExport.export_node_data(bpmn_diagram, node_id, params, output_element)
# for each edge in graph add sequence flow element, its attributes and BPMNEdge element
flows = bpmn_diagram.get_flows_list_by_process_id(subprocess_id)
for flow in flows:
params = flow[2]
BpmnDiagramGraphExport.export_flow_process_data(params, output_element) | [
"\n Adds Subprocess node attributes to exported XML element\n\n :param bpmn_diagram: BPMNDiagramGraph class instantion representing a BPMN process diagram,\n :param subprocess_params: dictionary with given subprocess parameters,\n :param output_element: object representing BPMN XML 'subprocess' element.\n "
] |
Please provide a description of the function:def export_data_object_info(bpmn_diagram, data_object_params, output_element):
output_element.set(consts.Consts.is_collection, data_object_params[consts.Consts.is_collection]) | [
"\n Adds DataObject node attributes to exported XML element\n\n :param bpmn_diagram: BPMNDiagramGraph class instantion representing a BPMN process diagram,\n :param data_object_params: dictionary with given subprocess parameters,\n :param output_element: object representing BPMN XML 'subprocess' element.\n "
] |
Please provide a description of the function:def export_complex_gateway_info(node_params, output_element):
output_element.set(consts.Consts.gateway_direction, node_params[consts.Consts.gateway_direction])
if consts.Consts.default in node_params and node_params[consts.Consts.default] is not None:
output_element.set(consts.Consts.default, node_params[consts.Consts.default]) | [
"\n Adds ComplexGateway node attributes to exported XML element\n\n :param node_params: dictionary with given complex gateway parameters,\n :param output_element: object representing BPMN XML 'complexGateway' element.\n "
] |
Please provide a description of the function:def export_event_based_gateway_info(node_params, output_element):
output_element.set(consts.Consts.gateway_direction, node_params[consts.Consts.gateway_direction])
output_element.set(consts.Consts.instantiate, node_params[consts.Consts.instantiate])
output_element.set(consts.Consts.event_gateway_type, node_params[consts.Consts.event_gateway_type]) | [
"\n Adds EventBasedGateway node attributes to exported XML element\n\n :param node_params: dictionary with given event based gateway parameters,\n :param output_element: object representing BPMN XML 'eventBasedGateway' element.\n "
] |
Please provide a description of the function:def export_inclusive_exclusive_gateway_info(node_params, output_element):
output_element.set(consts.Consts.gateway_direction, node_params[consts.Consts.gateway_direction])
if consts.Consts.default in node_params and node_params[consts.Consts.default] is not None:
output_element.set(consts.Consts.default, node_params[consts.Consts.default]) | [
"\n Adds InclusiveGateway or ExclusiveGateway node attributes to exported XML element\n\n :param node_params: dictionary with given inclusive or exclusive gateway parameters,\n :param output_element: object representing BPMN XML 'inclusiveGateway'/'exclusive' element.\n "
] |
Please provide a description of the function:def export_parallel_gateway_info(node_params, output_element):
output_element.set(consts.Consts.gateway_direction, node_params[consts.Consts.gateway_direction]) | [
"\n Adds parallel gateway node attributes to exported XML element\n\n :param node_params: dictionary with given parallel gateway parameters,\n :param output_element: object representing BPMN XML 'parallelGateway' element.\n "
] |
Please provide a description of the function:def export_start_event_info(node_params, output_element):
output_element.set(consts.Consts.parallel_multiple, node_params.get(consts.Consts.parallel_multiple))
output_element.set(consts.Consts.is_interrupting, node_params.get(consts.Consts.is_interrupting))
definitions = node_params.get(consts.Consts.event_definitions)
for definition in definitions:
definition_id = definition[consts.Consts.id]
definition_type = definition[consts.Consts.definition_type]
output_definition = eTree.SubElement(output_element, definition_type)
if definition_id != "":
output_definition.set(consts.Consts.id, definition_id) | [
"\n Adds StartEvent attributes to exported XML element\n\n :param node_params: dictionary with given intermediate catch event parameters,\n :param output_element: object representing BPMN XML 'intermediateCatchEvent' element.\n "
] |
Please provide a description of the function:def export_throw_event_info(node_params, output_element):
definitions = node_params[consts.Consts.event_definitions]
for definition in definitions:
definition_id = definition[consts.Consts.id]
definition_type = definition[consts.Consts.definition_type]
output_definition = eTree.SubElement(output_element, definition_type)
if definition_id != "":
output_definition.set(consts.Consts.id, definition_id) | [
"\n Adds EndEvent or IntermediateThrowingEvent attributes to exported XML element\n\n :param node_params: dictionary with given intermediate throw event parameters,\n :param output_element: object representing BPMN XML 'intermediateThrowEvent' element.\n "
] |
Please provide a description of the function:def export_boundary_event_info(node_params, output_element):
output_element.set(consts.Consts.parallel_multiple, node_params[consts.Consts.parallel_multiple])
output_element.set(consts.Consts.cancel_activity, node_params[consts.Consts.cancel_activity])
output_element.set(consts.Consts.attached_to_ref, node_params[consts.Consts.attached_to_ref])
definitions = node_params[consts.Consts.event_definitions]
for definition in definitions:
definition_id = definition[consts.Consts.id]
definition_type = definition[consts.Consts.definition_type]
output_definition = eTree.SubElement(output_element, definition_type)
if definition_id != "":
output_definition.set(consts.Consts.id, definition_id) | [
"\n Adds IntermediateCatchEvent attributes to exported XML element\n\n :param node_params: dictionary with given intermediate catch event parameters,\n :param output_element: object representing BPMN XML 'intermediateCatchEvent' element.\n "
] |
Please provide a description of the function:def export_definitions_element():
root = eTree.Element(consts.Consts.definitions)
root.set("xmlns", "http://www.omg.org/spec/BPMN/20100524/MODEL")
root.set("xmlns:bpmndi", "http://www.omg.org/spec/BPMN/20100524/DI")
root.set("xmlns:omgdc", "http://www.omg.org/spec/DD/20100524/DC")
root.set("xmlns:omgdi", "http://www.omg.org/spec/DD/20100524/DI")
root.set("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
root.set("targetNamespace", "http://www.signavio.com/bpmn20")
root.set("typeLanguage", "http://www.w3.org/2001/XMLSchema")
root.set("expressionLanguage", "http://www.w3.org/1999/XPath")
root.set("xmlns:xsd", "http://www.w3.org/2001/XMLSchema")
return root | [
"\n Creates root element ('definitions') for exported BPMN XML file.\n\n :return: definitions XML element.\n "
] |
Please provide a description of the function:def export_process_element(definitions, process_id, process_attributes_dictionary):
process = eTree.SubElement(definitions, consts.Consts.process)
process.set(consts.Consts.id, process_id)
process.set(consts.Consts.is_closed, process_attributes_dictionary[consts.Consts.is_closed])
process.set(consts.Consts.is_executable, process_attributes_dictionary[consts.Consts.is_executable])
process.set(consts.Consts.process_type, process_attributes_dictionary[consts.Consts.process_type])
return process | [
"\n Creates process element for exported BPMN XML file.\n\n :param process_id: string object. ID of exported process element,\n :param definitions: an XML element ('definitions'), root element of BPMN 2.0 document\n :param process_attributes_dictionary: dictionary that holds attribute values of 'process' element\n :return: process XML element\n "
] |
Please provide a description of the function:def export_lane_set(process, lane_set, plane_element):
lane_set_xml = eTree.SubElement(process, consts.Consts.lane_set)
for key, value in lane_set[consts.Consts.lanes].items():
BpmnDiagramGraphExport.export_lane(lane_set_xml, key, value, plane_element) | [
"\n Creates 'laneSet' element for exported BPMN XML file.\n\n :param process: an XML element ('process'), from exported BPMN 2.0 document,\n :param lane_set: dictionary with exported 'laneSet' element attributes and child elements,\n :param plane_element: XML object, representing 'plane' element of exported BPMN 2.0 XML.\n "
] |
Please provide a description of the function:def export_child_lane_set(parent_xml_element, child_lane_set, plane_element):
lane_set_xml = eTree.SubElement(parent_xml_element, consts.Consts.lane_set)
for key, value in child_lane_set[consts.Consts.lanes].items():
BpmnDiagramGraphExport.export_lane(lane_set_xml, key, value, plane_element) | [
"\n Creates 'childLaneSet' element for exported BPMN XML file.\n\n :param parent_xml_element: an XML element, parent of exported 'childLaneSet' element,\n :param child_lane_set: dictionary with exported 'childLaneSet' element attributes and child elements,\n :param plane_element: XML object, representing 'plane' element of exported BPMN 2.0 XML.\n "
] |
Please provide a description of the function:def export_lane(parent_xml_element, lane_id, lane_attr, plane_element):
lane_xml = eTree.SubElement(parent_xml_element, consts.Consts.lane)
lane_xml.set(consts.Consts.id, lane_id)
lane_xml.set(consts.Consts.name, lane_attr[consts.Consts.name])
if consts.Consts.child_lane_set in lane_attr and len(lane_attr[consts.Consts.child_lane_set]):
child_lane_set = lane_attr[consts.Consts.child_lane_set]
BpmnDiagramGraphExport.export_child_lane_set(lane_xml, child_lane_set, plane_element)
if consts.Consts.flow_node_refs in lane_attr and len(lane_attr[consts.Consts.flow_node_refs]):
for flow_node_ref_id in lane_attr[consts.Consts.flow_node_refs]:
flow_node_ref_xml = eTree.SubElement(lane_xml, consts.Consts.flow_node_ref)
flow_node_ref_xml.text = flow_node_ref_id
output_element_di = eTree.SubElement(plane_element, BpmnDiagramGraphExport.bpmndi_namespace +
consts.Consts.bpmn_shape)
output_element_di.set(consts.Consts.id, lane_id + "_gui")
output_element_di.set(consts.Consts.bpmn_element, lane_id)
output_element_di.set(consts.Consts.is_horizontal, lane_attr[consts.Consts.is_horizontal])
bounds = eTree.SubElement(output_element_di, "omgdc:Bounds")
bounds.set(consts.Consts.width, lane_attr[consts.Consts.width])
bounds.set(consts.Consts.height, lane_attr[consts.Consts.height])
bounds.set(consts.Consts.x, lane_attr[consts.Consts.x])
bounds.set(consts.Consts.y, lane_attr[consts.Consts.y]) | [
"\n Creates 'lane' element for exported BPMN XML file.\n\n :param parent_xml_element: an XML element, parent of exported 'lane' element,\n :param lane_id: string object. ID of exported lane element,\n :param lane_attr: dictionary with lane element attributes,\n :param plane_element: XML object, representing 'plane' element of exported BPMN 2.0 XML.\n "
] |
Please provide a description of the function:def export_diagram_plane_elements(root, diagram_attributes, plane_attributes):
diagram = eTree.SubElement(root, BpmnDiagramGraphExport.bpmndi_namespace + "BPMNDiagram")
diagram.set(consts.Consts.id, diagram_attributes[consts.Consts.id])
diagram.set(consts.Consts.name, diagram_attributes[consts.Consts.name])
plane = eTree.SubElement(diagram, BpmnDiagramGraphExport.bpmndi_namespace + "BPMNPlane")
plane.set(consts.Consts.id, plane_attributes[consts.Consts.id])
plane.set(consts.Consts.bpmn_element, plane_attributes[consts.Consts.bpmn_element])
return diagram, plane | [
"\n Creates 'diagram' and 'plane' elements for exported BPMN XML file.\n Returns a tuple (diagram, plane).\n\n :param root: object of Element class, representing a BPMN XML root element ('definitions'),\n :param diagram_attributes: dictionary that holds attribute values for imported 'BPMNDiagram' element,\n :param plane_attributes: dictionary that holds attribute values for imported 'BPMNPlane' element.\n "
] |
Please provide a description of the function:def export_node_data(bpmn_diagram, process_id, params, process):
node_type = params[consts.Consts.type]
output_element = eTree.SubElement(process, node_type)
output_element.set(consts.Consts.id, process_id)
output_element.set(consts.Consts.name, params[consts.Consts.node_name])
for incoming in params[consts.Consts.incoming_flow]:
incoming_element = eTree.SubElement(output_element, consts.Consts.incoming_flow)
incoming_element.text = incoming
for outgoing in params[consts.Consts.outgoing_flow]:
outgoing_element = eTree.SubElement(output_element, consts.Consts.outgoing_flow)
outgoing_element.text = outgoing
if node_type == consts.Consts.task \
or node_type == consts.Consts.user_task \
or node_type == consts.Consts.service_task \
or node_type == consts.Consts.manual_task:
BpmnDiagramGraphExport.export_task_info(params, output_element)
elif node_type == consts.Consts.subprocess:
BpmnDiagramGraphExport.export_subprocess_info(bpmn_diagram, params, output_element)
elif node_type == consts.Consts.data_object:
BpmnDiagramGraphExport.export_data_object_info(bpmn_diagram, params, output_element)
elif node_type == consts.Consts.complex_gateway:
BpmnDiagramGraphExport.export_complex_gateway_info(params, output_element)
elif node_type == consts.Consts.event_based_gateway:
BpmnDiagramGraphExport.export_event_based_gateway_info(params, output_element)
elif node_type == consts.Consts.inclusive_gateway or node_type == consts.Consts.exclusive_gateway:
BpmnDiagramGraphExport.export_inclusive_exclusive_gateway_info(params, output_element)
elif node_type == consts.Consts.parallel_gateway:
BpmnDiagramGraphExport.export_parallel_gateway_info(params, output_element)
elif node_type == consts.Consts.start_event:
BpmnDiagramGraphExport.export_start_event_info(params, output_element)
elif node_type == consts.Consts.intermediate_catch_event:
BpmnDiagramGraphExport.export_catch_event_info(params, output_element)
elif node_type == consts.Consts.end_event or node_type == consts.Consts.intermediate_throw_event:
BpmnDiagramGraphExport.export_throw_event_info(params, output_element)
elif node_type == consts.Consts.boundary_event:
BpmnDiagramGraphExport.export_boundary_event_info(params, output_element) | [
"\n Creates a new XML element (depends on node type) for given node parameters and adds it to 'process' element.\n\n :param bpmn_diagram: BPMNDiagramGraph class instantion representing a BPMN process diagram,\n :param process_id: string representing ID of given flow node,\n :param params: dictionary with node parameters,\n :param process: object of Element class, representing BPMN XML 'process' element (root for nodes).\n "
] |
Please provide a description of the function:def export_node_di_data(node_id, params, plane):
output_element_di = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace + consts.Consts.bpmn_shape)
output_element_di.set(consts.Consts.id, node_id + "_gui")
output_element_di.set(consts.Consts.bpmn_element, node_id)
bounds = eTree.SubElement(output_element_di, "omgdc:Bounds")
bounds.set(consts.Consts.width, params[consts.Consts.width])
bounds.set(consts.Consts.height, params[consts.Consts.height])
bounds.set(consts.Consts.x, params[consts.Consts.x])
bounds.set(consts.Consts.y, params[consts.Consts.y])
if params[consts.Consts.type] == consts.Consts.subprocess:
output_element_di.set(consts.Consts.is_expanded, params[consts.Consts.is_expanded]) | [
"\n Creates a new BPMNShape XML element for given node parameters and adds it to 'plane' element.\n\n :param node_id: string representing ID of given flow node,\n :param params: dictionary with node parameters,\n :param plane: object of Element class, representing BPMN XML 'BPMNPlane' element (root for node DI data).\n "
] |
Please provide a description of the function:def export_flow_process_data(params, process):
output_flow = eTree.SubElement(process, consts.Consts.sequence_flow)
output_flow.set(consts.Consts.id, params[consts.Consts.id])
output_flow.set(consts.Consts.name, params[consts.Consts.name])
output_flow.set(consts.Consts.source_ref, params[consts.Consts.source_ref])
output_flow.set(consts.Consts.target_ref, params[consts.Consts.target_ref])
if consts.Consts.condition_expression in params:
condition_expression_params = params[consts.Consts.condition_expression]
condition_expression = eTree.SubElement(output_flow, consts.Consts.condition_expression)
condition_expression.set(consts.Consts.id, condition_expression_params[consts.Consts.id])
condition_expression.set(consts.Consts.id, condition_expression_params[consts.Consts.id])
condition_expression.text = condition_expression_params[consts.Consts.condition_expression]
output_flow.set(consts.Consts.name, condition_expression_params[consts.Consts.condition_expression]) | [
"\n Creates a new SequenceFlow XML element for given edge parameters and adds it to 'process' element.\n\n :param params: dictionary with edge parameters,\n :param process: object of Element class, representing BPMN XML 'process' element (root for sequence flows)\n "
] |
Please provide a description of the function:def export_flow_di_data(params, plane):
output_flow = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace + consts.Consts.bpmn_edge)
output_flow.set(consts.Consts.id, params[consts.Consts.id] + "_gui")
output_flow.set(consts.Consts.bpmn_element, params[consts.Consts.id])
waypoints = params[consts.Consts.waypoints]
for waypoint in waypoints:
waypoint_element = eTree.SubElement(output_flow, "omgdi:waypoint")
waypoint_element.set(consts.Consts.x, waypoint[0])
waypoint_element.set(consts.Consts.y, waypoint[1]) | [
"\n Creates a new BPMNEdge XML element for given edge parameters and adds it to 'plane' element.\n\n :param params: dictionary with edge parameters,\n :param plane: object of Element class, representing BPMN XML 'BPMNPlane' element (root for edge DI data).\n "
] |
Please provide a description of the function:def export_xml_file(directory, filename, bpmn_diagram):
diagram_attributes = bpmn_diagram.diagram_attributes
plane_attributes = bpmn_diagram.plane_attributes
collaboration = bpmn_diagram.collaboration
process_elements_dict = bpmn_diagram.process_elements
definitions = BpmnDiagramGraphExport.export_definitions_element()
[_, plane] = BpmnDiagramGraphExport.export_diagram_plane_elements(definitions, diagram_attributes,
plane_attributes)
if collaboration is not None and len(collaboration) > 0:
message_flows = collaboration[consts.Consts.message_flows]
participants = collaboration[consts.Consts.participants]
collaboration_xml = eTree.SubElement(definitions, consts.Consts.collaboration)
collaboration_xml.set(consts.Consts.id, collaboration[consts.Consts.id])
for message_flow_id, message_flow_attr in message_flows.items():
message_flow = eTree.SubElement(collaboration_xml, consts.Consts.message_flow)
message_flow.set(consts.Consts.id, message_flow_id)
message_flow.set(consts.Consts.name, message_flow_attr[consts.Consts.name])
message_flow.set(consts.Consts.source_ref, message_flow_attr[consts.Consts.source_ref])
message_flow.set(consts.Consts.target_ref, message_flow_attr[consts.Consts.target_ref])
message_flow_params = bpmn_diagram.get_flow_by_id(message_flow_id)[2]
output_flow = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace + consts.Consts.bpmn_edge)
output_flow.set(consts.Consts.id, message_flow_id + "_gui")
output_flow.set(consts.Consts.bpmn_element, message_flow_id)
waypoints = message_flow_params[consts.Consts.waypoints]
for waypoint in waypoints:
waypoint_element = eTree.SubElement(output_flow, "omgdi:waypoint")
waypoint_element.set(consts.Consts.x, waypoint[0])
waypoint_element.set(consts.Consts.y, waypoint[1])
for participant_id, participant_attr in participants.items():
participant = eTree.SubElement(collaboration_xml, consts.Consts.participant)
participant.set(consts.Consts.id, participant_id)
participant.set(consts.Consts.name, participant_attr[consts.Consts.name])
participant.set(consts.Consts.process_ref, participant_attr[consts.Consts.process_ref])
output_element_di = eTree.SubElement(plane, BpmnDiagramGraphExport.bpmndi_namespace +
consts.Consts.bpmn_shape)
output_element_di.set(consts.Consts.id, participant_id + "_gui")
output_element_di.set(consts.Consts.bpmn_element, participant_id)
output_element_di.set(consts.Consts.is_horizontal, participant_attr[consts.Consts.is_horizontal])
bounds = eTree.SubElement(output_element_di, "omgdc:Bounds")
bounds.set(consts.Consts.width, participant_attr[consts.Consts.width])
bounds.set(consts.Consts.height, participant_attr[consts.Consts.height])
bounds.set(consts.Consts.x, participant_attr[consts.Consts.x])
bounds.set(consts.Consts.y, participant_attr[consts.Consts.y])
for process_id in process_elements_dict:
process_element_attr = process_elements_dict[process_id]
process = BpmnDiagramGraphExport.export_process_element(definitions, process_id, process_element_attr)
if consts.Consts.lane_set in process_element_attr:
BpmnDiagramGraphExport.export_lane_set(process, process_element_attr[consts.Consts.lane_set], plane)
# for each node in graph add correct type of element, its attributes and BPMNShape element
nodes = bpmn_diagram.get_nodes_list_by_process_id(process_id)
for node in nodes:
node_id = node[0]
params = node[1]
BpmnDiagramGraphExport.export_node_data(bpmn_diagram, node_id, params, process)
# BpmnDiagramGraphExport.export_node_di_data(node_id, params, plane)
# for each edge in graph add sequence flow element, its attributes and BPMNEdge element
flows = bpmn_diagram.get_flows_list_by_process_id(process_id)
for flow in flows:
params = flow[2]
BpmnDiagramGraphExport.export_flow_process_data(params, process)
# BpmnDiagramGraphExport.export_flow_di_data(params, plane)
# Export DI data
nodes = bpmn_diagram.get_nodes()
for node in nodes:
node_id = node[0]
params = node[1]
BpmnDiagramGraphExport.export_node_di_data(node_id, params, plane)
flows = bpmn_diagram.get_flows()
for flow in flows:
params = flow[2]
BpmnDiagramGraphExport.export_flow_di_data(params, plane)
BpmnDiagramGraphExport.indent(definitions)
tree = eTree.ElementTree(definitions)
try:
os.makedirs(directory)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
tree.write(directory + filename, encoding='utf-8', xml_declaration=True) | [
"\n Exports diagram inner graph to BPMN 2.0 XML file (with Diagram Interchange data).\n\n :param directory: string representing output directory,\n :param filename: string representing output file name,\n :param bpmn_diagram: BPMNDiagramGraph class instantion representing a BPMN process diagram.\n "
] |
Please provide a description of the function:def export_xml_file_no_di(directory, filename, bpmn_diagram):
diagram_graph = bpmn_diagram.diagram_graph
process_elements_dict = bpmn_diagram.process_elements
definitions = BpmnDiagramGraphExport.export_definitions_element()
for process_id in process_elements_dict:
process_element_attr = process_elements_dict[process_id]
process = BpmnDiagramGraphExport.export_process_element(definitions, process_id, process_element_attr)
# for each node in graph add correct type of element, its attributes and BPMNShape element
nodes = diagram_graph.nodes(data=True)
for node in nodes:
node_id = node[0]
params = node[1]
BpmnDiagramGraphExport.export_node_data(bpmn_diagram, node_id, params, process)
# for each edge in graph add sequence flow element, its attributes and BPMNEdge element
flows = diagram_graph.edges(data=True)
for flow in flows:
params = flow[2]
BpmnDiagramGraphExport.export_flow_process_data(params, process)
BpmnDiagramGraphExport.indent(definitions)
tree = eTree.ElementTree(definitions)
try:
os.makedirs(directory)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
tree.write(directory + filename, encoding='utf-8', xml_declaration=True) | [
"\n Exports diagram inner graph to BPMN 2.0 XML file (without Diagram Interchange data).\n\n :param directory: string representing output directory,\n :param filename: string representing output file name,\n :param bpmn_diagram: BPMNDiagramGraph class instance representing a BPMN process diagram.\n "
] |
Please provide a description of the function:def indent(elem, level=0):
i = "\n" + level * " "
j = "\n" + (level - 1) * " "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
elem.tail = i
for subelem in elem:
BpmnDiagramGraphExport.indent(subelem, level + 1)
if not elem.tail or not elem.tail.strip():
elem.tail = j
else:
if level and (not elem.tail or not elem.tail.strip()):
elem.tail = j
return elem | [
"\n Helper function, adds indentation to XML output.\n\n :param elem: object of Element class, representing element to which method adds intendation,\n :param level: current level of intendation.\n "
] |
Please provide a description of the function:def set_event_definition_list(self, value):
if value is None or not isinstance(value, list):
raise TypeError("EventDefinitionList new value must be a list")
else:
for element in value:
if not isinstance(element, event_definition.EventDefinition):
raise TypeError("EventDefinitionList elements in variable must be of Lane class")
self.__event_definition_list = value | [
"\n Setter for 'event_definition_list' field.\n :param value - a new value of 'event_definition_list' field. Must be a list of EventDefinition objects\n "
] |
Please provide a description of the function:def iterate_elements(parent):
element = parent.firstChild
while element is not None:
yield element
element = element.nextSibling | [
"\n Helper function that iterates over child Nodes/Elements of parent Node/Element.\n\n :param parent: object of Element class, representing parent element.\n "
] |
Please provide a description of the function:def generate_nodes_clasification(bpmn_diagram):
nodes_classification = {}
classification_element = "Element"
classification_start_event = "Start Event"
classification_end_event = "End Event"
task_list = bpmn_diagram.get_nodes(consts.Consts.task)
for element in task_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
subprocess_list = bpmn_diagram.get_nodes(consts.Consts.subprocess)
for element in subprocess_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
complex_gateway_list = bpmn_diagram.get_nodes(consts.Consts.complex_gateway)
for element in complex_gateway_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
event_based_gateway_list = bpmn_diagram.get_nodes(consts.Consts.event_based_gateway)
for element in event_based_gateway_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
inclusive_gateway_list = bpmn_diagram.get_nodes(consts.Consts.inclusive_gateway)
for element in inclusive_gateway_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
exclusive_gateway_list = bpmn_diagram.get_nodes(consts.Consts.exclusive_gateway)
for element in exclusive_gateway_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
parallel_gateway_list = bpmn_diagram.get_nodes(consts.Consts.parallel_gateway)
for element in parallel_gateway_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
start_event_list = bpmn_diagram.get_nodes(consts.Consts.start_event)
for element in start_event_list:
classification_labels = [classification_element, classification_start_event]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
intermediate_catch_event_list = bpmn_diagram.get_nodes(consts.Consts.intermediate_catch_event)
for element in intermediate_catch_event_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
end_event_list = bpmn_diagram.get_nodes(consts.Consts.end_event)
for element in end_event_list:
classification_labels = [classification_element, classification_end_event]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
intermediate_throw_event_list = bpmn_diagram.get_nodes(consts.Consts.intermediate_throw_event)
for element in intermediate_throw_event_list:
classification_labels = [classification_element]
BpmnImportUtils.split_join_classification(element, classification_labels, nodes_classification)
return nodes_classification | [
"\n Diagram elements classification. Implementation based on article \"A Simple Algorithm for Automatic Layout of\n BPMN Processes\".\n Assigns a classification to the diagram element according to specific element parameters.\n - Element - every element of the process which is not an edge,\n - Start Event - all types of start events,\n - End Event - all types of end events,\n - Join - an element with more than one incoming edge,\n - Split - an element with more than one outgoing edge.\n\n :param bpmn_diagram: BPMNDiagramGraph class instance representing a BPMN process diagram.\n :return: a dictionary of classification labels. Key - node id. Values - a list of labels.\n "
] |
Please provide a description of the function:def split_join_classification(element, classification_labels, nodes_classification):
classification_join = "Join"
classification_split = "Split"
if len(element[1][consts.Consts.incoming_flow]) >= 2:
classification_labels.append(classification_join)
if len(element[1][consts.Consts.outgoing_flow]) >= 2:
classification_labels.append(classification_split)
nodes_classification[element[0]] = classification_labels | [
"\n Add the \"Split\", \"Join\" classification, if the element qualifies for.\n\n :param element: an element from BPMN diagram,\n :param classification_labels: list of labels attached to the element,\n :param nodes_classification: dictionary of classification labels. Key - node id. Value - a list of labels.\n "
] |
Please provide a description of the function:def get_all_gateways(bpmn_graph):
gateways = filter(lambda node: node[1]['type'] in GATEWAY_TYPES, bpmn_graph.get_nodes())
return gateways | [
"\n Returns a list with all gateways in diagram\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n :return: a list with all gateways in diagram\n "
] |
Please provide a description of the function:def all_control_flow_elements_count(bpmn_graph):
gateway_counts = get_gateway_counts(bpmn_graph)
events_counts = get_events_counts(bpmn_graph)
control_flow_elements_counts = gateway_counts.copy()
control_flow_elements_counts.update(events_counts)
return sum([
count for name, count in control_flow_elements_counts.items()
]) | [
"\n Returns the total count of all control flow elements\n in the BPMNDiagramGraph instance.\n \n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n :return: total count of the control flow elements in the BPMNDiagramGraph instance\n "
] |
Please provide a description of the function:def TNE_metric(bpmn_graph):
events_counts = get_events_counts(bpmn_graph)
return sum(
[count for _, count in events_counts.items()]
) | [
"\n Returns the value of the TNE metric (Total Number of Events of the Model)\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def NOAC_metric(bpmn_graph):
activities_count = all_activities_count(bpmn_graph)
control_flow_count = all_control_flow_elements_count(bpmn_graph)
return activities_count + control_flow_count | [
"\n Returns the value of the NOAC metric (Number of Activities and control flow elements)\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def NOAJS_metric(bpmn_graph):
activities_count = all_activities_count(bpmn_graph)
gateways_count = all_gateways_count(bpmn_graph)
return activities_count + gateways_count | [
"\n Returns the value of the NOAJS metric (Number of Activities, joins and splits)\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def NumberOfNodes_metric(bpmn_graph):
activities_count = all_activities_count(bpmn_graph)
control_flow_count = all_control_flow_elements_count(bpmn_graph)
return activities_count + control_flow_count | [
"\n Returns the value of the Number of Nodes metric\n (\"Number of activities and routing elements in a model\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def GatewayHeterogenity_metric(bpmn_graph):
gateway_counts = get_gateway_counts(bpmn_graph)
present_gateways = [gateway_name
for gateway_name, count in gateway_counts.items()
if count > 0]
return len(present_gateways) | [
"\n Returns the value of the Gateway Heterogenity metric\n (\"Number of different types of gateways used in a mode\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def CoefficientOfNetworkComplexity_metric(bpmn_graph):
return float(len(bpmn_graph.get_flows())) / float(len(bpmn_graph.get_nodes())) | [
"\n Returns the value of the Coefficient of Network Complexity metric\n (\"Ratio of the total number of arcs in a process model to its total number of nodes.\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def AverageGatewayDegree_metric(bpmn_graph):
gateways_ids = [gateway[0] for gateway in get_all_gateways(bpmn_graph)]
all_nodes_degrees = bpmn_graph.diagram_graph.degree()
gateways_degree_values = [all_nodes_degrees[gateway_id] for gateway_id in gateways_ids]
return float(sum(gateways_degree_values)) / float(len(gateways_degree_values)) | [
"\n Returns the value of the Average Gateway Degree metric\n (\"Average of the number of both incoming and outgoing arcs of the gateway nodes in the process model\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def DurfeeSquare_metric(bpmn_graph):
all_types_count = Counter([node[1]['type'] for node in bpmn_graph.get_nodes() if node[1]['type']])
length = len(all_types_count)
histogram = [0] * (length + 1)
for _, count in all_types_count.items():
histogram[min(count, length)] += 1
sum_ = 0
for i, count in reversed(list(enumerate(histogram))):
sum_ += count
if sum_ >= i:
return i
return 0 | [
"\n Returns the value of the Durfee Square metric\n (\"Durfee Square equals d if there are d types of elements\n which occur at least d times in the model (each),\n and the other types of elements occur no more than d times (each)\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def PerfectSquare_metric(bpmn_graph):
all_types_count = Counter([node[1]['type'] for node in bpmn_graph.get_nodes() if node[1]['type']])
sorted_counts = [count for _, count in all_types_count.most_common()]
potential_perfect_square = min(len(sorted_counts), int(sqrt(sum(sorted_counts))))
for i in range(potential_perfect_square, 0, -1):
if sum(sorted_counts[:potential_perfect_square]) >= potential_perfect_square * potential_perfect_square:
return potential_perfect_square
else:
potential_perfect_square -= 1
return 0 | [
"\n Returns the value of the Perfect Square metric\n (\"Given a set of element types ranked\n in decreasing order of the number of their instances,\n the PSM is the (unique) largest number\n such that the top p types occur(together)\n at least p2 times.\")\n for the BPMNDiagramGraph instance.\n\n :param bpmn_graph: an instance of BpmnDiagramGraph representing BPMN model.\n "
] |
Please provide a description of the function:def export_process_to_csv(bpmn_diagram, directory, filename):
nodes = copy.deepcopy(bpmn_diagram.get_nodes())
start_nodes = []
export_elements = []
for node in nodes:
incoming_list = node[1].get(consts.Consts.incoming_flow)
if len(incoming_list) == 0:
start_nodes.append(node)
if len(start_nodes) != 1:
raise bpmn_exception.BpmnPythonError("Exporting to CSV format accepts only one start event")
nodes_classification = utils.BpmnImportUtils.generate_nodes_clasification(bpmn_diagram)
start_node = start_nodes.pop()
BpmnDiagramGraphCsvExport.export_node(bpmn_diagram, export_elements, start_node, nodes_classification)
try:
os.makedirs(directory)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
file_object = open(directory + filename, "w")
file_object.write("Order,Activity,Condition,Who,Subprocess,Terminated\n")
BpmnDiagramGraphCsvExport.write_export_node_to_file(file_object, export_elements)
file_object.close() | [
"\n Root method of CSV export functionality.\n\n :param bpmn_diagram: an instance of BpmnDiagramGraph class,\n :param directory: a string object, which is a path of output directory,\n :param filename: a string object, which is a name of output file.\n "
] |
Please provide a description of the function:def export_node(bpmn_graph, export_elements, node, nodes_classification, order=0, prefix="", condition="", who="",
add_join=False):
node_type = node[1][consts.Consts.type]
if node_type == consts.Consts.start_event:
return BpmnDiagramGraphCsvExport.export_start_event(bpmn_graph, export_elements, node, nodes_classification,
order=order, prefix=prefix, condition=condition,
who=who)
elif node_type == consts.Consts.end_event:
return BpmnDiagramGraphCsvExport.export_end_event(export_elements, node, order=order, prefix=prefix,
condition=condition, who=who)
else:
return BpmnDiagramGraphCsvExport.export_element(bpmn_graph, export_elements, node, nodes_classification,
order=order, prefix=prefix, condition=condition, who=who,
add_join=add_join) | [
"\n General method for node exporting\n\n :param bpmn_graph: an instance of BpmnDiagramGraph class,\n :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that\n will be used in exported CSV document,\n :param node: networkx.Node object,\n :param nodes_classification: dictionary of classification labels. Key - node id. Value - a list of labels,\n :param order: the order param of exported node,\n :param prefix: the prefix of exported node - if the task appears after some gateway, the prefix will identify\n the branch\n :param condition: the condition param of exported node,\n :param who: the condition param of exported node,\n :param add_join: boolean flag. Used to indicate if \"Join\" element should be added to CSV.\n :return: None or the next node object if the exported node was a gateway join.\n "
] |
Please provide a description of the function:def export_element(bpmn_graph, export_elements, node, nodes_classification, order=0, prefix="", condition="",
who="", add_join=False):
node_type = node[1][consts.Consts.type]
node_classification = nodes_classification[node[0]]
outgoing_flows = node[1].get(consts.Consts.outgoing_flow)
if node_type != consts.Consts.parallel_gateway and consts.Consts.default in node[1] \
and node[1][consts.Consts.default] is not None:
default_flow_id = node[1][consts.Consts.default]
else:
default_flow_id = None
if BpmnDiagramGraphCsvExport.classification_join in node_classification and not add_join:
# If the node is a join, then retract the recursion back to the split.
# In case of activity - return current node. In case of gateway - return outgoing node
# (we are making assumption that join has only one outgoing node)
if node_type == consts.Consts.task or node_type == consts.Consts.subprocess:
return node
else:
outgoing_flow_id = outgoing_flows[0]
outgoing_flow = bpmn_graph.get_flow_by_id(outgoing_flow_id)
outgoing_node = bpmn_graph.get_node_by_id(outgoing_flow[2][consts.Consts.target_ref])
return outgoing_node
else:
if node_type == consts.Consts.task:
export_elements.append({"Order": prefix + str(order), "Activity": node[1][consts.Consts.node_name],
"Condition": condition, "Who": who, "Subprocess": "", "Terminated": ""})
elif node_type == consts.Consts.subprocess:
export_elements.append({"Order": prefix + str(order), "Activity": node[1][consts.Consts.node_name],
"Condition": condition, "Who": who, "Subprocess": "yes", "Terminated": ""})
if BpmnDiagramGraphCsvExport.classification_split in node_classification:
next_node = None
alphabet_suffix_index = 0
for outgoing_flow_id in outgoing_flows:
outgoing_flow = bpmn_graph.get_flow_by_id(outgoing_flow_id)
outgoing_node = bpmn_graph.get_node_by_id(outgoing_flow[2][consts.Consts.target_ref])
# This will work only up to 26 outgoing flows
suffix = string.ascii_lowercase[alphabet_suffix_index]
next_prefix = prefix + str(order) + suffix
alphabet_suffix_index += 1
# parallel gateway does not uses conditions
if node_type != consts.Consts.parallel_gateway and consts.Consts.name in outgoing_flow[2] \
and outgoing_flow[2][consts.Consts.name] is not None:
condition = outgoing_flow[2][consts.Consts.name]
else:
condition = ""
if BpmnDiagramGraphCsvExport.classification_join in nodes_classification[outgoing_node[0]]:
export_elements.append(
{"Order": next_prefix + str(1), "Activity": "goto " + prefix + str(order + 1),
"Condition": condition, "Who": who, "Subprocess": "", "Terminated": ""})
elif outgoing_flow_id == default_flow_id:
tmp_next_node = BpmnDiagramGraphCsvExport.export_node(bpmn_graph, export_elements, outgoing_node,
nodes_classification, 1, next_prefix, "else",
who)
if tmp_next_node is not None:
next_node = tmp_next_node
else:
tmp_next_node = BpmnDiagramGraphCsvExport.export_node(bpmn_graph, export_elements, outgoing_node,
nodes_classification, 1, next_prefix,
condition, who)
if tmp_next_node is not None:
next_node = tmp_next_node
if next_node is not None:
return BpmnDiagramGraphCsvExport.export_node(bpmn_graph, export_elements, next_node,
nodes_classification, order=(order + 1), prefix=prefix,
who=who, add_join=True)
elif len(outgoing_flows) == 1:
outgoing_flow_id = outgoing_flows[0]
outgoing_flow = bpmn_graph.get_flow_by_id(outgoing_flow_id)
outgoing_node = bpmn_graph.get_node_by_id(outgoing_flow[2][consts.Consts.target_ref])
return BpmnDiagramGraphCsvExport.export_node(bpmn_graph, export_elements, outgoing_node,
nodes_classification, order=(order + 1), prefix=prefix,
who=who)
else:
return None | [
"\n Export a node with \"Element\" classification (task, subprocess or gateway)\n\n :param bpmn_graph: an instance of BpmnDiagramGraph class,\n :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that\n will be used in exported CSV document,\n :param node: networkx.Node object,\n :param nodes_classification: dictionary of classification labels. Key - node id. Value - a list of labels,\n :param order: the order param of exported node,\n :param prefix: the prefix of exported node - if the task appears after some gateway, the prefix will identify\n the branch\n :param condition: the condition param of exported node,\n :param who: the condition param of exported node,\n :param add_join: boolean flag. Used to indicate if \"Join\" element should be added to CSV.\n :return: None or the next node object if the exported node was a gateway join.\n "
] |
Please provide a description of the function:def export_start_event(bpmn_graph, export_elements, node, nodes_classification, order=0, prefix="", condition="",
who=""):
# Assuming that there is only one event definition
event_definitions = node[1].get(consts.Consts.event_definitions)
if event_definitions is not None and len(event_definitions) > 0:
event_definition = node[1][consts.Consts.event_definitions][0]
else:
event_definition = None
if event_definition is None:
activity = node[1][consts.Consts.node_name]
elif event_definition[consts.Consts.definition_type] == "messageEventDefinition":
activity = "message " + node[1][consts.Consts.node_name]
elif event_definition[consts.Consts.definition_type] == "timerEventDefinition":
activity = "timer " + node[1][consts.Consts.node_name]
else:
activity = node[1][consts.Consts.node_name]
export_elements.append({"Order": prefix + str(order), "Activity": activity, "Condition": condition,
"Who": who, "Subprocess": "", "Terminated": ""})
outgoing_flow_id = node[1][consts.Consts.outgoing_flow][0]
outgoing_flow = bpmn_graph.get_flow_by_id(outgoing_flow_id)
outgoing_node = bpmn_graph.get_node_by_id(outgoing_flow[2][consts.Consts.target_ref])
return BpmnDiagramGraphCsvExport.export_node(bpmn_graph, export_elements, outgoing_node, nodes_classification,
order + 1, prefix, who) | [
"\n Start event export\n\n :param bpmn_graph: an instance of BpmnDiagramGraph class,\n :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that\n will be used in exported CSV document,\n :param node: networkx.Node object,\n :param order: the order param of exported node,\n :param nodes_classification: dictionary of classification labels. Key - node id. Value - a list of labels,\n :param prefix: the prefix of exported node - if the task appears after some gateway, the prefix will identify\n the branch\n :param condition: the condition param of exported node,\n :param who: the condition param of exported node,\n :return: None or the next node object if the exported node was a gateway join.\n "
] |
Please provide a description of the function:def export_end_event(export_elements, node, order=0, prefix="", condition="", who=""):
# Assuming that there is only one event definition
event_definitions = node[1].get(consts.Consts.event_definitions)
if event_definitions is not None and len(event_definitions) > 0:
event_definition = node[1][consts.Consts.event_definitions][0]
else:
event_definition = None
if event_definition is None:
activity = node[1][consts.Consts.node_name]
elif event_definition[consts.Consts.definition_type] == "messageEventDefinition":
activity = "message " + node[1][consts.Consts.node_name]
else:
activity = node[1][consts.Consts.node_name]
export_elements.append({"Order": prefix + str(order), "Activity": activity, "Condition": condition, "Who": who,
"Subprocess": "", "Terminated": "yes"})
# No outgoing elements for EndEvent
return None | [
"\n End event export\n\n :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that\n will be used in exported CSV document,\n :param node: networkx.Node object,\n :param order: the order param of exported node,\n :param prefix: the prefix of exported node - if the task appears after some gateway, the prefix will identify\n the branch\n :param condition: the condition param of exported node,\n :param who: the condition param of exported node,\n :return: None or the next node object if the exported node was a gateway join.\n "
] |
Please provide a description of the function:def write_export_node_to_file(file_object, export_elements):
for export_element in export_elements:
# Order,Activity,Condition,Who,Subprocess,Terminated
file_object.write(
export_element["Order"] + "," + export_element["Activity"] + "," + export_element["Condition"] + "," +
export_element["Who"] + "," + export_element["Subprocess"] + "," + export_element["Terminated"] + "\n") | [
"\n Exporting process to CSV file\n\n :param file_object: object of File class,\n :param export_elements: a dictionary object. The key is a node ID, value is a dictionary of parameters that\n will be used in exported CSV document.\n "
] |
Please provide a description of the function:def set_parallel_multiple(self, value):
if value is None or not isinstance(value, bool):
raise TypeError("ParallelMultiple must be set to a bool")
else:
self.__parallel_multiple = value | [
"\n Setter for 'parallel_multiple' field.\n :param value - a new value of 'parallel_multiple' field. Must be a boolean type. Does not accept None value.\n "
] |
Please provide a description of the function:def set_triggered_by_event(self, value):
if value is None or not isinstance(value, bool):
raise TypeError("TriggeredByEvent must be set to a bool")
else:
self.__triggered_by_event = value | [
"\n Setter for 'triggered_by_event' field.\n :param value - a new value of 'triggered_by_event' field. Must be a boolean type. Does not accept None value.\n "
] |
Please provide a description of the function:def set_lane_set_list(self, value):
if value is None or not isinstance(value, list):
raise TypeError("LaneSetList new value must be a list")
else:
for element in value:
if not isinstance(element, lane_set.LaneSet):
raise TypeError("LaneSetList elements in variable must be of LaneSet class")
self.__lane_set_list = value | [
"\n Setter for 'lane_set_list' field.\n :param value - a new value of 'lane_set_list' field. Must be a list\n "
] |
Please provide a description of the function:def set_flow_element_list(self, value):
if value is None or not isinstance(value, list):
raise TypeError("FlowElementList new value must be a list")
else:
for element in value:
if not isinstance(element, flow_element.FlowElement):
raise TypeError("FlowElementList elements in variable must be of FlowElement class")
self.__flow_element_list = value | [
"\n Setter for 'flow_element_list' field.\n :param value - a new value of 'flow_element_list' field. Must be a list\n "
] |
Please provide a description of the function:def set_incoming(self, value):
if not isinstance(value, list):
raise TypeError("IncomingList new value must be a list")
for element in value:
if not isinstance(element, str):
raise TypeError("IncomingList elements in variable must be of String class")
self.__incoming_list = value | [
"\n Setter for 'incoming' field.\n :param value - a new value of 'incoming' field. List of IDs (String type) of incoming flows.\n "
] |
Please provide a description of the function:def set_outgoing(self, value):
if not isinstance(value, list):
raise TypeError("OutgoingList new value must be a list")
for element in value:
if not isinstance(element, str):
raise TypeError("OutgoingList elements in variable must be of String class")
self.__outgoing_list = value | [
"\n Setter for 'outgoing' field.\n :param value - a new value of 'outgoing' field. Must be a list of IDs (String type) of outgoing flows.\n "
] |
Please provide a description of the function:def set_process_type(self, value):
if value is None or not isinstance(value, str):
raise TypeError("ProcessType must be set to a String")
elif value not in Process.__process_type_list:
raise ValueError("ProcessType must be one of specified values: 'None', 'Public', 'Private'")
else:
self.__process_type = value | [
"\n Setter for 'process_type' field.\n :param value - a new value of 'process_type' field.\n "
] |
Please provide a description of the function:def set_is_closed(self, value):
if value is None or not isinstance(value, bool):
raise TypeError("IsClosed must be set to a bool")
else:
self.__is_closed = value | [
"\n Setter for 'is_closed' field.\n :param value - a new value of 'is_closed' field. Must be a boolean type. Does not accept None value.\n "
] |
Please provide a description of the function:def set_is_executable(self, value):
if value is None or not isinstance(value, bool):
raise TypeError("IsExecutable must be set to a bool")
else:
self.__is_executable = value | [
"\n Setter for 'is_executable' field.\n :param value - a new value of 'is_executable' field. Must be a boolean type. Does not accept None value.\n "
] |
Please provide a description of the function:def visualize_diagram(bpmn_diagram):
g = bpmn_diagram.diagram_graph
pos = bpmn_diagram.get_nodes_positions()
nx.draw_networkx_nodes(g, pos, node_shape='s', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.task))
nx.draw_networkx_nodes(g, pos, node_shape='s', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.subprocess))
nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.complex_gateway))
nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.event_based_gateway))
nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.inclusive_gateway))
nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.exclusive_gateway))
nx.draw_networkx_nodes(g, pos, node_shape='d', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.parallel_gateway))
nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.start_event))
nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.intermediate_catch_event))
nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.end_event))
nx.draw_networkx_nodes(g, pos, node_shape='o', node_color='white',
nodelist=bpmn_diagram.get_nodes_id_list_by_type(consts.Consts.intermediate_throw_event))
node_labels = {}
for node in g.nodes(data=True):
node_labels[node[0]] = node[1].get(consts.Consts.node_name)
nx.draw_networkx_labels(g, pos, node_labels)
nx.draw_networkx_edges(g, pos)
edge_labels = {}
for edge in g.edges(data=True):
edge_labels[(edge[0], edge[1])] = edge[2].get(consts.Consts.name)
nx.draw_networkx_edge_labels(g, pos, edge_labels)
plt.show() | [
"\n Shows a simple visualization of diagram\n\n :param bpmn_diagram: an instance of BPMNDiagramGraph class.\n "
] |
Please provide a description of the function:def bpmn_diagram_to_png(bpmn_diagram, file_name):
g = bpmn_diagram.diagram_graph
graph = pydotplus.Dot()
for node in g.nodes(data=True):
if node[1].get(consts.Consts.type) == consts.Consts.task:
n = pydotplus.Node(name=node[0], shape="box", style="rounded", label=node[1].get(consts.Consts.node_name))
elif node[1].get(consts.Consts.type) == consts.Consts.exclusive_gateway:
n = pydotplus.Node(name=node[0], shape="diamond", label=node[1].get(consts.Consts.node_name))
else:
n = pydotplus.Node(name=node[0], label=node[1].get(consts.Consts.node_name))
graph.add_node(n)
for edge in g.edges(data=True):
e = pydotplus.Edge(src=edge[0], dst=edge[1], label=edge[2].get(consts.Consts.name))
graph.add_edge(e)
graph.write(file_name + ".png", format='png') | [
"\n Create a png picture for given diagram\n\n :param bpmn_diagram: an instance of BPMNDiagramGraph class,\n :param file_name: name of generated file.\n "
] |
Please provide a description of the function:def set_id(self, value):
if value is None:
self.__id = value
if not isinstance(value, str):
raise TypeError("ID must be set to a String")
else:
self.__id = value | [
"\n Setter for 'id' field.\n :param value - a new value of 'id' field. Must be either None (ID is optional according to BPMN 2.0 XML Schema)\n or String type.\n "
] |
Please provide a description of the function:def set_source_ref(self, value):
if value is None or not isinstance(value, str):
raise TypeError("SourceRef is required and must be set to a String")
else:
self.__source_ref = value | [
"\n Setter for 'source_ref' field.\n :param value - a new value of 'source_ref' field. Required field. Must be a String type.\n "
] |
Please provide a description of the function:def set_target_ref(self, value):
if value is None or not isinstance(value, str):
raise TypeError("TargetRef is required and must be set to a String")
else:
self.__target_ref = value | [
"\n Setter for 'target_ref' field.\n :param value - a new value of 'target_ref' field. Required field. Must be a String type.\n "
] |
Please provide a description of the function:def set_is_immediate(self, value):
if value is None:
self.__is_immediate = value
elif not isinstance(value, bool):
raise TypeError("IsImediate must be set to a bool")
else:
self.__is_immediate = value | [
"\n Setter for 'is_immediate' field.\n :param value - a new value of 'is_immediate' field. Must be a boolean type.\n "
] |
Please provide a description of the function:def set_condition_expression(self, value):
if value is None:
self.__condition_expression = value
if not isinstance(value, condition_expression.ConditionExpression):
raise TypeError("ConditionExpression must be set to an instance of class ConditionExpression")
else:
self.__condition_expression = value | [
"\n Setter for 'condition_expression' field.\n :param value - a new value of 'condition_expression' field.\n "
] |
Please provide a description of the function:def set_default(self, value):
if value is None:
self.__default = value
elif not isinstance(value, str):
raise TypeError("Default must be set to a String")
else:
self.__default = value | [
"\n Setter for 'default' field.\n :param value - a new value of 'default' field. Must be either None (default is optional according to\n BPMN 2.0 XML Schema) or String.\n "
] |
Please provide a description of the function:def orientation(p1, p2, p3):
val = (p2[consts.Consts.y] - p1[consts.Consts.y]) * (p3[consts.Consts.x] - p2[consts.Consts.x]) \
- (p2[consts.Consts.x] - p1[consts.Consts.x]) * (p3[consts.Consts.y] - p2[consts.Consts.y])
if val == 0:
return 0 # collinear
elif val > 0:
return 1 # clockwise
else:
return 2 | [
"\n Finds orientation of three points p1, p2, p3.\n The function returns following values\n 0 --> p1, p2 and p3 are collinear\n 1 --> Clockwise\n 2 --> Counterclockwise\n :param p1: tuple representing two dimensional point\n :param p2: tuple representing two dimensional point\n :param p3: tuple representing two dimensional point\n "
] |
Please provide a description of the function:def set_process_ref(self, value):
if not isinstance(value, str):
raise TypeError("ProcessRef must be set to a String")
self.__process_ref = value | [
"\n Setter for 'process_ref' field.\n :param value - a new value of 'process_ref' field. Must be either None (process_ref is optional according to\n BPMN 2.0 XML Schema) or String.\n "
] |
Please provide a description of the function:def set_message_ref(self, value):
if value is None:
self.__message_ref = value
if not isinstance(value, str):
raise TypeError("MessageRef must be set to a String")
else:
self.__message_ref = value | [
"\n Setter for 'message_ref' field.\n :param value - a new value of 'message_ref' field. Must be either None (message_ref is optional according to\n BPMN 2.0 XML Schema) or String.\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.