mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-15 12:44:52 +00:00
7c219fd731
git-subtree-dir: SpiffWorkflow git-subtree-split: 63db3e45947ec66b8d0efc2c74064004f8ff482c
27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
from SpiffWorkflow.bpmn.specs.events.event_definitions import MessageEventDefinition
|
|
|
|
class MessageEventDefinition(MessageEventDefinition):
|
|
|
|
def __init__(self, name, correlation_properties=None, expression=None, message_var=None):
|
|
|
|
super(MessageEventDefinition, self).__init__(name, correlation_properties)
|
|
self.expression = expression
|
|
self.message_var = message_var
|
|
self.internal = False
|
|
|
|
def throw(self, my_task):
|
|
# We can't update our own payload, because if this task is reached again
|
|
# we have to evaluate it again so we have to create a new event
|
|
event = MessageEventDefinition(self.name, self.correlation_properties, self.expression, self.message_var)
|
|
event.payload = my_task.workflow.script_engine.evaluate(my_task, self.expression)
|
|
correlations = self.get_correlations(my_task.workflow.script_engine, event.payload)
|
|
my_task.workflow.correlations.update(correlations)
|
|
self._throw(event, my_task.workflow, my_task.workflow.outer_workflow, correlations)
|
|
|
|
def update_task_data(self, my_task):
|
|
my_task.data[self.message_var] = my_task.internal_data[self.name]
|
|
|
|
def reset(self, my_task):
|
|
my_task.internal_data.pop(self.message_var, None)
|
|
super(MessageEventDefinition, self).reset(my_task)
|