Feature/event payload migration fix (#443)

* also update exclusive gateways when migrating to event payload spiffworkflow

* pyl w/ burnettk

* build docker image for this branch w/ burnettk

* check to make sure configs are not None w/ burnettk

* do not migrate tasks related to exclusive gateways w/ burnettk

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2023-08-17 12:43:29 -04:00 committed by GitHub
parent a0202c6a5b
commit ed9bdd42da
2 changed files with 64 additions and 46 deletions

View File

@ -32,6 +32,7 @@ on:
branches:
- main
- feature/event-payloads-part-2
- feature/event-payload-migration-fix
- spiffdemo
jobs:

View File

@ -41,25 +41,39 @@ class VersionOneThree:
print("end VersionOneThree.run")
def get_relevant_task_definitions(self) -> list[TaskDefinitionModel]:
task_definitions: list[TaskDefinitionModel] = TaskDefinitionModel.query.filter_by(
typename="_BoundaryEventParent"
task_definitions: list[TaskDefinitionModel] = TaskDefinitionModel.query.filter(
# this actually affect most types of gateways but Exclusive is the only we fully support in the WebUi as of 2023-08-15
TaskDefinitionModel.typename.in_(["_BoundaryEventParent", "ExclusiveGateway"]) # type: ignore
).all()
return task_definitions
def process_task_definition(self, task_definition: TaskDefinitionModel) -> None:
task_definition.typename = "BoundaryEventSplit"
task_definition.typename = task_definition.typename.replace("_BoundaryEventParent", "BoundaryEventSplit")
task_definition.bpmn_identifier = task_definition.bpmn_identifier.replace(
"BoundaryEventParent", "BoundaryEventSplit"
)
properties_json = copy.copy(task_definition.properties_json)
properties_json.pop("main_child_task_spec")
properties_json.pop("main_child_task_spec", None)
properties_json["typename"] = task_definition.typename
properties_json["name"] = task_definition.bpmn_identifier
# mostly for ExclusiveGateways
if "cond_task_specs" in properties_json and properties_json["cond_task_specs"] is not None:
for cond_task_spec in properties_json["cond_task_specs"]:
cond_task_spec["task_spec"] = cond_task_spec["task_spec"].replace(
"BoundaryEventParent", "BoundaryEventSplit"
)
if "default_task_spec" in properties_json and properties_json["default_task_spec"] is not None:
properties_json["default_task_spec"] = properties_json["default_task_spec"].replace(
"BoundaryEventParent", "BoundaryEventSplit"
)
task_definition.properties_json = properties_json
flag_modified(task_definition, "properties_json") # type: ignore
db.session.add(task_definition)
if task_definition.typename == "BoundaryEventSplit":
join_properties_json = {
"name": task_definition.bpmn_identifier.replace("BoundaryEventSplit", "BoundaryEventJoin"),
"manual": False,
@ -107,6 +121,9 @@ class VersionOneThree:
db.session.add(child_task_definition)
def process_task_model(self, task_model: TaskModel, task_definition: TaskDefinitionModel) -> None:
if task_definition.typename != "BoundaryEventSplit":
return
task_model.properties_json["task_spec"] = task_definition.bpmn_identifier
flag_modified(task_model, "properties_json") # type: ignore
db.session.add(task_model)