Skip to content
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

Conversation

gustavjf
Copy link
Contributor

@gustavjf gustavjf commented Apr 29, 2019

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.

camunda-modeler#637_01

Scenario 2: Removing existing sequence flows of event-based targets when connecting from an event-based gateway.

camunda-modeler#637_02

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.

camunda-modeler#637_05

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:

camunda-modeler#637_03

@gustavjf gustavjf added the in progress Currently worked on label Apr 29, 2019
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Apr 29, 2019
@ghost ghost assigned gustavjf Apr 29, 2019
@gustavjf gustavjf added in progress Currently worked on and removed needs review Review pending labels Apr 29, 2019
@gustavjf gustavjf force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch from 836a36a to 645f8e0 Compare April 30, 2019 09:20
@ghost ghost added needs review Review pending and removed in progress Currently worked on labels Apr 30, 2019
@gustavjf gustavjf force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch 3 times, most recently from 2cd88c1 to eb4aa6f Compare May 2, 2019 09:48
@gustavjf gustavjf added in progress Currently worked on and removed needs review Review pending labels May 2, 2019
@gustavjf gustavjf changed the title WIP Disallow multiple incoming sequence flows to target events of event based gateway WIP Disallow multiple incoming sequence flows to target events of event-based gateway May 2, 2019

if (
is(source, 'bpmn:EventBasedGateway') &&
target.incoming.length > 0
Copy link
Contributor Author

@gustavjf gustavjf May 2, 2019

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:

camunda-modeler#637_04

@gustavjf gustavjf requested a review from barmac May 2, 2019 10:30
@gustavjf gustavjf changed the title WIP Disallow multiple incoming sequence flows to target events of event-based gateway Disallow multiple incoming sequence flows to target events of event-based gateway May 2, 2019
@gustavjf gustavjf added needs review Review pending and removed in progress Currently worked on labels May 2, 2019
Copy link
Member

@barmac barmac left a 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.

@gustavjf gustavjf added in progress Currently worked on and removed needs review Review pending labels May 2, 2019
@gustavjf gustavjf force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch from eb4aa6f to 5ed36d8 Compare May 2, 2019 12:44
@ghost ghost added needs review Review pending and removed in progress Currently worked on labels May 2, 2019
@gustavjf gustavjf requested a review from barmac May 2, 2019 12:51
@barmac
Copy link
Member

barmac commented May 2, 2019

Screenshot 2019-05-02 at 15 14 53

Screenshot 2019-05-02 at 15 13 02

It seems like somehow we don't remove the connection properly when we replace the gateways with event based gateways.

@gustavjf gustavjf added in progress Currently worked on and removed needs review Review pending labels May 2, 2019
@gustavjf gustavjf changed the title Disallow multiple incoming sequence flows to target events of event-based gateway WIP Disallow multiple incoming sequence flows to target events of event-based gateway May 2, 2019
@ghost ghost added needs review Review pending and removed in progress Currently worked on labels May 2, 2019
@gustavjf gustavjf force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch 4 times, most recently from 8ee7439 to b466fbd Compare May 3, 2019 10:43
@gustavjf
Copy link
Contributor Author

gustavjf commented May 3, 2019

@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 👍

@gustavjf gustavjf changed the title WIP Disallow multiple incoming sequence flows to target events of event-based gateway Disallow multiple incoming sequence flows to target events of event-based gateway May 3, 2019

beforeEach(bootstrapModeler(
diagramXML,
{ modules: [ coreModule, modelingModule, replaceModule ] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ modules: [ coreModule, modelingModule, replaceModule ] }
diagramXML, {
modules: [
coreModule,
modelingModule,
replaceModule
]
}));

Copy link
Member

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.

}
}

return result;
Copy link
Member

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
Copy link
Member

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');
Copy link
Member

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 :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return is(connection, 'bpmn:SequenceFlow');
filter(isSequenceFlow)


if (
is(source, 'bpmn:EventBasedGateway') &&
target.incoming.length > 0
Copy link
Member

@barmac barmac May 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
@gustavjf gustavjf force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch 2 times, most recently from acff1f6 to 169d101 Compare May 6, 2019 09:03
@gustavjf gustavjf requested a review from barmac May 6, 2019 09:06
gustavjf and others added 2 commits May 6, 2019 11:38
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.
@barmac barmac force-pushed the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch from 169d101 to 4db3cad Compare May 6, 2019 09:42
@ghost ghost assigned barmac May 6, 2019
Copy link
Member

@barmac barmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛵️

@gustavjf gustavjf merged commit e4fe8c2 into master May 6, 2019
@gustavjf gustavjf deleted the disallow-multiple-incoming-sequence-flows-to-target-events-of-event-based-gateway branch May 6, 2019 10:41
@ghost ghost removed the needs review Review pending label May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants