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