Skip to content

Commit 96127f9

Browse files
committed
clear events after catch
1 parent a169b39 commit 96127f9

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

SpiffWorkflow/bpmn/specs/mixins/events/event_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def _update_hook(self, my_task):
6464
def _run_hook(self, my_task):
6565

6666
self.event_definition.update_task_data(my_task)
67+
for task in my_task.workflow.get_tasks(my_task, spec_name=my_task.task_spec.name):
68+
task.task_spec.event_definition.reset(task)
6769
self.event_definition.reset(my_task)
6870
return super()._run_hook(my_task)
6971

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1qnx3d3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.17.0">
3+
<bpmn:message id="basic_message" name="basic_message" />
4+
<bpmn:collaboration id="Collaboration_0mcedjj">
5+
<bpmn:participant id="Participant_1my71xz" processRef="return_to_event" />
6+
<bpmn:correlationKey id="CorrelationKey_0eyxd4j" name="MainCorrelationKey" />
7+
</bpmn:collaboration>
8+
<bpmn:process id="return_to_event" name="Return to Event" isExecutable="true" camunda:versionTag="1">
9+
<bpmn:startEvent id="StartEvent_1">
10+
<bpmn:outgoing>Flow_0vt1twq</bpmn:outgoing>
11+
</bpmn:startEvent>
12+
<bpmn:exclusiveGateway id="Gateway_1n52pgs" default="Flow_0f9xz6o">
13+
<bpmn:incoming>Flow_0vt1twq</bpmn:incoming>
14+
<bpmn:incoming>Flow_1ypigfq</bpmn:incoming>
15+
<bpmn:outgoing>Flow_0f9xz6o</bpmn:outgoing>
16+
</bpmn:exclusiveGateway>
17+
<bpmn:exclusiveGateway id="Gateway_004qgwe" default="Flow_0wr036h">
18+
<bpmn:incoming>Flow_0q64ho5</bpmn:incoming>
19+
<bpmn:outgoing>Flow_0wr036h</bpmn:outgoing>
20+
<bpmn:outgoing>Flow_1ypigfq</bpmn:outgoing>
21+
</bpmn:exclusiveGateway>
22+
<bpmn:endEvent id="Event_0yxpeto">
23+
<bpmn:incoming>Flow_0wr036h</bpmn:incoming>
24+
</bpmn:endEvent>
25+
<bpmn:intermediateCatchEvent id="Event_10ncvxn">
26+
<bpmn:incoming>Flow_0f9xz6o</bpmn:incoming>
27+
<bpmn:outgoing>Flow_19iz45y</bpmn:outgoing>
28+
<bpmn:messageEventDefinition id="MessageEventDefinition_123nnte" messageRef="basic_message">
29+
<bpmn:extensionElements />
30+
</bpmn:messageEventDefinition>
31+
</bpmn:intermediateCatchEvent>
32+
<bpmn:sequenceFlow id="Flow_0vt1twq" sourceRef="StartEvent_1" targetRef="Gateway_1n52pgs" />
33+
<bpmn:sequenceFlow id="Flow_1ypigfq" sourceRef="Gateway_004qgwe" targetRef="Gateway_1n52pgs">
34+
<bpmn:conditionExpression>repeat</bpmn:conditionExpression>
35+
</bpmn:sequenceFlow>
36+
<bpmn:sequenceFlow id="Flow_0f9xz6o" sourceRef="Gateway_1n52pgs" targetRef="Event_10ncvxn" />
37+
<bpmn:sequenceFlow id="Flow_19iz45y" sourceRef="Event_10ncvxn" targetRef="manual" />
38+
<bpmn:sequenceFlow id="Flow_0q64ho5" sourceRef="manual" targetRef="Gateway_004qgwe" />
39+
<bpmn:sequenceFlow id="Flow_0wr036h" sourceRef="Gateway_004qgwe" targetRef="Event_0yxpeto" />
40+
<bpmn:manualTask id="manual">
41+
<bpmn:incoming>Flow_19iz45y</bpmn:incoming>
42+
<bpmn:outgoing>Flow_0q64ho5</bpmn:outgoing>
43+
</bpmn:manualTask>
44+
</bpmn:process>
45+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
46+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0mcedjj">
47+
<bpmndi:BPMNShape id="Participant_1my71xz_di" bpmnElement="Participant_1my71xz" isHorizontal="true">
48+
<dc:Bounds x="90" y="0" width="670" height="250" />
49+
</bpmndi:BPMNShape>
50+
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
51+
<dc:Bounds x="142" y="82" width="36" height="36" />
52+
</bpmndi:BPMNShape>
53+
<bpmndi:BPMNShape id="Gateway_1n52pgs_di" bpmnElement="Gateway_1n52pgs" isMarkerVisible="true">
54+
<dc:Bounds x="235" y="75" width="50" height="50" />
55+
</bpmndi:BPMNShape>
56+
<bpmndi:BPMNShape id="Gateway_004qgwe_di" bpmnElement="Gateway_004qgwe" isMarkerVisible="true">
57+
<dc:Bounds x="585" y="75" width="50" height="50" />
58+
</bpmndi:BPMNShape>
59+
<bpmndi:BPMNShape id="Event_0yxpeto_di" bpmnElement="Event_0yxpeto">
60+
<dc:Bounds x="702" y="82" width="36" height="36" />
61+
</bpmndi:BPMNShape>
62+
<bpmndi:BPMNShape id="Event_07bqt35_di" bpmnElement="Event_10ncvxn">
63+
<dc:Bounds x="332" y="82" width="36" height="36" />
64+
</bpmndi:BPMNShape>
65+
<bpmndi:BPMNShape id="Activity_0eryu93_di" bpmnElement="manual">
66+
<dc:Bounds x="420" y="60" width="100" height="80" />
67+
</bpmndi:BPMNShape>
68+
<bpmndi:BPMNEdge id="Flow_0vt1twq_di" bpmnElement="Flow_0vt1twq">
69+
<di:waypoint x="178" y="100" />
70+
<di:waypoint x="235" y="100" />
71+
</bpmndi:BPMNEdge>
72+
<bpmndi:BPMNEdge id="Flow_1ypigfq_di" bpmnElement="Flow_1ypigfq">
73+
<di:waypoint x="610" y="125" />
74+
<di:waypoint x="610" y="210" />
75+
<di:waypoint x="260" y="210" />
76+
<di:waypoint x="260" y="125" />
77+
</bpmndi:BPMNEdge>
78+
<bpmndi:BPMNEdge id="Flow_0f9xz6o_di" bpmnElement="Flow_0f9xz6o">
79+
<di:waypoint x="285" y="100" />
80+
<di:waypoint x="332" y="100" />
81+
</bpmndi:BPMNEdge>
82+
<bpmndi:BPMNEdge id="Flow_19iz45y_di" bpmnElement="Flow_19iz45y">
83+
<di:waypoint x="368" y="100" />
84+
<di:waypoint x="420" y="100" />
85+
</bpmndi:BPMNEdge>
86+
<bpmndi:BPMNEdge id="Flow_0q64ho5_di" bpmnElement="Flow_0q64ho5">
87+
<di:waypoint x="520" y="100" />
88+
<di:waypoint x="585" y="100" />
89+
</bpmndi:BPMNEdge>
90+
<bpmndi:BPMNEdge id="Flow_0wr036h_di" bpmnElement="Flow_0wr036h">
91+
<di:waypoint x="635" y="100" />
92+
<di:waypoint x="702" y="100" />
93+
</bpmndi:BPMNEdge>
94+
</bpmndi:BPMNPlane>
95+
</bpmndi:BPMNDiagram>
96+
</bpmn:definitions>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from SpiffWorkflow import TaskState
2+
from SpiffWorkflow.bpmn import BpmnWorkflow, BpmnEvent
3+
from SpiffWorkflow.bpmn.specs.event_definitions import MessageEventDefinition
4+
5+
from ..BpmnWorkflowTestCase import BpmnWorkflowTestCase
6+
7+
8+
class MessagesTest(BpmnWorkflowTestCase):
9+
10+
def testEventWaitsAfterLoopback(self):
11+
spec, subprocesses = self.load_workflow_spec("return_to_event.bpmn", "return_to_event")
12+
workflow = BpmnWorkflow(spec, subprocesses)
13+
# Advance to the event
14+
workflow.do_engine_steps()
15+
catching_task = workflow.get_next_task(state=TaskState.WAITING)
16+
17+
# Send the event
18+
event = BpmnEvent(catching_task.task_spec.event_definition)
19+
workflow.catch(event)
20+
workflow.do_engine_steps()
21+
22+
task = workflow.get_next_task(state=TaskState.READY)
23+
self.assertEqual(task.task_spec.name, 'manual')
24+
task.data['repeat'] = True
25+
task.run()
26+
workflow.do_engine_steps()
27+
28+
# When we return, the previous event should be cleared and we should wait again
29+
catching_task = workflow.get_next_task(state=TaskState.WAITING)
30+
self.assertEqual(catching_task.task_spec.name, 'Event_10ncvxn')
31+

0 commit comments

Comments
 (0)