pyl w/ burnettk
This commit is contained in:
parent
203b16ed5b
commit
3062fb278f
|
@ -1084,11 +1084,17 @@ class ProcessInstanceProcessor:
|
|||
self._add_bpmn_process_definitions(bpmn_spec_dict)
|
||||
|
||||
subprocesses = process_instance_data_dict.pop("subprocesses")
|
||||
bpmn_process_parent, new_task_models, new_json_data_models = TaskService.add_bpmn_process(
|
||||
process_instance_data_dict, self.process_instance_model
|
||||
bpmn_process_parent, new_task_models, new_json_data_models = (
|
||||
TaskService.add_bpmn_process(
|
||||
process_instance_data_dict, self.process_instance_model
|
||||
)
|
||||
)
|
||||
for subprocess_task_id, subprocess_properties in subprocesses.items():
|
||||
_bpmn_subprocess, subprocess_new_task_models, subprocess_new_json_data_models = TaskService.add_bpmn_process(
|
||||
(
|
||||
_bpmn_subprocess,
|
||||
subprocess_new_task_models,
|
||||
subprocess_new_json_data_models,
|
||||
) = TaskService.add_bpmn_process(
|
||||
subprocess_properties,
|
||||
self.process_instance_model,
|
||||
bpmn_process_parent,
|
||||
|
|
|
@ -59,7 +59,12 @@ class TaskService:
|
|||
spiff_task: SpiffTask,
|
||||
process_instance: ProcessInstanceModel,
|
||||
serializer: BpmnWorkflowSerializer,
|
||||
) -> Tuple[Optional[BpmnProcessModel], TaskModel, dict[str, TaskModel], dict[str, JsonDataModel]]:
|
||||
) -> Tuple[
|
||||
Optional[BpmnProcessModel],
|
||||
TaskModel,
|
||||
dict[str, TaskModel],
|
||||
dict[str, JsonDataModel],
|
||||
]:
|
||||
spiff_task_guid = str(spiff_task.id)
|
||||
task_model: Optional[TaskModel] = TaskModel.query.filter_by(
|
||||
guid=spiff_task_guid
|
||||
|
@ -111,22 +116,26 @@ class TaskService:
|
|||
# This is the top level workflow, which has no guid
|
||||
# check for bpmn_process_id because mypy doesn't realize bpmn_process can be None
|
||||
if process_instance.bpmn_process_id is None:
|
||||
bpmn_process, new_task_models, new_json_data_models = cls.add_bpmn_process(
|
||||
serializer.workflow_to_dict(
|
||||
spiff_task.workflow._get_outermost_workflow()
|
||||
),
|
||||
process_instance,
|
||||
bpmn_process, new_task_models, new_json_data_models = (
|
||||
cls.add_bpmn_process(
|
||||
serializer.workflow_to_dict(
|
||||
spiff_task.workflow._get_outermost_workflow()
|
||||
),
|
||||
process_instance,
|
||||
)
|
||||
)
|
||||
else:
|
||||
bpmn_process = BpmnProcessModel.query.filter_by(
|
||||
guid=subprocess_guid
|
||||
).first()
|
||||
if bpmn_process is None:
|
||||
bpmn_process, new_task_models, new_json_data_models = cls.add_bpmn_process(
|
||||
serializer.workflow_to_dict(subprocess),
|
||||
process_instance,
|
||||
process_instance.bpmn_process,
|
||||
subprocess_guid,
|
||||
bpmn_process, new_task_models, new_json_data_models = (
|
||||
cls.add_bpmn_process(
|
||||
serializer.workflow_to_dict(subprocess),
|
||||
process_instance,
|
||||
process_instance.bpmn_process,
|
||||
subprocess_guid,
|
||||
)
|
||||
)
|
||||
return (bpmn_process, new_task_models, new_json_data_models)
|
||||
|
||||
|
@ -141,6 +150,9 @@ class TaskService:
|
|||
tasks = bpmn_process_dict.pop("tasks")
|
||||
bpmn_process_data_dict = bpmn_process_dict.pop("data")
|
||||
|
||||
new_task_models = {}
|
||||
new_json_data_models = {}
|
||||
|
||||
bpmn_process = None
|
||||
if bpmn_process_parent is not None:
|
||||
bpmn_process = BpmnProcessModel.query.filter_by(
|
||||
|
@ -170,7 +182,7 @@ class TaskService:
|
|||
json_data = JsonDataModel(
|
||||
hash=bpmn_process_data_hash, data=bpmn_process_data_dict
|
||||
)
|
||||
db.session.add(json_data)
|
||||
new_json_data_models[bpmn_process_data_hash] = json_data
|
||||
bpmn_process.json_data_hash = bpmn_process_data_hash
|
||||
|
||||
if bpmn_process_parent is None:
|
||||
|
@ -179,8 +191,6 @@ class TaskService:
|
|||
bpmn_process.parent_process_id = bpmn_process_parent.id
|
||||
db.session.add(bpmn_process)
|
||||
|
||||
new_task_models = {}
|
||||
new_json_data_models = {}
|
||||
if bpmn_process_is_new:
|
||||
for task_id, task_properties in tasks.items():
|
||||
task_data_dict = task_properties.pop("data")
|
||||
|
@ -201,7 +211,9 @@ class TaskService:
|
|||
task_model.state = TaskStateNames[state_int]
|
||||
task_model.properties_json = task_properties
|
||||
|
||||
json_data = TaskService.update_task_data_on_task_model(task_model, task_data_dict)
|
||||
json_data = TaskService.update_task_data_on_task_model(
|
||||
task_model, task_data_dict
|
||||
)
|
||||
new_task_models[task_model.guid] = task_model
|
||||
if json_data is not None:
|
||||
new_json_data_models[json_data.hash] = json_data
|
||||
|
|
|
@ -72,8 +72,10 @@ class TaskModelSavingDelegate(EngineStepDelegate):
|
|||
|
||||
def will_complete_task(self, spiff_task: SpiffTask) -> None:
|
||||
if self.should_update_task_model():
|
||||
_bpmn_process, task_model, new_task_models, new_json_data_models = TaskService.find_or_create_task_model_from_spiff_task(
|
||||
spiff_task, self.process_instance, self.serializer
|
||||
_bpmn_process, task_model, new_task_models, new_json_data_models = (
|
||||
TaskService.find_or_create_task_model_from_spiff_task(
|
||||
spiff_task, self.process_instance, self.serializer
|
||||
)
|
||||
)
|
||||
self.current_task_model = task_model
|
||||
self.task_models.update(new_task_models)
|
||||
|
@ -111,8 +113,10 @@ class TaskModelSavingDelegate(EngineStepDelegate):
|
|||
| TaskState.MAYBE
|
||||
| TaskState.LIKELY
|
||||
):
|
||||
_bpmn_process, task_model, new_task_models, new_json_data_models = TaskService.find_or_create_task_model_from_spiff_task(
|
||||
waiting_spiff_task, self.process_instance, self.serializer
|
||||
_bpmn_process, task_model, new_task_models, new_json_data_models = (
|
||||
TaskService.find_or_create_task_model_from_spiff_task(
|
||||
waiting_spiff_task, self.process_instance, self.serializer
|
||||
)
|
||||
)
|
||||
self.task_models.update(new_task_models)
|
||||
self.json_data_models.update(new_json_data_models)
|
||||
|
|
Loading…
Reference in New Issue