Skip to content

Commit 7bffbb3

Browse files
committed
fix!: ShapeUtil does not include BPMN artifacts in flow node kinds
Regarding the BPMN semantic, artifacts are not executable flow nodes so they are no longer returned in the result of the `ShapeUtil.flowNodeKinds` method. BREAKING CHANGES: artifacts are no longer considered as flow nodes. Code using the `ShapeUtil.flowNodeKinds` method may need to be updated to concat the array returned by the `ShapeUtil.artifactKinds` method to restore the previous content.
1 parent c2ab98d commit 7bffbb3

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/component/parser/json/converter/ProcessConverter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const orderedFlowNodeBpmnTypes: BpmnSemanticType[] = [
7878
'adHocSubProcess',
7979
'transaction',
8080
// process boundary events afterward as we need its parent activity to be available when building it
81-
...(ShapeUtil.flowNodeKinds().filter(kind => kind !== ShapeBpmnElementKind.EVENT_BOUNDARY) as BpmnSemanticType[]),
81+
...([...ShapeUtil.flowNodeKinds(), ...ShapeUtil.artifactKinds()].filter(kind => kind !== ShapeBpmnElementKind.EVENT_BOUNDARY) as BpmnSemanticType[]),
8282
ShapeBpmnElementKind.EVENT_BOUNDARY,
8383
];
8484

src/model/bpmn/internal/shape/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ShapeUtil {
104104
}
105105

106106
static flowNodeKinds(): ShapeBpmnElementKind[] {
107-
return Object.values(ShapeBpmnElementKind).filter(kind => !ShapeUtil.isPoolOrLane(kind));
107+
return Object.values(ShapeBpmnElementKind).filter(kind => !ShapeUtil.isPoolOrLane(kind) && !ShapeUtil.isArtifact(kind));
108108
}
109109

110110
/**

test/unit/component/mxgraph/renderer/StyleComputer.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,23 @@ describe('Style Computer', () => {
556556
const additionalColorsStyle = expectAdditionalColorsStyle ? ';fillColor=#000003;strokeColor=#FF0203;fontColor=#010101' : '';
557557
expect(computeStyleWithRendererOptions(shape)).toBe(`${kind}${additionalColorsStyle}`);
558558
});
559+
559560
it.each([ShapeBpmnElementKind.LANE, ShapeBpmnElementKind.POOL])('%s', (kind: ShapeBpmnElementKind) => {
560561
const shape = newShape(newShapeBpmnElement(kind), newLabelExtension('#aa0101'));
561562
shape.extensions.fillColor = '#AA0003';
562563
shape.extensions.strokeColor = '#FF02AA';
563564
const additionalColorsStyle = expectAdditionalColorsStyle ? ';fillColor=#AA0003;swimlaneFillColor=#AA0003;strokeColor=#FF02AA;fontColor=#aa0101' : '';
564565
expect(computeStyleWithRendererOptions(shape)).toBe(`${kind};horizontal=1${additionalColorsStyle}`);
565566
});
567+
568+
it.each([ShapeBpmnElementKind.GROUP, ShapeBpmnElementKind.TEXT_ANNOTATION])('%s', (kind: ShapeBpmnElementKind) => {
569+
const shape = newShape(newShapeBpmnElement(kind), newLabelExtension('#aa0101'));
570+
shape.extensions.fillColor = '#AA0003';
571+
shape.extensions.strokeColor = '#FF02AA';
572+
const additionalColorsStyle = expectAdditionalColorsStyle ? ';fillColor=#AA0003;strokeColor=#FF02AA;fontColor=#aa0101' : '';
573+
expect(computeStyleWithRendererOptions(shape)).toBe(`${kind}${additionalColorsStyle}`);
574+
});
575+
566576
it('no extension', () => {
567577
const shape = newShape(newShapeBpmnElement(ShapeBpmnElementKind.TASK));
568578
expect(computeStyleWithRendererOptions(shape)).toBe(`task`);

test/unit/model/bpmn/internal/shape/utils.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ describe('ShapeUtil', () => {
3131

3232
it('flow node kinds', () => {
3333
const flowNodeKinds = ShapeUtil.flowNodeKinds();
34-
expect(flowNodeKinds).toContain(ShapeBpmnElementKind.TASK);
35-
expect(flowNodeKinds).toContain(ShapeBpmnElementKind.EVENT_INTERMEDIATE_CATCH);
36-
expect(flowNodeKinds).toContain(ShapeBpmnElementKind.GROUP); // artifact should not be included
34+
35+
expect(flowNodeKinds).toEqual(expect.arrayContaining(ShapeUtil.activityKinds()));
36+
expect(flowNodeKinds).toEqual(expect.arrayContaining(ShapeUtil.eventKinds()));
37+
expect(flowNodeKinds).toEqual(expect.arrayContaining(ShapeUtil.gatewayKinds()));
38+
3739
expect(flowNodeKinds).not.toContain(ShapeBpmnElementKind.POOL);
40+
expect(flowNodeKinds).not.toContain(ShapeBpmnElementKind.GROUP);
3841
});
3942

4043
it('artifact kinds', () => {
@@ -90,8 +93,8 @@ describe('ShapeUtil', () => {
9093
${ShapeBpmnElementKind.CALL_ACTIVITY} | ${true}
9194
${ShapeBpmnElementKind.POOL} | ${false}
9295
${ShapeBpmnElementKind.LANE} | ${false}
93-
${ShapeBpmnElementKind.GROUP} | ${true}
94-
${ShapeBpmnElementKind.TEXT_ANNOTATION} | ${true}
96+
${ShapeBpmnElementKind.GROUP} | ${false}
97+
${ShapeBpmnElementKind.TEXT_ANNOTATION} | ${false}
9598
${FlowKind.MESSAGE_FLOW} | ${false}
9699
${'unknown'} | ${false}
97100
${'receiveTask'} | ${true}

0 commit comments

Comments
 (0)