feat(modeling): allow data associations from and to events

Closes #384
This commit is contained in:
Nico Rehwaldt 2015-10-21 16:25:56 +02:00 committed by Ricardo Matias
parent 238e4f14f8
commit f68054295b
4 changed files with 48 additions and 14 deletions

View File

@ -516,7 +516,6 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent)
BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) {
connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
};
@ -573,7 +572,7 @@ BpmnUpdater.prototype.updateConnection = function(context) {
businessObject.targetRef = newTarget;
}
businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
this.updateConnectionWaypoints(connection);
};

View File

@ -7,6 +7,7 @@ var find = require('lodash/collection/find'),
var getParents = require('../modeling/util/ModelingUtil').getParents,
is = require('../../util/ModelUtil').is,
isAny = require('../modeling/util/ModelingUtil').isAny,
getBusinessObject = require('../../util/ModelUtil').getBusinessObject,
isExpanded = require('../../util/DiUtil').isExpanded,
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess,
@ -327,14 +328,15 @@ function canDrop(element, target, position) {
return isExpanded(target) !== false;
}
return is(target, 'bpmn:Participant') || is(target, 'bpmn:Lane');
return isAny(target, [ 'bpmn:Participant', 'bpmn:Lane' ]);
}
if (is(element, 'bpmn:Artifact')) {
return is(target, 'bpmn:Collaboration') ||
is(target, 'bpmn:Lane') ||
is(target, 'bpmn:Participant') ||
is(target, 'bpmn:Process');
return isAny(target, [
'bpmn:Collaboration',
'bpmn:Lane',
'bpmn:Participant',
'bpmn:Process' ]);
}
if (is(element, 'bpmn:MessageFlow')) {
@ -578,12 +580,16 @@ function canConnectSequenceFlow(source, target) {
!(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
}
function canConnectDataAssociation(source, target) {
if (is(source, 'bpmn:DataObjectReference') && is(target, 'bpmn:Activity')) {
if (is(source, 'bpmn:DataObjectReference') &&
isAny(target, [ 'bpmn:Activity', 'bpmn:ThrowEvent' ])) {
return { type: 'bpmn:DataInputAssociation' };
}
if (is(target, 'bpmn:DataObjectReference') && is(source, 'bpmn:Activity')) {
if (is(target, 'bpmn:DataObjectReference') &&
isAny(source, [ 'bpmn:Activity', 'bpmn:CatchEvent' ])) {
return { type: 'bpmn:DataOutputAssociation' };
}
@ -598,9 +604,8 @@ function canInsert(shape, flow, position) {
// at this point we are not really able to talk
// about connection rules (yet)
return (
is(flow, 'bpmn:SequenceFlow') ||
is(flow, 'bpmn:MessageFlow')
) && is(shape, 'bpmn:FlowNode') && !is(shape, 'bpmn:BoundaryEvent') &&
canDrop(shape, flow.parent, position);
isAny(flow, [ 'bpmn:SequenceFlow', 'bpmn:MessageFlow' ]) &&
is(shape, 'bpmn:FlowNode') &&
!is(shape, 'bpmn:BoundaryEvent') &&
canDrop(shape, flow.parent, position));
}

View File

@ -15,7 +15,9 @@ describe('features/modeling/behavior - data objects -', function() {
var rootShape;
describe('DataObjectReference', function() {
var processDiagramXML = require('./CreateDataObjectBehavior.data-object-reference.bpmn');
beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules }));
@ -27,6 +29,7 @@ describe('features/modeling/behavior - data objects -', function() {
rootShape = canvas.getRootElement();
}));
it('should create the corresponding DataObject', inject(function(modeling) {
// when
@ -63,6 +66,7 @@ describe('features/modeling/behavior - data objects -', function() {
});
describe('create', function() {
var processDiagramXML = require('./CreateDataObjectBehavior.create-data-association.bpmn');
@ -78,6 +82,7 @@ describe('features/modeling/behavior - data objects -', function() {
taskShape = elementRegistry.get('Task_1');
}));
describe('dataOutputAssociation', function() {
it('should execute', inject(function(modeling) {
@ -170,6 +175,7 @@ describe('features/modeling/behavior - data objects -', function() {
});
describe('remove', function() {
var processDiagramXML = require('./CreateDataObjectBehavior.remove-data-association.bpmn');
@ -191,6 +197,7 @@ describe('features/modeling/behavior - data objects -', function() {
inputAssociation = elementRegistry.get('DataInputAssociation_1');
}));
describe('DataOutputAssociation', function() {
it('should execute', inject(function(modeling) {
@ -235,6 +242,7 @@ describe('features/modeling/behavior - data objects -', function() {
});
describe('dataInputAssociation', function() {
it('should execute', inject(function(modeling) {

View File

@ -110,6 +110,28 @@ describe('features/modeling/rules - BpmnRules', function() {
it('connect StartEvent_None -> DataObjectReference', inject(function() {
expectCanConnect('StartEvent_None', 'DataObjectReference', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: { type: 'bpmn:DataOutputAssociation' }
});
}));
it('connect DataObjectReference -> EndEvent_None', inject(function() {
expectCanConnect('DataObjectReference', 'EndEvent_None', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: { type: 'bpmn:DataInputAssociation' }
});
}));
it('connect EndEvent_None -> DataObjectReference', inject(function() {
expectCanConnect('EndEvent_None', 'DataObjectReference', {
sequenceFlow: false,
messageFlow: false,
association: true,