spiff-arena/SpiffWorkflow/spiff/specs/events/event_definitions.py
Jon Herron 7c219fd731 Squashed 'SpiffWorkflow/' content from commit 63db3e4
git-subtree-dir: SpiffWorkflow
git-subtree-split: 63db3e45947ec66b8d0efc2c74064004f8ff482c
2022-10-12 10:19:53 -04:00

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)