fix(bpmn-importer): hide sequence flows inside collapsed subprocesses

Closes #231
This commit is contained in:
Philipp Fromme 2016-06-08 09:34:11 +02:00 committed by Vladimirs Katusenoks
parent 6da1a0cb63
commit a314e8dbfa
3 changed files with 187 additions and 4 deletions

View File

@ -65,7 +65,8 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
var di = semantic.di,
element,
translate = this._translate;
translate = this._translate,
hidden;
// ROOT ELEMENT
// handle the special case that we deal with a
@ -82,7 +83,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
else if (is(di, 'bpmndi:BPMNShape')) {
var collapsed = !isExpanded(semantic);
var hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
var bounds = semantic.di.bounds;
@ -108,7 +109,10 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
var source = this._getSource(semantic),
target = this._getTarget(semantic);
hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
element = this._elementFactory.createConnection(elementData(semantic, {
hidden: hidden,
source: source,
target: target,
waypoints: collectWaypoints(semantic.di.waypoint)
@ -247,4 +251,4 @@ BpmnImporter.prototype._getTarget = function(semantic) {
BpmnImporter.prototype._getElement = function(semantic) {
return this._elementRegistry.get(semantic.id);
};
};

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_U0Z10NLzEeSKyddZMwwjAA" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://activiti.org/bpmn">
<bpmn2:process id="Process_1" isExecutable="false">
<bpmn2:subProcess id="SubProcess_1">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
<bpmn2:startEvent id="StartEvent_2">
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="StartEvent_2" targetRef="ExclusiveGateway_1"/>
<bpmn2:exclusiveGateway id="ExclusiveGateway_1">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_1" targetRef="Task_1"/>
<bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="ExclusiveGateway_1" targetRef="ScriptTask_1"/>
<bpmn2:scriptTask id="ScriptTask_1">
<bpmn2:incoming>SequenceFlow_6</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing>
</bpmn2:scriptTask>
<bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="ScriptTask_1" targetRef="EndEvent_3"/>
<bpmn2:task id="Task_1">
<bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
</bpmn2:task>
<bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="Task_1" targetRef="EndEvent_1"/>
<bpmn2:endEvent id="EndEvent_1">
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:endEvent id="EndEvent_3">
<bpmn2:incoming>SequenceFlow_7</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:subProcess>
<bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="SubProcess_1" targetRef="EndEvent_2"/>
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="SubProcess_1"/>
<bpmn2:endEvent id="EndEvent_2">
<bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_26" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="300.0" y="229.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="318.0" y="270.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_SubProcess_8" bpmnElement="SubProcess_1">
<dc:Bounds height="80.0" width="100.0" x="532.0" y="207.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_26" targetElement="_BPMNShape_SubProcess_8">
<di:waypoint xsi:type="dc:Point" x="336.0" y="247.0"/>
<di:waypoint xsi:type="dc:Point" x="532.0" y="247.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="364.0" y="247.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_27" bpmnElement="StartEvent_2">
<dc:Bounds height="36.0" width="36.0" x="396.0" y="144.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="414.0" y="185.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_1">
<dc:Bounds height="80.0" width="100.0" x="564.0" y="132.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_StartEvent_27" targetElement="_BPMNShape_ExclusiveGateway_19">
<di:waypoint xsi:type="dc:Point" x="432.0" y="162.0"/>
<di:waypoint xsi:type="dc:Point" x="480.0" y="162.0"/>
<di:waypoint xsi:type="dc:Point" x="480.0" y="198.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="454.0" y="162.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_58" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="732.0" y="144.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="750.0" y="185.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_Task_3" targetElement="_BPMNShape_EndEvent_58">
<di:waypoint xsi:type="dc:Point" x="664.0" y="172.0"/>
<di:waypoint xsi:type="dc:Point" x="704.0" y="172.0"/>
<di:waypoint xsi:type="dc:Point" x="704.0" y="162.0"/>
<di:waypoint xsi:type="dc:Point" x="732.0" y="162.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="686.0" y="172.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_59" bpmnElement="EndEvent_2">
<dc:Bounds height="36.0" width="36.0" x="840.0" y="229.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="858.0" y="270.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_SubProcess_8" targetElement="_BPMNShape_EndEvent_59">
<di:waypoint xsi:type="dc:Point" x="632.0" y="247.0"/>
<di:waypoint xsi:type="dc:Point" x="813.0" y="246.0"/>
<di:waypoint xsi:type="dc:Point" x="840.0" y="247.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="634.0" y="247.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_19" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="455.0" y="198.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="480.0" y="253.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_19" targetElement="_BPMNShape_Task_3">
<di:waypoint xsi:type="dc:Point" x="505.0" y="223.0"/>
<di:waypoint xsi:type="dc:Point" x="541.0" y="223.0"/>
<di:waypoint xsi:type="dc:Point" x="541.0" y="172.0"/>
<di:waypoint xsi:type="dc:Point" x="564.0" y="172.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="538.0" y="218.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_ScriptTask_2" bpmnElement="ScriptTask_1">
<dc:Bounds height="80.0" width="100.0" x="555.0" y="282.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_19" targetElement="_BPMNShape_ScriptTask_2">
<di:waypoint xsi:type="dc:Point" x="480.0" y="248.0"/>
<di:waypoint xsi:type="dc:Point" x="480.0" y="322.0"/>
<di:waypoint xsi:type="dc:Point" x="555.0" y="322.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="478.0" y="322.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_60" bpmnElement="EndEvent_3">
<dc:Bounds height="36.0" width="36.0" x="705.0" y="304.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="723.0" y="345.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_ScriptTask_2" targetElement="_BPMNShape_EndEvent_60">
<di:waypoint xsi:type="dc:Point" x="655.0" y="322.0"/>
<di:waypoint xsi:type="dc:Point" x="705.0" y="322.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="677.0" y="322.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

View File

@ -10,6 +10,8 @@ var Diagram = require('diagram-js/lib/Diagram'),
Importer = require('../../../lib/import/Importer'),
Viewer = require('../../../lib/Viewer');
var find = require('lodash/collection/find');
describe('import - Importer', function() {
@ -395,4 +397,32 @@ describe('import - Importer', function() {
});
});
describe('hiding', function() {
it('should hide shapes and connections inside of collapsed subprocess', function(done) {
// given
var xml = require('../../fixtures/bpmn/import/collapsed/processWithChildren.bpmn');
// when
runImport(diagram, xml, function(err, warnings) {
var elementRegistry = diagram.get('elementRegistry');
var children = elementRegistry.get('SubProcess_1').children;
var visible = find(children, function(child) {
return !child.hidden;
});
// then
expect(visible).to.be.undefined;
done(err);
});
});
});
});