Skip to content

Commit

Permalink
run subworkflow start task instead of updating children
Browse files Browse the repository at this point in the history
  • Loading branch information
essweine committed Sep 19, 2023
1 parent e17e3d7 commit 518c834
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from copy import deepcopy

from SpiffWorkflow.util.task import TaskState, TaskFilter
from SpiffWorkflow.util.task import TaskState
from SpiffWorkflow.specs.base import TaskSpec
from SpiffWorkflow.bpmn.exceptions import WorkflowDataException

Expand Down Expand Up @@ -64,8 +64,8 @@ def copy_data(self, my_task, subworkflow):
# But our data management is already hopelessly messed up and in dire needs of reconsideration
if len(subworkflow.spec.data_objects) > 0:
subworkflow.data = my_task.workflow.data
start = subworkflow.get_tasks(task_filter=TaskFilter(spec_name='Start'))
start[0].set_data(**my_task.data)
start = subworkflow.get_next_task(spec_name='Start')
start.set_data(**my_task.data)

def update_data(self, my_task, subworkflow):
my_task.data = deepcopy(subworkflow.last_task.data)
Expand All @@ -77,8 +77,8 @@ def create_workflow(self, my_task):
def start_workflow(self, my_task):
subworkflow = my_task.workflow.top_workflow.get_subprocess(my_task)
self.copy_data(my_task, subworkflow)
for child in subworkflow.task_tree.children:
child.task_spec._update(child)
start = subworkflow.get_next_task(spec_name='Start')
start.run()
my_task._set_state(TaskState.WAITING)


Expand All @@ -89,10 +89,10 @@ def __init__(self, wf_spec, bpmn_id, subworkflow_spec, **kwargs):

def copy_data(self, my_task, subworkflow):

start = subworkflow.get_tasks(task_filter=TaskFilter(spec_name='Start'))
start = subworkflow.get_next_task(spec_name='Start')
if subworkflow.spec.io_specification is None or len(subworkflow.spec.io_specification.data_inputs) == 0:
# Copy all task data into start task if no inputs specified
start[0].set_data(**my_task.data)
start.set_data(**my_task.data)
else:
# Otherwise copy only task data with the specified names
for var in subworkflow.spec.io_specification.data_inputs:
Expand All @@ -102,24 +102,24 @@ def copy_data(self, my_task, subworkflow):
task=my_task,
data_input=var,
)
start[0].data[var.bpmn_id] = my_task.data[var.bpmn_id]
start.data[var.bpmn_id] = my_task.data[var.bpmn_id]

def update_data(self, my_task, subworkflow):

if subworkflow.spec.io_specification is None or len(subworkflow.spec.io_specification.data_outputs) == 0:
# Copy all workflow data if no outputs are specified
my_task.data = deepcopy(subworkflow.last_task.data)
else:
end = subworkflow.get_tasks(task_filter=TaskFilter(spec_name='End'))
end = subworkflow.get_next_task(spec_name='End')
# Otherwise only copy data with the specified names
for var in subworkflow.spec.io_specification.data_outputs:
if var.bpmn_id not in end[0].data:
if var.bpmn_id not in end.data:
raise WorkflowDataException(
"The Data Output was not available in the subprocess output.",
task=my_task,
data_output=var,
)
my_task.data[var.bpmn_id] = end[0].data[var.bpmn_id]
my_task.data[var.bpmn_id] = end.data[var.bpmn_id]


class TransactionSubprocess(SubWorkflowTask):
Expand Down

0 comments on commit 518c834

Please sign in to comment.