mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-05 22:53:57 +00:00
cd4da465 Merge pull request #264 from sartography/bugfix/dmn-equality-with-boolean 414a59eb disambiguate DMN expressions eea53c91 Merge pull request #263 from sartography/feature/cleanup-task-completion d248d5b1 execute postscript before other complete hook tasks c09f1a90 streamline predict & remove some duplicated calls to it 64c21791 remove duplicate calls to update 4ca1076d move task update to _on_complete to ensure data is copied consistently after task related activities are done d037a7eb small changes for readability 025bc30f Quick patch -- is_executable needs to be accurate immediately. 14d3d8c3 Merge pull request #262 from sartography/feature/parser_info_features 849c223e We are jumping through a lot of complex xml parsing in SpiffWorkflow-Backend because we need to know some basic information about a BPMN process at the moment it is saved. Rather than do that work in the backend, it seems better to have SpiffWorkflow handle parsing the xml and providing a bit of metadata, including: git-subtree-dir: SpiffWorkflow git-subtree-split: cd4da465e125ca1ae1b57d227bfa324d9d4c507c
44 lines
1.5 KiB
Python
44 lines
1.5 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):
|
|
if self.postscript is not None:
|
|
self.execute_script(my_task, self.postscript)
|
|
super()._on_complete_hook(my_task) |