From 518c834e7bce64fbe79cb95228dfdd3101d8d45d Mon Sep 17 00:00:00 2001 From: Elizabeth Esswein Date: Tue, 19 Sep 2023 15:52:07 -0400 Subject: [PATCH] run subworkflow start task instead of updating children --- .../bpmn/specs/mixins/subworkflow_task.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py b/SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py index 091dac6f..340a0567 100644 --- a/SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py +++ b/SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py @@ -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 @@ -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) @@ -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) @@ -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: @@ -102,7 +102,7 @@ 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): @@ -110,16 +110,16 @@ def update_data(self, my_task, subworkflow): # 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):