-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow multiple incoming sequence flows to target events of event-based gateway #1006
Disallow multiple incoming sequence flows to target events of event-based gateway #1006
Conversation
836a36a
to
645f8e0
Compare
2cd88c1
to
eb4aa6f
Compare
|
||
if ( | ||
is(source, 'bpmn:EventBasedGateway') && | ||
target.incoming.length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This handles multiple connections, despite the test checking only for single connections.
This is because after ddc5c02, multiple connections are disallowed. However, it may be that a diagram is imported which was created with a tool that does not disallow multiple connections, so better to cover the case with multiple connections.
Disregard, multiple-connections test case added:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle properly a case when the event based gateway target has already two incoming connections and then we connect the event based gateway.
eb4aa6f
to
5ed36d8
Compare
8ee7439
to
b466fbd
Compare
@barmac Thanks, I've added tests and new behavior for dealing with the replacement scenario you mentioned. PR description has been updated to demonstrate this. Could you have another look? Hopefully we've got it this time 👍 |
|
||
beforeEach(bootstrapModeler( | ||
diagramXML, | ||
{ modules: [ coreModule, modelingModule, replaceModule ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ modules: [ coreModule, modelingModule, replaceModule ] } | |
diagramXML, { | |
modules: [ | |
coreModule, | |
modelingModule, | |
replaceModule | |
] | |
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same in other places for consistence's sake.
lib/features/rules/BpmnRules.js
Outdated
} | ||
} | ||
|
||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
923-932 could be replaced simply with connections.some(isOutgoingEventBasedGatewayConnection)
. It's implemented in IE11.
return; | ||
} | ||
|
||
newShapeOutgoingConnections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be refactored as it's really difficult to understand. For sure we don't need map
here. Consider assigning step results to variables.
|
||
existingIncomingConnections | ||
.filter(function(connection) { | ||
return is(connection, 'bpmn:SequenceFlow'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check this condition multiple times in the file so why don't we have a helper for this? It will increase the readibility of the code :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return is(connection, 'bpmn:SequenceFlow'); | |
filter(isSequenceFlow) |
|
||
if ( | ||
is(source, 'bpmn:EventBasedGateway') && | ||
target.incoming.length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target.incoming.length > 0 | |
target.incoming.length |
This prevents multiple incoming sequence flows to target events of an event-based gateway when the connection source is not an event-based gateway.
acff1f6
to
169d101
Compare
Handles two new scenarios: 1. A user wants to connect an event-based gateway to an event-based gateway target with existing incoming sequence flows. The existing sequence flows are removed before connecting the new one. 2. A user wants to replace a gateway, that is already connected to event-based gateway targets, with an event-based gateway. The existing incoming sequence flows of the targets, which do not belong to the newly replaced event-based gateway, are removed before the replacement operation finishes. This is because target elements in an event gateway configuration must not have any additional incoming sequence flows other than that from the event gateway.
169d101
to
4db3cad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛵️
Which issue does this PR address?
Relates to camunda/camunda-modeler#637
This updates an existing BPMN rule and adds new modeling behavior for event-based gateways.
When disallowing multiple incoming sequence flows to target events of an event-based gateway, there are three scenarios that are covered here:
Scenario 1: Disallowing a connection to an event-based target when the source is not an event-based gateway.
Scenario 2: Removing existing sequence flows of event-based targets when connecting from an event-based gateway.
Scenario 3: When a user replaces a gateway, that is already connected to event-based targets, with an event-based gateway, then the existing incoming sequence flows of the targets, which do not belong to the newly replaced event-based gateway, are removed.
A fourth scenario which is not covered here would be preventing the user from connecting an event-based gateway to a target which already has an incoming connection from that same event-based gateway. This will be looked at as a separate case.
Instead, the existing connection would be implicitly removed: