feat(copy-paste): copy process properties

Clone the linked process when copying a participant.

This ensures that properties attached to the process
are not getting lost.

Closes #1161
This commit is contained in:
Philipp Fromme 2019-09-05 21:37:41 +02:00 committed by Nico Rehwaldt
parent c01e64a16d
commit 2f001e1f4a
3 changed files with 50 additions and 23 deletions

View File

@ -73,12 +73,18 @@ export default function BpmnCopyPaste(bpmnFactory, eventBus, moddleCopy) {
eventBus.on('moddleCopy.canCopyProperty', function(context) { eventBus.on('moddleCopy.canCopyProperty', function(context) {
var parent = context.parent, var parent = context.parent,
property = context.property, property = context.property,
propertyName = context.propertyName; propertyName = context.propertyName,
bpmnProcess;
if (is(parent, 'bpmn:Participant') && if (
is(property, 'bpmn:Process') && propertyName === 'processRef' &&
propertyName === 'processRef') { is(parent, 'bpmn:Participant') &&
return bpmnFactory.create('bpmn:Process'); is(property, 'bpmn:Process')
) {
bpmnProcess = bpmnFactory.create('bpmn:Process');
// return copy of process
return moddleCopy.copyElement(property, bpmnProcess);
} }
}); });

View File

@ -9,6 +9,8 @@ import copyPasteModule from 'diagram-js/lib/features/copy-paste';
import coreModule from 'lib/core'; import coreModule from 'lib/core';
import modelingModule from 'lib/features/modeling'; import modelingModule from 'lib/features/modeling';
import camundaPackage from 'camunda-bpmn-moddle/resources/camunda.json';
import { import {
find, find,
forEach, forEach,
@ -509,7 +511,12 @@ describe('features/copy-paste', function() {
describe('participants', function() { describe('participants', function() {
beforeEach(bootstrapModeler(collaborationAssociationsXML, { modules: testModules })); beforeEach(bootstrapModeler(collaborationAssociationsXML, {
modules: testModules,
moddleExtensions: {
camunda: camundaPackage
}
}));
it('should copy process when copying participant', inject( it('should copy process when copying participant', inject(
@ -543,6 +550,16 @@ describe('features/copy-paste', function() {
expect(participantBo.processRef).not.to.equal(participantInputBo.processRef); expect(participantBo.processRef).not.to.equal(participantInputBo.processRef);
expect(participantBo.processRef).not.to.equal(participantOutputBo.processRef); expect(participantBo.processRef).not.to.equal(participantOutputBo.processRef);
expect(participantBo.processRef.isExecutable).to.be.true;
expect(participantBo.processRef.extensionElements.values).to.have.length(1);
var executionListener = participantBo.processRef.extensionElements.values[0];
expect(executionListener.$type).to.equal('camunda:ExecutionListener');
expect(executionListener.class).to.equal('Foo');
expect(executionListener.event).to.equal('start');
}); });
expect(getBusinessObject(participants[0]).processRef) expect(getBusinessObject(participants[0]).processRef)
@ -563,8 +580,6 @@ describe('features/copy-paste', function() {
describe('nested properties', function() { describe('nested properties', function() {
var camundaPackage = require('camunda-bpmn-moddle/resources/camunda.json');
beforeEach(bootstrapModeler(copyPropertiesXML, { beforeEach(bootstrapModeler(copyPropertiesXML, {
modules: testModules, modules: testModules,
moddleExtensions: { moddleExtensions: {

View File

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2"> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.2">
<bpmn:collaboration id="Collaboration_1"> <bpmn:collaboration id="Collaboration_1">
<bpmn:participant id="Participant_Output" processRef="Process_Output" /> <bpmn:participant id="Participant_Output" processRef="Process_Output" />
<bpmn:participant id="Participant_Input" processRef="Process_Input" /> <bpmn:participant id="Participant_Input" processRef="Process_Input" />
</bpmn:collaboration> </bpmn:collaboration>
<bpmn:process id="Process_Output" isExecutable="false"> <bpmn:process id="Process_Output" isExecutable="true">
<bpmn:extensionElements>
<camunda:executionListener class="Foo" event="start" />
</bpmn:extensionElements>
<bpmn:task id="Task_1"> <bpmn:task id="Task_1">
<bpmn:dataOutputAssociation id="DataOutputAssociation_1"> <bpmn:dataOutputAssociation id="DataOutputAssociation_1">
<bpmn:targetRef>DataStoreReference_1</bpmn:targetRef> <bpmn:targetRef>DataStoreReference_1</bpmn:targetRef>
@ -12,7 +15,10 @@
</bpmn:task> </bpmn:task>
<bpmn:dataStoreReference id="DataStoreReference_1" /> <bpmn:dataStoreReference id="DataStoreReference_1" />
</bpmn:process> </bpmn:process>
<bpmn:process id="Process_Input" isExecutable="false"> <bpmn:process id="Process_Input" isExecutable="true">
<bpmn:extensionElements>
<camunda:executionListener class="Foo" event="start" />
</bpmn:extensionElements>
<bpmn:dataStoreReference id="DataStoreReference_2" /> <bpmn:dataStoreReference id="DataStoreReference_2" />
<bpmn:task id="Task_2"> <bpmn:task id="Task_2">
<bpmn:property id="Property_0l7g57i" name="__targetRef_placeholder" /> <bpmn:property id="Property_0l7g57i" name="__targetRef_placeholder" />
@ -24,37 +30,37 @@
</bpmn:process> </bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">
<bpmndi:BPMNShape id="Participant_166hvof_di" bpmnElement="Participant_Output"> <bpmndi:BPMNShape id="Participant_166hvof_di" bpmnElement="Participant_Output" isHorizontal="true">
<dc:Bounds x="302" y="60" width="600" height="250" /> <dc:Bounds x="152" y="60" width="600" height="250" />
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_17elucr_di" bpmnElement="Task_1"> <bpmndi:BPMNShape id="Task_17elucr_di" bpmnElement="Task_1">
<dc:Bounds x="416" y="100" width="100" height="80" /> <dc:Bounds x="266" y="100" width="100" height="80" />
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataStoreReference_1muhdww_di" bpmnElement="DataStoreReference_1"> <bpmndi:BPMNShape id="DataStoreReference_1muhdww_di" bpmnElement="DataStoreReference_1">
<dc:Bounds x="746" y="216" width="50" height="50" /> <dc:Bounds x="596" y="216" width="50" height="50" />
<bpmndi:BPMNLabel> <bpmndi:BPMNLabel>
<dc:Bounds x="726" y="266" width="90" height="20" /> <dc:Bounds x="726" y="266" width="90" height="20" />
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataOutputAssociation_0bncpb8_di" bpmnElement="DataOutputAssociation_1"> <bpmndi:BPMNEdge id="DataOutputAssociation_0bncpb8_di" bpmnElement="DataOutputAssociation_1">
<di:waypoint x="516" y="157" /> <di:waypoint x="366" y="157" />
<di:waypoint x="746" y="233" /> <di:waypoint x="596" y="233" />
</bpmndi:BPMNEdge> </bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Participant_1duzt5k_di" bpmnElement="Participant_Input"> <bpmndi:BPMNShape id="Participant_1duzt5k_di" bpmnElement="Participant_Input" isHorizontal="true">
<dc:Bounds x="302" y="354" width="600" height="250" /> <dc:Bounds x="152" y="354" width="600" height="250" />
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DataStoreReference_0q26vzn_di" bpmnElement="DataStoreReference_2"> <bpmndi:BPMNShape id="DataStoreReference_0q26vzn_di" bpmnElement="DataStoreReference_2">
<dc:Bounds x="758" y="491" width="50" height="50" /> <dc:Bounds x="608" y="491" width="50" height="50" />
<bpmndi:BPMNLabel> <bpmndi:BPMNLabel>
<dc:Bounds x="738" y="541" width="90" height="20" /> <dc:Bounds x="738" y="541" width="90" height="20" />
</bpmndi:BPMNLabel> </bpmndi:BPMNLabel>
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_10pzi8y_di" bpmnElement="Task_2"> <bpmndi:BPMNShape id="Task_10pzi8y_di" bpmnElement="Task_2">
<dc:Bounds x="426" y="375" width="100" height="80" /> <dc:Bounds x="276" y="375" width="100" height="80" />
</bpmndi:BPMNShape> </bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataInputAssociation_1sf5ecg_di" bpmnElement="DataInputAssociation_1"> <bpmndi:BPMNEdge id="DataInputAssociation_1sf5ecg_di" bpmnElement="DataInputAssociation_1">
<di:waypoint x="758" y="508" /> <di:waypoint x="608" y="508" />
<di:waypoint x="526" y="431" /> <di:waypoint x="376" y="431" />
</bpmndi:BPMNEdge> </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane> </bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram> </bpmndi:BPMNDiagram>