cpee-transformation 1.0.3 → 1.0.7
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 +73 -1
- data/cpee-transformation.gemspec +10 -2
- data/lib/cpee/transformation/bpmn2.rb +35 -2
- data/lib/cpee/transformation/cpee.rb +49 -5
- data/lib/cpee/transformation/graphviz.rb +190 -33
- data/lib/cpee/transformation/implementation.rb +6 -0
- data/lib/cpee/transformation/implementation.xml +4 -0
- data/lib/cpee/transformation/mermaid.rb +55 -18
- data/lib/cpee/transformation/ptml.rb +71 -68
- data/lib/cpee/transformation/structures.rb +41 -6
- data/lib/cpee/transformation/target.rb +14 -1
- data/lib/cpee/transformation/transformer.rb +1 -1
- data/server/trans.conf +1 -0
- data/tools/trans_bpmn2-to-graphviz +85 -0
- data/tools/{bpmn2_to_ptml.rb → trans_bpmn2-to-ptml} +1 -3
- data/tools/trans_cpee-to-bpmn2 +92 -0
- data/tools/trans_cpee-to-graphviz +85 -0
- data/tools/{cpee_to_ptml.rb → trans_cpee-to-ptml} +1 -3
- metadata +35 -24
- /data/tools/{bpmn2_to_cpee.rb → trans_bpmn2-to-cpee} +0 -0
- /data/tools/{bpmn2_to_mermaid.rb → trans_bpmn2-to-mermaid} +0 -0
- /data/tools/{cpee_to_cpee.rb → trans_cpee-to-cpee} +0 -0
- /data/tools/{cpee_to_dataflow.rb → trans_cpee-to-dataflow} +0 -0
- /data/tools/{cpee_to_mermaid.rb → trans_cpee-to-mermaid} +0 -0
- /data/tools/{cpee_to_text_bf.rb → trans_cpee-to-text-bf} +0 -0
- /data/tools/{cpee_to_text_df-poe.rb → trans_cpee-to-text-df-poe} +0 -0
- /data/tools/{cpee_to_text_df-por.rb → trans_cpee-to-text-df-por} +0 -0
- /data/tools/{mermaid_to_cpee.rb → trans_mermaid-to-cpee} +0 -0
- /data/tools/{ptml_to_cpee.rb → trans_ptml-to-cpee} +0 -0
|
@@ -64,6 +64,42 @@ module CPEE
|
|
|
64
64
|
end
|
|
65
65
|
private :map_nodes
|
|
66
66
|
|
|
67
|
+
ENTITIES = { 'quot' => '"', 'amp' => '&', 'lt' => '<', 'gt' => '>', 'apos' => "'", 'nbsp' => " " }
|
|
68
|
+
|
|
69
|
+
### mermaid entity codes (#quot; #35;) and <br>, in one pass, so that
|
|
70
|
+
### decoded text is not decoded again
|
|
71
|
+
def decode(text) #{{{
|
|
72
|
+
text.gsub(/<br\s*\/?>|#(\d+|[a-zA-Z]+);/i) do |m|
|
|
73
|
+
code = $1 ### the =~ below would overwrite $1
|
|
74
|
+
if code.nil?
|
|
75
|
+
"\n"
|
|
76
|
+
elsif code =~ /^\d+$/
|
|
77
|
+
code.to_i.chr(Encoding::UTF_8)
|
|
78
|
+
else
|
|
79
|
+
ENTITIES[code] || m
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end #}}}
|
|
83
|
+
private :decode
|
|
84
|
+
|
|
85
|
+
### only double quotes delimit a mermaid string, single quotes are text
|
|
86
|
+
def unquote(text) #{{{
|
|
87
|
+
text = text.to_s.strip
|
|
88
|
+
if text =~ /\A"(.*)"\z/m
|
|
89
|
+
decode($1).strip
|
|
90
|
+
else
|
|
91
|
+
### older output escaped brackets instead of quoting
|
|
92
|
+
decode(text.gsub(/\\([()])/,'\1'))
|
|
93
|
+
end
|
|
94
|
+
end #}}}
|
|
95
|
+
private :unquote
|
|
96
|
+
|
|
97
|
+
### strip one pair of brackets and unquote: ( ) -> '', (" ") -> '', ("B") -> B, ('B') -> 'B'
|
|
98
|
+
def clean_label(label) #{{{
|
|
99
|
+
unquote(label.to_s.sub(/^\(/,'').sub(/\)$/,''))
|
|
100
|
+
end #}}}
|
|
101
|
+
private :clean_label
|
|
102
|
+
|
|
67
103
|
def extract_nodelink(text) #{{{
|
|
68
104
|
first = nil
|
|
69
105
|
text.each_line do |line|
|
|
@@ -91,22 +127,14 @@ module CPEE
|
|
|
91
127
|
rlabel = $3
|
|
92
128
|
end
|
|
93
129
|
|
|
94
|
-
llabel =
|
|
95
|
-
rlabel =
|
|
96
|
-
llabel.sub(/^'/,'')
|
|
97
|
-
llabel.sub(/'$/,'')
|
|
98
|
-
llabel.sub(/^"/,'')
|
|
99
|
-
llabel.sub(/"$/,'')
|
|
100
|
-
rlabel.sub(/^'/,'')
|
|
101
|
-
rlabel.sub(/'$/,'')
|
|
102
|
-
rlabel.sub(/^"/,'')
|
|
103
|
-
rlabel.sub(/"$/,'')
|
|
130
|
+
llabel = clean_label(llabel)
|
|
131
|
+
rlabel = clean_label(rlabel)
|
|
104
132
|
|
|
105
133
|
# every line contains a link
|
|
106
|
-
@graph.add_link Link.new(lid, rid, c.nil? ? nil : c
|
|
134
|
+
@graph.add_link Link.new(lid, rid, c.nil? ? nil : unquote(c))
|
|
107
135
|
|
|
108
|
-
n1 = Node.new(self.object_id,lid,map_nodes(ltype),llabel
|
|
109
|
-
n2 = Node.new(self.object_id,rid,map_nodes(rtype),rlabel
|
|
136
|
+
n1 = Node.new(self.object_id,lid,map_nodes(ltype),llabel,0,1)
|
|
137
|
+
n2 = Node.new(self.object_id,rid,map_nodes(rtype),rlabel,1,0)
|
|
110
138
|
|
|
111
139
|
@graph.add_node n1, :outgoing
|
|
112
140
|
@graph.add_node n2, :incoming
|
|
@@ -149,6 +177,15 @@ module CPEE
|
|
|
149
177
|
|
|
150
178
|
private
|
|
151
179
|
|
|
180
|
+
### always a double quoted mermaid string, with entity codes for what mermaid
|
|
181
|
+
### (html, quotes) or the reader (-->, |) would interpret. "" is a mermaid
|
|
182
|
+
### syntax error, so empty becomes " "
|
|
183
|
+
def text(s)
|
|
184
|
+
s = s.to_s.strip
|
|
185
|
+
s = s.empty? ? ' ' : s.gsub(/[#"&<>|]/) { |c| c == '"' ? '#quot;' : "##{c.ord};" }.gsub(/\r?\n/,'<br>')
|
|
186
|
+
"\"#{s}\""
|
|
187
|
+
end
|
|
188
|
+
|
|
152
189
|
def set_fromto(pn,nid)
|
|
153
190
|
if pn.is_a?(Array) && pn.length > 1
|
|
154
191
|
@fromto << [pn[0],nid,pn[1]]
|
|
@@ -160,9 +197,9 @@ module CPEE
|
|
|
160
197
|
def print_Node(node,pn)
|
|
161
198
|
nid = node.id
|
|
162
199
|
if node.endpoints.empty? && ((!node.script.nil? && node.script.strip != '') || node.type == :scriptTask)
|
|
163
|
-
@labels[nid] = "#{nid}:script:(#{node.label
|
|
200
|
+
@labels[nid] = "#{nid}:script:(#{text node.label})"
|
|
164
201
|
else
|
|
165
|
-
@labels[nid] = "#{nid}:task:(#{node.label
|
|
202
|
+
@labels[nid] = "#{nid}:task:(#{text node.label})"
|
|
166
203
|
end
|
|
167
204
|
set_fromto pn, nid
|
|
168
205
|
nid
|
|
@@ -204,7 +241,7 @@ module CPEE
|
|
|
204
241
|
### branches without condition (incl. otherwise) are plain edges, the reader
|
|
205
242
|
### treats the last of them as otherwise
|
|
206
243
|
pn = if branch.condition.any?
|
|
207
|
-
generate_in_list(branch,["#{nid}s","
|
|
244
|
+
generate_in_list(branch,["#{nid}s","|#{text branch.condition.join(' or ')}|"])
|
|
208
245
|
else
|
|
209
246
|
generate_in_list(branch,"#{nid}s")
|
|
210
247
|
end
|
|
@@ -226,9 +263,9 @@ module CPEE
|
|
|
226
263
|
|
|
227
264
|
cn = if node.mode == :pre_test
|
|
228
265
|
set_fromto "#{nid}s", "#{nid}e"
|
|
229
|
-
[ ["#{nid}e", "
|
|
266
|
+
[ ["#{nid}e", "|#{text cond}|"], "#{nid}s"]
|
|
230
267
|
else
|
|
231
|
-
set_fromto ["#{nid}e","
|
|
268
|
+
set_fromto ["#{nid}e","|#{text cond}|"], "#{nid}s"
|
|
232
269
|
["#{nid}s", "#{nid}e"]
|
|
233
270
|
end
|
|
234
271
|
|
|
@@ -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)
|
|
@@ -181,60 +188,61 @@ module CPEE
|
|
|
181
188
|
end
|
|
182
189
|
|
|
183
190
|
def print_Loop(node,res)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
|
198
235
|
generate_in_list(branch,res)
|
|
199
|
-
|
|
200
|
-
elsif branch.length >1
|
|
236
|
+
elsif items.length >1
|
|
201
237
|
branch_last = @last
|
|
202
238
|
rid = rand.to_s[2..11]
|
|
203
239
|
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
204
|
-
|
|
240
|
+
set_edges(@last,rid,res)
|
|
205
241
|
@last = rid
|
|
206
242
|
generate_in_list(branch,res)
|
|
207
243
|
@last = branch_last
|
|
208
244
|
end
|
|
209
245
|
end
|
|
210
|
-
elsif node.sub.length > 2
|
|
211
|
-
node.sub.reverse.each do |branch|
|
|
212
|
-
if branch[0].type == :break
|
|
213
|
-
rid = rand.to_s[2..11]
|
|
214
|
-
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
215
|
-
set_edges(@last,rid,res)
|
|
216
|
-
#Add new xor
|
|
217
|
-
xor_id = rand.to_s[2..11]
|
|
218
|
-
res.add('xor', 'id' => xor_id, 'name' => 'help-xor')
|
|
219
|
-
set_edges(@last,xor_id,res)
|
|
220
|
-
escape_id = rand.to_s[2..11]
|
|
221
|
-
res.add('manualTask', 'id' => escape_id, 'name' => 'escape')
|
|
222
|
-
set_edges(xor_id,escape_id,res)
|
|
223
|
-
@last = xor_id
|
|
224
|
-
else
|
|
225
|
-
if branch.length == 1
|
|
226
|
-
generate_in_list(branch,res)
|
|
227
|
-
elsif branch.length >1
|
|
228
|
-
branch_last = @last
|
|
229
|
-
rid = rand.to_s[2..11]
|
|
230
|
-
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
231
|
-
set_edges(@last,rid,res)
|
|
232
|
-
@last = rid
|
|
233
|
-
generate_in_list(branch,res)
|
|
234
|
-
@last = branch_last
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
246
|
end
|
|
239
247
|
end
|
|
240
248
|
@last = original_last
|
|
@@ -242,11 +250,7 @@ module CPEE
|
|
|
242
250
|
end
|
|
243
251
|
|
|
244
252
|
def print_Node(node,res) #{{{
|
|
245
|
-
|
|
246
|
-
if res.children.length == 0
|
|
247
|
-
res.add('sequence', 'id' => @last, 'name' => 'main-sequence')
|
|
248
|
-
end
|
|
249
|
-
nid = "a#{node.niceid}"
|
|
253
|
+
nid = uid("a#{node.niceid}")
|
|
250
254
|
if node.endpoints.empty? && ((!node.script.nil? && node.script.strip != '') || node.type == :scriptTask)
|
|
251
255
|
n = res.add('automaticTask','id' => nid, 'name' => node.label)
|
|
252
256
|
else
|
|
@@ -268,9 +272,10 @@ module CPEE
|
|
|
268
272
|
|
|
269
273
|
def print_Conditional(node,res) #{{{
|
|
270
274
|
original_last = @last
|
|
271
|
-
nid = "a#{node.id}"
|
|
275
|
+
nid = uid("a#{node.id}")
|
|
272
276
|
|
|
273
|
-
|
|
277
|
+
### process trees have no deferred choice, xor is closest
|
|
278
|
+
if node.type == :exclusiveGateway || node.type == :eventBasedGateway
|
|
274
279
|
res.add('xor','id' => nid, 'name' => nil)
|
|
275
280
|
elsif node.type == :parallelGateway
|
|
276
281
|
res.add('and','id' => nid, 'name' => nil)
|
|
@@ -278,33 +283,31 @@ module CPEE
|
|
|
278
283
|
res.add('or','id' => nid, 'name' => nil)
|
|
279
284
|
end
|
|
280
285
|
|
|
281
|
-
|
|
282
|
-
if res.children.length == 1
|
|
283
|
-
res.attributes['root'] = nid
|
|
284
|
-
else
|
|
285
|
-
set_edges(@last,nid,res)
|
|
286
|
-
end
|
|
286
|
+
set_edges(@last,nid,res)
|
|
287
287
|
@last = nid
|
|
288
288
|
node.sub.each do |branch|
|
|
289
|
-
#get conditions and default
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
|
293
295
|
rid = rand.to_s[2..11]
|
|
294
296
|
res.add('automaticTask', 'id' => rid, 'name' => 'tau')
|
|
295
|
-
set_edges_condition(@last,rid,res,cond,default)
|
|
296
|
-
elsif
|
|
297
|
+
conditional ? set_edges_condition(@last,rid,res,cond,default) : set_edges(@last,rid,res)
|
|
298
|
+
elsif items.length == 1
|
|
297
299
|
generate_in_list(branch,res)
|
|
298
|
-
if
|
|
300
|
+
if !conditional
|
|
301
|
+
elsif default
|
|
299
302
|
res.find("//parentsNode[@sourceId='#{@last}']").last.attributes['default'] = default
|
|
300
303
|
else
|
|
301
304
|
res.find("//parentsNode[@sourceId='#{@last}']").last.attributes['condition'] = cond
|
|
302
305
|
end
|
|
303
|
-
elsif
|
|
306
|
+
elsif items.length >1
|
|
304
307
|
branch_last = @last
|
|
305
308
|
rid = rand.to_s[2..11]
|
|
306
309
|
res.add('sequence', 'id' => rid, 'name' => 'just-sequence')
|
|
307
|
-
set_edges_condition(@last,rid,res,cond,default)
|
|
310
|
+
conditional ? set_edges_condition(@last,rid,res,cond,default) : set_edges(@last,rid,res)
|
|
308
311
|
@last = rid
|
|
309
312
|
generate_in_list(branch,res)
|
|
310
313
|
@last = branch_last
|
|
@@ -91,6 +91,26 @@ module CPEE
|
|
|
91
91
|
super context, '-2', :terminate, 'TERMINATE', 1, []
|
|
92
92
|
end
|
|
93
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 #}}}
|
|
94
114
|
|
|
95
115
|
class Alternative < Array #{{{
|
|
96
116
|
include Container
|
|
@@ -299,6 +319,8 @@ module CPEE
|
|
|
299
319
|
ret << print_tree(e,indent + (last ? ' ' : '│ '),verbose)
|
|
300
320
|
elsif e.is_a?(Break) || e.is_a?(Terminate)
|
|
301
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"
|
|
302
324
|
else
|
|
303
325
|
ret << indent + pchar + ' ' + e.niceid.to_s + (verbose ? " (#{e.label})" : "") + "\n"
|
|
304
326
|
end
|
|
@@ -315,9 +337,9 @@ module CPEE
|
|
|
315
337
|
end
|
|
316
338
|
|
|
317
339
|
def remove(trcs)
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
340
|
+
### a set, deleting one by one is quadratic for many traces
|
|
341
|
+
rem = trcs.to_set
|
|
342
|
+
self.reject!{ |t| rem.include?(t) }
|
|
321
343
|
end
|
|
322
344
|
def remove_by_endnode(enode)
|
|
323
345
|
self.delete_if do |t|
|
|
@@ -419,8 +441,19 @@ module CPEE
|
|
|
419
441
|
|
|
420
442
|
def add_breaks(context,front=true)
|
|
421
443
|
### traces that are a prefix of another trace were cut short at an earlier
|
|
422
|
-
### visited node, they do not leave the loop, so they get no break
|
|
423
|
-
|
|
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] }
|
|
424
457
|
### a trace whose last node occurs earlier in it is a loop (to the head or to
|
|
425
458
|
### an inner loop), not a way out. a trace ending in terminate needs no break
|
|
426
459
|
trueloops = self.find_all{ |t| t[0..-2].include?(t.last) || t.last&.type == :terminate }.length
|
|
@@ -441,8 +474,10 @@ module CPEE
|
|
|
441
474
|
end
|
|
442
475
|
def loops_and_partial_loops
|
|
443
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
|
|
444
479
|
self.each do |t|
|
|
445
|
-
lo << t if
|
|
480
|
+
lo << t if sn.include?(t[1])
|
|
446
481
|
end
|
|
447
482
|
lo.uniq!
|
|
448
483
|
lo
|
|
@@ -23,13 +23,25 @@ module CPEE
|
|
|
23
23
|
module Target
|
|
24
24
|
|
|
25
25
|
class Default
|
|
26
|
-
def initialize(tree)
|
|
26
|
+
def initialize(tree,dir=nil)
|
|
27
27
|
@tree = tree
|
|
28
|
+
@dir = dir # layout direction of the source model (td, lr), if known
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
### SingleParallel markers are only printed by targets that know them
|
|
32
|
+
def ignore?(e,nam)
|
|
33
|
+
e.is_a?(SingleParallel) && !respond_to?("print_#{nam}".to_sym,true)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
### the elements of a list this target prints (e.g. to count them)
|
|
37
|
+
def visible(list)
|
|
38
|
+
list.reject { |e| ignore?(e,e.class.name.gsub(/\w+:+/,'')) }
|
|
28
39
|
end
|
|
29
40
|
|
|
30
41
|
def generate_in_list(list,res)
|
|
31
42
|
list.each do |e|
|
|
32
43
|
nam = e.class.name.gsub(/\w+:+/,'')
|
|
44
|
+
next if ignore?(e,nam)
|
|
33
45
|
res = send("print_#{nam}".to_sym,e,res) # always save last node
|
|
34
46
|
end
|
|
35
47
|
res
|
|
@@ -39,6 +51,7 @@ module CPEE
|
|
|
39
51
|
post = []
|
|
40
52
|
list.each do |e|
|
|
41
53
|
nam = e.class.name.gsub(/\w+:+/,'')
|
|
54
|
+
next if ignore?(e,nam)
|
|
42
55
|
post += send("print_#{nam}".to_sym,e,res)
|
|
43
56
|
end
|
|
44
57
|
post.compact!
|
data/server/trans.conf
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:bpmnexport: npx -y -p cpee-layout@^1.2.0 bpmnexport
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
|
|
41
|
+
require_relative '../lib/cpee/transformation/transformer' rescue nil
|
|
42
|
+
require_relative '../lib/cpee/transformation/bpmn2' rescue nil
|
|
43
|
+
require_relative '../lib/cpee/transformation/graphviz' rescue nil
|
|
44
|
+
|
|
45
|
+
interactive = false
|
|
46
|
+
printtree = false
|
|
47
|
+
|
|
48
|
+
ARGV.options { |opt|
|
|
49
|
+
opt.summary_indent = ' ' * 2
|
|
50
|
+
opt.summary_width = 18
|
|
51
|
+
opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} FNAME\n"
|
|
52
|
+
opt.on("Options:")
|
|
53
|
+
opt.on("--help", "-h", "This text") { puts opt; exit }
|
|
54
|
+
opt.on("--interactive", "-i", "Interactive mode") { interactive = true }
|
|
55
|
+
opt.on("--tree", "-t", "Print tree") { printtree = true }
|
|
56
|
+
opt.on("")
|
|
57
|
+
opt.on(wrap("[FNAME]","convert cpee bpmn2 in file FNAME to graphviz and output to console."))
|
|
58
|
+
opt.parse!
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ARGV.length != 1
|
|
62
|
+
puts ARGV.options
|
|
63
|
+
exit
|
|
64
|
+
else
|
|
65
|
+
f = ARGV[0]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
model = CPEE::Transformation::Source::BPMN2.new(File.read(f))
|
|
69
|
+
|
|
70
|
+
trans = CPEE::Transformation::Transformer.new(model)
|
|
71
|
+
traces = trans.build_traces
|
|
72
|
+
|
|
73
|
+
if interactive
|
|
74
|
+
puts traces.legend
|
|
75
|
+
puts
|
|
76
|
+
tree = trans.build_tree(true)
|
|
77
|
+
else
|
|
78
|
+
tree = trans.build_tree(false)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
if printtree
|
|
82
|
+
puts tree.to_s
|
|
83
|
+
else
|
|
84
|
+
puts trans.generate_model(CPEE::Transformation::Target::Graphviz)
|
|
85
|
+
end
|
|
@@ -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
|