mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-15 04:34:16 +00:00
71f8c94096
161cb7a450 Merge pull request #302 from sartography/bugfix/subprocess-task-state e12c950627 start workflow while subprocess is waiting git-subtree-dir: SpiffWorkflow git-subtree-split: 161cb7a4509a3d0e0574f3e2a98157862c053bad
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
from SpiffWorkflow.task import TaskState
|
|
from SpiffWorkflow.bpmn.specs.SubWorkflowTask import (
|
|
SubWorkflowTask as DefaultSubWorkflow,
|
|
TransactionSubprocess as DefaultTransaction,
|
|
CallActivity as DefaultCallActivity,
|
|
)
|
|
from SpiffWorkflow.spiff.specs.spiff_task import SpiffBpmnTask
|
|
|
|
|
|
class SubWorkflowTask(DefaultSubWorkflow, SpiffBpmnTask):
|
|
|
|
def __init__(self, wf_spec, name, subworkflow_spec, transaction=False, **kwargs):
|
|
|
|
SpiffBpmnTask.__init__(self, wf_spec, name, **kwargs)
|
|
# We don't so much as a class hierachy as a class pile and I'm giving up doing
|
|
# this properly
|
|
self.spec = subworkflow_spec
|
|
self.transaction = transaction
|
|
self.in_assign = []
|
|
self.out_assign = []
|
|
|
|
def _update_hook(self, my_task):
|
|
# Don't really like duplicating this, but we need to run SpiffBpmn update rather than the default
|
|
wf = my_task.workflow._get_outermost_workflow(my_task)
|
|
if my_task.id not in wf.subprocesses:
|
|
SpiffBpmnTask._update_hook(self, my_task)
|
|
self.create_workflow(my_task)
|
|
self.start_workflow(my_task)
|
|
my_task._set_state(TaskState.WAITING)
|
|
|
|
def _on_complete_hook(self, my_task):
|
|
SpiffBpmnTask._on_complete_hook(self, my_task)
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'Subprocess'
|
|
|
|
|
|
class TransactionSubprocess(SubWorkflowTask, DefaultTransaction):
|
|
|
|
def __init__(self, wf_spec, name, subworkflow_spec, transaction=True, **kwargs):
|
|
|
|
SpiffBpmnTask.__init__(self, wf_spec, name, **kwargs)
|
|
self.spec = subworkflow_spec
|
|
self.transaction = transaction
|
|
self.in_assign = []
|
|
self.out_assign = []
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'Transactional Subprocess'
|
|
|
|
|
|
class CallActivity(SubWorkflowTask, DefaultCallActivity):
|
|
|
|
def __init__(self, wf_spec, name, subworkflow_spec, **kwargs):
|
|
|
|
SpiffBpmnTask.__init__(self, wf_spec, name, **kwargs)
|
|
self.spec = subworkflow_spec
|
|
self.in_assign = []
|
|
self.out_assign = []
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'Call Activity'
|