Skip to content

Commit 5f5ce96

Browse files
authored
[FEAT] Display inclusive gateway (#245)
Display inclusive gateway
1 parent 292c91b commit 5f5ce96

File tree

4 files changed

+167
-0
lines changed

4 files changed

+167
-0
lines changed

docs/bpmn-support.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ The default rendering uses `white` as fill color and `black` as stroke color.
179179
|icon:check-circle-o[]
180180
|Icon may be subject to change +
181181

182+
|Inclusive
183+
|icon:check-circle-o[]
184+
|Icon may be subject to change +
185+
182186
|Parallel
183187
|icon:check-circle-o[]
184188
|Icon may be subject to change +

src/component/mxgraph/StyleConfigurator.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,18 @@ export default class StyleConfigurator {
127127

128128
this.putCellStyle(kind, style);
129129
});
130+
// TODO: this is temporary rendering - to be removed with proper rendering implementation
131+
const temporaryStyle = this.cloneDefaultVertexStyle();
132+
temporaryStyle[this.mxConstants.STYLE_SHAPE] = this.mxConstants.SHAPE_RHOMBUS;
133+
temporaryStyle[this.mxConstants.STYLE_PERIMETER] = this.mxPerimeter.RhombusPerimeter;
134+
temporaryStyle[this.mxConstants.STYLE_VERTICAL_ALIGN] = 'top';
135+
temporaryStyle[this.mxConstants.STYLE_STROKECOLOR] = '#f00';
136+
temporaryStyle[this.mxConstants.STYLE_STROKEWIDTH] = 2;
137+
temporaryStyle[this.mxConstants.STYLE_FILLCOLOR] = '#f00';
138+
temporaryStyle[this.mxConstants.STYLE_FILL_OPACITY] = 25;
139+
140+
temporaryStyle[this.mxConstants.STYLE_SPACING_TOP] = 55;
141+
temporaryStyle[this.mxConstants.STYLE_SPACING_RIGHT] = 110;
142+
this.putCellStyle(ShapeBpmnElementKind.GATEWAY_INCLUSIVE, temporaryStyle);
130143
}
131144
}

src/model/bpmn/shape/ShapeBpmnElementKind.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export enum ShapeBpmnElementKind {
2424
TASK = 'task',
2525
GATEWAY_PARALLEL = 'parallelGateway',
2626
GATEWAY_EXCLUSIVE = 'exclusiveGateway',
27+
GATEWAY_INCLUSIVE = 'inclusiveGateway',
2728
EVENT_START = 'startEvent',
2829
EVENT_END = 'endEvent',
2930
EVENT_INTERMEDIATE_CATCH = 'intermediateCatchEvent',
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/**
2+
* Copyright 2020 Bonitasoft S.A.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import { ShapeBpmnElementKind } from '../../../../../src/model/bpmn/shape/ShapeBpmnElementKind';
17+
import { parseJsonAndExpectOnlyFlowNodes, verifyShape } from './JsonTestUtils';
18+
19+
describe('parse bpmn as json for inclusive gateway', () => {
20+
it('json containing one process with a single inclusive gateway', () => {
21+
const json = `{
22+
"definitions" : {
23+
"process": {
24+
"inclusiveGateway": {
25+
"id":"inclusiveGateway_id_0",
26+
"name":"inclusiveGateway name"
27+
}
28+
},
29+
"BPMNDiagram": {
30+
"name":"process 0",
31+
"BPMNPlane": {
32+
"BPMNShape": {
33+
"id":"shape_inclusiveGateway_id_0",
34+
"bpmnElement":"inclusiveGateway_id_0",
35+
"Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 }
36+
}
37+
}
38+
}
39+
}
40+
}`;
41+
42+
const model = parseJsonAndExpectOnlyFlowNodes(json, 1);
43+
44+
verifyShape(model.flowNodes[0], {
45+
shapeId: 'shape_inclusiveGateway_id_0',
46+
bpmnElementId: 'inclusiveGateway_id_0',
47+
bpmnElementName: 'inclusiveGateway name',
48+
bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE,
49+
boundsX: 362,
50+
boundsY: 232,
51+
boundsWidth: 36,
52+
boundsHeight: 45,
53+
});
54+
});
55+
56+
it('json containing one process declared as array with a single inclusive gateway', () => {
57+
const json = `{
58+
"definitions": {
59+
"process": [
60+
{
61+
"inclusiveGateway": {
62+
"id":"inclusiveGateway_id_1",
63+
"name":"inclusiveGateway name"
64+
}
65+
}
66+
],
67+
"BPMNDiagram": {
68+
"name":"process 0",
69+
"BPMNPlane": {
70+
"BPMNShape": {
71+
"id":"shape_inclusiveGateway_id_1",
72+
"bpmnElement":"inclusiveGateway_id_1",
73+
"Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 }
74+
}
75+
}
76+
}
77+
}
78+
}`;
79+
80+
const model = parseJsonAndExpectOnlyFlowNodes(json, 1);
81+
82+
verifyShape(model.flowNodes[0], {
83+
shapeId: 'shape_inclusiveGateway_id_1',
84+
bpmnElementId: 'inclusiveGateway_id_1',
85+
bpmnElementName: 'inclusiveGateway name',
86+
bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE,
87+
boundsX: 362,
88+
boundsY: 232,
89+
boundsWidth: 36,
90+
boundsHeight: 45,
91+
});
92+
});
93+
94+
it('json containing one process with an array of inclusive gateways with name & without name', () => {
95+
const json = `{
96+
"definitions" : {
97+
"process": {
98+
"inclusiveGateway": [
99+
{
100+
"id":"inclusiveGateway_id_0",
101+
"name":"inclusiveGateway name"
102+
}, {
103+
"id":"inclusiveGateway_id_1"
104+
}
105+
]
106+
},
107+
"BPMNDiagram": {
108+
"name":"process 0",
109+
"BPMNPlane": {
110+
"BPMNShape": [
111+
{
112+
"id":"shape_inclusiveGateway_id_0",
113+
"bpmnElement":"inclusiveGateway_id_0",
114+
"Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 }
115+
}, {
116+
"id":"shape_inclusiveGateway_id_1",
117+
"bpmnElement":"inclusiveGateway_id_1",
118+
"Bounds": { "x": 365, "y": 235, "width": 35, "height": 46 }
119+
}
120+
]
121+
}
122+
}
123+
}
124+
}`;
125+
126+
const model = parseJsonAndExpectOnlyFlowNodes(json, 2);
127+
128+
verifyShape(model.flowNodes[0], {
129+
shapeId: 'shape_inclusiveGateway_id_0',
130+
bpmnElementId: 'inclusiveGateway_id_0',
131+
bpmnElementName: 'inclusiveGateway name',
132+
bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE,
133+
boundsX: 362,
134+
boundsY: 232,
135+
boundsWidth: 36,
136+
boundsHeight: 45,
137+
});
138+
verifyShape(model.flowNodes[1], {
139+
shapeId: 'shape_inclusiveGateway_id_1',
140+
bpmnElementId: 'inclusiveGateway_id_1',
141+
bpmnElementName: undefined,
142+
bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE,
143+
boundsX: 365,
144+
boundsY: 235,
145+
boundsWidth: 35,
146+
boundsHeight: 46,
147+
});
148+
});
149+
});

0 commit comments

Comments
 (0)