Spaces:
Running
Running
work a bit
Browse files- modules/toWizard.py +21 -35
modules/toWizard.py
CHANGED
@@ -60,17 +60,22 @@ def connect(data, text_mapping, i):
|
|
60 |
return None, None
|
61 |
|
62 |
current_id = data['BPMN_id'][i]
|
|
|
|
|
63 |
next_idx = data['links'][target_idx][1]
|
64 |
next_id = data['BPMN_id'][next_idx]
|
65 |
-
if next_id.split('_')[0] == '
|
|
|
|
|
|
|
|
|
66 |
for idx, link in enumerate(data['links']):
|
67 |
if link[0] == next_idx and link[1] is not None:
|
68 |
next_text.append(text_mapping[data['BPMN_id'][link[1]]])
|
69 |
else:
|
70 |
next_text.append(text_mapping[next_id])
|
71 |
-
current_text = text_mapping[current_id]
|
72 |
|
73 |
-
return current_text, next_text
|
74 |
|
75 |
def check_start(val):
|
76 |
if val[0] is None:
|
@@ -106,16 +111,6 @@ def find_merge(bpmn_id, links):
|
|
106 |
|
107 |
return merge_elements
|
108 |
|
109 |
-
def find_end_states(data):
|
110 |
-
end_states = {}
|
111 |
-
bpmn_id = data['BPMN_id']
|
112 |
-
for idx, link in enumerate(data['links']):
|
113 |
-
if link[0] is None:
|
114 |
-
continue
|
115 |
-
if bpmn_id[link[0]].split('_')[0] == 'exclusiveGateway':
|
116 |
-
end_states[bpmn_id[idx]] = 'state_'+str(idx)
|
117 |
-
return end_states
|
118 |
-
|
119 |
def create_wizard_file(data, text_mapping):
|
120 |
root = ET.Element('methodAndStyleWizard')
|
121 |
|
@@ -133,7 +128,6 @@ def create_wizard_file(data, text_mapping):
|
|
133 |
|
134 |
processDescription = ET.SubElement(root, 'processDescription')
|
135 |
|
136 |
-
|
137 |
for idx, Bpmn_id in enumerate(data['BPMN_id']):
|
138 |
# Start Event
|
139 |
element_type = Bpmn_id.split('_')[0]
|
@@ -144,14 +138,12 @@ def create_wizard_file(data, text_mapping):
|
|
144 |
if idx >= len(data['links']):
|
145 |
continue
|
146 |
if check_start(data['links'][idx]) and (element_type=='event' or element_type=='messageEvent'):
|
147 |
-
startEvent = ET.SubElement(root, 'startEvent', attrib={'name': text_mapping[Bpmn_id], 'eventType': eventType})
|
148 |
|
149 |
requestMessage = ET.SubElement(root, 'requestMessage')
|
150 |
requester = ET.SubElement(root, 'requester')
|
151 |
|
152 |
endEvents = ET.SubElement(root, 'endStates')
|
153 |
-
|
154 |
-
print('mapping: ', text_mapping)
|
155 |
|
156 |
# Add end states event to the collaboration element
|
157 |
for idx, Bpmn_id in enumerate(data['BPMN_id']):
|
@@ -164,23 +156,23 @@ def create_wizard_file(data, text_mapping):
|
|
164 |
ET.SubElement(endEvents, 'endState', attrib={'name': text_mapping[Bpmn_id], 'eventType': 'None', 'isRegular': 'False'})
|
165 |
|
166 |
|
167 |
-
|
168 |
activities = ET.SubElement(root, 'activities')
|
169 |
-
|
170 |
for idx, activity_name in enumerate(data['BPMN_id']):
|
171 |
if activity_name.startswith('task'):
|
172 |
activity = ET.SubElement(activities, 'activity', attrib={'name': text_mapping.get(activity_name, activity_name), 'performer': ''})
|
173 |
endStates = ET.SubElement(activity, 'endStates')
|
174 |
-
current_text, next_text = connect(data, text_mapping, idx)
|
175 |
if next_text is not None and len(next_text) == 1:
|
176 |
ET.SubElement(endStates, 'endState', attrib={'name': next_text[0], 'isRegular': 'True'})
|
|
|
|
|
|
|
|
|
177 |
ET.SubElement(activity, 'subActivities')
|
178 |
ET.SubElement(activity, 'subActivityFlows')
|
179 |
ET.SubElement(activity, 'messageFlows')
|
180 |
|
181 |
-
endStates_text = find_end_states(data)
|
182 |
-
#print(endStates_text)
|
183 |
-
|
184 |
merge_object = find_merge(data['BPMN_id'], data['links'])
|
185 |
|
186 |
activityFlows = ET.SubElement(root, 'activityFlows')
|
@@ -188,16 +180,14 @@ def create_wizard_file(data, text_mapping):
|
|
188 |
for i, link in enumerate(data['links']):
|
189 |
# create flow with start event
|
190 |
if link[0] is None and link[1] is not None and (data['BPMN_id'][i].split('_')[0] == 'event' or data['BPMN_id'][i].split('_')[0] == 'messageEvent'):
|
191 |
-
current_text, next_text = connect(data, text_mapping, i)
|
192 |
-
print('current_text: ', current_text)
|
193 |
-
print('next_text: ', next_text)
|
194 |
if current_text is None or next_text is None:
|
195 |
continue
|
196 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'startEvent': current_text, 'endState': '---', 'target': next_text[0], 'isMerging': 'False', 'isPredefined': 'True'})
|
197 |
i+=1
|
198 |
# create flow with tasks
|
199 |
if link[0] is not None and link[1] is not None and data['BPMN_id'][i].split('_')[0] == 'task':
|
200 |
-
current_text, next_text = connect(data, text_mapping, i)
|
201 |
if current_text is None or next_text is None:
|
202 |
continue
|
203 |
|
@@ -206,20 +196,16 @@ def create_wizard_file(data, text_mapping):
|
|
206 |
else:
|
207 |
merge = 'False'
|
208 |
|
209 |
-
if len(next_text)
|
|
|
|
|
|
|
210 |
for next in next_text:
|
211 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next, 'isMerging': merge, 'isPredefined': 'True'})
|
212 |
elif len(next_text) == 1:
|
213 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next_text[0], 'isMerging': merge, 'isPredefined': 'True'})
|
214 |
else:
|
215 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next_text, 'isMerging': merge, 'isPredefined': 'True'})
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
"""if data['BPMN_id'][i] in endStates_text:
|
220 |
-
endState = endStates_text[data['BPMN_id'][i]]
|
221 |
-
else:
|
222 |
-
endState = '---'"""
|
223 |
|
224 |
i+=1
|
225 |
|
|
|
60 |
return None, None
|
61 |
|
62 |
current_id = data['BPMN_id'][i]
|
63 |
+
current_text = text_mapping[current_id]
|
64 |
+
|
65 |
next_idx = data['links'][target_idx][1]
|
66 |
next_id = data['BPMN_id'][next_idx]
|
67 |
+
if next_id.split('_')[0] == 'exclusiveGateway':
|
68 |
+
for idx, link in enumerate(data['links']):
|
69 |
+
if link[0] == next_idx and link[1] is not None:
|
70 |
+
next_text.append(text_mapping[data['BPMN_id'][link[1]]])
|
71 |
+
elif next_id.split('_')[0] == 'parallelGateway':
|
72 |
for idx, link in enumerate(data['links']):
|
73 |
if link[0] == next_idx and link[1] is not None:
|
74 |
next_text.append(text_mapping[data['BPMN_id'][link[1]]])
|
75 |
else:
|
76 |
next_text.append(text_mapping[next_id])
|
|
|
77 |
|
78 |
+
return current_text, next_text, next_id
|
79 |
|
80 |
def check_start(val):
|
81 |
if val[0] is None:
|
|
|
111 |
|
112 |
return merge_elements
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
def create_wizard_file(data, text_mapping):
|
115 |
root = ET.Element('methodAndStyleWizard')
|
116 |
|
|
|
128 |
|
129 |
processDescription = ET.SubElement(root, 'processDescription')
|
130 |
|
|
|
131 |
for idx, Bpmn_id in enumerate(data['BPMN_id']):
|
132 |
# Start Event
|
133 |
element_type = Bpmn_id.split('_')[0]
|
|
|
138 |
if idx >= len(data['links']):
|
139 |
continue
|
140 |
if check_start(data['links'][idx]) and (element_type=='event' or element_type=='messageEvent'):
|
141 |
+
startEvent = ET.SubElement(root, 'startEvent', attrib={'name': text_mapping[Bpmn_id], 'eventType': eventType, 'isRegular': 'False'})
|
142 |
|
143 |
requestMessage = ET.SubElement(root, 'requestMessage')
|
144 |
requester = ET.SubElement(root, 'requester')
|
145 |
|
146 |
endEvents = ET.SubElement(root, 'endStates')
|
|
|
|
|
147 |
|
148 |
# Add end states event to the collaboration element
|
149 |
for idx, Bpmn_id in enumerate(data['BPMN_id']):
|
|
|
156 |
ET.SubElement(endEvents, 'endState', attrib={'name': text_mapping[Bpmn_id], 'eventType': 'None', 'isRegular': 'False'})
|
157 |
|
158 |
|
159 |
+
# Add activities to the collaboration element
|
160 |
activities = ET.SubElement(root, 'activities')
|
|
|
161 |
for idx, activity_name in enumerate(data['BPMN_id']):
|
162 |
if activity_name.startswith('task'):
|
163 |
activity = ET.SubElement(activities, 'activity', attrib={'name': text_mapping.get(activity_name, activity_name), 'performer': ''})
|
164 |
endStates = ET.SubElement(activity, 'endStates')
|
165 |
+
current_text, next_text, next_id = connect(data, text_mapping, idx)
|
166 |
if next_text is not None and len(next_text) == 1:
|
167 |
ET.SubElement(endStates, 'endState', attrib={'name': next_text[0], 'isRegular': 'True'})
|
168 |
+
elif next_text is not None and len(next_text) >= 2 and next_id.split('_')[0] == 'exclusiveGateway':
|
169 |
+
ET.SubElement(endStates, 'endState', attrib={'name': next_text[0], 'isRegular': 'True'})
|
170 |
+
for i in range(1, len(next_text)):
|
171 |
+
ET.SubElement(endStates, 'endState', attrib={'name': next_text[i], 'isRegular': 'False'})
|
172 |
ET.SubElement(activity, 'subActivities')
|
173 |
ET.SubElement(activity, 'subActivityFlows')
|
174 |
ET.SubElement(activity, 'messageFlows')
|
175 |
|
|
|
|
|
|
|
176 |
merge_object = find_merge(data['BPMN_id'], data['links'])
|
177 |
|
178 |
activityFlows = ET.SubElement(root, 'activityFlows')
|
|
|
180 |
for i, link in enumerate(data['links']):
|
181 |
# create flow with start event
|
182 |
if link[0] is None and link[1] is not None and (data['BPMN_id'][i].split('_')[0] == 'event' or data['BPMN_id'][i].split('_')[0] == 'messageEvent'):
|
183 |
+
current_text, next_text, _ = connect(data, text_mapping, i)
|
|
|
|
|
184 |
if current_text is None or next_text is None:
|
185 |
continue
|
186 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'startEvent': current_text, 'endState': '---', 'target': next_text[0], 'isMerging': 'False', 'isPredefined': 'True'})
|
187 |
i+=1
|
188 |
# create flow with tasks
|
189 |
if link[0] is not None and link[1] is not None and data['BPMN_id'][i].split('_')[0] == 'task':
|
190 |
+
current_text, next_text, next_id = connect(data, text_mapping, i)
|
191 |
if current_text is None or next_text is None:
|
192 |
continue
|
193 |
|
|
|
196 |
else:
|
197 |
merge = 'False'
|
198 |
|
199 |
+
if len(next_text) == 2 and next_id.split('_')[0] == 'exclusiveGateway':
|
200 |
+
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': next_text[0]+'?', 'target': next_text[0], 'isMerging': 'False', 'isPredefined': 'True'})
|
201 |
+
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next_text[1], 'isMerging': 'False', 'isPredefined': 'True'})
|
202 |
+
elif len(next_text) > 1 and next_id.split('_')[0] == 'parallelGateway':
|
203 |
for next in next_text:
|
204 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next, 'isMerging': merge, 'isPredefined': 'True'})
|
205 |
elif len(next_text) == 1:
|
206 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next_text[0], 'isMerging': merge, 'isPredefined': 'True'})
|
207 |
else:
|
208 |
ET.SubElement(activityFlows, 'activityFlow', attrib={'activity': current_text, 'endState': '---', 'target': next_text, 'isMerging': merge, 'isPredefined': 'True'})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
i+=1
|
211 |
|