cpee 2.1.136 → 2.1.140

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/cockpit/compliance-view.html +0 -7
  3. data/cockpit/compliance.html +0 -7
  4. data/cockpit/css/ui.css +1 -1
  5. data/cockpit/edit.html +0 -7
  6. data/cockpit/graph.html +0 -5
  7. data/cockpit/index.html +0 -7
  8. data/cockpit/js/instance.js +27 -4
  9. data/cockpit/js/llm.js +79 -21
  10. data/cockpit/js/wfadaptor.js +10 -4
  11. data/cockpit/llm.html +0 -7
  12. data/cockpit/llmmodel.html +0 -7
  13. data/cockpit/model.html +0 -7
  14. data/cockpit/only_llm.html +0 -7
  15. data/cockpit/themes/THEMES.MD +4 -0
  16. data/cockpit/themes/presetlr/symbols/loop_end_pre.svg +1 -1
  17. data/cockpit/track.html +0 -5
  18. data/cpee.gemspec +2 -2
  19. data/lib/cpee/implementation.rb +5 -0
  20. data/lib/cpee/implementation_callbacks.rb +2 -2
  21. data/lib/cpee/implementation_notifications.rb +4 -1
  22. data/lib/cpee/implementation_properties.rb +63 -19
  23. data/lib/cpee/json_pointer.rb +110 -0
  24. data/lib/cpee/message.rb +22 -2
  25. data/lib/cpee/persistence.rb +4 -0
  26. data/lib/cpee/redis.rb +8 -0
  27. data/lib/properties/t_dslx.rng +11 -1
  28. data/lib/properties.xml +4 -7
  29. data/server/executionhandlers/eval/connection.rb +12 -3
  30. data/server/executionhandlers/ruby/connection.rb +12 -3
  31. data/server/executionhandlers/ruby/controller.rb +17 -2
  32. data/server/routing/end.pid +1 -1
  33. data/server/routing/forward-events-00.pid +1 -1
  34. data/server/routing/forward-events.rb +30 -19
  35. data/server/routing/forward-votes.pid +1 -1
  36. data/server/routing/forward-votes.rb +56 -43
  37. data/server/routing/persist.pid +1 -1
  38. data/server/routing/persist.rb +49 -28
  39. metadata +8 -2
  40. data/cockpit/js/build-bpmn2.js +0 -302
@@ -1,302 +0,0 @@
1
- /*
2
- This file is part of cpee-layout.
3
-
4
- cpee-layout is free software: you can redistribute it and/or modify it under
5
- the terms of the GNU Lesser General Public License as published by the Free
6
- Software Foundation, either version 3 of the License, or (at your option) any
7
- later version.
8
-
9
- cpee-layout is distributed in the hope that it will be useful, but WITHOUT
10
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
- FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12
- details.
13
-
14
- You should have received a copy of the GNU Lesser General Public License
15
- along with cpee-layout (file LICENSE in the main directory). If not, see
16
- <http://www.gnu.org/licenses/>.
17
-
18
- The CPEE type mapping and the BPMN output follow build-bpmn.js,
19
- Copyright 2026 David Kindermann (Apache-2.0).
20
- */
21
-
22
- //
23
- // build-bpmn2.js
24
- //
25
- // Creates BPMN XML from wfadaptor's get_svg_metrics():
26
- // bpmn2_convert(pos_matrix, con_list, lr, geometry), like david_bpmn_convert of
27
- // build-bpmn.js plus the orientation and the geometry of the drawing. Rows and columns are
28
- // 0-indexed.
29
- //
30
- // Unlike build-bpmn.js, the layout is not computed again: every symbol is
31
- // placed where the metrics (and so the SVG) have it, and the flows are drawn
32
- // with right angles only, entering their targets perpendicularly.
33
- //
34
- // 1) nodes cells → BPMN shapes, or placeholders that flows pass through
35
- // 2) flows con_list, followed through placeholders from shape to shape
36
- // 3) route right-angled waypoints, bending where the placeholders are
37
- // 4) xml process and diagram interchange
38
- //
39
-
40
- // the svg rows (geometry.row apart) are spread to ROW here, so that tasks have
41
- // the bpmn-js default height (rows are vertical in lr as well)
42
- const SYM = 30; // symbol size
43
- const TASK_H = 80; // task height, as bpmn-js; its icon is in the top left corner, so one line of text stays below it
44
- const ROW = TASK_H + 10; // row distance, the gap stays as in the svg
45
- const GAP = 10; // space between a task and the next symbol
46
- const SPACE = 10; // extra space in front of every column, the svg is a bit tight for bpmn
47
- const PAD = 20; // tasks are this much wider on both sides, bpmn-js puts its text close to the border
48
- const BACK = 20; // flows that go around (loops) go back this far right of the target's line
49
-
50
- // cpee types → BPMN element (kind) and event definition (def), or placeholder.
51
- // Tasks, and all types not listed, get their kind from the subtype
52
- const TYPE_MAP = {
53
- description: { kind: "startEvent" },
54
- start_event: { kind: "startEvent", def: "message" },
55
- event_start: { kind: "startEvent", def: "signal" }, // the start of a signal branch
56
- end: { kind: "endEvent" },
57
- end_event: { kind: "endEvent", def: "message" },
58
- event_end: { kind: "endEvent", def: "terminate" },
59
- terminate: { kind: "endEvent", def: "terminate" },
60
- call: { task: true },
61
- callmanipulate: { task: true },
62
- manipulate: { task: true },
63
- loop_head: { kind: "exclusiveGateway" },
64
- loop_tail: { kind: "exclusiveGateway" },
65
- loop_finish: { kind: "exclusiveGateway" },
66
- loop_tail_pre: { kind: "exclusiveGateway" }, // presetlr: pre_test loops
67
- loop_finish_pre: { kind: "exclusiveGateway" },
68
- parallel_start: { kind: "parallelGateway" },
69
- parallel_simple: { kind: "parallelGateway" },
70
- parallel_complex: { kind: "complexGateway" },
71
- parallel_eventbased_parallel: { kind: "complexGateway" },
72
- parallel_branch_event: { kind: "intermediateThrowEvent", def: "signal" },
73
- parallel_branch_event_rev: { kind: "intermediateThrowEvent", def: "signal" },
74
- parallel_branch_normal: { placeholder: "pass" },
75
- choose_inclusive: { kind: "inclusiveGateway" },
76
- choose_inclusive_finish: { kind: "inclusiveGateway" },
77
- choose_exclusive: { kind: "exclusiveGateway" },
78
- choose_exclusive_finish: { kind: "exclusiveGateway" },
79
- alternative: { placeholder: "case" }, // its label names the flow
80
- otherwise: { placeholder: "default" }, // its label names the flow, without one the flow is the default
81
- stop: { placeholder: "pass" }
82
- };
83
- const TASK_SUBTYPES = { user: "userTask", service: "serviceTask", script: "scriptTask" };
84
- const EVENT_SUBTYPES = {
85
- timer: { kind: "intermediateCatchEvent", def: "timer" },
86
- message_receive: { kind: "intermediateCatchEvent", def: "message" },
87
- message_send: { kind: "intermediateThrowEvent", def: "message" }
88
- };
89
-
90
- const fmt = (n) => Number(n).toFixed(2).replace(/\.?0+$/, "");
91
- const key = (r, c) => r + "," + c;
92
- function xmlEscape(s = "") {
93
- return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
94
- }
95
- function xmlEventDef(def, id) {
96
- return def ? `<${def}EventDefinition id="${id}_def"/>` : "";
97
- }
98
- function xmlSignavioBg(color) { // Signavio: background color per shape
99
- return `<extensionElements><signavio:signavioMetaData metaKey="bgcolor" metaValue="${xmlEscape(color || "#ffffff")}"/></extensionElements>`;
100
- }
101
-
102
- // 1) nodes: kind is the BPMN element, or null for placeholders. Names are the
103
- // labels only, the svg has no room for more. x is where the symbol is drawn,
104
- // mid the middle of its row, labelBox where its label is, relative to the symbol
105
- function buildNodes(matrix, geometry) {
106
- const nodes = new Map();
107
- let n = 0;
108
- matrix.forEach((row, r) => (row || []).forEach((cell, c) => {
109
- if (!cell) return;
110
- const t = TYPE_MAP[cell.type] || { task: true };
111
- const node = { r, c, x: cell.x - geometry.shift + SPACE * c, mid: r * ROW + geometry.top + TASK_H / 2, width: cell.width, fill: cell.fill, id: "n" + (++n), kind: null, label: cell.label || null };
112
- const l = cell.label_box;
113
- if (l) node.labelBox = { dx: l.x - (cell.x - geometry.shift), dy: l.y - (geometry.top + r * geometry.row), w: l.width, h: l.height };
114
- if (!t.task) {
115
- Object.assign(node, t);
116
- } else { // the subtype comes from the endpoint's properties (cockpit only)
117
- const sub = typeof cell.subtype === "string" ? cell.subtype : "";
118
- const ev = sub.startsWith("event/") ? (EVENT_SUBTYPES[sub.split("/").slice(1).join("_")] || EVENT_SUBTYPES[sub.split("/")[1]] || { kind: "intermediateCatchEvent" }) : null;
119
- if (ev) {
120
- Object.assign(node, { kind: ev.kind, def: ev.def });
121
- } else {
122
- node.kind = sub == "marker/subprocess" ? "subProcess"
123
- : sub.startsWith("task/") ? (TASK_SUBTYPES[sub.split("/")[1]] || "serviceTask")
124
- : cell.type == "manipulate" ? "scriptTask" : "serviceTask";
125
- }
126
- }
127
- nodes.set(key(r, c), node);
128
- }));
129
- // every column after one with a task moves by the width tasks gain
130
- const taskCols = new Set([...nodes.values()].filter(isTask).map((n) => n.c));
131
- for (const n of nodes.values()) n.x += 2 * PAD * [...taskCols].filter((c) => c < n.c).length;
132
- return nodes;
133
- }
134
-
135
- // bounds as in the svg: tasks span their label and the row, everything else
136
- // is a symbol in the middle of the row
137
- function bounds(node) {
138
- const x = node.x;
139
- if (!node.kind) return { x: x + SYM / 2, y: node.mid, w: 0, h: 0 }; // placeholders are points
140
- if (isTask(node)) return { x, y: node.mid - TASK_H / 2, w: Math.max(SYM, node.width - GAP) + 2 * PAD, h: TASK_H };
141
- return { x, y: node.mid - SYM / 2, w: SYM, h: SYM };
142
- }
143
- const isTask = (node) => /Task$|^subProcess$/.test(node.kind);
144
-
145
- // labels of events, gateways and placeholders are where the svg shows them,
146
- // relative to their symbol. Labels the svg does not show have no bounds
147
- function labelBounds(node) {
148
- const l = node.labelBox;
149
- return l ? { x: node.x + l.dx, y: node.mid - SYM / 2 + l.dy, w: l.w, h: l.h } : null;
150
- }
151
-
152
- // 2) flows from shape to shape, following con_list through placeholders
153
- function buildFlows(nodes, conlist) {
154
- const out = new Map();
155
- for (const e of conlist) {
156
- const f = key(e.from.row, e.from.col), t = key(e.to.row, e.to.col);
157
- if (!nodes.has(f) || !nodes.has(t)) throw new Error("bpmn2_convert: con_list connects an empty cell, " + f + " -> " + t);
158
- if (!out.has(f)) out.set(f, []);
159
- out.get(f).push(t);
160
- }
161
- const flows = [];
162
- const seen = new Set();
163
- for (const [k, src] of nodes) {
164
- if (!src.kind) continue;
165
- const walk = (from, via, anchor, visited) => {
166
- for (const t of out.get(from) || []) {
167
- const n = nodes.get(t);
168
- if (n.kind) {
169
- const sig = src.id + ">" + n.id;
170
- if (seen.has(sig)) continue;
171
- seen.add(sig);
172
- flows.push({ src, dst: n, via, anchor });
173
- } else if (!visited.has(t)) {
174
- visited.add(t);
175
- walk(t, via.concat([n]), n.placeholder != "pass" ? n : anchor, visited);
176
- }
177
- }
178
- };
179
- walk(k, [], null, new Set([k]));
180
- }
181
- for (const f of flows) {
182
- if (!f.anchor) continue;
183
- if (f.anchor.label) f.name = f.anchor.label;
184
- else if (f.anchor.placeholder == "default" && f.src.kind == "exclusiveGateway") f.isDefault = true;
185
- }
186
- return flows;
187
- }
188
-
189
- // 3) right angles only. a is the position along the flow, c across it
190
- function route(flow, lr, nodes) {
191
- const P = (a, c) => lr ? { x: a, y: c } : { x: c, y: a };
192
- const box = (n) => {
193
- const b = bounds(n);
194
- const s = { x: n.kind ? b.x + SYM / 2 : b.x, y: n.mid }; // the symbol, not the label
195
- const next = n.mid + ROW / 2; // between this row and the next
196
- return lr ? { n, a: s.x, c: s.y, a0: b.x, a1: b.x + b.w, c0: b.y, c1: b.y + b.h, turn: GAP / 2 }
197
- : { n, a: s.y, c: s.x, a0: b.y, a1: b.y + b.h, c0: b.x, c1: b.x + b.w, turn: next - (b.y + b.h) };
198
- };
199
- const shapes = [...nodes.values()].filter((n) => n.kind).map(box);
200
- const blocking = (c, from, to, except) => shapes.filter((b) => !except.includes(b.n) && b.c0 <= c && c <= b.c1 && b.a1 > Math.min(from, to) && b.a0 < Math.max(from, to));
201
- // a leg follows its own direction (dir), forwards or backwards along the flow
202
- const leg = (s, d) => {
203
- const dA = d.a - s.a, dC = d.c - s.c, dir = dA < 0 ? -1 : 1, except = [s.n, d.n];
204
- const out = dir > 0 ? s.a1 : s.a0, into = dir > 0 ? d.a0 : d.a1; // the sides facing each other
205
- if (Math.abs(dA) < 0.5) return dC > 0 ? [P(s.a, s.c1), P(d.a, d.c0)] : [P(s.a, s.c0), P(d.a, d.c1)]; // straight across
206
- if (Math.abs(dC) < 0.5 && !blocking(s.c, s.a, d.a, except).length) return [P(out, s.c), P(into, d.c)]; // straight along
207
- if (dC > 0 && !blocking(d.c, s.a, d.a, except).length) return [P(s.a, s.c1), P(s.a, d.c), P(into, d.c)]; // branch out: across, then along into the target
208
- if (dC < 0 && !blocking(s.c, s.a, d.a, except).length) return [P(out, s.c), P(d.a, s.c), P(d.a, d.c1)]; // join: along, then across into the target
209
- // shapes in the way (e.g. the content of a loop): leave on the far side, turn,
210
- // and go back parallel to the target's line, BACK beside it on the right (or
211
- // beside what is in the way). Symbols are entered at 45 degrees
212
- const far = dir > 0 ? s.a0 : s.a1, turn = far - dir * s.turn;
213
- const inway = blocking(d.c + BACK, turn, into, except);
214
- const lane = inway.length ? Math.max(...inway.map((b) => b.c1)) + BACK : d.c + BACK;
215
- if (d.n.kind && !isTask(d.n)) {
216
- const edge = /Gateway$/.test(d.n.kind) ? SYM / 4 : SYM / 2 / Math.SQRT2; // the border at 45 degrees: diamond or circle
217
- return [P(far, s.c), P(turn, s.c), P(turn, lane), P(d.a - dir * (lane - d.c), lane), P(d.a - dir * edge, d.c + edge)];
218
- }
219
- const end = lane <= d.c1 ? [P(into, lane)] : [P(d.a, lane), P(d.a, d.c1)];
220
- return [P(far, s.c), P(turn, s.c), P(turn, lane)].concat(end);
221
- };
222
- // source and target on one line, along or across the flow: straight, unless
223
- // another shape is in the way (e.g. the content of a loop)
224
- const s = box(flow.src), d = box(flow.dst), except = [flow.src, flow.dst];
225
- const across = shapes.some((b) => !except.includes(b.n) && b.a0 <= s.a && s.a <= b.a1 && b.c1 > Math.min(s.c, d.c) && b.c0 < Math.max(s.c, d.c));
226
- if (flow.src !== flow.dst) {
227
- if (Math.abs(d.c - s.c) < 0.5 && !blocking(s.c, s.a, d.a, except).length) return d.a > s.a ? [P(s.a1, s.c), P(d.a0, d.c)] : [P(s.a0, s.c), P(d.a1, d.c)];
228
- if (Math.abs(d.a - s.a) < 0.5 && !across) return d.c > s.c ? [P(s.a, s.c1), P(d.a, d.c0)] : [P(s.a, s.c0), P(d.a, d.c1)];
229
- }
230
-
231
- const stops = [flow.src].concat(flow.via, [flow.dst]).map(box);
232
- let pts = [];
233
- for (let i = 0; i < stops.length - 1; i++) pts = pts.concat(leg(stops[i], stops[i + 1]));
234
- // drop repeated points and points in the middle of a straight line
235
- pts = pts.filter((p, i) => i == 0 || p.x != pts[i - 1].x || p.y != pts[i - 1].y);
236
- return pts.filter((p, i) => {
237
- if (i == 0 || i == pts.length - 1) return true;
238
- const a = pts[i - 1], b = pts[i + 1];
239
- return !((a.x == p.x && p.x == b.x) || (a.y == p.y && p.y == b.y));
240
- });
241
- }
242
-
243
- // 4) xml
244
- function generateXML(nodes, flows, lr) {
245
- const shapes = [...nodes.values()].filter((n) => n.kind);
246
- flows.forEach((f, i) => { f.id = "e" + (i + 1); });
247
- const defaults = new Map(flows.filter((f) => f.isDefault).map((f) => [f.src.id, f.id]));
248
- const nameAttr = (s) => s ? ` name="${xmlEscape(s)}"` : "";
249
-
250
- const proc = shapes.map((s) => {
251
- const def = defaults.has(s.id) ? ` default="${defaults.get(s.id)}"` : "";
252
- return ` <${s.kind} id="${s.id}"${nameAttr(s.label)}${def}>${xmlSignavioBg(s.fill)}${xmlEventDef(s.def, s.id)}</${s.kind}>`;
253
- }).concat(flows.map((f) =>
254
- ` <sequenceFlow id="${f.id}" sourceRef="${f.src.id}" targetRef="${f.dst.id}"${nameAttr(f.name)}/>`
255
- )).join("\n");
256
-
257
- const xmlBounds = (b, indent) => `${indent}<omgdc:Bounds x="${fmt(b.x)}" y="${fmt(b.y)}" width="${fmt(b.w)}" height="${fmt(b.h)}"/>\n`;
258
- const xmlLabel = (b) => b ? ` <bpmndi:BPMNLabel>\n${xmlBounds(b, " ")} </bpmndi:BPMNLabel>\n` : "";
259
- const di = shapes.map((s) => {
260
- const marker = /Gateway$/.test(s.kind) ? ' isMarkerVisible="true"' : "";
261
- return ` <bpmndi:BPMNShape id="${s.id}_gui" bpmnElement="${s.id}"${marker}>\n` +
262
- xmlBounds(bounds(s), " ") +
263
- xmlLabel(s.label && !isTask(s) ? labelBounds(s) : null) +
264
- ` </bpmndi:BPMNShape>`;
265
- }).concat(flows.map((f) =>
266
- ` <bpmndi:BPMNEdge id="${f.id}_gui" bpmnElement="${f.id}">\n` +
267
- route(f, lr, nodes).map((p) => ` <omgdi:waypoint x="${fmt(p.x)}" y="${fmt(p.y)}"/>`).join("\n") + "\n" +
268
- xmlLabel(f.name ? labelBounds(f.anchor) : null) +
269
- ` </bpmndi:BPMNEdge>`
270
- )).join("\n");
271
-
272
- return `<?xml version="1.0" encoding="UTF-8"?>
273
- <definitions
274
- xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
275
- xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
276
- xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
277
- xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
278
- xmlns:signavio="http://www.signavio.com"
279
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
280
- targetNamespace="https://example.com/bpmn"
281
- >
282
- <process id="process1" isExecutable="false">
283
- ${proc}
284
- </process>
285
- <bpmndi:BPMNDiagram id="diagram1">
286
- <bpmndi:BPMNPlane id="plane1" bpmnElement="process1">
287
- ${di}
288
- </bpmndi:BPMNPlane>
289
- </bpmndi:BPMNDiagram>
290
- </definitions>`;
291
- }
292
-
293
- // returns the BPMN XML as a string
294
- function bpmn2_convert(dpm, dcl, lr, geometry) {
295
- if (!Array.isArray(dpm) || !Array.isArray(dcl) || typeof lr !== "boolean" || !geometry) throw new Error("bpmn2_convert: needs pos_matrix, con_list, lr and geometry of get_svg_metrics");
296
- const nodes = buildNodes(dpm, geometry);
297
- return generateXML(nodes, buildFlows(nodes, dcl), lr);
298
- }
299
-
300
- if (typeof window !== "undefined") {
301
- window.bpmn2_convert = bpmn2_convert;
302
- }