2023-03-01 16:38:23 -05:00
|
|
|
from SpiffWorkflow.task import TaskState
|
2023-02-23 10:42:56 -05:00
|
|
|
from SpiffWorkflow.bpmn.specs.SubWorkflowTask import (
|
|
|
|
SubWorkflowTask as DefaultSubWorkflow,
|
|
|
|
TransactionSubprocess as DefaultTransaction,
|
|
|
|
CallActivity as DefaultCallActivity,
|
|
|
|
)
|
2022-10-12 10:19:53 -04:00
|
|
|
from SpiffWorkflow.spiff.specs.spiff_task import SpiffBpmnTask
|
|
|
|
|
2023-02-23 10:42:56 -05:00
|
|
|
|
|
|
|
class SubWorkflowTask(DefaultSubWorkflow, SpiffBpmnTask):
|
2022-10-12 10:19:53 -04:00
|
|
|
|
|
|
|
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 = []
|
|
|
|
|
2023-02-23 10:42:56 -05:00
|
|
|
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)
|
2023-03-01 16:38:23 -05:00
|
|
|
self.start_workflow(my_task)
|
|
|
|
my_task._set_state(TaskState.WAITING)
|
2022-10-14 15:42:16 -04:00
|
|
|
|
|
|
|
def _on_complete_hook(self, my_task):
|
|
|
|
SpiffBpmnTask._on_complete_hook(self, my_task)
|
|
|
|
|
2022-10-12 10:19:53 -04:00
|
|
|
@property
|
|
|
|
def spec_type(self):
|
|
|
|
return 'Subprocess'
|
|
|
|
|
2022-10-14 15:42:16 -04:00
|
|
|
|
2023-02-23 10:42:56 -05:00
|
|
|
class TransactionSubprocess(SubWorkflowTask, DefaultTransaction):
|
2022-10-12 10:19:53 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
|
2022-10-14 15:42:16 -04:00
|
|
|
|
2023-02-23 10:42:56 -05:00
|
|
|
class CallActivity(SubWorkflowTask, DefaultCallActivity):
|
2022-10-12 10:19:53 -04:00
|
|
|
|
|
|
|
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'
|