-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9747: Support diverging inclusive gateway r=korthout a=skayliu ## Description <!-- Please explain the changes you made here. --> This PR adds support for the diverging (i.e. splitting, forking) inclusive gateway. <img width="50%" alt="Screen Shot 2022-08-05 at 19 59 33" src="https://user-images.githubusercontent.com/3511026/183134257-7b62393c-eb51-4b06-9651-de834ebc2741.png"> When the inclusive gateway is entered: - The condition of each outgoing sequence flow (of the inclusive gateway) is evaluated, and - if `true` that sequence flow will be taken. - if none of the conditions evaluates to `true`, the _default_ flow is taken. - if none of the conditions evaluates to `true`, and no flow is set as _default_, then an incident is raised. - Depending on the conditions, any combination of the flows can be taken. - If the inclusive gateway only has one outgoing sequence flow, then it does not need to have a condition. For example, when the conditions of flows `a` and `b` evaluate to `true`, then flows `a` and `b` are taken and their targets activated. <img width="50%" alt="Screen Shot 2022-08-05 at 20 14 55" src="https://user-images.githubusercontent.com/3511026/183137053-a02a6694-3217-465a-8b87-41fb048cb2f2.png"> If none of the conditions evaluates to `true`, then the _default_ flow is taken. <img width="50%" alt="Screen Shot 2022-08-05 at 20 17 20" src="https://user-images.githubusercontent.com/3511026/183137419-3ea72405-59bf-4c2f-beb3-ef1e26369e0c.png"> Related docs: - [conditions](https://docs.camunda.io/docs/components/modeler/bpmn/exclusive-gateways/#conditions) (for exclusive gateway) - [incidents](https://docs.camunda.io/docs/components/concepts/incidents/) ## Out of scope This PR does not add support for the converging (i.e. merging, joining) inclusive gateway. - The diverging inclusive gateway adds a lot of value, even without the converging behavior. - In addition, a combination of parallel and exclusive gateways can be used to merge the flows again. ## Related issues <!-- Which issues are closed by this PR or are related --> closes #6018 Co-authored-by: skayliu <skay463@163.com>
- Loading branch information
Showing
19 changed files
with
1,049 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...src/main/java/io/camunda/zeebe/model/bpmn/validation/zeebe/InclusiveGatewayValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright © 2017 camunda services GmbH (info@camunda.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.zeebe.model.bpmn.validation.zeebe; | ||
|
||
import io.camunda.zeebe.model.bpmn.instance.InclusiveGateway; | ||
import io.camunda.zeebe.model.bpmn.instance.SequenceFlow; | ||
import org.camunda.bpm.model.xml.validation.ModelElementValidator; | ||
import org.camunda.bpm.model.xml.validation.ValidationResultCollector; | ||
|
||
public class InclusiveGatewayValidator implements ModelElementValidator<InclusiveGateway> { | ||
|
||
@Override | ||
public Class<InclusiveGateway> getElementType() { | ||
return InclusiveGateway.class; | ||
} | ||
|
||
@Override | ||
public void validate( | ||
final InclusiveGateway element, final ValidationResultCollector validationResultCollector) { | ||
|
||
final SequenceFlow defaultFlow = element.getDefault(); | ||
final int size = element.getIncoming().size(); | ||
if (defaultFlow != null) { | ||
if (defaultFlow.getConditionExpression() == null && size > 1) { | ||
validationResultCollector.addError( | ||
0, "Must have a condition even if it's marked as the default flow"); | ||
} | ||
if (defaultFlow.getSource() != element) { | ||
validationResultCollector.addError(0, "Default flow must start at gateway"); | ||
} | ||
} | ||
if (size > 1) { | ||
validationResultCollector.addError( | ||
0, "Currently the inclusive gateway can only have one incoming sequence flow"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...test/resources/io/camunda/zeebe/model/bpmn/validation/default-flow-inclusive-gateway.bpmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.2"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:startEvent id="StartEvent_1"> | ||
<bpmn:outgoing>SequenceFlow_0s7tk8n</bpmn:outgoing> | ||
</bpmn:startEvent> | ||
<bpmn:inclusiveGateway id="inclusiveGateway" default="SequenceFlow_0s7tk8n"> | ||
<bpmn:incoming>SequenceFlow_0s7tk8n</bpmn:incoming> | ||
<bpmn:outgoing>SequenceFlow_1hlr3xw</bpmn:outgoing> | ||
</bpmn:inclusiveGateway> | ||
<bpmn:endEvent id="EndEvent_1lg4ndn"> | ||
<bpmn:incoming>SequenceFlow_1hlr3xw</bpmn:incoming> | ||
</bpmn:endEvent> | ||
<bpmn:sequenceFlow id="SequenceFlow_1hlr3xw" sourceRef="inclusiveGateway" targetRef="EndEvent_1lg4ndn"> | ||
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">$.foo == true</bpmn:conditionExpression> | ||
</bpmn:sequenceFlow> | ||
<bpmn:sequenceFlow id="SequenceFlow_0s7tk8n" sourceRef="StartEvent_1" targetRef="inclusiveGateway" /> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> | ||
<dc:Bounds x="173" y="102" width="36" height="36" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="InclusiveGateway_0dqu8hv_di" bpmnElement="inclusiveGateway" isMarkerVisible="true"> | ||
<dc:Bounds x="277" y="95" width="50" height="50" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="302" y="149" width="0" height="12" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="EndEvent_1lg4ndn_di" bpmnElement="EndEvent_1lg4ndn"> | ||
<dc:Bounds x="396" y="102" width="36" height="36" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="414" y="142" width="0" height="12" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNEdge id="SequenceFlow_1hlr3xw_di" bpmnElement="SequenceFlow_1hlr3xw"> | ||
<di:waypoint xsi:type="dc:Point" x="327" y="120" /> | ||
<di:waypoint xsi:type="dc:Point" x="396" y="120" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="361.5" y="99" width="0" height="12" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNEdge> | ||
<bpmndi:BPMNEdge id="SequenceFlow_0s7tk8n_di" bpmnElement="SequenceFlow_0s7tk8n"> | ||
<di:waypoint xsi:type="dc:Point" x="209" y="120" /> | ||
<di:waypoint xsi:type="dc:Point" x="277" y="120" /> | ||
<bpmndi:BPMNLabel> | ||
<dc:Bounds x="243" y="99" width="0" height="12" /> | ||
</bpmndi:BPMNLabel> | ||
</bpmndi:BPMNEdge> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.