do not display instructions for end events at the top level of the process w/ burnettk (#414)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2023-07-27 11:43:53 -04:00 committed by GitHub
parent cdaf2ea6c5
commit 51642ccd96
3 changed files with 37 additions and 18 deletions

View File

@ -445,6 +445,12 @@ def _interstitial_stream(
tasks = get_reportable_tasks() tasks = get_reportable_tasks()
while True: while True:
for spiff_task in tasks: for spiff_task in tasks:
# ignore the instructions if they are on the EndEvent for the top level process
if not TaskService.is_main_process_end_event(spiff_task):
print(
"TaskService.get_task_type_from_spiff_task:"
f" {TaskService.get_task_type_from_spiff_task(spiff_task)}"
)
try: try:
instructions = render_instructions(spiff_task) instructions = render_instructions(spiff_task)
except Exception as e: except Exception as e:
@ -467,6 +473,8 @@ def _interstitial_stream(
return return
if execute_tasks: if execute_tasks:
try: try:
# run_until_user_message does not run tasks with instructions to use one_at_a_time
# to force it to run the task.
processor.do_engine_steps(execution_strategy_name="one_at_a_time") processor.do_engine_steps(execution_strategy_name="one_at_a_time")
processor.do_engine_steps(execution_strategy_name="run_until_user_message") processor.do_engine_steps(execution_strategy_name="run_until_user_message")
processor.save() # Fixme - maybe find a way not to do this on every loop? processor.save() # Fixme - maybe find a way not to do this on every loop?
@ -479,6 +487,9 @@ def _interstitial_stream(
yield _render_data("error", api_error) yield _render_data("error", api_error)
ErrorHandlingService.handle_error(process_instance, wfe) ErrorHandlingService.handle_error(process_instance, wfe)
return return
# return if process instance is now complete and let the frontend redirect to show page
if process_instance.status not in ProcessInstanceModel.active_statuses():
return
# path used by the interstitial page while executing tasks - ie the background processor is not executing them # path used by the interstitial page while executing tasks - ie the background processor is not executing them
ready_engine_task_count = _get_ready_engine_step_count(processor.bpmn_process_instance) ready_engine_task_count = _get_ready_engine_step_count(processor.bpmn_process_instance)

View File

@ -1477,10 +1477,7 @@ class ProcessInstanceProcessor:
if self.bpmn_process_instance.is_completed(): if self.bpmn_process_instance.is_completed():
for spiff_task in SpiffTask.Iterator(self.bpmn_process_instance.task_tree, TaskState.ANY_MASK): for spiff_task in SpiffTask.Iterator(self.bpmn_process_instance.task_tree, TaskState.ANY_MASK):
# Assure that we find the end event for this process_instance, and not for any sub-process_instances. # Assure that we find the end event for this process_instance, and not for any sub-process_instances.
if ( if TaskService.is_main_process_end_event(spiff_task):
spiff_task.task_spec.__class__.__name__ == "EndEvent"
and spiff_task.workflow == self.bpmn_process_instance
):
endtasks.append(spiff_task) endtasks.append(spiff_task)
if len(endtasks) > 0: if len(endtasks) > 0:
return endtasks[-1] return endtasks[-1]

View File

@ -613,6 +613,17 @@ class TaskService:
) )
return task_draft_data return task_draft_data
@classmethod
def get_task_type_from_spiff_task(cls, spiff_task: SpiffTask) -> str:
# wrap in str so mypy doesn't lose its mind
return str(spiff_task.task_spec.__class__.__name__)
@classmethod
def is_main_process_end_event(cls, spiff_task: SpiffTask) -> bool:
return (
cls.get_task_type_from_spiff_task(spiff_task) == "EndEvent" and spiff_task.workflow.parent_workflow is None
)
@classmethod @classmethod
def bpmn_process_for_called_activity_or_top_level_process(cls, task_model: TaskModel) -> BpmnProcessModel: def bpmn_process_for_called_activity_or_top_level_process(cls, task_model: TaskModel) -> BpmnProcessModel:
"""Returns either the bpmn process for the call activity calling the process or the top level bpmn process. """Returns either the bpmn process for the call activity calling the process or the top level bpmn process.