Skip to content

Commit

Permalink
fix(rules): disallow creating DataStoreReference if process is missing
Browse files Browse the repository at this point in the history
Closes #1456
  • Loading branch information
barmac authored and fake-join[bot] committed May 31, 2021
1 parent e0c4dea commit 7f1c0be
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/features/rules/BpmnRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ function canDrop(element, target, position) {
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
}

// disallow dropping data store reference if there is no process to append to
if (is(element, 'bpmn:DataStoreReference') && is(target, 'bpmn:Collaboration')) {
return some(getBusinessObject(target).get('participants'), function(participant) {
return !!participant.get('processRef');
});
}

// account for the fact that data associations are always
// rendered and moved to top (Process or Collaboration level)
//
Expand Down
13 changes: 13 additions & 0 deletions test/spec/features/rules/BpmnRules.collaboration-empty.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions 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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_biH3sOTeEeS2YerRfpjPrw" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="Collaboration">
<bpmn2:participant id="Participant" name="Pool"/>
</bpmn2:collaboration>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant" isHorizontal="true">
<dc:Bounds x="72" y="48" width="706" height="266" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
20 changes: 20 additions & 0 deletions test/spec/features/rules/BpmnRulesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ describe('features/modeling/rules - BpmnRules', function() {
expectCanCreate([task1, task2], 'SequenceFlow', false);
}));


describe('empty pool', function() {

var testXML = require('./BpmnRules.collaboration-empty.bpmn');

beforeEach(bootstrapModeler(testXML, { modules: testModules }));


it('should not allow to drop DataStoreReference when there is no process to append to',
inject(function(elementFactory) {

// given
var dataStoreReference = elementFactory.createShape({ type: 'bpmn:DataStoreReference' });

// then
expectCanCreate(dataStoreReference, 'Collaboration', false);
})
);
});

});


Expand Down

0 comments on commit 7f1c0be

Please sign in to comment.