Merge pull request #146 from sartography/test_arena_push
Test arena push
This commit is contained in:
commit
1e831706a1
|
@ -670,6 +670,72 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/suspend:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process group
|
||||
schema:
|
||||
type: string
|
||||
- name: process_model_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process model.
|
||||
schema:
|
||||
type: string
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process instance.
|
||||
schema:
|
||||
type: integer
|
||||
post:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_suspend
|
||||
summary: Suspend a process instance
|
||||
tags:
|
||||
- Process Instances
|
||||
responses:
|
||||
"200":
|
||||
description: Empty ok true response on successful suspension.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-models/{process_group_id}/{process_model_id}/process-instances/{process_instance_id}/resume:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process group
|
||||
schema:
|
||||
type: string
|
||||
- name: process_model_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process model.
|
||||
schema:
|
||||
type: string
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process instance.
|
||||
schema:
|
||||
type: integer
|
||||
post:
|
||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_resume
|
||||
summary: Resume a process instance
|
||||
tags:
|
||||
- Process Instances
|
||||
responses:
|
||||
"200":
|
||||
description: Empty ok true response on successful resume.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-models/{process_group_id}/{process_model_id}/process-instances/reports:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
|
|
|
@ -64,4 +64,9 @@ class ActiveTaskModel(SpiffworkflowBaseDBModel):
|
|||
if hasattr(task, "process_model_identifier"):
|
||||
new_task.process_model_identifier = task.process_model_identifier
|
||||
|
||||
# active tasks only have status when getting the list on the home page
|
||||
# and it comes from the process_instance. it should not be confused with task_status.
|
||||
if hasattr(task, "status"):
|
||||
new_task.process_instance_status = task.status
|
||||
|
||||
return new_task
|
||||
|
|
|
@ -111,6 +111,7 @@ class Task:
|
|||
process_name: str = "",
|
||||
properties: Union[dict, None] = None,
|
||||
process_instance_id: Union[int, None] = None,
|
||||
process_instance_status: Union[str, None] = None,
|
||||
process_model_display_name: Union[str, None] = None,
|
||||
process_group_identifier: Union[str, None] = None,
|
||||
process_model_identifier: Union[str, None] = None,
|
||||
|
@ -134,6 +135,7 @@ class Task:
|
|||
self.data = {}
|
||||
|
||||
self.process_instance_id = process_instance_id
|
||||
self.process_instance_status = process_instance_status
|
||||
self.process_group_identifier = process_group_identifier
|
||||
self.process_model_identifier = process_model_identifier
|
||||
self.process_model_display_name = process_model_display_name
|
||||
|
@ -178,6 +180,7 @@ class Task:
|
|||
"process_name": self.process_name,
|
||||
"properties": self.properties,
|
||||
"process_instance_id": self.process_instance_id,
|
||||
"process_instance_status": self.process_instance_status,
|
||||
"process_model_display_name": self.process_model_display_name,
|
||||
"process_group_identifier": self.process_group_identifier,
|
||||
"process_model_identifier": self.process_model_identifier,
|
||||
|
|
|
@ -45,6 +45,7 @@ from spiffworkflow_backend.models.process_group import ProcessGroupSchema
|
|||
from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModelSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
||||
from spiffworkflow_backend.models.process_instance_report import (
|
||||
ProcessInstanceReportModel,
|
||||
)
|
||||
|
@ -452,6 +453,34 @@ def process_instance_terminate(
|
|||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||
|
||||
|
||||
def process_instance_suspend(
|
||||
process_group_id: str,
|
||||
process_model_id: str,
|
||||
process_instance_id: int,
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_instance_suspend."""
|
||||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
process_instance_id
|
||||
)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
processor.suspend()
|
||||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||
|
||||
|
||||
def process_instance_resume(
|
||||
process_group_id: str,
|
||||
process_model_id: str,
|
||||
process_instance_id: int,
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_instance_resume."""
|
||||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
process_instance_id
|
||||
)
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
processor.resume()
|
||||
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
|
||||
|
||||
|
||||
def process_instance_log_list(
|
||||
process_group_id: str,
|
||||
process_model_id: str,
|
||||
|
@ -898,6 +927,7 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
|
|||
.add_columns(
|
||||
ProcessInstanceModel.process_model_identifier,
|
||||
ProcessInstanceModel.process_group_identifier,
|
||||
ProcessInstanceModel.status,
|
||||
ActiveTaskModel.task_name,
|
||||
ActiveTaskModel.task_title,
|
||||
ActiveTaskModel.task_type,
|
||||
|
@ -909,7 +939,6 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res
|
|||
)
|
||||
.paginate(page=page, per_page=per_page, error_out=False)
|
||||
)
|
||||
|
||||
tasks = [ActiveTaskModel.to_task(active_task) for active_task in active_tasks.items]
|
||||
|
||||
response_json = {
|
||||
|
@ -949,6 +978,14 @@ def process_instance_task_list(
|
|||
def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response:
|
||||
"""Task_show."""
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
|
||||
if process_instance.status == ProcessInstanceStatus.suspended.value:
|
||||
raise ApiError(
|
||||
error_code="error_suspended",
|
||||
message="The process instance is suspended",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
process_model = get_process_model(
|
||||
process_instance.process_model_identifier,
|
||||
process_instance.process_group_identifier,
|
||||
|
|
|
@ -1132,3 +1132,15 @@ class ProcessInstanceProcessor:
|
|||
self.process_instance_model.status = "terminated"
|
||||
db.session.add(self.process_instance_model)
|
||||
db.session.commit()
|
||||
|
||||
def suspend(self) -> None:
|
||||
"""Suspend."""
|
||||
self.process_instance_model.status = ProcessInstanceStatus.suspended.value
|
||||
db.session.add(self.process_instance_model)
|
||||
db.session.commit()
|
||||
|
||||
def resume(self) -> None:
|
||||
"""Resume."""
|
||||
self.process_instance_model.status = ProcessInstanceStatus.waiting.value
|
||||
db.session.add(self.process_instance_model)
|
||||
db.session.commit()
|
||||
|
|
Loading…
Reference in New Issue