Skip to content

Commit

Permalink
update data object serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
essweine committed Mar 12, 2024
1 parent 9c74ab2 commit e7d4fae
Show file tree
Hide file tree
Showing 5 changed files with 682 additions and 3 deletions.
2 changes: 0 additions & 2 deletions SpiffWorkflow/bpmn/serializer/default/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,4 @@ def subprocesses_from_dict(self, dct, workflow, top_workflow=None):
sp = self.registry.restore(dct.pop(str(task.id)), task=task, top_workflow=top_workflow)
top_workflow.subprocesses[task.id] = sp
sp.completed_event.connect(task.task_spec._on_subworkflow_completed, task)
if len(sp.spec.data_objects) > 0:
sp.data = task.workflow.data
self.subprocesses_from_dict(dct, sp, top_workflow)
32 changes: 31 additions & 1 deletion SpiffWorkflow/bpmn/serializer/migration/version_1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,34 @@ def add_new_typenames(dct):
for sp in dct['subprocesses'].values():
sp['typename'] = 'BpmnSubWorkflow'
for task in sp['tasks'].values():
task['typename'] = 'Task'
task['typename'] = 'Task'

def update_data_objects(dct):

def delete_duplicates(data_objects, spec, wf):
for name in data_objects:
spec['data_objects'].pop(name, None)
if name in wf['data']:
del wf['data'][name]

def move_data_objects(data_objects, wf):
if len(data_objects) > 0:
wf['data']['data_objects'] = {}
for data_obj in data_objects:
if data_obj in wf['data']:
wf['data']['data_objects'][data_obj] = wf['data'].pop(data_obj)

def update(wf, spec, parent_spec):
if len(spec.get('data_objects', [])) > 0 and 'data_objects' not in wf['data']:
for task in wf['tasks'].values():
ts = spec['task_specs'].get(task['task_spec'])
if ts['typename'] in ['SubWorkflowTask', 'TransactionSubprocess'] and task['id'] in dct['subprocesses']:
sp_spec = dct['subprocess_specs'].get(ts['spec'])
sp = dct['subprocesses'][task['id']]
update(sp, sp_spec, spec)
if parent_spec is not None:
delete_duplicates(parent_spec['data_objects'], spec, wf)
move_data_objects(spec['data_objects'], wf)

update(dct, dct['spec'], None)

2 changes: 2 additions & 0 deletions SpiffWorkflow/bpmn/serializer/migration/version_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
remove_boundary_event_parent,
remove_root_task,
add_new_typenames,
update_data_objects,
)

def from_version_1_2(dct):
Expand All @@ -41,6 +42,7 @@ def from_version_1_2(dct):
remove_boundary_event_parent(dct)
remove_root_task(dct)
add_new_typenames(dct)
update_data_objects(dct)


def from_version_1_1(dct):
Expand Down
Loading

0 comments on commit e7d4fae

Please sign in to comment.