cpee-transformation 1.0.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61bbed7eec2d5c90a7e146f5c1bc3e59c0ffaffe191a0d7ba51c8ab43de21433
4
- data.tar.gz: 660d67bf5dad21acdd20776be18aa44374242403321f1a405444eba0c44a395a
3
+ metadata.gz: 8702f90089fd5baaddfa08045af0abcacfb5b253d8396827eb99daabb200e596
4
+ data.tar.gz: 6f7d4a223a40d261c3029ae7742378f379b5be304103aedd2661d514405c9994
5
5
  SHA512:
6
- metadata.gz: bec2f7ae1f8ed396de9162eb1cb7226b1a4bbb1244562b2f901931ea54960b8341f8e5776cdae5876366fc3091306887b3ae9f9673d189141ce774a87e2abef3
7
- data.tar.gz: c13eece54bee6c22e51029d1b311f044b251d687cb5a83baeb24485554b7ee2840f38c33bc5c763398225fc283b161390ce49577904558458217fe3278adb6c1
6
+ metadata.gz: 984586caa45d868466e5e14ff79b2f44fe1df8e82c4dafb8eac0c4874e555242a731859a34ea57acd0b68ca7fbcbe16cd2682e4af52880dcf845d8174528f165
7
+ data.tar.gz: 57b36295c10df9062d2da0ab2b1c9e0803b6e5a49099177d183abf7959dd08918a80a22b5880453a9bbb1bc4ece1a34ab29840182e6731667b8f54bfb306cb05
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-transformation"
3
- s.version = "1.0.1"
3
+ s.version = "1.0.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "CPEE Transformation between different formats"
@@ -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 COPYING in the main directory). If not,
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'
@@ -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 COPYING in the main directory). If not,
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'
@@ -74,7 +74,10 @@ module CPEE
74
74
 
75
75
  def extract_nodelink(doc) #{{{
76
76
  doc.find("/bm:definitions/bm:process/bm:*[@id and @name and not(@itemSubjectRef) and not(name()='sequenceFlow')]").each do |e|
77
- n = Node.new(self.object_id,e.attributes['id'],e.qname.name.to_sym,e.attributes['name'].strip,e.find('count(bm:incoming)'),e.find('count(bm:outgoing)'))
77
+ type = e.qname.name.to_sym
78
+ ### an end event with a terminate definition ends the whole process
79
+ type = :terminate if type == :endEvent && e.find('bm:terminateEventDefinition').any?
80
+ n = Node.new(self.object_id,e.attributes['id'],type,e.attributes['name'].strip,e.find('count(bm:incoming)'),e.find('count(bm:outgoing)'))
78
81
 
79
82
  if e.attributes['scriptFormat'] != ''
80
83
  n.script_type = e.attributes['scriptFormat']
@@ -113,12 +116,13 @@ module CPEE
113
116
  @start = n if n.type == :startEvent && @start == nil
114
117
  end
115
118
 
116
- # extract all sequences to a links
119
+ # extract all sequences to a links, default flows of gateways are otherwise
120
+ defaults = doc.find("/bm:definitions/bm:process/bm:*[@default]/@default").map{ |d| d.value }
117
121
  doc.find("/bm:definitions/bm:process/bm:sequenceFlow").each do |e|
118
122
  source = e.attributes['sourceRef']
119
123
  target = e.attributes['targetRef']
120
124
  cond = e.find('bm:conditionExpression')
121
- @graph.add_link Link.new(source, target, cond.empty? ? nil : cond.first.text.strip)
125
+ @graph.add_link Link.new(source, target, cond.empty? ? nil : cond.first.text.strip, defaults.include?(e.attributes['id']))
122
126
  end
123
127
 
124
128
  @graph.clean_up do |node|
@@ -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 COPYING in the main directory). If not,
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'
@@ -56,19 +56,19 @@ module CPEE
56
56
  end
57
57
 
58
58
  def dive(node,n1=nil,condition=nil,otherwise=false)
59
- if node.children.empty?
59
+ if node.children.empty? || node.text_only?
60
60
  return n1
61
61
  end
62
62
  if n1.nil?
63
63
  nid = id_find(node.attributes['id'] || node.attributes['eid'])
64
- n1 = @start = Node.new(0,nid,:startEvent,'',0,1)
64
+ n1 = @start = Node.new(self.object_id,nid,:startEvent,'',0,1)
65
65
  end
66
66
  node.children.each do |ele|
67
67
  case ele.qname.name
68
68
  when 'loop'
69
69
  if ele.attributes['mode'] == 'pre_test'
70
70
  nid = id_find(ele.attributes['eid'])
71
- nx = Node.new(0,nid,:exclusiveGateway,nil,2,2)
71
+ nx = Node.new(self.object_id,nid,:exclusiveGateway,nil,2,2)
72
72
  @graph.add_node nx
73
73
  @graph.add_link Link.new(n1.id, nx.id, condition, otherwise)
74
74
 
@@ -79,14 +79,14 @@ module CPEE
79
79
  n1 = nx
80
80
  else
81
81
  nid = id_find(ele.attributes['eid'])
82
- nx = Node.new(0,nid,:exclusiveGateway,nil,2,1)
82
+ nx = Node.new(self.object_id,nid,:exclusiveGateway,nil,2,1)
83
83
  @graph.add_node nx
84
84
  @graph.add_link Link.new(n1.id, nx.id, condition, otherwise)
85
85
  condition = nil
86
86
 
87
87
  bn = dive ele, nx, ele.attributes['condition']
88
88
 
89
- no = Node.new(0,nid + 'e',:exclusiveGateway,nil,1,2)
89
+ no = Node.new(self.object_id,nid + 'e',:exclusiveGateway,nil,1,2)
90
90
  @graph.add_node no
91
91
  @graph.add_link Link.new(bn.id, no.id)
92
92
  @graph.add_link Link.new(no.id, nx.id, ele.attributes['condition'])
@@ -94,7 +94,7 @@ module CPEE
94
94
  end
95
95
  when 'call'
96
96
  nid = id_find(ele.attributes['id'])
97
- no = Node.new(0,nid,:task,ele.find("string(d:parameters/d:label)"),1,1)
97
+ no = Node.new(self.object_id,nid,:task,ele.find("string(d:parameters/d:label)"),1,1)
98
98
  no.methods << ele.find("string(d:parameters/d:method)")
99
99
  no.endpoints << ele.attributes['endpoint']
100
100
  ele.find("d:parameters/d:arguments/d:*").each do |e|
@@ -110,7 +110,7 @@ module CPEE
110
110
  n1 = no
111
111
  when 'manipulate'
112
112
  nid = id_find(ele.attributes['id'])
113
- no = Node.new(0,nid,:scriptTask,ele.attributes['label'].to_s,1,1)
113
+ no = Node.new(self.object_id,nid,:scriptTask,ele.attributes['label'].to_s,1,1)
114
114
  no.script_type = 'application/x-ruby'
115
115
  no.script = ele.find("string(d:code)")
116
116
  @graph.add_link Link.new(n1.id, no.id, condition, otherwise)
@@ -120,12 +120,12 @@ module CPEE
120
120
  when 'parallel'
121
121
  bra = ele.find('d:parallel_branch')
122
122
  nid = id_find(ele.attributes['eid'])
123
- ns = Node.new(0,nid,:parallelGateway,nil,1,bra.length)
123
+ ns = Node.new(self.object_id,nid,:parallelGateway,nil,1,bra.length)
124
124
  ns.attributes[:wait] = ele.attributes['wait'] || -1
125
125
  ns.attributes[:cancel] = ele.attributes['cancel'] || 'last'
126
126
  @graph.add_link Link.new(n1.id, ns.id, condition, otherwise)
127
127
  condition = nil
128
- ne = Node.new(0,nid + 'e',:parallelGateway,nil,1,bra.length)
128
+ ne = Node.new(self.object_id,nid + 'e',:parallelGateway,nil,1,bra.length)
129
129
  @graph.add_node ns
130
130
  @graph.add_node ne
131
131
  bra.each do |br|
@@ -136,10 +136,10 @@ module CPEE
136
136
  when 'choose'
137
137
  nid = id_find(ele.attributes['eid'])
138
138
  bra = ele.find('d:alternative|d:otherwise')
139
- ns = Node.new(0,nid,:exclusiveGateway,ele.attributes['label'],1,bra.length)
139
+ ns = Node.new(self.object_id,nid,:exclusiveGateway,ele.attributes['label'],1,bra.length)
140
140
  @graph.add_link Link.new(n1.id, ns.id, condition, otherwise)
141
141
  condition = nil
142
- ne = Node.new(0,nid + 'e',:exclusiveGateway,nil,1,bra.length)
142
+ ne = Node.new(self.object_id,nid + 'e',:exclusiveGateway,nil,1,bra.length)
143
143
  @graph.add_node ns
144
144
  @graph.add_node ne
145
145
  bra.each do |br|
@@ -153,7 +153,14 @@ module CPEE
153
153
  n1 = ne
154
154
  when 'escape'
155
155
  nid = id_find(ele.attributes['eid'])
156
- no = Node.new(0,nid,:break,'',1,1)
156
+ no = Node.new(self.object_id,nid,:break,'',1,1)
157
+ @graph.add_link Link.new(n1.id, no.id, condition, otherwise)
158
+ @graph.add_node no
159
+ condition = nil
160
+ n1 = no
161
+ when 'terminate'
162
+ nid = id_find(ele.attributes['eid'])
163
+ no = Node.new(self.object_id,nid,:terminate,'',1,0)
157
164
  @graph.add_link Link.new(n1.id, no.id, condition, otherwise)
158
165
  @graph.add_node no
159
166
  condition = nil
@@ -168,7 +175,7 @@ module CPEE
168
175
  doc = XML::Smart::string(text)
169
176
  doc.register_namespace :d, 'http://cpee.org/ns/description/1.0'
170
177
  bn = dive doc.root
171
- ne = Node.new(0,Digest::MD5.hexdigest(Kernel::rand().to_s),:endEvent,'',1,0)
178
+ ne = Node.new(self.object_id,Digest::MD5.hexdigest(Kernel::rand().to_s),:endEvent,'',1,0)
172
179
  @graph.add_node ne
173
180
  @graph.add_link Link.new(bn.id, ne.id)
174
181
  end
@@ -197,6 +204,11 @@ module CPEE
197
204
  res
198
205
  end
199
206
 
207
+ def print_Terminate(node,res)
208
+ res.add('terminate', 'a:alt_id' => node.id)
209
+ res
210
+ end
211
+
200
212
  def print_Loop(node,res)
201
213
  eid = "e#{(@eid += 1)}"
202
214
  if node.sub.length == 2 && node.sub[1].condition.empty? && ((node.sub[1].length == 1 && node.sub[1][0].class.name.gsub(/\w+:+/,'') == 'Break') || node.sub[1].length == 0)
@@ -207,10 +219,12 @@ module CPEE
207
219
  end
208
220
  generate_in_list(node.sub[0],s1)
209
221
  else
210
- s1 = res.add('loop', 'mode' => node.mode, 'condition' => node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && '), 'eid' => eid)
211
222
  if node.sub.length == 1
223
+ s1 = res.add('loop', 'mode' => node.mode, 'condition' => node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && '), 'eid' => eid)
212
224
  generate_in_list(node.sub[0],s1)
213
225
  else
226
+ ### the choose over all alternatives decides (escape), so loop forever
227
+ s1 = res.add('loop', 'mode' => node.mode, 'condition' => 'true', 'eid' => eid)
214
228
  print_Conditional(node,s1)
215
229
  end
216
230
  end
@@ -273,21 +287,20 @@ module CPEE
273
287
 
274
288
  def print_Conditional(node,res)
275
289
  eid = "e#{(@eid += 1)}"
276
- s1 = res.add('d:choose', 'label' => node.label, 'mode' => node.mode == :inclusive ? 'inclusive' : 'exclusive', 'a:alt_id' => node.id, 'eid' => eid)
277
- otherwise = false
290
+ s1 = res.add('d:choose', 'label' => node.respond_to?(:label) ? node.label : '', 'mode' => node.mode == :inclusive ? 'inclusive' : 'exclusive', 'a:alt_id' => node.id, 'eid' => eid)
291
+ ### the otherwise is the explicit one, else the last branch without condition
292
+ ### (keeps the order stable), compare by identity as empty branches are ==
293
+ ow = node.sub.reverse.find{ |b| b.condition.empty? && b.otherwise } || node.sub.reverse.find{ |b| b.condition.empty? }
278
294
  node.sub.each do |branch|
279
295
  bid = "e#{(@eid += 1)}"
280
296
  s2 = if branch.condition.any?
281
297
  a = s1.add('d:alternative','condition' => branch.condition.join(' or '), 'eid' => bid)
282
298
  a.attributes['language'] = branch.condition_type unless branch.condition_type.nil?
283
299
  a
300
+ elsif branch.equal?(ow)
301
+ s1.add('d:otherwise', 'eid' => bid)
284
302
  else
285
- if branch.otherwise || !otherwise
286
- otherwise = true
287
- s1.add('d:otherwise', 'eid' => bid)
288
- else
289
- s1.add('d:alternative', 'condition' => '', 'eid' => bid)
290
- end
303
+ s1.add('d:alternative', 'condition' => '', 'eid' => bid)
291
304
  end
292
305
  branch.attributes.each do |k,v|
293
306
  s2.attributes[k] = v
@@ -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 COPYING in the main directory). If not,
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'
@@ -118,6 +118,10 @@ module CPEE
118
118
  res
119
119
  end #}}}
120
120
 
121
+ def print_Terminate(node,res) #{{{
122
+ res
123
+ end #}}}
124
+
121
125
  end
122
126
 
123
127
  end #}}}
@@ -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 COPYING in the main directory). If not,
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'
@@ -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 COPYING in the main directory). If not,
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 'riddl/server'
@@ -12,7 +12,7 @@
12
12
  for more details.
13
13
 
14
14
  You should have received a copy of the GNU Lesser General Public License
15
- along with CPEE-TRANSFORMATION (file COPYING in the main directory). If not,
15
+ along with CPEE-TRANSFORMATION (file LICENSE in the main directory). If not,
16
16
  see <http://www.gnu.org/licenses/>.
17
17
  -->
18
18
 
@@ -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 COPYING in the main directory). If not,
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'
@@ -56,6 +56,8 @@ module CPEE
56
56
  when 'inclusivegateway'; :inclusiveGateway
57
57
  when 'endevent'; :endEvent
58
58
  when 'startevent'; :startEvent
59
+ when 'escalate'; :break
60
+ when 'terminate'; :terminate
59
61
  else
60
62
  nil
61
63
  end
@@ -103,8 +105,8 @@ module CPEE
103
105
  # every line contains a link
104
106
  @graph.add_link Link.new(lid, rid, c.nil? ? nil : c.to_s.gsub(/(^"|"$)/, ''))
105
107
 
106
- n1 = Node.new(0,lid,map_nodes(ltype),llabel.sub(/^\(/,'').sub(/\)$/,''),0,1)
107
- n2 = Node.new(0,rid,map_nodes(rtype),rlabel.sub(/^\(/,'').sub(/\)$/,''),1,0)
108
+ n1 = Node.new(self.object_id,lid,map_nodes(ltype),llabel.sub(/^\(/,'').sub(/\)$/,''),0,1)
109
+ n2 = Node.new(self.object_id,rid,map_nodes(rtype),rlabel.sub(/^\(/,'').sub(/\)$/,''),1,0)
108
110
 
109
111
  @graph.add_node n1, :outgoing
110
112
  @graph.add_node n2, :incoming
@@ -136,7 +138,8 @@ module CPEE
136
138
  end
137
139
 
138
140
  def id_find(nid)
139
- nid = 'g0' unless nid
141
+ ### copy, next! would otherwise also change the node id and the entry in @nids
142
+ nid = nid ? nid.dup : 'g0'
140
143
  while @nids.include?(nid)
141
144
  nid.next!
142
145
  end
@@ -165,13 +168,21 @@ module CPEE
165
168
  nid
166
169
  end
167
170
 
171
+ ### breaks and terminates all have the same node id, so make them unique
168
172
  def print_Break(node,pn)
169
- nid = node.id
173
+ nid = id_find('b1')
170
174
  @labels[nid] = "#{nid}:escalate:((^))"
171
175
  set_fromto pn, nid
172
176
  nid
173
177
  end
174
178
 
179
+ def print_Terminate(node,pn)
180
+ nid = id_find('t1')
181
+ @labels[nid] = "#{nid}:terminate:((terminate))"
182
+ set_fromto pn, nid
183
+ nid
184
+ end
185
+
175
186
  def print_Parallel(node,pn)
176
187
  nid = id_find(node.id)
177
188
  set_fromto pn, "#{nid}s"
@@ -190,14 +201,12 @@ module CPEE
190
201
  @labels["#{nid}s"] = "#{nid}s:exclusivegateway:{x}"
191
202
  @labels["#{nid}e"] = "#{nid}e:exclusivegateway:{x}"
192
203
  node.sub.each do |branch|
204
+ ### branches without condition (incl. otherwise) are plain edges, the reader
205
+ ### treats the last of them as otherwise
193
206
  pn = if branch.condition.any?
194
207
  generate_in_list(branch,["#{nid}s","|\"#{branch.condition.join(' or ')}\"|"])
195
208
  else
196
- if branch.otherwise
197
- generate_in_list(branch,["#{nid}s","|\"|\"|"])
198
- else
199
- generate_in_list(branch,"#{nid}s")
200
- end
209
+ generate_in_list(branch,"#{nid}s")
201
210
  end
202
211
  set_fromto pn, "#{nid}e"
203
212
  end
@@ -211,22 +220,22 @@ module CPEE
211
220
  @labels["#{nid}s"] = "#{nid}s:exclusivegateway:{x}"
212
221
  @labels["#{nid}e"] = "#{nid}e:exclusivegateway:{x}"
213
222
 
223
+ single = node.sub.length == 1 || (node.sub.length == 2 && node.sub[1].condition.empty? && ((node.sub[1].length == 1 && node.sub[1][0].class.name.gsub(/\w+:+/,'') == 'Break') || node.sub[1].length == 0))
224
+ ### if the conditional over all alternatives decides (break), loop forever
225
+ cond = !single || node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && ')
226
+
214
227
  cn = if node.mode == :pre_test
215
228
  set_fromto "#{nid}s", "#{nid}e"
216
- [ ["#{nid}e", "|\"#{node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && ')}\"|"], "#{nid}s"]
229
+ [ ["#{nid}e", "|\"#{cond}\"|"], "#{nid}s"]
217
230
  else
218
- set_fromto ["#{nid}e","|\"#{node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && ')}\"|"], "#{nid}s"
231
+ set_fromto ["#{nid}e","|\"#{cond}\"|"], "#{nid}s"
219
232
  ["#{nid}s", "#{nid}e"]
220
233
  end
221
234
 
222
- pn = if node.sub.length == 2 && node.sub[1].condition.empty? && ((node.sub[1].length == 1 && node.sub[1][0].class.name.gsub(/\w+:+/,'') == 'Break') || node.sub[1].length == 0)
235
+ pn = if single
223
236
  generate_in_list(node.sub[0],cn[0])
224
237
  else
225
- if node.sub.length == 1
226
- generate_in_list(node.sub[0],cn[0])
227
- else
228
- print_Conditional(node,cn[0])
229
- end
238
+ print_Conditional(node,cn[0])
230
239
  end
231
240
  set_fromto pn, cn[1]
232
241
 
@@ -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 COPYING in the main directory). If not,
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'
@@ -173,6 +173,13 @@ module CPEE
173
173
  res
174
174
  end
175
175
 
176
+ def print_Terminate(node,res)
177
+ rid = rand.to_s[2..11]
178
+ n = res.add('manualTask','id' => rid, 'name' => node.label)
179
+ set_edges(@last,rid,res)
180
+ res
181
+ end
182
+
176
183
  def print_Loop(node,res)
177
184
  if node.mode == :pre_test
178
185
  original_last = @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 COPYING in the main directory). If not,
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,11 @@ 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 #}}}
89
94
 
90
95
  class Alternative < Array #{{{
91
96
  include Container
@@ -252,12 +257,17 @@ module CPEE
252
257
  def link(f,t)
253
258
  @links.find{ |x| x.from == f && x.to == t }
254
259
  end
260
+ def links_from(f)
261
+ @links.find_all{ |x| x.from == f }
262
+ end
255
263
 
256
264
  def add_link(l)
257
265
  @links << l
258
266
  end
259
267
 
260
268
  def next_nodes(from)
269
+ ### a terminate ends the process, nothing follows
270
+ return [] if from&.type == :terminate
261
271
  links = @links.find_all { |x| x.from == from.id }
262
272
  links.map{|x| @nodes[x.to] }
263
273
  end
@@ -287,7 +297,7 @@ module CPEE
287
297
  cname = e.class.to_s.gsub(/[^:]*::/,'')
288
298
  ret << indent + pchar + ' ' + cname + " #{cname == 'Alternative' ? e.condition : ''}\n"
289
299
  ret << print_tree(e,indent + (last ? ' ' : '│ '),verbose)
290
- elsif e.is_a?(Break)
300
+ elsif e.is_a?(Break) || e.is_a?(Terminate)
291
301
  ret << indent + pchar + ' ' + e.class.to_s.gsub(/[^:]*::/,'') + "\n"
292
302
  else
293
303
  ret << indent + pchar + ' ' + e.niceid.to_s + (verbose ? " (#{e.label})" : "") + "\n"
@@ -408,13 +418,18 @@ module CPEE
408
418
  end
409
419
 
410
420
  def add_breaks(context,front=true)
411
- trueloops = self.find_all{ |t| t.last == t.first }.length
421
+ ### 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
+ self.delete_if{ |t| self.any?{ |o| o.length > t.length && o[0...t.length] == t } }
424
+ ### a trace whose last node occurs earlier in it is a loop (to the head or to
425
+ ### an inner loop), not a way out. a trace ending in terminate needs no break
426
+ trueloops = self.find_all{ |t| t[0..-2].include?(t.last) || t.last&.type == :terminate }.length
412
427
  tb = Break.new(context)
413
428
  if trueloops == self.length
414
429
  self << (front ? [nil,tb] : [tb,nil])
415
430
  else
416
431
  self.each do |t|
417
- t << tb unless t.last == t.first ### an explicit break
432
+ t << tb unless t[0..-2].include?(t.last) || t.last&.type == :terminate ### an explicit break
418
433
  end
419
434
  end
420
435
  end
@@ -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 COPYING in the main directory). If not,
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
@@ -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 COPYING in the main directory). If not,
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 COPYING in the main directory). If not,
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 COPYING in the main directory). If not,
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 COPYING in the main directory). If not,
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
- if !traces.all_tail? && traces.length > 1 && !traces.all_loops?
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
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not, see
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
@@ -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 COPYING in the main directory). If not,
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-transformation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler