Skip to content

Commit

Permalink
add version migration
Browse files Browse the repository at this point in the history
  • Loading branch information
essweine committed May 29, 2024
1 parent 0833800 commit 4503799
Show file tree
Hide file tree
Showing 5 changed files with 450 additions and 2 deletions.
13 changes: 13 additions & 0 deletions SpiffWorkflow/bpmn/serializer/migration/version_1_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

def update_mi_states(dct):

typenames = ['StandardLoopTask', 'SequentialMultiInstanceTask', 'ParallelMultiInstanceTask']
def update(tasks, task_specs):
for task in tasks:
task_spec = task_specs.get(task['task_spec'], {})
if task['state'] == 8 and task_spec['typename'] in typenames:
task['state'] = 32

for up in dct['subprocesses'].values():
update(sp['tasks'].values(), sp['spec']['task_specs'])
update(dct['tasks'].values(), dct['spec']['task_specs'])
26 changes: 25 additions & 1 deletion SpiffWorkflow/bpmn/serializer/migration/version_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,39 @@
add_new_typenames,
update_data_objects,
)
from .version_1_4 import update_mi_states

def from_version_1_3(dct):
"""Upgrade serialization from v1.3 to v1.4
Multiinstance tasks now rely on events rather than polling to merge children, so once
they are reached, they should be STARTED rather than WAITING.
"""
dct['VERSION'] = "1.3"
update_mi_states(dct)

def from_version_1_2(dct):
"""Upgrade serialization from v.1.2 to v.1.3
The internal/external distinction on event definitions was replaced with the ability to
target a specific workflow.
Boundary event parent gateway tasks ave been replaced with a gateway structure.
The creation of an unnecessary root task was removed; the workflow spec's start task is
used as the root instead.
BpmnWorkflows and BpmnSubworkflows were split into to classes.
Data objects are now stored on the topmost workflow where they are defined.
"""
dct['VERSION'] = "1.3"
update_event_definition_attributes(dct)
remove_boundary_event_parent(dct)
remove_root_task(dct)
add_new_typenames(dct)
update_data_objects(dct)


def from_version_1_1(dct):
"""
Upgrade v1.1 serialization to v1.2.
Expand Down Expand Up @@ -98,4 +121,5 @@ def from_version_1_0(dct):
'1.0': from_version_1_0,
'1.1': from_version_1_1,
'1.2': from_version_1_2,
'1.3': from_version_1_3,
}
2 changes: 1 addition & 1 deletion SpiffWorkflow/bpmn/serializer/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .config import DEFAULT_CONFIG

# This is the default version set on the workflow, it can be overridden in init
VERSION = "1.3"
VERSION = "1.4"


class BpmnWorkflowSerializer:
Expand Down
Loading

0 comments on commit 4503799

Please sign in to comment.