make sure we set the subprocesses correctly in the bpmn dict w/ burnettk
This commit is contained in:
parent
4ee7b299f2
commit
628dc14d7c
|
@ -551,18 +551,26 @@ class ProcessInstanceProcessor:
|
|||
bpmn_process_definition: BpmnProcessDefinitionModel,
|
||||
spiff_bpmn_process_dict: dict,
|
||||
) -> None:
|
||||
# find all child subprocesses of a process
|
||||
bpmn_process_subprocess_definitions = (
|
||||
BpmnProcessDefinitionRelationshipModel.query.filter_by(
|
||||
bpmn_process_definition_parent_id=bpmn_process_definition.id
|
||||
).all()
|
||||
BpmnProcessDefinitionModel.query.join(
|
||||
BpmnProcessDefinitionRelationshipModel,
|
||||
BpmnProcessDefinitionModel.id
|
||||
== BpmnProcessDefinitionRelationshipModel.bpmn_process_definition_child_id,
|
||||
)
|
||||
.filter_by(bpmn_process_definition_parent_id=bpmn_process_definition.id)
|
||||
.all()
|
||||
)
|
||||
for bpmn_subprocess_definition in bpmn_process_subprocess_definitions:
|
||||
spec = cls._set_definition_dict_for_bpmn_subprocess_definitions(
|
||||
bpmn_subprocess_definition, spiff_bpmn_process_dict
|
||||
spec = cls._get_definition_dict_for_bpmn_process_definition(
|
||||
bpmn_subprocess_definition
|
||||
)
|
||||
spiff_bpmn_process_dict["subprocess_specs"][
|
||||
bpmn_subprocess_definition.bpmn_identifier
|
||||
] = spec
|
||||
cls._set_definition_dict_for_bpmn_subprocess_definitions(
|
||||
bpmn_subprocess_definition, spiff_bpmn_process_dict
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _get_bpmn_process_dict(cls, bpmn_process: BpmnProcessModel) -> dict:
|
||||
|
@ -1019,7 +1027,7 @@ class ProcessInstanceProcessor:
|
|||
bpmn_process = self.process_instance_model.bpmn_process
|
||||
|
||||
if bpmn_process is None:
|
||||
bpmn_process = BpmnProcessModel()
|
||||
bpmn_process = BpmnProcessModel(guid=bpmn_process_guid)
|
||||
|
||||
bpmn_process.properties_json = bpmn_process_dict
|
||||
|
||||
|
@ -1101,8 +1109,12 @@ class ProcessInstanceProcessor:
|
|||
|
||||
subprocesses = process_instance_data_dict.pop("subprocesses")
|
||||
bpmn_process_parent = self._add_bpmn_process(process_instance_data_dict)
|
||||
for _subprocess_task_id, subprocess_properties in subprocesses.items():
|
||||
self._add_bpmn_process(subprocess_properties, bpmn_process_parent)
|
||||
for subprocess_task_id, subprocess_properties in subprocesses.items():
|
||||
self._add_bpmn_process(
|
||||
subprocess_properties,
|
||||
bpmn_process_parent,
|
||||
bpmn_process_guid=subprocess_task_id,
|
||||
)
|
||||
|
||||
def save(self) -> None:
|
||||
"""Saves the current state of this processor to the database."""
|
||||
|
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
from flask import g
|
||||
from flask.app import Flask
|
||||
from flask.testing import FlaskClient
|
||||
from SpiffWorkflow.task import TaskState # type: ignore
|
||||
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
||||
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
||||
|
||||
|
@ -261,6 +262,36 @@ class TestProcessInstanceProcessor(BaseTest):
|
|||
|
||||
assert process_instance.status == ProcessInstanceStatus.complete.value
|
||||
|
||||
def test_can_load_up_processor_after_running_model_with_call_activities(
|
||||
self,
|
||||
app: Flask,
|
||||
client: FlaskClient,
|
||||
with_db_and_bpmn_file_cleanup: None,
|
||||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
"""Test_does_not_recreate_human_tasks_on_multiple_saves."""
|
||||
initiator_user = self.find_or_create_user("initiator_user")
|
||||
|
||||
process_model = load_test_spec(
|
||||
process_model_id="test_group/call_activity_nested",
|
||||
process_model_source_directory="call_activity_nested",
|
||||
)
|
||||
process_instance = self.create_process_instance_from_process_model(
|
||||
process_model=process_model, user=initiator_user
|
||||
)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
processor.do_engine_steps(save=True)
|
||||
|
||||
# ensure this does not raise
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
|
||||
# this task will be found within subprocesses
|
||||
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
|
||||
"do_nothing", processor.bpmn_process_instance
|
||||
)
|
||||
assert spiff_task is not None
|
||||
assert spiff_task.state == TaskState.COMPLETED
|
||||
|
||||
def test_does_not_recreate_human_tasks_on_multiple_saves(
|
||||
self,
|
||||
app: Flask,
|
||||
|
|
Loading…
Reference in New Issue