diff --git a/docs/bpmn-support.adoc b/docs/bpmn-support.adoc index 7ba837c3cd..c10a521ba9 100644 --- a/docs/bpmn-support.adoc +++ b/docs/bpmn-support.adoc @@ -179,6 +179,10 @@ The default rendering uses `white` as fill color and `black` as stroke color. |icon:check-circle-o[] |Icon may be subject to change + +|Inclusive +|icon:check-circle-o[] +|Icon may be subject to change + + |Parallel |icon:check-circle-o[] |Icon may be subject to change + diff --git a/src/component/mxgraph/StyleConfigurator.ts b/src/component/mxgraph/StyleConfigurator.ts index a480bee55e..6554096821 100644 --- a/src/component/mxgraph/StyleConfigurator.ts +++ b/src/component/mxgraph/StyleConfigurator.ts @@ -127,5 +127,18 @@ export default class StyleConfigurator { this.putCellStyle(kind, style); }); + // TODO: this is temporary rendering - to be removed with proper rendering implementation + const temporaryStyle = this.cloneDefaultVertexStyle(); + temporaryStyle[this.mxConstants.STYLE_SHAPE] = this.mxConstants.SHAPE_RHOMBUS; + temporaryStyle[this.mxConstants.STYLE_PERIMETER] = this.mxPerimeter.RhombusPerimeter; + temporaryStyle[this.mxConstants.STYLE_VERTICAL_ALIGN] = 'top'; + temporaryStyle[this.mxConstants.STYLE_STROKECOLOR] = '#f00'; + temporaryStyle[this.mxConstants.STYLE_STROKEWIDTH] = 2; + temporaryStyle[this.mxConstants.STYLE_FILLCOLOR] = '#f00'; + temporaryStyle[this.mxConstants.STYLE_FILL_OPACITY] = 25; + + temporaryStyle[this.mxConstants.STYLE_SPACING_TOP] = 55; + temporaryStyle[this.mxConstants.STYLE_SPACING_RIGHT] = 110; + this.putCellStyle(ShapeBpmnElementKind.GATEWAY_INCLUSIVE, temporaryStyle); } } diff --git a/src/model/bpmn/shape/ShapeBpmnElementKind.ts b/src/model/bpmn/shape/ShapeBpmnElementKind.ts index b5f508d63d..c3e9375194 100644 --- a/src/model/bpmn/shape/ShapeBpmnElementKind.ts +++ b/src/model/bpmn/shape/ShapeBpmnElementKind.ts @@ -24,6 +24,7 @@ export enum ShapeBpmnElementKind { TASK = 'task', GATEWAY_PARALLEL = 'parallelGateway', GATEWAY_EXCLUSIVE = 'exclusiveGateway', + GATEWAY_INCLUSIVE = 'inclusiveGateway', EVENT_START = 'startEvent', EVENT_END = 'endEvent', EVENT_INTERMEDIATE_CATCH = 'intermediateCatchEvent', diff --git a/test/unit/component/parser/json/BpmnJsonParser.gateway.inclusive.test.ts b/test/unit/component/parser/json/BpmnJsonParser.gateway.inclusive.test.ts new file mode 100644 index 0000000000..3fcd086be3 --- /dev/null +++ b/test/unit/component/parser/json/BpmnJsonParser.gateway.inclusive.test.ts @@ -0,0 +1,149 @@ +/** + * Copyright 2020 Bonitasoft S.A. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { ShapeBpmnElementKind } from '../../../../../src/model/bpmn/shape/ShapeBpmnElementKind'; +import { parseJsonAndExpectOnlyFlowNodes, verifyShape } from './JsonTestUtils'; + +describe('parse bpmn as json for inclusive gateway', () => { + it('json containing one process with a single inclusive gateway', () => { + const json = `{ + "definitions" : { + "process": { + "inclusiveGateway": { + "id":"inclusiveGateway_id_0", + "name":"inclusiveGateway name" + } + }, + "BPMNDiagram": { + "name":"process 0", + "BPMNPlane": { + "BPMNShape": { + "id":"shape_inclusiveGateway_id_0", + "bpmnElement":"inclusiveGateway_id_0", + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } + } + } + } + } + }`; + + const model = parseJsonAndExpectOnlyFlowNodes(json, 1); + + verifyShape(model.flowNodes[0], { + shapeId: 'shape_inclusiveGateway_id_0', + bpmnElementId: 'inclusiveGateway_id_0', + bpmnElementName: 'inclusiveGateway name', + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, + boundsX: 362, + boundsY: 232, + boundsWidth: 36, + boundsHeight: 45, + }); + }); + + it('json containing one process declared as array with a single inclusive gateway', () => { + const json = `{ + "definitions": { + "process": [ + { + "inclusiveGateway": { + "id":"inclusiveGateway_id_1", + "name":"inclusiveGateway name" + } + } + ], + "BPMNDiagram": { + "name":"process 0", + "BPMNPlane": { + "BPMNShape": { + "id":"shape_inclusiveGateway_id_1", + "bpmnElement":"inclusiveGateway_id_1", + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } + } + } + } + } + }`; + + const model = parseJsonAndExpectOnlyFlowNodes(json, 1); + + verifyShape(model.flowNodes[0], { + shapeId: 'shape_inclusiveGateway_id_1', + bpmnElementId: 'inclusiveGateway_id_1', + bpmnElementName: 'inclusiveGateway name', + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, + boundsX: 362, + boundsY: 232, + boundsWidth: 36, + boundsHeight: 45, + }); + }); + + it('json containing one process with an array of inclusive gateways with name & without name', () => { + const json = `{ + "definitions" : { + "process": { + "inclusiveGateway": [ + { + "id":"inclusiveGateway_id_0", + "name":"inclusiveGateway name" + }, { + "id":"inclusiveGateway_id_1" + } + ] + }, + "BPMNDiagram": { + "name":"process 0", + "BPMNPlane": { + "BPMNShape": [ + { + "id":"shape_inclusiveGateway_id_0", + "bpmnElement":"inclusiveGateway_id_0", + "Bounds": { "x": 362, "y": 232, "width": 36, "height": 45 } + }, { + "id":"shape_inclusiveGateway_id_1", + "bpmnElement":"inclusiveGateway_id_1", + "Bounds": { "x": 365, "y": 235, "width": 35, "height": 46 } + } + ] + } + } + } + }`; + + const model = parseJsonAndExpectOnlyFlowNodes(json, 2); + + verifyShape(model.flowNodes[0], { + shapeId: 'shape_inclusiveGateway_id_0', + bpmnElementId: 'inclusiveGateway_id_0', + bpmnElementName: 'inclusiveGateway name', + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, + boundsX: 362, + boundsY: 232, + boundsWidth: 36, + boundsHeight: 45, + }); + verifyShape(model.flowNodes[1], { + shapeId: 'shape_inclusiveGateway_id_1', + bpmnElementId: 'inclusiveGateway_id_1', + bpmnElementName: undefined, + bpmnElementKind: ShapeBpmnElementKind.GATEWAY_INCLUSIVE, + boundsX: 365, + boundsY: 235, + boundsWidth: 35, + boundsHeight: 46, + }); + }); +});