cpee-transformation 1.0.2 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +68 -1
- data/cpee-transformation.gemspec +10 -2
- data/lib/cpee/transformation/beautiful.rb +1 -1
- data/lib/cpee/transformation/bpmn2.rb +38 -4
- data/lib/cpee/transformation/cpee.rb +78 -23
- data/lib/cpee/transformation/dataflow.rb +5 -1
- data/lib/cpee/transformation/graphviz.rb +1 -1
- data/lib/cpee/transformation/implementation.rb +5 -1
- data/lib/cpee/transformation/implementation.xml +4 -1
- data/lib/cpee/transformation/mermaid.rb +27 -18
- data/lib/cpee/transformation/ptml.rb +79 -69
- data/lib/cpee/transformation/structures.rb +58 -8
- data/lib/cpee/transformation/target.rb +13 -1
- data/lib/cpee/transformation/text-bf.rb +6 -1
- data/lib/cpee/transformation/text-df-PO-extended.rb +6 -1
- data/lib/cpee/transformation/text-df-PO-reduced.rb +6 -1
- data/lib/cpee/transformation/transformer.rb +20 -2
- data/server/trans.conf +1 -0
- data/server/trans.pid +1 -0
- data/tools/bpmn2_to_cpee.rb +1 -1
- data/tools/bpmn2_to_mermaid.rb +1 -1
- data/tools/bpmn2_to_ptml.rb +2 -4
- data/tools/cpee_to_bpmn2.rb +92 -0
- data/tools/cpee_to_cpee.rb +1 -1
- data/tools/cpee_to_dataflow.rb +1 -1
- data/tools/cpee_to_mermaid.rb +1 -1
- data/tools/cpee_to_ptml.rb +2 -4
- data/tools/cpee_to_text_bf.rb +1 -1
- data/tools/cpee_to_text_df-poe.rb +1 -1
- data/tools/cpee_to_text_df-por.rb +1 -1
- data/tools/mermaid_to_cpee.rb +1 -1
- data/tools/ptml_to_cpee.rb +1 -1
- metadata +11 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
require_relative 'target'
|
|
@@ -141,14 +141,21 @@ module CPEE
|
|
|
141
141
|
def generate
|
|
142
142
|
start_id = "rootid"
|
|
143
143
|
@last = start_id
|
|
144
|
+
@ids = Hash.new(0)
|
|
144
145
|
res = XML::Smart.string("<ptml><processTree id='tree01' name='ptml-tree' root='#{start_id}'/></ptml>")
|
|
145
|
-
|
|
146
|
+
res.root.children[0].add('sequence', 'id' => start_id, 'name' => 'main-sequence')
|
|
146
147
|
generate_in_list(@tree,res.root.children[0])
|
|
147
148
|
res.to_s
|
|
148
149
|
end
|
|
149
150
|
|
|
150
151
|
private
|
|
151
152
|
|
|
153
|
+
### nodes can occur more than once in the tree (e.g. unrolled loops)
|
|
154
|
+
def uid(id)
|
|
155
|
+
n = (@ids[id] += 1)
|
|
156
|
+
n == 1 ? id : "#{id}_#{n}"
|
|
157
|
+
end
|
|
158
|
+
|
|
152
159
|
def set_edges(source,target,res)
|
|
153
160
|
rid = rand.to_s[2..11]
|
|
154
161
|
res.add('parentsNode','id'=> rid, 'sourceId' => source, 'targetId' => target)
|
|
@@ -173,61 +180,69 @@ module CPEE
|
|
|
173
180
|
res
|
|
174
181
|
end
|
|
175
182
|
|
|
183
|
+
def print_Terminate(node,res)
|
|
184
|
+
rid = rand.to_s[2..11]
|
|
185
|
+
n = res.add('manualTask','id' => rid, 'name' => node.label)
|
|
186
|
+
set_edges(@last,rid,res)
|
|
187
|
+
res
|
|
188
|
+
end
|
|
189
|
+
|
|
176
190
|
def print_Loop(node,res)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
### post_test loops are written like pre_test loops
|
|
192
|
+
original_last = @last
|
|
193
|
+
nid = uid("a#{node.id}")
|
|
194
|
+
res.add('xorLoop','id' => nid, 'name' => nil)
|
|
195
|
+
set_edges(@last,nid,res)
|
|
196
|
+
@last = nid
|
|
197
|
+
if node.sub.length == 2
|
|
198
|
+
node.sub.reverse.each do |branch|
|
|
199
|
+
cond = branch.condition.any? ? branch.condition[0] : nil
|
|
200
|
+
items = visible(branch)
|
|
201
|
+
if items[0]&.type == :break
|
|
202
|
+
rid = rand.to_s[2..11]
|
|
203
|
+
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
204
|
+
set_edges(@last,rid,res)
|
|
205
|
+
elsif items.length == 1
|
|
206
|
+
generate_in_list(branch,res)
|
|
207
|
+
res.find("//parentsNode[@sourceId='#{@last}']").last.attributes['condition'] = cond
|
|
208
|
+
elsif items.length >1
|
|
209
|
+
branch_last = @last
|
|
210
|
+
rid = rand.to_s[2..11]
|
|
211
|
+
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
212
|
+
set_edges_condition(@last,rid,res,cond,false)
|
|
213
|
+
@last = rid
|
|
214
|
+
generate_in_list(branch,res)
|
|
215
|
+
@last = branch_last
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
elsif node.sub.length > 2
|
|
219
|
+
node.sub.reverse.each do |branch|
|
|
220
|
+
items = visible(branch)
|
|
221
|
+
if items[0]&.type == :break
|
|
222
|
+
rid = rand.to_s[2..11]
|
|
223
|
+
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
224
|
+
set_edges(@last,rid,res)
|
|
225
|
+
#Add new xor
|
|
226
|
+
xor_id = rand.to_s[2..11]
|
|
227
|
+
res.add('xor', 'id' => xor_id, 'name' => 'help-xor')
|
|
228
|
+
set_edges(@last,xor_id,res)
|
|
229
|
+
escape_id = rand.to_s[2..11]
|
|
230
|
+
res.add('manualTask', 'id' => escape_id, 'name' => 'escape')
|
|
231
|
+
set_edges(xor_id,escape_id,res)
|
|
232
|
+
@last = xor_id
|
|
233
|
+
else
|
|
234
|
+
if items.length == 1
|
|
191
235
|
generate_in_list(branch,res)
|
|
192
|
-
|
|
193
|
-
elsif branch.length >1
|
|
236
|
+
elsif items.length >1
|
|
194
237
|
branch_last = @last
|
|
195
238
|
rid = rand.to_s[2..11]
|
|
196
239
|
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
197
|
-
|
|
240
|
+
set_edges(@last,rid,res)
|
|
198
241
|
@last = rid
|
|
199
242
|
generate_in_list(branch,res)
|
|
200
243
|
@last = branch_last
|
|
201
244
|
end
|
|
202
245
|
end
|
|
203
|
-
elsif node.sub.length > 2
|
|
204
|
-
node.sub.reverse.each do |branch|
|
|
205
|
-
if branch[0].type == :break
|
|
206
|
-
rid = rand.to_s[2..11]
|
|
207
|
-
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
208
|
-
set_edges(@last,rid,res)
|
|
209
|
-
#Add new xor
|
|
210
|
-
xor_id = rand.to_s[2..11]
|
|
211
|
-
res.add('xor', 'id' => xor_id, 'name' => 'help-xor')
|
|
212
|
-
set_edges(@last,xor_id,res)
|
|
213
|
-
escape_id = rand.to_s[2..11]
|
|
214
|
-
res.add('manualTask', 'id' => escape_id, 'name' => 'escape')
|
|
215
|
-
set_edges(xor_id,escape_id,res)
|
|
216
|
-
@last = xor_id
|
|
217
|
-
else
|
|
218
|
-
if branch.length == 1
|
|
219
|
-
generate_in_list(branch,res)
|
|
220
|
-
elsif branch.length >1
|
|
221
|
-
branch_last = @last
|
|
222
|
-
rid = rand.to_s[2..11]
|
|
223
|
-
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
224
|
-
set_edges(@last,rid,res)
|
|
225
|
-
@last = rid
|
|
226
|
-
generate_in_list(branch,res)
|
|
227
|
-
@last = branch_last
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
246
|
end
|
|
232
247
|
end
|
|
233
248
|
@last = original_last
|
|
@@ -235,11 +250,7 @@ module CPEE
|
|
|
235
250
|
end
|
|
236
251
|
|
|
237
252
|
def print_Node(node,res) #{{{
|
|
238
|
-
|
|
239
|
-
if res.children.length == 0
|
|
240
|
-
res.add('sequence', 'id' => @last, 'name' => 'main-sequence')
|
|
241
|
-
end
|
|
242
|
-
nid = "a#{node.niceid}"
|
|
253
|
+
nid = uid("a#{node.niceid}")
|
|
243
254
|
if node.endpoints.empty? && ((!node.script.nil? && node.script.strip != '') || node.type == :scriptTask)
|
|
244
255
|
n = res.add('automaticTask','id' => nid, 'name' => node.label)
|
|
245
256
|
else
|
|
@@ -261,9 +272,10 @@ module CPEE
|
|
|
261
272
|
|
|
262
273
|
def print_Conditional(node,res) #{{{
|
|
263
274
|
original_last = @last
|
|
264
|
-
nid = "a#{node.id}"
|
|
275
|
+
nid = uid("a#{node.id}")
|
|
265
276
|
|
|
266
|
-
|
|
277
|
+
### process trees have no deferred choice, xor is closest
|
|
278
|
+
if node.type == :exclusiveGateway || node.type == :eventBasedGateway
|
|
267
279
|
res.add('xor','id' => nid, 'name' => nil)
|
|
268
280
|
elsif node.type == :parallelGateway
|
|
269
281
|
res.add('and','id' => nid, 'name' => nil)
|
|
@@ -271,33 +283,31 @@ module CPEE
|
|
|
271
283
|
res.add('or','id' => nid, 'name' => nil)
|
|
272
284
|
end
|
|
273
285
|
|
|
274
|
-
|
|
275
|
-
if res.children.length == 1
|
|
276
|
-
res.attributes['root'] = nid
|
|
277
|
-
else
|
|
278
|
-
set_edges(@last,nid,res)
|
|
279
|
-
end
|
|
286
|
+
set_edges(@last,nid,res)
|
|
280
287
|
@last = nid
|
|
281
288
|
node.sub.each do |branch|
|
|
282
|
-
#get conditions and default
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
#get conditions and default (parallel branches have none)
|
|
290
|
+
conditional = branch.condition?
|
|
291
|
+
cond = conditional && branch.condition.any? ? branch.condition[0] : nil
|
|
292
|
+
default = conditional && branch.otherwise ? true : nil
|
|
293
|
+
items = visible(branch)
|
|
294
|
+
if items.length == 0
|
|
286
295
|
rid = rand.to_s[2..11]
|
|
287
296
|
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
288
|
-
set_edges_condition(@last,rid,res,cond,default)
|
|
289
|
-
elsif
|
|
297
|
+
conditional ? set_edges_condition(@last,rid,res,cond,default) : set_edges(@last,rid,res)
|
|
298
|
+
elsif items.length == 1
|
|
290
299
|
generate_in_list(branch,res)
|
|
291
|
-
if
|
|
300
|
+
if !conditional
|
|
301
|
+
elsif default
|
|
292
302
|
res.find("//parentsNode[@sourceId='#{@last}']").last.attributes['default'] = default
|
|
293
303
|
else
|
|
294
304
|
res.find("//parentsNode[@sourceId='#{@last}']").last.attributes['condition'] = cond
|
|
295
305
|
end
|
|
296
|
-
elsif
|
|
306
|
+
elsif items.length >1
|
|
297
307
|
branch_last = @last
|
|
298
308
|
rid = rand.to_s[2..11]
|
|
299
309
|
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
300
|
-
set_edges_condition(@last,rid,res,cond,default)
|
|
310
|
+
conditional ? set_edges_condition(@last,rid,res,cond,default) : set_edges(@last,rid,res)
|
|
301
311
|
@last = rid
|
|
302
312
|
generate_in_list(branch,res)
|
|
303
313
|
@last = branch_last
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
module CPEE
|
|
@@ -86,6 +86,31 @@ module CPEE
|
|
|
86
86
|
super context, '-1', :break, 'BREAK', 1, []
|
|
87
87
|
end
|
|
88
88
|
end #}}}
|
|
89
|
+
class Terminate < Node #{{{
|
|
90
|
+
def initialize(context)
|
|
91
|
+
super context, '-2', :terminate, 'TERMINATE', 1, []
|
|
92
|
+
end
|
|
93
|
+
end #}}}
|
|
94
|
+
### a cpee parallel whose branches are not direct children (e.g. created
|
|
95
|
+
### in a loop). Its content is a sequence between an open and a close
|
|
96
|
+
### marker, so that cpee in and cpee out can be the same. Targets without a
|
|
97
|
+
### print method for it ignore it.
|
|
98
|
+
class SingleParallel < Node #{{{
|
|
99
|
+
def initialize(context,id,open,attributes={})
|
|
100
|
+
super context, id, :singleParallel, '', 1, 1
|
|
101
|
+
@open = open
|
|
102
|
+
@attributes.merge!(attributes)
|
|
103
|
+
end
|
|
104
|
+
def open?; @open; end
|
|
105
|
+
end #}}}
|
|
106
|
+
### a cpee parallel_branch that is not a direct child of a parallel, see
|
|
107
|
+
### SingleParallel.
|
|
108
|
+
class SingleParallelBranch < SingleParallel #{{{
|
|
109
|
+
def initialize(context,id,open,attributes={})
|
|
110
|
+
super
|
|
111
|
+
@type = :singleParallelBranch
|
|
112
|
+
end
|
|
113
|
+
end #}}}
|
|
89
114
|
|
|
90
115
|
class Alternative < Array #{{{
|
|
91
116
|
include Container
|
|
@@ -252,12 +277,17 @@ module CPEE
|
|
|
252
277
|
def link(f,t)
|
|
253
278
|
@links.find{ |x| x.from == f && x.to == t }
|
|
254
279
|
end
|
|
280
|
+
def links_from(f)
|
|
281
|
+
@links.find_all{ |x| x.from == f }
|
|
282
|
+
end
|
|
255
283
|
|
|
256
284
|
def add_link(l)
|
|
257
285
|
@links << l
|
|
258
286
|
end
|
|
259
287
|
|
|
260
288
|
def next_nodes(from)
|
|
289
|
+
### a terminate ends the process, nothing follows
|
|
290
|
+
return [] if from&.type == :terminate
|
|
261
291
|
links = @links.find_all { |x| x.from == from.id }
|
|
262
292
|
links.map{|x| @nodes[x.to] }
|
|
263
293
|
end
|
|
@@ -287,8 +317,10 @@ module CPEE
|
|
|
287
317
|
cname = e.class.to_s.gsub(/[^:]*::/,'')
|
|
288
318
|
ret << indent + pchar + ' ' + cname + " #{cname == 'Alternative' ? e.condition : ''}\n"
|
|
289
319
|
ret << print_tree(e,indent + (last ? ' ' : '│ '),verbose)
|
|
290
|
-
elsif e.is_a?(Break)
|
|
320
|
+
elsif e.is_a?(Break) || e.is_a?(Terminate)
|
|
291
321
|
ret << indent + pchar + ' ' + e.class.to_s.gsub(/[^:]*::/,'') + "\n"
|
|
322
|
+
elsif e.is_a?(SingleParallel)
|
|
323
|
+
ret << indent + pchar + ' ' + e.class.to_s.gsub(/[^:]*::/,'') + (e.open? ? '' : ' End') + "\n"
|
|
292
324
|
else
|
|
293
325
|
ret << indent + pchar + ' ' + e.niceid.to_s + (verbose ? " (#{e.label})" : "") + "\n"
|
|
294
326
|
end
|
|
@@ -305,9 +337,9 @@ module CPEE
|
|
|
305
337
|
end
|
|
306
338
|
|
|
307
339
|
def remove(trcs)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
340
|
+
### a set, deleting one by one is quadratic for many traces
|
|
341
|
+
rem = trcs.to_set
|
|
342
|
+
self.reject!{ |t| rem.include?(t) }
|
|
311
343
|
end
|
|
312
344
|
def remove_by_endnode(enode)
|
|
313
345
|
self.delete_if do |t|
|
|
@@ -408,13 +440,29 @@ module CPEE
|
|
|
408
440
|
end
|
|
409
441
|
|
|
410
442
|
def add_breaks(context,front=true)
|
|
411
|
-
|
|
443
|
+
### traces that are a prefix of another trace were cut short at an earlier
|
|
444
|
+
### visited node, they do not leave the loop, so they get no break.
|
|
445
|
+
### sorted, all extensions of a trace directly follow it, so comparing
|
|
446
|
+
### with the next different trace is enough
|
|
447
|
+
keys = self.map{ |t| t.map{ |n| n.object_id } }
|
|
448
|
+
prefix = {}
|
|
449
|
+
last = nextdiff = nil
|
|
450
|
+
(0...self.length).sort_by{ |i| keys[i] }.reverse_each do |i|
|
|
451
|
+
k = keys[i]
|
|
452
|
+
nextdiff = last unless k == last
|
|
453
|
+
prefix[i] = true if nextdiff && nextdiff.length > k.length && nextdiff[0...k.length] == k
|
|
454
|
+
last = k
|
|
455
|
+
end
|
|
456
|
+
self.reject!.with_index{ |t,i| prefix[i] }
|
|
457
|
+
### a trace whose last node occurs earlier in it is a loop (to the head or to
|
|
458
|
+
### an inner loop), not a way out. a trace ending in terminate needs no break
|
|
459
|
+
trueloops = self.find_all{ |t| t[0..-2].include?(t.last) || t.last&.type == :terminate }.length
|
|
412
460
|
tb = Break.new(context)
|
|
413
461
|
if trueloops == self.length
|
|
414
462
|
self << (front ? [nil,tb] : [tb,nil])
|
|
415
463
|
else
|
|
416
464
|
self.each do |t|
|
|
417
|
-
t << tb unless t.last
|
|
465
|
+
t << tb unless t[0..-2].include?(t.last) || t.last&.type == :terminate ### an explicit break
|
|
418
466
|
end
|
|
419
467
|
end
|
|
420
468
|
end
|
|
@@ -426,8 +474,10 @@ module CPEE
|
|
|
426
474
|
end
|
|
427
475
|
def loops_and_partial_loops
|
|
428
476
|
lo = Traces.new self.find_all{ |t| t.first == t.last }
|
|
477
|
+
### computed once, traces added below share their second node anyway
|
|
478
|
+
sn = lo.second_nodes.to_set
|
|
429
479
|
self.each do |t|
|
|
430
|
-
lo << t if
|
|
480
|
+
lo << t if sn.include?(t[1])
|
|
431
481
|
end
|
|
432
482
|
lo.uniq!
|
|
433
483
|
lo
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
module CPEE
|
|
@@ -27,9 +27,20 @@ module CPEE
|
|
|
27
27
|
@tree = tree
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
### SingleParallel markers are only printed by targets that know them
|
|
31
|
+
def ignore?(e,nam)
|
|
32
|
+
e.is_a?(SingleParallel) && !respond_to?("print_#{nam}".to_sym,true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
### the elements of a list this target prints (e.g. to count them)
|
|
36
|
+
def visible(list)
|
|
37
|
+
list.reject { |e| ignore?(e,e.class.name.gsub(/\w+:+/,'')) }
|
|
38
|
+
end
|
|
39
|
+
|
|
30
40
|
def generate_in_list(list,res)
|
|
31
41
|
list.each do |e|
|
|
32
42
|
nam = e.class.name.gsub(/\w+:+/,'')
|
|
43
|
+
next if ignore?(e,nam)
|
|
33
44
|
res = send("print_#{nam}".to_sym,e,res) # always save last node
|
|
34
45
|
end
|
|
35
46
|
res
|
|
@@ -39,6 +50,7 @@ module CPEE
|
|
|
39
50
|
post = []
|
|
40
51
|
list.each do |e|
|
|
41
52
|
nam = e.class.name.gsub(/\w+:+/,'')
|
|
53
|
+
next if ignore?(e,nam)
|
|
42
54
|
post += send("print_#{nam}".to_sym,e,res)
|
|
43
55
|
end
|
|
44
56
|
post.compact!
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/target')
|
|
@@ -83,6 +83,11 @@ module CPEE
|
|
|
83
83
|
[nil]
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
def print_Terminate(node,res)
|
|
87
|
+
res << get_next("at this point the process is terminated. ")
|
|
88
|
+
[nil]
|
|
89
|
+
end
|
|
90
|
+
|
|
86
91
|
def print_Loop(node,res)
|
|
87
92
|
post = []
|
|
88
93
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/target')
|
|
@@ -98,6 +98,11 @@ module CPEE
|
|
|
98
98
|
res
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
def print_Terminate(node,res)
|
|
102
|
+
res << "At this point the process is terminated. "
|
|
103
|
+
res
|
|
104
|
+
end
|
|
105
|
+
|
|
101
106
|
def print_Loop(node,res)
|
|
102
107
|
@loop ||= 0
|
|
103
108
|
@loop += 1
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
require File.expand_path(File.dirname(__FILE__) + '/target')
|
|
@@ -98,6 +98,11 @@ module CPEE
|
|
|
98
98
|
res
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
def print_Terminate(node,res)
|
|
102
|
+
res << "At this point the process is terminated. "
|
|
103
|
+
res
|
|
104
|
+
end
|
|
105
|
+
|
|
101
106
|
def print_Loop(node,res)
|
|
102
107
|
logic = Proc.new do
|
|
103
108
|
if node.mode == :pre_test
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# for more details.
|
|
14
14
|
#
|
|
15
15
|
# You should have received a copy of the GNU Lesser General Public License
|
|
16
|
-
# along with CPEE-TRANSFORMATION (file
|
|
16
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
17
17
|
# see <http://www.gnu.org/licenses/>.
|
|
18
18
|
|
|
19
19
|
require_relative 'structures'
|
|
@@ -83,6 +83,8 @@ module CPEE
|
|
|
83
83
|
flat ? nil : Conditional.new(node.id,:inclusive,node.type,node.label)
|
|
84
84
|
when :break
|
|
85
85
|
flat ? Break.new(node.id) : Break.new(node.id)
|
|
86
|
+
when :terminate
|
|
87
|
+
Terminate.new(node.id)
|
|
86
88
|
when :endEvent, :startEvent, nil
|
|
87
89
|
nil
|
|
88
90
|
else
|
|
@@ -113,7 +115,10 @@ module CPEE
|
|
|
113
115
|
else
|
|
114
116
|
### if traces.all_tail? && traces.length > 1 && !traces.all_loops?
|
|
115
117
|
### we had traces.all_tail? here. why?
|
|
116
|
-
|
|
118
|
+
### a direct link from the branch (e.g. loop gateway) to the first node wins
|
|
119
|
+
if (dl = @source.graph.link(branch.id,traces.first_node.id))
|
|
120
|
+
dl
|
|
121
|
+
elsif !traces.all_tail? && traces.length > 1 && !traces.all_loops?
|
|
117
122
|
@source.graph.link(traces.first[-2].id,traces.first[-1].id)
|
|
118
123
|
else
|
|
119
124
|
@source.graph.link(branch.id,traces.first_node.id)
|
|
@@ -156,6 +161,8 @@ module CPEE
|
|
|
156
161
|
### at the output time it is decided wether this can be optimized
|
|
157
162
|
branch << Loop.new(node.id)
|
|
158
163
|
branch.last.mode = :post_test if loops.all_tail?
|
|
164
|
+
### there is no way out, so add a default otherwise with a break
|
|
165
|
+
loops.add_breaks(self.object_id,node.type == :exclusiveGateway)
|
|
159
166
|
### remove the exclusive gateway because we no longer need it
|
|
160
167
|
### if there is non (tail controlled, remove the loop target (last)
|
|
161
168
|
if node.type == :exclusiveGateway
|
|
@@ -267,6 +274,17 @@ module CPEE
|
|
|
267
274
|
puts '--> ebranch down to ' + (down + 1).to_s if debug
|
|
268
275
|
build_ttree nb, trcs, endnode, debug, down + 1
|
|
269
276
|
puts '--> ebranch up from ' + (down + 1).to_s if debug
|
|
277
|
+
else
|
|
278
|
+
### empty branch (e.g. loops straight back), its target is already gone
|
|
279
|
+
### so use the only gateway link that no other branch starts with
|
|
280
|
+
used = tracesgroup.reject{ |t| t.finished? }.map{ |t| t.first_node&.id }
|
|
281
|
+
lis = @source.graph.links_from(nb.id).reject{ |l| used.include?(l.to) }
|
|
282
|
+
if lis.length == 1 && nb.condition?
|
|
283
|
+
li = lis.first
|
|
284
|
+
nb.condition << li.condition if !li.condition.nil? && !li.condition&.strip&.empty?
|
|
285
|
+
nb.otherwise = li.otherwise if li.condition.nil?
|
|
286
|
+
nb.condition_type = "text/x-ruby"
|
|
287
|
+
end
|
|
270
288
|
end
|
|
271
289
|
end
|
|
272
290
|
# remove all traces that don't start with endnode to account for loops
|
data/server/trans.conf
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:bpmnexport: npx -y -p cpee-layout@^1.2.0 bpmnexport
|
data/server/trans.pid
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1235950
|
data/tools/bpmn2_to_cpee.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# for more details.
|
|
15
15
|
#
|
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
-
# along with CPEE-TRANSFORMATION (file
|
|
17
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
18
18
|
# see <http://www.gnu.org/licenses/>.
|
|
19
19
|
|
|
20
20
|
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|
data/tools/bpmn2_to_mermaid.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# for more details.
|
|
15
15
|
#
|
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
-
# along with CPEE-TRANSFORMATION (file
|
|
17
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
18
18
|
# see <http://www.gnu.org/licenses/>.
|
|
19
19
|
|
|
20
20
|
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|
data/tools/bpmn2_to_ptml.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# for more details.
|
|
15
15
|
#
|
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
-
# along with CPEE-TRANSFORMATION (file
|
|
17
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
18
18
|
# see <http://www.gnu.org/licenses/>.
|
|
19
19
|
|
|
20
20
|
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|
|
@@ -54,7 +54,7 @@ ARGV.options { |opt|
|
|
|
54
54
|
opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
|
|
55
55
|
opt.on("--tree", "-t", "Print tree") { printtree = true }
|
|
56
56
|
opt.on("")
|
|
57
|
-
opt.on(wrap("[FNAME]","convert
|
|
57
|
+
opt.on(wrap("[FNAME]","convert bpmn2 in file FNAME to ptml and output to console."))
|
|
58
58
|
opt.parse!
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -78,8 +78,6 @@ else
|
|
|
78
78
|
tree = trans.build_tree(false)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
pp tree
|
|
82
|
-
|
|
83
81
|
if printtree
|
|
84
82
|
puts tree.to_s
|
|
85
83
|
else
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
#
|
|
4
|
+
# This file is part of CPEE-TRANSFORMATION.
|
|
5
|
+
#
|
|
6
|
+
# CPEE-TRANSFORMATION is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or (at your
|
|
9
|
+
# option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# CPEE-TRANSFORMATION is distributed in the hope that it will be useful, but
|
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
14
|
+
# for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
18
|
+
# see <http://www.gnu.org/licenses/>.
|
|
19
|
+
|
|
20
|
+
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|
|
21
|
+
lines = []
|
|
22
|
+
s = ARGV.options.summary_indent + s1 + ' ' * (indent - s1.length - ARGV.options.summary_indent.length) + s2
|
|
23
|
+
line, s = s[0..indent-2], s[indent..-1]
|
|
24
|
+
s.split(/\n/).each do |ss|
|
|
25
|
+
ss.split(/[ \t]+/).each do |word|
|
|
26
|
+
if line.size + word.size >= width
|
|
27
|
+
lines << line
|
|
28
|
+
line = (" " * (indent)) + word
|
|
29
|
+
else
|
|
30
|
+
line << " " << word
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
lines << line if line
|
|
34
|
+
line = (" " * (indent-1))
|
|
35
|
+
end
|
|
36
|
+
return lines.join("\n")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
require 'optparse'
|
|
40
|
+
require 'psych'
|
|
41
|
+
|
|
42
|
+
require_relative '../lib/cpee/transformation/transformer' rescue nil
|
|
43
|
+
require_relative '../lib/cpee/transformation/cpee' rescue nil
|
|
44
|
+
require_relative '../lib/cpee/transformation/bpmn2' rescue nil
|
|
45
|
+
|
|
46
|
+
# bpmnexport from cpee-layout, configured as for the server, see Target::BPMN2
|
|
47
|
+
conf = File.join(__dir__,'..','server','trans.conf')
|
|
48
|
+
CPEE::Transformation::Target::BPMN2.opts = {
|
|
49
|
+
:basepath => File.dirname(conf)
|
|
50
|
+
}.merge(File.exist?(conf) ? Psych::load_file(conf) || {} : {})
|
|
51
|
+
|
|
52
|
+
interactive = false
|
|
53
|
+
printtree = false
|
|
54
|
+
|
|
55
|
+
ARGV.options { |opt|
|
|
56
|
+
opt.summary_indent = ' ' * 2
|
|
57
|
+
opt.summary_width = 18
|
|
58
|
+
opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
|
|
59
|
+
opt.on("Options:")
|
|
60
|
+
opt.on("--help", "-h", "This text") { puts opt; exit }
|
|
61
|
+
opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
|
|
62
|
+
opt.on("--tree", "-t", "Print tree") { printtree = true }
|
|
63
|
+
opt.on("")
|
|
64
|
+
opt.on(wrap("[FNAME]","convert cpee tree in file FNAME to bpmn2 and output to console."))
|
|
65
|
+
opt.parse!
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if ARGV.length != 1
|
|
69
|
+
puts ARGV.options
|
|
70
|
+
exit
|
|
71
|
+
else
|
|
72
|
+
f = ARGV[0]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
model = CPEE::Transformation::Source::CPEE.new(File.read(f))
|
|
76
|
+
|
|
77
|
+
trans = CPEE::Transformation::Transformer.new(model)
|
|
78
|
+
traces = trans.build_traces
|
|
79
|
+
|
|
80
|
+
if interactive
|
|
81
|
+
puts traces.legend
|
|
82
|
+
puts
|
|
83
|
+
tree = trans.build_tree(true)
|
|
84
|
+
else
|
|
85
|
+
tree = trans.build_tree(false)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if printtree
|
|
89
|
+
puts tree.to_s
|
|
90
|
+
else
|
|
91
|
+
puts trans.generate_model(CPEE::Transformation::Target::BPMN2)
|
|
92
|
+
end
|
data/tools/cpee_to_cpee.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# for more details.
|
|
15
15
|
#
|
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
|
17
|
-
# along with CPEE-TRANSFORMATION (file
|
|
17
|
+
# along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
|
|
18
18
|
# see <http://www.gnu.org/licenses/>.
|
|
19
19
|
|
|
20
20
|
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|
data/tools/cpee_to_dataflow.rb
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
13
13
|
#
|
|
14
14
|
# You should have received a copy of the GNU Lesser General Public License along with
|
|
15
|
-
# cpee-transformation (file
|
|
15
|
+
# cpee-transformation (file LICENSE in the main directory). If not, see
|
|
16
16
|
# <http://www.gnu.org/licenses/>.
|
|
17
17
|
|
|
18
18
|
def wrap(s1, s2, width=78, indent=ARGV.options.summary_width + 3)
|