fix(rules): allow TextAnnotation <-> Data(Store|Object) connection

Closes #687
This commit is contained in:
Nico Rehwaldt 2017-05-17 16:37:05 +02:00 committed by Philipp Fromme
parent 8e55edd80f
commit 8015b21b15
2 changed files with 67 additions and 22 deletions

View File

@ -190,22 +190,6 @@ function isTextAnnotation(element) {
return is(element, 'bpmn:TextAnnotation'); return is(element, 'bpmn:TextAnnotation');
} }
function isArtifact(element) {
return isAny(element, [
'bpmn:DataObjectReference',
'bpmn:DataStoreReference',
'bpmn:Group',
'bpmn:TextAnnotation'
]);
}
function isDataObject(element) {
return isAny(element, [
'bpmn:DataObjectReference',
'bpmn:DataStoreReference'
]);
}
function isCompensationBoundary(element) { function isCompensationBoundary(element) {
return is(element, 'bpmn:BoundaryEvent') && return is(element, 'bpmn:BoundaryEvent') &&
hasEventDefinition(element, 'bpmn:CompensateEventDefinition'); hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
@ -714,6 +698,22 @@ function canResize(shape, newBounds) {
return false; return false;
} }
/**
* Check, whether one side of the relationship
* is a text annotation.
*/
function isOneTextAnnotation(source, target) {
var sourceTextAnnotation = isTextAnnotation(source),
targetTextAnnotation = isTextAnnotation(target);
return (
(sourceTextAnnotation || targetTextAnnotation) &&
(sourceTextAnnotation !== targetTextAnnotation)
);
}
function canConnectAssociation(source, target) { function canConnectAssociation(source, target) {
// do not connect connections // do not connect connections
@ -726,12 +726,13 @@ function canConnectAssociation(source, target) {
return true; return true;
} }
// only connect artifacts with other BPMN (graphical) elements // don't connect parent <-> child
// connect if different parent if (isParent(target, source) || isParent(source, target)) {
return ((isArtifact(source) && !isDataObject(source) && !isArtifact(target)) || return false;
(!isArtifact(source) && isArtifact(target) && !isDataObject(target))) && }
!isParent(target, source) &&
!isParent(source, target); // allow connection of associations between <!TextAnnotation> and <TextAnnotation>
return isOneTextAnnotation(source, target);
} }
function canConnectMessageFlow(source, target) { function canConnectMessageFlow(source, target) {

View File

@ -207,6 +207,50 @@ describe('features/modeling/rules - BpmnRules', function() {
})); }));
it('connect DataObjectReference -> TextAnnotation', inject(function() {
expectCanConnect('DataObjectReference', 'TextAnnotation', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: false
});
}));
it('connect TextAnnotation -> DataObjectReference', inject(function() {
expectCanConnect('TextAnnotation', 'DataObjectReference', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: false
});
}));
it('connect DataStoreReference -> TextAnnotation', inject(function() {
expectCanConnect('DataStoreReference', 'TextAnnotation', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: false
});
}));
it('connect TextAnnotation -> DataStoreReference', inject(function() {
expectCanConnect('TextAnnotation', 'DataStoreReference', {
sequenceFlow: false,
messageFlow: false,
association: true,
dataAssociation: false
});
}));
it('connect StartEvent_None -> DataStoreReference', inject(function() { it('connect StartEvent_None -> DataStoreReference', inject(function() {
expectCanConnect('StartEvent_None', 'DataStoreReference', { expectCanConnect('StartEvent_None', 'DataStoreReference', {