From a4e0386ab720e1d67360d427cdcbbe1750882088 Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Mon, 22 Jul 2024 13:14:12 -0400 Subject: [PATCH] set the subprocess task state back to STARTED in pi migrations w/ burnettk (#1970) Co-authored-by: jasquat --- .../services/process_instance_service.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py index a1245d85c..2f1e44260 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py @@ -231,9 +231,25 @@ class ProcessInstanceService: subprocesses_diffs, ) = cls.check_process_instance_can_be_migrated(process_instance, target_bpmn_process_hash=target_bpmn_process_hash) - deleted_tasks = migrate_workflow(top_level_bpmn_process_diff, processor.bpmn_process_instance, target_bpmn_process_spec) + migration_task_mask = TaskState.READY | TaskState.WAITING | TaskState.STARTED + + deleted_tasks = migrate_workflow( + top_level_bpmn_process_diff, + processor.bpmn_process_instance, + target_bpmn_process_spec, + reset_mask=migration_task_mask, + ) for sp_id, sp in processor.bpmn_process_instance.subprocesses.items(): - deleted_tasks += migrate_workflow(subprocesses_diffs[sp_id], sp, target_subprocess_specs.get(sp.spec.name)) + deleted_tasks += migrate_workflow( + subprocesses_diffs[sp_id], + sp, + target_subprocess_specs.get(sp.spec.name), + reset_mask=migration_task_mask, + ) + # make sure we change the subprocess_spiff_task state back to STARTED after the migration + if not sp.is_completed(): + subprocess_spiff_task = processor.bpmn_process_instance.get_task_from_id(sp_id) + subprocess_spiff_task._set_state(TaskState.STARTED) processor.bpmn_process_instance.subprocess_specs = target_subprocess_specs if preserve_old_process_instance: