mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-05 22:53:57 +00:00
742f549e98
d27519a36 Merge pull request #259 from sartography/bugfix/spiff-postscript-execution 21aa8a12c update execution order for postscripts d83fd3d81 Merge pull request #256 from sartography/feature/xml-validation 8303aaab5 uping the sleep time in a test slightly to see if we can get this test to pass consistently in CI. 1d251d55d determine whether to validate by passing in a validator instead of a parameter 2d3daad2d add spiff schema f8c65dc60 Minor changes to BPMN diagrams to assure all tests are run against valid BPMN Diagrams. Changes required: 9e06b25bf add DMN validation 1b7cbeba0 set parser to validate by default 53fdbba52 add schemas & validation option a212d9c5d general cleanup git-subtree-dir: SpiffWorkflow git-subtree-split: d27519a3631b9772094e5f24dba2f478b0c47135
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from copy import deepcopy
|
|
|
|
from SpiffWorkflow.task import TaskState
|
|
from SpiffWorkflow.bpmn.specs .BpmnSpecMixin import BpmnSpecMixin
|
|
|
|
class SpiffBpmnTask(BpmnSpecMixin):
|
|
|
|
def __init__(self, wf_spec, name, prescript=None, postscript=None, **kwargs):
|
|
|
|
# WHy am I doing this instead of just calling super?
|
|
# Because I need to deal with multiple inheritance and the kwargs nightmare created by our parser design
|
|
BpmnSpecMixin.__init__(self, wf_spec, name, **kwargs)
|
|
self.prescript = prescript
|
|
self.postscript = postscript
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'Spiff BPMN Task'
|
|
|
|
def execute_script(self, my_task, script):
|
|
try:
|
|
my_task.workflow.script_engine.execute(my_task, script)
|
|
except Exception as exc:
|
|
my_task._set_state(TaskState.WAITING)
|
|
raise exc
|
|
|
|
def get_payload(self, my_task, script, expr):
|
|
try:
|
|
data = deepcopy(my_task.data)
|
|
my_task.worklflow.script_engine.execute(my_task, script, data)
|
|
return my_task.workflow.script_engine._evaluate(expr, data)
|
|
except Exception as exc:
|
|
my_task._set_state(TaskState.WAITING)
|
|
raise exc
|
|
|
|
def _on_ready_hook(self, my_task):
|
|
super()._on_ready_hook(my_task)
|
|
if self.prescript is not None:
|
|
self.execute_script(my_task, self.prescript)
|
|
|
|
def _on_complete_hook(self, my_task):
|
|
super()._on_complete_hook(my_task)
|
|
if self.postscript is not None:
|
|
self.execute_script(my_task, self.postscript)
|