fix(modeling): append DataStoreReference to first available process
Related to #1456
This commit is contained in:
parent
d5cc469531
commit
e0c4dea90d
|
@ -2,7 +2,10 @@ import inherits from 'inherits';
|
||||||
|
|
||||||
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
||||||
|
|
||||||
import { is } from '../../../util/ModelUtil';
|
import {
|
||||||
|
getBusinessObject,
|
||||||
|
is
|
||||||
|
} from '../../../util/ModelUtil';
|
||||||
|
|
||||||
import { isAny } from '../util/ModelingUtil';
|
import { isAny } from '../util/ModelingUtil';
|
||||||
|
|
||||||
|
@ -20,9 +23,9 @@ export default function DataStoreBehavior(
|
||||||
|
|
||||||
commandStack.registerHandler('dataStore.updateContainment', UpdateSemanticParentHandler);
|
commandStack.registerHandler('dataStore.updateContainment', UpdateSemanticParentHandler);
|
||||||
|
|
||||||
function getFirstParticipant() {
|
function getFirstParticipantWithProcessRef() {
|
||||||
return elementRegistry.filter(function(element) {
|
return elementRegistry.filter(function(element) {
|
||||||
return is(element, 'bpmn:Participant');
|
return is(element, 'bpmn:Participant') && getBusinessObject(element).processRef;
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +38,7 @@ export default function DataStoreBehavior(
|
||||||
function updateDataStoreParent(dataStore, newDataStoreParent) {
|
function updateDataStoreParent(dataStore, newDataStoreParent) {
|
||||||
var dataStoreBo = dataStore.businessObject || dataStore;
|
var dataStoreBo = dataStore.businessObject || dataStore;
|
||||||
|
|
||||||
newDataStoreParent = newDataStoreParent || getFirstParticipant();
|
newDataStoreParent = newDataStoreParent || getFirstParticipantWithProcessRef();
|
||||||
|
|
||||||
if (newDataStoreParent) {
|
if (newDataStoreParent) {
|
||||||
var newDataStoreParentBo = newDataStoreParent.businessObject || newDataStoreParent;
|
var newDataStoreParentBo = newDataStoreParent.businessObject || newDataStoreParent;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="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" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.15.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
||||||
|
<bpmn:collaboration id="Collaboration">
|
||||||
|
<bpmn:participant id="Participant" />
|
||||||
|
<bpmn:participant id="Participant_2" processRef="Process_2" />
|
||||||
|
</bpmn:collaboration>
|
||||||
|
<bpmn:process id="Process_2" isExecutable="false" />
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
|
||||||
|
<bpmndi:BPMNShape id="Participant_di" bpmnElement="Participant" isHorizontal="false">
|
||||||
|
<dc:Bounds x="42" y="46" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Participant_066vvzt_di" bpmnElement="Participant_2">
|
||||||
|
<dc:Bounds x="42" y="514" width="600" height="250" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -45,7 +45,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should create DataStoreReference on sub process', inject(function(elementRegistry, modeling, bpmnjs) {
|
it('should create DataStoreReference on sub process', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var subProcessElement = elementRegistry.get('SubProcess'),
|
var subProcessElement = elementRegistry.get('SubProcess'),
|
||||||
|
@ -70,7 +70,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should create DataStoreReference on collaboration', inject(function(elementRegistry, modeling, bpmnjs) {
|
it('should create DataStoreReference on collaboration', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var collaborationElement = elementRegistry.get('Collaboration'),
|
var collaborationElement = elementRegistry.get('Collaboration'),
|
||||||
|
@ -95,6 +95,41 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
expect(dataStoreReference.dataStoreRef).not.to.exist;
|
expect(dataStoreReference.dataStoreRef).not.to.exist;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
describe('empty pool', function() {
|
||||||
|
|
||||||
|
var processDiagramXML = require('./DataStoreBehavior.empty-pool.bpmn');
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
it('should create DataStoreReference on collaboration if first participant is an empty pool',
|
||||||
|
inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
|
// give
|
||||||
|
var collaboration = elementRegistry.get('Collaboration'),
|
||||||
|
participantWithProcess = elementRegistry.get('Participant_2').businessObject;
|
||||||
|
|
||||||
|
// when
|
||||||
|
var dataStoreShape = modeling.createShape(
|
||||||
|
{ type: 'bpmn:DataStoreReference' },
|
||||||
|
{ x: 420, y: 370 },
|
||||||
|
collaboration
|
||||||
|
);
|
||||||
|
|
||||||
|
var dataStoreReference = dataStoreShape.businessObject;
|
||||||
|
|
||||||
|
// then
|
||||||
|
// reference correctly wired
|
||||||
|
expect(dataStoreReference.$parent).to.exist;
|
||||||
|
expect(dataStoreReference.$parent).to.eql(participantWithProcess.processRef);
|
||||||
|
expect(participantWithProcess.processRef.flowElements).to.contain(dataStoreReference);
|
||||||
|
|
||||||
|
// no actual data store created
|
||||||
|
expect(dataStoreReference.dataStoreRef).not.to.exist;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +140,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
it('should move DataStoreReference to Participant', inject(function(elementRegistry, modeling, bpmnjs) {
|
it('should move DataStoreReference to Participant', inject(function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var participantElement = elementRegistry.get('Participant'),
|
var participantElement = elementRegistry.get('Participant'),
|
||||||
|
@ -123,7 +158,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should move DataStoreReference from partipant to Collaboration keeping parent particpant', inject(
|
it('should move DataStoreReference from partipant to Collaboration keeping parent particpant', inject(
|
||||||
function(elementRegistry, modeling, bpmnjs) {
|
function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var collaborationElement = elementRegistry.get('Collaboration'),
|
var collaborationElement = elementRegistry.get('Collaboration'),
|
||||||
|
@ -143,7 +178,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should move DataStoreReference from subprocess to Collaboration keeping parent particpant', inject(
|
it('should move DataStoreReference from subprocess to Collaboration keeping parent particpant', inject(
|
||||||
function(elementRegistry, modeling, bpmnjs) {
|
function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var collaborationElement = elementRegistry.get('Collaboration'),
|
var collaborationElement = elementRegistry.get('Collaboration'),
|
||||||
|
@ -163,7 +198,7 @@ describe('features/modeling/behavior - data store', function() {
|
||||||
|
|
||||||
|
|
||||||
it('should move without changing parent', inject(
|
it('should move without changing parent', inject(
|
||||||
function(elementRegistry, modeling, bpmnjs) {
|
function(elementRegistry, modeling) {
|
||||||
|
|
||||||
// give
|
// give
|
||||||
var collaborationElement = elementRegistry.get('Collaboration'),
|
var collaborationElement = elementRegistry.get('Collaboration'),
|
||||||
|
|
Loading…
Reference in New Issue