Skip to content

Commit

Permalink
added support to serialize data object category as well w/ burnettk e…
Browse files Browse the repository at this point in the history
…ssweine
  • Loading branch information
jasquat committed Dec 7, 2023
1 parent d3d23f3 commit c729ed4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion SpiffWorkflow/spiff/serializer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
MessageEventDefinition as DefaultMessageEventDefinition,
SignalEventDefinition as DefaultSignalEventDefinition,
ErrorEventDefinition as DefaultErrorEventDefinition,
EscalationEventDefinition as DefaultEscalationEventDefinition,
EscalationEventDefinition as DefaultEscalationEventDefinition,
)

from SpiffWorkflow.spiff.specs.defaults import (
Expand Down Expand Up @@ -77,6 +77,9 @@
ItemAwareEventDefinitionConverter,
ErrorEscalationEventDefinitionConverter,
)
from SpiffWorkflow.bpmn.specs.data_spec import DataObject as DefaultDataObject
from SpiffWorkflow.spiff.specs.data_object import DataObject
from SpiffWorkflow.spiff.serializer.data_spec import DataObjectConverter

SPIFF_CONFIG = deepcopy(DEFAULT_CONFIG)

Expand All @@ -92,6 +95,7 @@
SPIFF_CONFIG.pop(DefaultStandardLoopTask)
SPIFF_CONFIG.pop(DefaultParallelMultiInstanceTask)
SPIFF_CONFIG.pop(DefaultSequentialMultiInstanceTask)
SPIFF_CONFIG.pop(DefaultDataObject)

SPIFF_CONFIG[NoneTask] = SpiffBpmnTaskConverter
SPIFF_CONFIG[ManualTask] = SpiffBpmnTaskConverter
Expand All @@ -110,3 +114,4 @@
SPIFF_CONFIG[ErrorEventDefinition] = ErrorEscalationEventDefinitionConverter
SPIFF_CONFIG[EscalationEventDefinition] = ErrorEscalationEventDefinitionConverter
SPIFF_CONFIG[BusinessRuleTask] = BusinessRuleTaskConverter
SPIFF_CONFIG[DataObject] = DataObjectConverter
7 changes: 7 additions & 0 deletions SpiffWorkflow/spiff/serializer/data_spec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from SpiffWorkflow.bpmn.serializer.helpers.spec import BpmnDataSpecificationConverter, EventDefinitionConverter

class DataObjectConverter(BpmnDataSpecificationConverter):
def to_dict(self, data_spec):
dct = super().to_dict(data_spec)
dct['category'] = data_spec.category
return dct
1 change: 1 addition & 0 deletions tests/SpiffWorkflow/spiff/data_object_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def test_can_get_category_from_data_object(self):
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
category = self.workflow.spec.data_objects['obj_1'].category
self.assertEqual(category, 'obj_1_category')
self.save_restore()

0 comments on commit c729ed4

Please sign in to comment.