diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index 555ec211..22c1178b 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -81,6 +81,10 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) { businessObject.isInterrupting = false; } + if (attrs.associationDirection) { + businessObject.associationDirection = attrs.associationDirection; + } + var eventDefinitions, newEventDefinition; diff --git a/lib/features/rules/BpmnRules.js b/lib/features/rules/BpmnRules.js index f093720e..391a0195 100644 --- a/lib/features/rules/BpmnRules.js +++ b/lib/features/rules/BpmnRules.js @@ -144,6 +144,15 @@ function getOrganizationalParent(element) { return bo; } +function isTextAnnotation(element) { + return is(element, 'bpmn:TextAnnotation'); +} + +function isCompensationBoundary(element) { + return is(element, 'bpmn:BoundaryEvent') && + hasEventDefinition(element, 'bpmn:CompensateEventDefinition'); +} + function isForCompensation(e) { return getBusinessObject(e).isForCompensation; } @@ -224,9 +233,7 @@ function isSequenceFlowSource(element) { !(is(element, 'bpmn:IntermediateThrowEvent') && hasEventDefinition(element, 'bpmn:LinkEventDefinition') ) && - !(is(element, 'bpmn:BoundaryEvent') && - hasEventDefinition(element, 'bpmn:CompensateEventDefinition') - ) && + !isCompensationBoundary(element) && !isForCompensation(element); } @@ -281,24 +288,42 @@ function canConnect(source, target, connection) { return false; } - if (canConnectMessageFlow(source, target) && !is(connection, 'bpmn:DataAssociation')) { - return { type: 'bpmn:MessageFlow' }; - } + if (!is(connection, 'bpmn:DataAssociation')) { - if (canConnectSequenceFlow(source, target) && !is(connection, 'bpmn:DataAssociation')) { - return { type: 'bpmn:SequenceFlow' }; - } - - var dataAssociation = canConnectDataAssociation(source, target); - - if (dataAssociation && (!connection || is(connection, 'bpmn:DataAssociation'))) { - return dataAssociation; - } - - if (is(connection, 'bpmn:Association') && !is(connection, 'bpmn:DataAssociation')) { - if (canConnectAssociation(source, target)) { - return { type: 'bpmn:Association' }; + if (canConnectMessageFlow(source, target)) { + return { type: 'bpmn:MessageFlow' }; } + + if (canConnectSequenceFlow(source, target)) { + return { type: 'bpmn:SequenceFlow' }; + } + } + + var connectDataAssociation = canConnectDataAssociation(source, target); + + if (connectDataAssociation) { + return connectDataAssociation; + } + + if (isCompensationBoundary(source) && isForCompensation(target)) { + return { + type: 'bpmn:Association', + associationDirection: 'One' + }; + } + + if (is(connection, 'bpmn:Association') && canConnectAssociation(source, target)) { + + return { + type: 'bpmn:Association' + }; + } + + if (isTextAnnotation(source) || isTextAnnotation(target)) { + + return { + type: 'bpmn:Association' + }; } return false; @@ -556,7 +581,7 @@ function canResize(shape, newBounds) { return !newBounds || (newBounds.width >= 250 && newBounds.height >= 50); } - if (is(shape, 'bpmn:TextAnnotation')) { + if (isTextAnnotation(shape)) { return true; }