Skip to content

Commit

Permalink
Merge branch 'PM4PY-1542' into 'integration'
Browse files Browse the repository at this point in the history
PM4PY-1542 More general namespace in BPMN exporting in PM4Py

See merge request process-mining/pm4py/pm4py-core!591
  • Loading branch information
fit-alessandro-berti committed Jan 15, 2022
2 parents d2dc3cf + efbb273 commit effce8d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions pm4py/objects/bpmn/exporter/variants/etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def get_xml_string(bpmn_graph, parameters=None):
import xml.etree.ElementTree as ET
from xml.dom import minidom

definitions = ET.Element("definitions")
definitions.set("xmlns", "http://www.omg.org/spec/BPMN/20100524/MODEL")
definitions = ET.Element("bpmn:definitions")
definitions.set("xmlns:bpmn", "http://www.omg.org/spec/BPMN/20100524/MODEL")
definitions.set("xmlns:bpmndi", "http://www.omg.org/spec/BPMN/20100524/DI")
definitions.set("xmlns:omgdc", "http://www.omg.org/spec/DD/20100524/DC")
definitions.set("xmlns:omgdi", "http://www.omg.org/spec/DD/20100524/DI")
Expand All @@ -53,7 +53,7 @@ def get_xml_string(bpmn_graph, parameters=None):
{"bpmnElement": "id" + process, "id": "id" + str(uuid.uuid4())})
process_planes[process] = plane

p = ET.SubElement(definitions, "process",
p = ET.SubElement(definitions, "bpmn:process",
{"id": "id" + process, "isClosed": "false", "isExecutable": "false",
"processType": "None"})
process_process[process] = p
Expand Down Expand Up @@ -83,50 +83,50 @@ def get_xml_string(bpmn_graph, parameters=None):
if isinstance(node, BPMN.StartEvent):
isInterrupting = "true" if node.get_isInterrupting() else "false"
parallelMultiple = "true" if node.get_parallelMultiple() else "false"
task = ET.SubElement(process, "startEvent",
task = ET.SubElement(process, "bpmn:startEvent",
{"id": node.get_id(), "isInterrupting": isInterrupting, "name": node.get_name(),
"parallelMultiple": parallelMultiple})
elif isinstance(node, BPMN.EndEvent):
task = ET.SubElement(process, "endEvent", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:endEvent", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.IntermediateCatchEvent):
task = ET.SubElement(process, "intermediateCatchEvent", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:intermediateCatchEvent", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.IntermediateThrowEvent):
task = ET.SubElement(process, "intermediateThrowEvent", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:intermediateThrowEvent", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.BoundaryEvent):
task = ET.SubElement(process, "boundaryEvent", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:boundaryEvent", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.Task):
task = ET.SubElement(process, "task", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:task", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.SubProcess):
task = ET.SubElement(process, "subProcess", {"id": node.get_id(), "name": node.get_name()})
task = ET.SubElement(process, "bpmn:subProcess", {"id": node.get_id(), "name": node.get_name()})
elif isinstance(node, BPMN.ExclusiveGateway):
task = ET.SubElement(process, "exclusiveGateway",
task = ET.SubElement(process, "bpmn:exclusiveGateway",
{"id": node.get_id(), "gatewayDirection": node.get_gateway_direction().value.lower(),
"name": ""})
elif isinstance(node, BPMN.ParallelGateway):
task = ET.SubElement(process, "parallelGateway",
task = ET.SubElement(process, "bpmn:parallelGateway",
{"id": node.get_id(), "gatewayDirection": node.get_gateway_direction().value.lower(),
"name": ""})
elif isinstance(node, BPMN.InclusiveGateway):
task = ET.SubElement(process, "inclusiveGateway",
task = ET.SubElement(process, "bpmn:inclusiveGateway",
{"id": node.get_id(), "gatewayDirection": node.get_gateway_direction().value.lower(),
"name": ""})
else:
raise Exception("Unexpected node type.")

for in_arc in node.get_in_arcs():
arc_xml = ET.SubElement(task, "incoming")
arc_xml = ET.SubElement(task, "bpmn:incoming")
arc_xml.text = "id" + str(in_arc.get_id())

for out_arc in node.get_out_arcs():
arc_xml = ET.SubElement(task, "outgoing")
arc_xml = ET.SubElement(task, "bpmn:outgoing")
arc_xml.text = "id" + str(out_arc.get_id())

for flow in bpmn_graph.get_flows():
process = process_process[flow.get_process()]

source = flow.get_source()
target = flow.get_target()
flow_xml = ET.SubElement(process, "sequenceFlow", {"id": "id" + str(flow.get_id()), "name": flow.get_name(),
flow_xml = ET.SubElement(process, "bpmn:sequenceFlow", {"id": "id" + str(flow.get_id()), "name": flow.get_name(),
"sourceRef": str(source.get_id()),
"targetRef": str(target.get_id())})

Expand Down

0 comments on commit effce8d

Please sign in to comment.