parent
1cdce93f5b
commit
d520574d1a
|
@ -238,6 +238,41 @@ function getDefinitions(element) {
|
|||
return element;
|
||||
}
|
||||
|
||||
BpmnUpdater.prototype.getLaneSet = function(container) {
|
||||
|
||||
var laneSet, laneSets;
|
||||
|
||||
// bpmn:Lane
|
||||
if (is(container, 'bpmn:Lane')) {
|
||||
laneSet = container.childLaneSet;
|
||||
|
||||
if (!laneSet) {
|
||||
laneSet = this._bpmnFactory.create('bpmn:LaneSet');
|
||||
container.childLaneSet = laneSet;
|
||||
laneSet.$parent = container;
|
||||
}
|
||||
|
||||
return laneSet;
|
||||
}
|
||||
|
||||
// bpmn:Participant
|
||||
if (is(container, 'bpmn:Participant')) {
|
||||
container = container.processRef;
|
||||
}
|
||||
|
||||
// bpmn:FlowElementsContainer
|
||||
laneSets = container.get('laneSets');
|
||||
laneSet = laneSets[0];
|
||||
|
||||
if (!laneSet) {
|
||||
laneSet = this._bpmnFactory.create('bpmn:LaneSet');
|
||||
laneSet.$parent = container;
|
||||
laneSets.push(laneSet);
|
||||
}
|
||||
|
||||
return laneSet;
|
||||
};
|
||||
|
||||
BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) {
|
||||
|
||||
var containment;
|
||||
|
@ -246,10 +281,30 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (is(businessObject, 'bpmn:Lane')) {
|
||||
|
||||
if (newParent) {
|
||||
newParent = this.getLaneSet(newParent);
|
||||
}
|
||||
|
||||
containment = 'lanes';
|
||||
} else
|
||||
|
||||
if (is(businessObject, 'bpmn:FlowElement')) {
|
||||
|
||||
if (newParent && is(newParent, 'bpmn:Participant')) {
|
||||
if (newParent) {
|
||||
|
||||
if (is(newParent, 'bpmn:Participant')) {
|
||||
newParent = newParent.processRef;
|
||||
} else
|
||||
|
||||
if (is(newParent, 'bpmn:Lane')) {
|
||||
do {
|
||||
// unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer)
|
||||
newParent = newParent.$parent.$parent;
|
||||
} while(is(newParent, 'bpmn:Lane'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
containment = 'flowElements';
|
||||
|
|
|
@ -0,0 +1,218 @@
|
|||
'use strict';
|
||||
|
||||
var TestHelper = require('../../../../TestHelper');
|
||||
|
||||
/* global bootstrapModeler, inject */
|
||||
|
||||
|
||||
var modelingModule = require('../../../../../lib/features/modeling'),
|
||||
coreModule = require('../../../../../lib/core');
|
||||
|
||||
|
||||
describe('features/modeling - create lanes', function() {
|
||||
|
||||
|
||||
describe('should add to participant', function() {
|
||||
|
||||
var diagramXML = require('./no-lane.bpmn');
|
||||
|
||||
var testModules = [ coreModule, modelingModule ];
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('execute', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var participantShape = elementRegistry.get('Participant'),
|
||||
participant = participantShape.businessObject,
|
||||
bpmnProcess = participant.processRef;
|
||||
|
||||
// when
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, participantShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
|
||||
// then
|
||||
expect(laneShape).to.exist;
|
||||
expect(lane).to.exist;
|
||||
|
||||
|
||||
expect(bpmnProcess.laneSets).to.exist;
|
||||
|
||||
var laneSet = bpmnProcess.laneSets[0];
|
||||
|
||||
// expect correct bpmn containment for new laneSet
|
||||
expect(laneSet.$parent).to.eql(bpmnProcess);
|
||||
|
||||
// expect correct bpmn containment for lane
|
||||
expect(laneSet.lanes).to.contain(lane);
|
||||
expect(lane.$parent).to.equal(laneSet);
|
||||
|
||||
// expect correct di wiring
|
||||
expect(lane.di.$parent).to.eql(participant.di.$parent);
|
||||
expect(lane.di.$parent.planeElement).to.include(lane.di);
|
||||
}));
|
||||
|
||||
|
||||
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
||||
|
||||
// given
|
||||
var participantShape = elementRegistry.get('Participant'),
|
||||
participant = participantShape.businessObject,
|
||||
bpmnProcess = participant.processRef;
|
||||
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, participantShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
var laneSet = lane.$parent;
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(lane.$parent).to.be.null;
|
||||
expect(laneSet.lanes).not.to.contain(lane);
|
||||
|
||||
// lane sets remain initialized
|
||||
expect(bpmnProcess.laneSets).to.exist;
|
||||
expect(bpmnProcess.laneSets.length).to.eql(1);
|
||||
}));
|
||||
|
||||
|
||||
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
||||
|
||||
// given
|
||||
var participantShape = elementRegistry.get('Participant'),
|
||||
participant = participantShape.businessObject,
|
||||
bpmnProcess = participant.processRef;
|
||||
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, participantShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
commandStack.redo();
|
||||
|
||||
// then
|
||||
expect(laneShape).to.exist;
|
||||
expect(lane).to.exist;
|
||||
|
||||
expect(bpmnProcess.laneSets).to.exist;
|
||||
|
||||
var laneSet = bpmnProcess.laneSets[0];
|
||||
|
||||
// expect correct bpmn containment
|
||||
expect(laneSet.lanes).to.contain(lane);
|
||||
expect(lane.$parent).to.equal(laneSet);
|
||||
|
||||
// expect correct di wiring
|
||||
expect(lane.di.$parent).to.eql(participant.di.$parent);
|
||||
expect(lane.di.$parent.planeElement).to.include(lane.di);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('should add to lane', function() {
|
||||
|
||||
var diagramXML = require('./nested-lane.bpmn');
|
||||
|
||||
var testModules = [ coreModule, modelingModule ];
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('execute', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var parentLaneShape = elementRegistry.get('Lane'),
|
||||
parentLane = parentLaneShape.businessObject;
|
||||
|
||||
// when
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, parentLaneShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
|
||||
// then
|
||||
expect(laneShape).to.exist;
|
||||
expect(lane).to.exist;
|
||||
|
||||
var laneSet = parentLane.childLaneSet;
|
||||
|
||||
expect(laneSet).to.exist;
|
||||
|
||||
// expect correct bpmn containment for new laneSet
|
||||
expect(laneSet.$parent).to.eql(parentLane);
|
||||
|
||||
// expect correct bpmn containment for lane
|
||||
expect(laneSet.lanes).to.contain(lane);
|
||||
expect(lane.$parent).to.equal(laneSet);
|
||||
|
||||
// expect correct di wiring
|
||||
expect(lane.di.$parent).to.eql(parentLane.di.$parent);
|
||||
expect(lane.di.$parent.planeElement).to.include(lane.di);
|
||||
}));
|
||||
|
||||
|
||||
it('undo', inject(function(elementRegistry, commandStack, modeling) {
|
||||
|
||||
// given
|
||||
var parentLaneShape = elementRegistry.get('Lane'),
|
||||
parentLane = parentLaneShape.businessObject;
|
||||
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, parentLaneShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
var laneSet = lane.$parent;
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
expect(lane.$parent).to.be.null;
|
||||
expect(laneSet.lanes).not.to.contain(lane);
|
||||
|
||||
// childLaneSet sets remain initialized
|
||||
expect(parentLane.childLaneSet).to.exist;
|
||||
}));
|
||||
|
||||
|
||||
it('redo', inject(function(elementRegistry, commandStack, modeling) {
|
||||
|
||||
// given
|
||||
var parentLaneShape = elementRegistry.get('Lane'),
|
||||
parentLane = parentLaneShape.businessObject;
|
||||
|
||||
var laneShape = modeling.createShape({ type: 'bpmn:Lane' }, { x: 180, y: 100 }, parentLaneShape);
|
||||
|
||||
var lane = laneShape.businessObject;
|
||||
|
||||
// when
|
||||
commandStack.undo();
|
||||
commandStack.redo();
|
||||
|
||||
// then
|
||||
expect(laneShape).to.exist;
|
||||
expect(lane).to.exist;
|
||||
|
||||
var laneSet = parentLane.childLaneSet;
|
||||
|
||||
expect(laneSet).to.exist;
|
||||
|
||||
// expect correct bpmn containment for new laneSet
|
||||
expect(laneSet.$parent).to.eql(parentLane);
|
||||
|
||||
// expect correct bpmn containment for lane
|
||||
expect(laneSet.lanes).to.contain(lane);
|
||||
expect(lane.$parent).to.equal(laneSet);
|
||||
|
||||
// expect correct di wiring
|
||||
expect(lane.di.$parent).to.eql(parentLane.di.$parent);
|
||||
expect(lane.di.$parent.planeElement).to.include(lane.di);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,72 @@
|
|||
<?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="_4bAZoD9WEeWLcNBL4nCk1A" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
|
||||
<bpmn2:collaboration id="_Collaboration_2">
|
||||
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane"/>
|
||||
</bpmn2:collaboration>
|
||||
<bpmn2:process id="Process_Lane" isExecutable="false">
|
||||
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||
<bpmn2:lane id="Lane" name="Lane">
|
||||
<bpmn2:childLaneSet xsi:type="bpmn2:tLaneSet" id="LaneSet_2">
|
||||
<bpmn2:lane id="Nested_Lane" name="Nested_Lane">
|
||||
<bpmn2:flowNodeRef>Boundary</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>Task_Boundary</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>Task</bpmn2:flowNodeRef>
|
||||
</bpmn2:lane>
|
||||
</bpmn2:childLaneSet>
|
||||
</bpmn2:lane>
|
||||
</bpmn2:laneSet>
|
||||
<bpmn2:boundaryEvent id="Boundary" name="Boundary" attachedToRef="Task_Boundary">
|
||||
<bpmn2:outgoing>SequenceFlow_From_Boundary</bpmn2:outgoing>
|
||||
</bpmn2:boundaryEvent>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow_From_Boundary" name="" sourceRef="Boundary" targetRef="Task"/>
|
||||
<bpmn2:task id="Task_Boundary" name="Task_Boundary">
|
||||
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
|
||||
</bpmn2:task>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_Boundary" targetRef="Task"/>
|
||||
<bpmn2:task id="Task" name="Task">
|
||||
<bpmn2:incoming>SequenceFlow_From_Boundary</bpmn2:incoming>
|
||||
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
|
||||
</bpmn2:task>
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_Lane" isHorizontal="true">
|
||||
<dc:Bounds height="181.0" width="540.0" x="156.0" y="84.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_Boundary">
|
||||
<dc:Bounds height="80.0" width="100.0" x="348.0" y="114.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_2" bpmnElement="Boundary">
|
||||
<dc:Bounds height="36.0" width="36.0" x="395.0" y="176.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="21.0" width="61.0" x="336.0" y="211.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
|
||||
<dc:Bounds height="80.0" width="100.0" x="516.0" y="114.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_From_Boundary" sourceElement="_BPMNShape_BoundaryEvent_2" targetElement="_BPMNShape_Task_3">
|
||||
<di:waypoint xsi:type="dc:Point" x="413.0" y="212.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="413.0" y="242.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="566.0" y="242.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="566.0" y="194.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="6.0" width="6.0" x="458.0" y="242.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_3">
|
||||
<di:waypoint xsi:type="dc:Point" x="448.0" y="154.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="516.0" y="154.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="6.0" width="6.0" x="487.0" y="154.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Lane_3" bpmnElement="Lane" isHorizontal="true">
|
||||
<dc:Bounds height="181.0" width="510.0" x="186.0" y="84.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Lane_4" bpmnElement="Nested_Lane" isHorizontal="true">
|
||||
<dc:Bounds height="181.0" width="480.0" x="216.0" y="84.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn2:definitions>
|
|
@ -0,0 +1,55 @@
|
|||
<?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="_4bAZoD9WEeWLcNBL4nCk1A" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
|
||||
<bpmn2:collaboration id="Collaboration">
|
||||
<bpmn2:participant id="Participant" name="Participant" processRef="Process"/>
|
||||
</bpmn2:collaboration>
|
||||
<bpmn2:process id="Process" isExecutable="false">
|
||||
<bpmn2:task id="Task_Boundary" name="Task_Boundary">
|
||||
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
|
||||
</bpmn2:task>
|
||||
<bpmn2:boundaryEvent id="Boundary" name="Boundary" attachedToRef="Task_Boundary">
|
||||
<bpmn2:outgoing>SequenceFlow_From_Boundary</bpmn2:outgoing>
|
||||
</bpmn2:boundaryEvent>
|
||||
<bpmn2:task id="Task" name="Task">
|
||||
<bpmn2:incoming>SequenceFlow_From_Boundary</bpmn2:incoming>
|
||||
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
|
||||
</bpmn2:task>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow_From_Boundary" name="" sourceRef="Boundary" targetRef="Task"/>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_Boundary" targetRef="Task"/>
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant" isHorizontal="true">
|
||||
<dc:Bounds height="181.0" width="540.0" x="156.0" y="84.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_Boundary">
|
||||
<dc:Bounds height="80.0" width="100.0" x="348.0" y="114.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_2" bpmnElement="Boundary">
|
||||
<dc:Bounds height="36.0" width="36.0" x="395.0" y="176.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="21.0" width="61.0" x="336.0" y="211.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task">
|
||||
<dc:Bounds height="80.0" width="100.0" x="516.0" y="114.0"/>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_From_Boundary" sourceElement="_BPMNShape_BoundaryEvent_2" targetElement="_BPMNShape_Task_3">
|
||||
<di:waypoint xsi:type="dc:Point" x="413.0" y="212.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="413.0" y="242.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="566.0" y="242.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="566.0" y="194.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="6.0" width="6.0" x="458.0" y="242.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_3">
|
||||
<di:waypoint xsi:type="dc:Point" x="448.0" y="154.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="516.0" y="154.0"/>
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="6.0" width="6.0" x="487.0" y="154.0"/>
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn2:definitions>
|
Loading…
Reference in New Issue