mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-22 12:48:25 +00:00
Adds endpoint to retrieve all user tasks for a workflow, regardless of state
This commit is contained in:
parent
8d39a96606
commit
e4b2a7a641
33
crc/api.yml
33
crc/api.yml
@ -465,10 +465,39 @@ paths:
|
||||
responses:
|
||||
'204':
|
||||
description: The workflow was removed
|
||||
/workflow/{workflow_id}/all_tasks:
|
||||
get:
|
||||
operationId: crc.api.workflow.get_all_tasks
|
||||
summary: Return a list of all tasks for this workflow
|
||||
tags:
|
||||
- Workflows and Tasks
|
||||
parameters:
|
||||
- name: workflow_id
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the workflow
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
'200':
|
||||
description: Expected response to a valid request
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Task"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/workflow/{workflow_id}/tasks:
|
||||
get:
|
||||
operationId: crc.api.workflow.get_tasks
|
||||
summary: Return a list of all tasks for this workflow
|
||||
operationId: crc.api.workflow.get_ready_user_tasks
|
||||
summary: Returns the list of ready user tasks for this workflow
|
||||
tags:
|
||||
- Workflows and Tasks
|
||||
parameters:
|
||||
|
@ -76,7 +76,18 @@ def delete(workflow_id):
|
||||
session.commit()
|
||||
3
|
||||
|
||||
def get_tasks(workflow_id):
|
||||
|
||||
def get_all_tasks(workflow_id):
|
||||
workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||
processor = WorkflowProcessor(workflow.workflow_spec_id, workflow.bpmn_workflow_json)
|
||||
spiff_tasks = processor.get_all_user_tasks()
|
||||
tasks = []
|
||||
for st in spiff_tasks:
|
||||
tasks.append(Task.from_spiff(st))
|
||||
return TaskSchema(many=True).dump(tasks)
|
||||
|
||||
|
||||
def get_ready_user_tasks(workflow_id):
|
||||
workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||
processor = WorkflowProcessor(workflow.workflow_spec_id, workflow.bpmn_workflow_json)
|
||||
spiff_tasks = processor.get_ready_user_tasks()
|
||||
|
@ -60,8 +60,8 @@ class Task:
|
||||
instance = cls(spiff_task.id,
|
||||
spiff_task.task_spec.name,
|
||||
spiff_task.task_spec.description,
|
||||
spiff_task.get_state_name(),
|
||||
"task",
|
||||
spiff_task.get_state_name(),
|
||||
{},
|
||||
spiff_task.task_spec.documentation)
|
||||
if hasattr(spiff_task.task_spec, "form"):
|
||||
|
@ -1,5 +1,6 @@
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
|
||||
from SpiffWorkflow import Task as SpiffTask
|
||||
from SpiffWorkflow.bpmn.BpmnScriptEngine import BpmnScriptEngine
|
||||
from SpiffWorkflow.bpmn.parser.task_parsers import UserTaskParser
|
||||
from SpiffWorkflow.bpmn.parser.util import full_tag
|
||||
@ -111,6 +112,10 @@ class WorkflowProcessor:
|
||||
def get_ready_user_tasks(self):
|
||||
return self.bpmn_workflow.get_ready_user_tasks()
|
||||
|
||||
def get_all_user_tasks(self):
|
||||
all_tasks = self.bpmn_workflow.get_tasks(SpiffTask.ANY_MASK)
|
||||
return [t for t in all_tasks if not self.bpmn_workflow._is_engine_task(t.task_spec)]
|
||||
|
||||
@staticmethod
|
||||
def __get_process_id(et_root: ElementTree.Element):
|
||||
process_elements = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user