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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e864c92b6f08671c7597c20f38324a63aabfaf8c4fb4a0faf13bf0673ffede3a
|
|
4
|
+
data.tar.gz: ff4e121e613c2cfa9989febfe4ef347d48771349769f57d3f473d83893b7d444
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 005ccfff1028e4f76549c4fb02e8c45a99aab234ab29e6c314066e772d12e798eaf8b67c5598c1d447ae31fd00a8894afa5ed6a30e4bc9a78818ed31a65a18c0
|
|
7
|
+
data.tar.gz: 343c9853cbb58c160fe6883f5f94e96cf6484010139aef4309e310d506728ec5d3bb7600767919b10c622a8ca9e6e84d9eedd43153c4069bb35b93d26604af1f
|
data/README.md
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
# cpee-transformation
|
|
1
|
+
# cpee-transformation
|
|
2
|
+
|
|
3
|
+
## Dependencies
|
|
4
|
+
|
|
5
|
+
The Ruby dependencies (riddl, xml-smart, ...) are installed with the gem. The
|
|
6
|
+
BPMN2 target additionally needs
|
|
7
|
+
[cpee-layout](https://github.com/etm/cpee-layout) (Node.js >= 22.22), which is
|
|
8
|
+
not a gem dependency. By default it is run through `npx`, which fetches it on
|
|
9
|
+
first use (so the first BPMN2 request needs network access and is slow). To
|
|
10
|
+
avoid that, install it and point `trans.conf` to it (see BPMN2 target):
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install -g cpee-layout
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Without Node.js, everything except the `/bpmn2/...` routes works.
|
|
17
|
+
|
|
18
|
+
## Service
|
|
19
|
+
|
|
20
|
+
`cpee-trans new DIR` scaffolds the service into `DIR`: the server `trans` and
|
|
21
|
+
its config `trans.conf`, which is read from the same directory.
|
|
22
|
+
|
|
23
|
+
`trans` (port 9295) transforms process models. Routes are
|
|
24
|
+
`/TARGET/SOURCE`, POSTed with the model as `description` and `type` set to
|
|
25
|
+
`description` (the transformed model), `dataelements` or `endpoints` (lists of
|
|
26
|
+
name/value pairs, from BPMN2 sources only).
|
|
27
|
+
|
|
28
|
+
| Route | Source | Target |
|
|
29
|
+
| --------------------------- | -------- | -------------------------- |
|
|
30
|
+
| `/cpee/bpmn2` | BPMN2 | CPEE |
|
|
31
|
+
| `/cpee/mermaid` | mermaid | CPEE |
|
|
32
|
+
| `/cpee/graphviz` | graphviz | CPEE |
|
|
33
|
+
| `/bpmn2/cpee` | CPEE | BPMN2 |
|
|
34
|
+
| `/bpmn2/mermaid` | mermaid | BPMN2 |
|
|
35
|
+
| `/bpmn2/graphviz` | graphviz | BPMN2 |
|
|
36
|
+
| `/mermaid/cpee` | CPEE | mermaid |
|
|
37
|
+
| `/text-bf/cpee` | CPEE | text, text-bf |
|
|
38
|
+
| `/text-df-PO-extended/cpee` | CPEE | text, text-df-PO-extended |
|
|
39
|
+
| `/text-df-PO-reduced/cpee` | CPEE | text, text-df-PO-reduced |
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
curl -F 'description=@model.xml;type=text/xml' -F 'type=description' http://localhost:9295/bpmn2/cpee
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### BPMN2 target
|
|
46
|
+
|
|
47
|
+
The BPMN2 target generates the CPEE model and lays it out with `bpmnexport`
|
|
48
|
+
from [cpee-layout](https://github.com/etm/cpee-layout), so the result is BPMN
|
|
49
|
+
with diagram interchange, laid out as drawn by cpee-layout. How `bpmnexport` is
|
|
50
|
+
run is set in `trans.conf`. The default (also without a setting) is
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
:bpmnexport: npx -y -p cpee-layout@^1.2.0 bpmnexport
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
and after `npm install -g cpee-layout` it can be
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
:bpmnexport: bpmnexport
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
A command name is searched in `PATH`, a path (containing `/`) is relative to
|
|
63
|
+
the directory of `trans`, `~` works too, e.g.
|
|
64
|
+
`~/Projects/cpee-layout/bin/bpmnexport` for a checkout. Arguments may follow, e.g. `bpmnexport -lr` for a left to
|
|
65
|
+
right layout.
|
|
66
|
+
|
|
67
|
+
`tools/cpee_to_bpmn2.rb FNAME` does the same on the command line, using the
|
|
68
|
+
`server/trans.conf` of the gem. If `bpmnexport` can't be run or fails, the request returns 500.
|
data/cpee-transformation.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cpee-transformation"
|
|
3
|
-
s.version = "1.0.
|
|
3
|
+
s.version = "1.0.6"
|
|
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"
|
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.require_path = 'lib'
|
|
12
12
|
s.extra_rdoc_files = ['README.md']
|
|
13
13
|
s.bindir = 'tools'
|
|
14
|
-
s.executables = ['bpmn2_to_cpee.rb', 'bpmn2_to_mermaid.rb', 'bpmn2_to_ptml.rb', 'cpee_to_cpee.rb', 'cpee_to_mermaid.rb', 'cpee_to_ptml.rb', 'cpee_to_text_bf.rb', 'cpee_to_text_df-poe.rb', 'cpee_to_text_df-por.rb', 'cpee-trans', 'mermaid_to_cpee.rb', 'ptml_to_cpee.rb']
|
|
14
|
+
s.executables = ['bpmn2_to_cpee.rb', 'bpmn2_to_mermaid.rb', 'bpmn2_to_ptml.rb', 'cpee_to_bpmn2.rb', 'cpee_to_cpee.rb', 'cpee_to_mermaid.rb', 'cpee_to_ptml.rb', 'cpee_to_text_bf.rb', 'cpee_to_text_df-poe.rb', 'cpee_to_text_df-por.rb', 'cpee-trans', 'mermaid_to_cpee.rb', 'ptml_to_cpee.rb']
|
|
15
15
|
|
|
16
16
|
s.required_ruby_version = '>=3.2'
|
|
17
17
|
|
|
@@ -25,5 +25,13 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_runtime_dependency 'xml-smart', '~> 0.4'
|
|
26
26
|
s.add_runtime_dependency 'typhoeus', '~> 1.4'
|
|
27
27
|
s.add_runtime_dependency 'highline', '~> 2.0'
|
|
28
|
+
|
|
29
|
+
s.post_install_message = <<~MSG
|
|
30
|
+
The BPMN2 target uses bpmnexport from cpee-layout (Node.js >= 22.22). By
|
|
31
|
+
default npx fetches it on first use. To avoid that, run
|
|
32
|
+
npm install -g cpee-layout
|
|
33
|
+
and set ":bpmnexport: bpmnexport" in trans.conf of your service
|
|
34
|
+
(scaffolded with cpee-trans new DIR).
|
|
35
|
+
MSG
|
|
28
36
|
end
|
|
29
37
|
|
|
@@ -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'
|
|
@@ -13,11 +13,15 @@
|
|
|
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'
|
|
20
|
+
require_relative 'target'
|
|
21
|
+
require_relative 'cpee'
|
|
20
22
|
require 'xml/smart'
|
|
23
|
+
require 'open3'
|
|
24
|
+
require 'shellwords'
|
|
21
25
|
|
|
22
26
|
module CPEE
|
|
23
27
|
|
|
@@ -74,7 +78,10 @@ module CPEE
|
|
|
74
78
|
|
|
75
79
|
def extract_nodelink(doc) #{{{
|
|
76
80
|
doc.find("/bm:definitions/bm:process/bm:*[@id and @name and not(@itemSubjectRef) and not(name()='sequenceFlow')]").each do |e|
|
|
77
|
-
|
|
81
|
+
type = e.qname.name.to_sym
|
|
82
|
+
### an end event with a terminate definition ends the whole process
|
|
83
|
+
type = :terminate if type == :endEvent && e.find('bm:terminateEventDefinition').any?
|
|
84
|
+
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
85
|
|
|
79
86
|
if e.attributes['scriptFormat'] != ''
|
|
80
87
|
n.script_type = e.attributes['scriptFormat']
|
|
@@ -113,12 +120,13 @@ module CPEE
|
|
|
113
120
|
@start = n if n.type == :startEvent && @start == nil
|
|
114
121
|
end
|
|
115
122
|
|
|
116
|
-
# extract all sequences to a links
|
|
123
|
+
# extract all sequences to a links, default flows of gateways are otherwise
|
|
124
|
+
defaults = doc.find("/bm:definitions/bm:process/bm:*[@default]/@default").map{ |d| d.value }
|
|
117
125
|
doc.find("/bm:definitions/bm:process/bm:sequenceFlow").each do |e|
|
|
118
126
|
source = e.attributes['sourceRef']
|
|
119
127
|
target = e.attributes['targetRef']
|
|
120
128
|
cond = e.find('bm:conditionExpression')
|
|
121
|
-
@graph.add_link Link.new(source, target, cond.empty? ? nil : cond.first.text.strip)
|
|
129
|
+
@graph.add_link Link.new(source, target, cond.empty? ? nil : cond.first.text.strip, defaults.include?(e.attributes['id']))
|
|
122
130
|
end
|
|
123
131
|
|
|
124
132
|
@graph.clean_up do |node|
|
|
@@ -138,6 +146,32 @@ module CPEE
|
|
|
138
146
|
|
|
139
147
|
end
|
|
140
148
|
|
|
149
|
+
module Target #{{{
|
|
150
|
+
|
|
151
|
+
# bpmnexport from cpee-layout (npm install -g cpee-layout) lays out the
|
|
152
|
+
# generated CPEE model as drawn and writes it as BPMN with diagram
|
|
153
|
+
# interchange. opts[:bpmnexport] (trans.conf) is a command name, searched
|
|
154
|
+
# in PATH, or a path, relative to the server dir, optionally followed by
|
|
155
|
+
# arguments (e.g. -lr). By default npx fetches cpee-layout on first use.
|
|
156
|
+
class BPMN2 < Default
|
|
157
|
+
BPMNEXPORT = 'npx -y -p cpee-layout@^1.2.0 bpmnexport'
|
|
158
|
+
|
|
159
|
+
class << self
|
|
160
|
+
attr_accessor :opts
|
|
161
|
+
end
|
|
162
|
+
@opts = {}
|
|
163
|
+
|
|
164
|
+
def generate
|
|
165
|
+
opts = self.class.opts
|
|
166
|
+
cmd, *args = Shellwords.split(opts[:bpmnexport] || BPMNEXPORT)
|
|
167
|
+
cmd = File.expand_path(cmd, opts[:basepath] || Dir.pwd) if cmd.include?('/')
|
|
168
|
+
out, err, st = Open3.capture3(cmd, *args, '-', stdin_data: Target::CPEE.new(@tree).generate)
|
|
169
|
+
raise "#{cmd}: #{err}" unless st.success?
|
|
170
|
+
out
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
end #}}}
|
|
141
175
|
|
|
142
176
|
end
|
|
143
177
|
|
|
@@ -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'
|
|
@@ -61,14 +61,14 @@ module CPEE
|
|
|
61
61
|
end
|
|
62
62
|
if n1.nil?
|
|
63
63
|
nid = id_find(node.attributes['id'] || node.attributes['eid'])
|
|
64
|
-
n1 = @start = Node.new(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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)
|
|
@@ -119,13 +119,19 @@ module CPEE
|
|
|
119
119
|
n1 = no
|
|
120
120
|
when 'parallel'
|
|
121
121
|
bra = ele.find('d:parallel_branch')
|
|
122
|
+
if bra.empty? && ele.find('d:*').length == 1
|
|
123
|
+
### e.g. branches created in a loop: content is a sequence
|
|
124
|
+
n1 = dive_single(SingleParallel, ele, n1, condition, otherwise)
|
|
125
|
+
condition = nil
|
|
126
|
+
next
|
|
127
|
+
end
|
|
122
128
|
nid = id_find(ele.attributes['eid'])
|
|
123
|
-
ns = Node.new(
|
|
129
|
+
ns = Node.new(self.object_id,nid,:parallelGateway,nil,1,bra.length)
|
|
124
130
|
ns.attributes[:wait] = ele.attributes['wait'] || -1
|
|
125
131
|
ns.attributes[:cancel] = ele.attributes['cancel'] || 'last'
|
|
126
132
|
@graph.add_link Link.new(n1.id, ns.id, condition, otherwise)
|
|
127
133
|
condition = nil
|
|
128
|
-
ne = Node.new(
|
|
134
|
+
ne = Node.new(self.object_id,nid + 'e',:parallelGateway,nil,1,bra.length)
|
|
129
135
|
@graph.add_node ns
|
|
130
136
|
@graph.add_node ne
|
|
131
137
|
bra.each do |br|
|
|
@@ -136,10 +142,10 @@ module CPEE
|
|
|
136
142
|
when 'choose'
|
|
137
143
|
nid = id_find(ele.attributes['eid'])
|
|
138
144
|
bra = ele.find('d:alternative|d:otherwise')
|
|
139
|
-
ns = Node.new(
|
|
145
|
+
ns = Node.new(self.object_id,nid,:exclusiveGateway,ele.attributes['label'],1,bra.length)
|
|
140
146
|
@graph.add_link Link.new(n1.id, ns.id, condition, otherwise)
|
|
141
147
|
condition = nil
|
|
142
|
-
ne = Node.new(
|
|
148
|
+
ne = Node.new(self.object_id,nid + 'e',:exclusiveGateway,nil,1,bra.length)
|
|
143
149
|
@graph.add_node ns
|
|
144
150
|
@graph.add_node ne
|
|
145
151
|
bra.each do |br|
|
|
@@ -151,9 +157,20 @@ module CPEE
|
|
|
151
157
|
end
|
|
152
158
|
end
|
|
153
159
|
n1 = ne
|
|
160
|
+
when 'parallel_branch'
|
|
161
|
+
### only reached when not a direct child of a parallel
|
|
162
|
+
n1 = dive_single(SingleParallelBranch, ele, n1, condition, otherwise)
|
|
163
|
+
condition = nil
|
|
154
164
|
when 'escape'
|
|
155
165
|
nid = id_find(ele.attributes['eid'])
|
|
156
|
-
no = Node.new(
|
|
166
|
+
no = Node.new(self.object_id,nid,:break,'',1,1)
|
|
167
|
+
@graph.add_link Link.new(n1.id, no.id, condition, otherwise)
|
|
168
|
+
@graph.add_node no
|
|
169
|
+
condition = nil
|
|
170
|
+
n1 = no
|
|
171
|
+
when 'terminate'
|
|
172
|
+
nid = id_find(ele.attributes['eid'])
|
|
173
|
+
no = Node.new(self.object_id,nid,:terminate,'',1,0)
|
|
157
174
|
@graph.add_link Link.new(n1.id, no.id, condition, otherwise)
|
|
158
175
|
@graph.add_node no
|
|
159
176
|
condition = nil
|
|
@@ -164,11 +181,28 @@ module CPEE
|
|
|
164
181
|
end
|
|
165
182
|
private :dive
|
|
166
183
|
|
|
184
|
+
### open marker, content as a sequence, close marker
|
|
185
|
+
def dive_single(klass,ele,n1,condition,otherwise)
|
|
186
|
+
attrs = {}
|
|
187
|
+
ele.attributes.each { |a| attrs[a.qname.name] = a.value unless a.qname.name == 'eid' }
|
|
188
|
+
nid = id_find(ele.attributes['eid'])
|
|
189
|
+
ns = klass.new(self.object_id,nid,true,attrs)
|
|
190
|
+
@graph.add_node ns
|
|
191
|
+
@graph.add_link Link.new(n1.id, ns.id, condition, otherwise)
|
|
192
|
+
bn = dive ele, ns
|
|
193
|
+
ne = klass.new(self.object_id,nid + 'e',false)
|
|
194
|
+
@graph.add_node ne
|
|
195
|
+
@graph.add_link Link.new(bn.id, ne.id)
|
|
196
|
+
ne
|
|
197
|
+
end
|
|
198
|
+
private :dive_single
|
|
199
|
+
|
|
167
200
|
def extract_original(text)
|
|
168
201
|
doc = XML::Smart::string(text)
|
|
169
202
|
doc.register_namespace :d, 'http://cpee.org/ns/description/1.0'
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
# a model (root description) or a testset, which contains it
|
|
204
|
+
bn = dive(doc.find('//d:description').first || doc.root)
|
|
205
|
+
ne = Node.new(self.object_id,Digest::MD5.hexdigest(Kernel::rand().to_s),:endEvent,'',1,0)
|
|
172
206
|
@graph.add_node ne
|
|
173
207
|
@graph.add_link Link.new(bn.id, ne.id)
|
|
174
208
|
end
|
|
@@ -192,11 +226,31 @@ module CPEE
|
|
|
192
226
|
end
|
|
193
227
|
|
|
194
228
|
private
|
|
229
|
+
### open: everything up to the close marker goes inside
|
|
230
|
+
def print_single(name,node,res)
|
|
231
|
+
if node.open?
|
|
232
|
+
res.add(name, node.attributes.merge('a:alt_id' => node.id, 'eid' => "e#{(@eid += 1)}"))
|
|
233
|
+
else
|
|
234
|
+
res.parent
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
def print_SingleParallel(node,res)
|
|
238
|
+
print_single('parallel',node,res)
|
|
239
|
+
end
|
|
240
|
+
def print_SingleParallelBranch(node,res)
|
|
241
|
+
print_single('parallel_branch',node,res)
|
|
242
|
+
end
|
|
243
|
+
|
|
195
244
|
def print_Break(node,res)
|
|
196
245
|
res.add('escape', 'a:alt_id' => node.id)
|
|
197
246
|
res
|
|
198
247
|
end
|
|
199
248
|
|
|
249
|
+
def print_Terminate(node,res)
|
|
250
|
+
res.add('terminate', 'a:alt_id' => node.id)
|
|
251
|
+
res
|
|
252
|
+
end
|
|
253
|
+
|
|
200
254
|
def print_Loop(node,res)
|
|
201
255
|
eid = "e#{(@eid += 1)}"
|
|
202
256
|
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 +261,12 @@ module CPEE
|
|
|
207
261
|
end
|
|
208
262
|
generate_in_list(node.sub[0],s1)
|
|
209
263
|
else
|
|
210
|
-
s1 = res.add('loop', 'mode' => node.mode, 'condition' => node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && '), 'eid' => eid)
|
|
211
264
|
if node.sub.length == 1
|
|
265
|
+
s1 = res.add('loop', 'mode' => node.mode, 'condition' => node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && '), 'eid' => eid)
|
|
212
266
|
generate_in_list(node.sub[0],s1)
|
|
213
267
|
else
|
|
268
|
+
### the choose over all alternatives decides (escape), so loop forever
|
|
269
|
+
s1 = res.add('loop', 'mode' => node.mode, 'condition' => 'true', 'eid' => eid)
|
|
214
270
|
print_Conditional(node,s1)
|
|
215
271
|
end
|
|
216
272
|
end
|
|
@@ -273,21 +329,20 @@ module CPEE
|
|
|
273
329
|
|
|
274
330
|
def print_Conditional(node,res)
|
|
275
331
|
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
|
|
332
|
+
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)
|
|
333
|
+
### the otherwise is the explicit one, else the last branch without condition
|
|
334
|
+
### (keeps the order stable), compare by identity as empty branches are ==
|
|
335
|
+
ow = node.sub.reverse.find{ |b| b.condition.empty? && b.otherwise } || node.sub.reverse.find{ |b| b.condition.empty? }
|
|
278
336
|
node.sub.each do |branch|
|
|
279
337
|
bid = "e#{(@eid += 1)}"
|
|
280
338
|
s2 = if branch.condition.any?
|
|
281
339
|
a = s1.add('d:alternative','condition' => branch.condition.join(' or '), 'eid' => bid)
|
|
282
340
|
a.attributes['language'] = branch.condition_type unless branch.condition_type.nil?
|
|
283
341
|
a
|
|
342
|
+
elsif branch.equal?(ow)
|
|
343
|
+
s1.add('d:otherwise', 'eid' => bid)
|
|
284
344
|
else
|
|
285
|
-
|
|
286
|
-
otherwise = true
|
|
287
|
-
s1.add('d:otherwise', 'eid' => bid)
|
|
288
|
-
else
|
|
289
|
-
s1.add('d:alternative', 'condition' => '', 'eid' => bid)
|
|
290
|
-
end
|
|
345
|
+
s1.add('d:alternative', 'condition' => '', 'eid' => bid)
|
|
291
346
|
end
|
|
292
347
|
branch.attributes.each do |k,v|
|
|
293
348
|
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
|
|
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
|
|
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
|
|
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'
|
|
@@ -50,6 +50,8 @@ module CPEE
|
|
|
50
50
|
mtype, target = case @h['RIDDL_DECLARATION_PATH'].split('/')[-2]
|
|
51
51
|
when 'cpee'
|
|
52
52
|
['text/xml', CPEE::Transformation::Target::CPEE]
|
|
53
|
+
when 'bpmn2'
|
|
54
|
+
['text/xml', CPEE::Transformation::Target::BPMN2]
|
|
53
55
|
when 'mermaid'
|
|
54
56
|
['text/plain', CPEE::Transformation::Target::Mermaid]
|
|
55
57
|
when 'text-bf'
|
|
@@ -118,6 +120,8 @@ module CPEE
|
|
|
118
120
|
end #}}}
|
|
119
121
|
|
|
120
122
|
def self::implementation(opts)
|
|
123
|
+
# the hash itself, as --config is merged into it only afterwards
|
|
124
|
+
CPEE::Transformation::Target::BPMN2.opts = opts
|
|
121
125
|
Proc.new do
|
|
122
126
|
interface 'xml_cpee' do
|
|
123
127
|
run ExtractDescription if post 'xmldedesc'
|
|
@@ -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
|
|
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
|
|
|
@@ -31,10 +31,13 @@
|
|
|
31
31
|
<tile>
|
|
32
32
|
<layer name="xml_cpee">
|
|
33
33
|
<apply-to>/cpee/bpmn2</apply-to>
|
|
34
|
+
<apply-to>/bpmn2/cpee</apply-to>
|
|
34
35
|
</layer>
|
|
35
36
|
<layer name="text_cpee">
|
|
36
37
|
<apply-to>/cpee/mermaid</apply-to>
|
|
37
38
|
<apply-to>/cpee/graphviz</apply-to>
|
|
39
|
+
<apply-to>/bpmn2/mermaid</apply-to>
|
|
40
|
+
<apply-to>/bpmn2/graphviz</apply-to>
|
|
38
41
|
</layer>
|
|
39
42
|
<layer name="xml_text">
|
|
40
43
|
<apply-to>/mermaid/cpee</apply-to>
|
|
@@ -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'
|
|
@@ -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(
|
|
107
|
-
n2 = Node.new(
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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", "|\"#{
|
|
229
|
+
[ ["#{nid}e", "|\"#{cond}\"|"], "#{nid}s"]
|
|
217
230
|
else
|
|
218
|
-
set_fromto ["#{nid}e","|\"#{
|
|
231
|
+
set_fromto ["#{nid}e","|\"#{cond}\"|"], "#{nid}s"
|
|
219
232
|
["#{nid}s", "#{nid}e"]
|
|
220
233
|
end
|
|
221
234
|
|
|
222
|
-
pn = if
|
|
235
|
+
pn = if single
|
|
223
236
|
generate_in_list(node.sub[0],cn[0])
|
|
224
237
|
else
|
|
225
|
-
|
|
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
|
|