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

omit default on inclusive gw with matched conditions #421

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions SpiffWorkflow/bpmn/specs/mixins/inclusive_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def check(spec):
return complete

def _run_hook(self, my_task):
outputs = self._get_matching_outputs(my_task)
if len(outputs) == 0:
matches, defaults = self._get_matching_outputs(my_task)
if len(matches + defaults) == 0:
raise WorkflowTaskException('No conditions satisfied on gateway', task=my_task)
my_task._sync_children(outputs, TaskState.FUTURE)
my_task._sync_children(matches or defaults, TaskState.FUTURE)
return True
13 changes: 8 additions & 5 deletions SpiffWorkflow/specs/MultiChoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,20 @@ def _predict_hook(self, my_task):
my_task._add_child(spec, TaskState.MAYBE)

def _get_matching_outputs(self, my_task):
outputs = []
matches, defaults = [], []
for condition, output in self.cond_task_specs:
if self.choice is not None and output not in self.choice:
continue
if condition is None or condition._matches(my_task):
outputs.append(my_task.workflow.spec.get_task_spec_from_name(output))
return outputs
if condition is None:
defaults.append(my_task.workflow.spec.get_task_spec_from_name(output))
elif condition._matches(my_task):
matches.append(my_task.workflow.spec.get_task_spec_from_name(output))
return matches, defaults

def _run_hook(self, my_task):
"""Runs the task. Should not be called directly."""
my_task._sync_children(self._get_matching_outputs(my_task), TaskState.FUTURE)
matches, defaults = self._get_matching_outputs(my_task)
my_task._sync_children(matches + defaults, TaskState.FUTURE)
for child in my_task.children:
child.task_spec._predict(child, mask=TaskState.FUTURE|TaskState.PREDICTED_MASK)
return True
Expand Down
5 changes: 5 additions & 0 deletions tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def testNoPathFromSecondGateway(self):

def testParallelCondition(self):
self.set_data({'v': 0, 'u': 1, 'w': 1})
gw = self.workflow.get_next_task(state=TaskState.READY)
gw.run()
self.assertIsNone(self.workflow.get_next_task(spec_name='increment_v'))
self.assertTrue(self.workflow.get_next_task(spec_name='u_plus_v').state, TaskState.READY)
self.assertTrue(self.workflow.get_next_task(spec_name='w_plus_v').state, TaskState.READY)
self.workflow.do_engine_steps()
self.assertTrue(self.workflow.is_completed())
self.assertDictEqual(self.workflow.data, {'v': 0, 'u': 1, 'w': 1})
Expand Down
Loading