Skip to content

Commit d9fca82

Browse files
committed
omit default on inclusive gw with matched conditions
1 parent 7da6dd9 commit d9fca82

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

SpiffWorkflow/bpmn/specs/mixins/inclusive_gateway.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def check(spec):
120120

121121
def _run_hook(self, my_task):
122122
outputs = self._get_matching_outputs(my_task)
123-
if len(outputs) == 0:
123+
defaults = self._get_default_outputs(my_task)
124+
matches = [ts for ts in outputs if ts not in defaults]
125+
if len(outputs) == 0 and len(defaults) == 0:
124126
raise WorkflowTaskException('No conditions satisfied on gateway', task=my_task)
125-
my_task._sync_children(outputs, TaskState.FUTURE)
127+
my_task._sync_children(matches or defaults, TaskState.FUTURE)
126128
return True

SpiffWorkflow/specs/MultiChoice.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def _get_matching_outputs(self, my_task):
111111
outputs.append(my_task.workflow.spec.get_task_spec_from_name(output))
112112
return outputs
113113

114+
def _get_default_outputs(self, my_task):
115+
defaults = [output for cond, output in self.cond_task_specs if cond is None]
116+
return [my_task.workflow.spec.get_task_spec_from_name(output) for output in defaults]
117+
114118
def _run_hook(self, my_task):
115119
"""Runs the task. Should not be called directly."""
116120
my_task._sync_children(self._get_matching_outputs(my_task), TaskState.FUTURE)

tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def testNoPathFromSecondGateway(self):
3232

3333
def testParallelCondition(self):
3434
self.set_data({'v': 0, 'u': 1, 'w': 1})
35+
gw = self.workflow.get_next_task(state=TaskState.READY)
36+
gw.run()
37+
self.assertIsNone(self.workflow.get_next_task(spec_name='increment_v'))
38+
self.assertTrue(self.workflow.get_next_task(spec_name='u_plus_v').state, TaskState.READY)
39+
self.assertTrue(self.workflow.get_next_task(spec_name='w_plus_v').state, TaskState.READY)
3540
self.workflow.do_engine_steps()
3641
self.assertTrue(self.workflow.is_completed())
3742
self.assertDictEqual(self.workflow.data, {'v': 0, 'u': 1, 'w': 1})

0 commit comments

Comments
 (0)