get task data from json data table now w/ burnettk

This commit is contained in:
jasquat 2023-03-20 17:05:15 -04:00
parent d6684124fd
commit 28bda31802
No known key found for this signature in database
4 changed files with 22 additions and 38 deletions

View File

@ -1585,7 +1585,7 @@ paths:
items:
$ref: "#/components/schemas/Task"
/task-data/{modified_process_model_identifier}/{process_instance_id}/{spiff_step}:
/task-data/{modified_process_model_identifier}/{process_instance_id}/{task_guid}:
parameters:
- name: modified_process_model_identifier
in: path
@ -1599,12 +1599,12 @@ paths:
description: The unique id of an existing process instance.
schema:
type: integer
- name: spiff_step
- name: task_guid
in: path
required: true
description: If set will return the tasks as they were during a specific step of execution.
description: The guid of the task to show.
schema:
type: integer
type: string
get:
operationId: spiffworkflow_backend.routes.tasks_controller.task_data_show
summary: Get task data for a single task in a spiff step.
@ -1638,12 +1638,12 @@ paths:
description: The unique id of the task.
schema:
type: string
- name: spiff_step
in: query
required: false
description: If set will return the tasks as they were during a specific step of execution.
- name: task_guid
in: path
required: true
description: The guid of the task to show.
schema:
type: integer
type: string
put:
operationId: spiffworkflow_backend.routes.process_api_blueprint.task_data_update
summary: Update the task data for requested instance and task

View File

@ -66,6 +66,8 @@ class TaskModel(SpiffworkflowBaseDBModel):
start_in_seconds: float = db.Column(db.DECIMAL(17, 6))
end_in_seconds: Union[float, None] = db.Column(db.DECIMAL(17, 6))
data: Optional[dict] = None
def python_env_data(self) -> dict:
return JsonDataModel.find_data_dict_by_hash(self.python_env_data_hash)

View File

@ -1,5 +1,6 @@
"""APIs for dealing with process groups, process models, and process instances."""
import json
from spiffworkflow_backend.models.task import TaskModel # noqa: F401
import os
import uuid
from sys import exc_info
@ -169,38 +170,19 @@ def task_list_for_my_groups(
def task_data_show(
modified_process_model_identifier: str,
process_instance_id: int,
spiff_step: int = 0,
task_guid: int = 0,
) -> flask.wrappers.Response:
process_instance = _find_process_instance_by_id_or_raise(process_instance_id)
step_detail = (
db.session.query(SpiffStepDetailsModel)
.filter(
SpiffStepDetailsModel.process_instance_id == process_instance.id,
SpiffStepDetailsModel.spiff_step == spiff_step,
)
.first()
)
if step_detail is None:
task_model = TaskModel.query.filter_by(guid=task_guid, process_instance_id=process_instance_id).first()
if task_model is None:
raise ApiError(
error_code="spiff_step_for_proces_instance_not_found",
message="The given spiff step for the given process instance could not be found.",
error_code="task_not_found",
message=(
f"Cannot find a task with guid '{task_guid}' for process instance '{process_instance_id}'"
),
status_code=400,
)
processor = ProcessInstanceProcessor(process_instance)
spiff_task = processor.__class__.get_task_by_bpmn_identifier(
step_detail.bpmn_task_identifier, processor.bpmn_process_instance
)
task_data = step_detail.task_json["task_data"] | step_detail.task_json["python_env"]
task = ProcessInstanceService.spiff_task_to_api_task(
processor,
spiff_task,
task_spiff_step=spiff_step,
)
task.data = task_data
return make_response(jsonify(task), 200)
task_model.data = task_model.json_data()
return make_response(jsonify(task_model), 200)
def _munge_form_ui_schema_based_on_hidden_fields_in_task_data(task: Task) -> None:

View File

@ -523,7 +523,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
) {
setShowTaskDataLoading(true);
HttpService.makeCallToBackend({
path: `${targetUris.processInstanceTaskDataPath}/${task.id}`,
path: `${targetUris.processInstanceTaskDataPath}/${task.guid}`,
httpMethod: 'GET',
successCallback: processTaskResult,
failureCallback: (error: any) => {