mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-24 13:28:31 +00:00
fixed a couple apis for the react frontend w/ burnettk
This commit is contained in:
parent
4d05f35ed6
commit
60c60e7ea3
@ -38,20 +38,7 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/WorkflowSpecCategory"
|
$ref: "#/components/schemas/WorkflowSpecCategory"
|
||||||
/process-models/{process_model_id}:
|
/process-models:
|
||||||
get:
|
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_show
|
|
||||||
summary: Returns a single process model
|
|
||||||
tags:
|
|
||||||
- Workflow Specification
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Workflow spec.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/WorkflowSpec"
|
|
||||||
/workflow-specification:
|
|
||||||
# get:
|
# get:
|
||||||
# operationId: crc.api.workflow.all_specifications
|
# operationId: crc.api.workflow.all_specifications
|
||||||
# summary: Provides a list of workflows specifications that can be added to a study manually. Please note that Protocol Builder will handle this most of the time.
|
# summary: Provides a list of workflows specifications that can be added to a study manually. Please note that Protocol Builder will handle this most of the time.
|
||||||
@ -96,9 +83,9 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/WorkflowSpec"
|
$ref: "#/components/schemas/WorkflowSpec"
|
||||||
/workflow-specification/{spec_id}/file:
|
/process-models/{process_model_id}/file:
|
||||||
parameters:
|
parameters:
|
||||||
- name: spec_id
|
- name: process_model_id
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
description: The unique id of an existing workflow specification to validate.
|
description: The unique id of an existing workflow specification to validate.
|
||||||
@ -139,26 +126,26 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#components/schemas/File"
|
$ref: "#components/schemas/File"
|
||||||
/workflow-specification/{spec_id}:
|
/process-models/{process_model_id}:
|
||||||
parameters:
|
parameters:
|
||||||
- name: spec_id
|
- name: process_model_id
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
description: The unique id of an existing workflow specification.
|
description: The unique id of an existing workflow specification.
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
# get:
|
get:
|
||||||
# operationId: crc.api.workflow.get_workflow_specification
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_model_show
|
||||||
# summary: Returns a single workflow specification
|
summary: Returns a single process model
|
||||||
# tags:
|
tags:
|
||||||
# - Workflow Specifications
|
- Workflow Specification
|
||||||
# responses:
|
responses:
|
||||||
# '200':
|
'200':
|
||||||
# description: Workflow specification.
|
description: Workflow spec.
|
||||||
# content:
|
content:
|
||||||
# application/json:
|
application/json:
|
||||||
# schema:
|
schema:
|
||||||
# $ref: "#/components/schemas/WorkflowSpec"
|
$ref: "#/components/schemas/WorkflowSpec"
|
||||||
post:
|
post:
|
||||||
operationId: spiffworkflow_backend.routes.process_api_blueprint.create_process_instance
|
operationId: spiffworkflow_backend.routes.process_api_blueprint.create_process_instance
|
||||||
summary: Creates a workflow from a workflow spec and returns the workflow
|
summary: Creates a workflow from a workflow spec and returns the workflow
|
||||||
@ -200,9 +187,9 @@ paths:
|
|||||||
# responses:
|
# responses:
|
||||||
# '204':
|
# '204':
|
||||||
# description: The workflow specification has been removed.
|
# description: The workflow specification has been removed.
|
||||||
/process-models/{spec_id}/file/{file_name}:
|
/process-models/{process_model_id}/file/{file_name}:
|
||||||
parameters:
|
parameters:
|
||||||
- name: spec_id
|
- name: process_model_id
|
||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
description: The unique id of an existing workflow specification to validate.
|
description: The unique id of an existing workflow specification to validate.
|
||||||
@ -460,7 +447,7 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
example: MyTask
|
example: MyTask
|
||||||
spec_id:
|
process_model_id:
|
||||||
type: string
|
type: string
|
||||||
x-nullable: true
|
x-nullable: true
|
||||||
example: My Spec Name
|
example: My Spec Name
|
||||||
|
@ -101,6 +101,8 @@ class File:
|
|||||||
data_store: Optional[dict] = field(default_factory=dict)
|
data_store: Optional[dict] = field(default_factory=dict)
|
||||||
user_uid: Optional[str] = None
|
user_uid: Optional[str] = None
|
||||||
file_contents: Optional[str] = None
|
file_contents: Optional[str] = None
|
||||||
|
process_model_id: Optional[str] = None
|
||||||
|
process_group_id: Optional[str] = None
|
||||||
archived: bool = False
|
archived: bool = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -134,6 +136,8 @@ class FileSchema(Schema):
|
|||||||
"user_uid",
|
"user_uid",
|
||||||
"url",
|
"url",
|
||||||
"file_contents",
|
"file_contents",
|
||||||
|
"process_model_id",
|
||||||
|
"process_group_id",
|
||||||
]
|
]
|
||||||
unknown = INCLUDE
|
unknown = INCLUDE
|
||||||
|
|
||||||
|
@ -43,43 +43,45 @@ def add_process_model(body):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_file(spec_id, file_name):
|
def get_file(process_model_id, file_name):
|
||||||
"""Get_file."""
|
"""Get_file."""
|
||||||
process_model = ProcessModelService().get_spec(spec_id)
|
process_model = ProcessModelService().get_spec(process_model_id)
|
||||||
files = SpecFileService.get_files(process_model, file_name)
|
files = SpecFileService.get_files(process_model, file_name)
|
||||||
if len(files) == 0:
|
if len(files) == 0:
|
||||||
raise ApiError(
|
raise ApiError(
|
||||||
code="unknown file",
|
code="unknown file",
|
||||||
message=f"No information exists for file {file_name}"
|
message=f"No information exists for file {file_name}"
|
||||||
f" it does not exist in workflow {spec_id}.",
|
f" it does not exist in workflow {process_model_id}.",
|
||||||
status_code=404,
|
status_code=404,
|
||||||
)
|
)
|
||||||
|
|
||||||
file = files[0]
|
file = files[0]
|
||||||
file_contents = SpecFileService.get_data(process_model, file.name)
|
file_contents = SpecFileService.get_data(process_model, file.name)
|
||||||
file.file_contents = file_contents
|
file.file_contents = file_contents
|
||||||
|
file.process_model_id = process_model.id
|
||||||
|
file.process_group_id = process_model.process_group_id
|
||||||
return FileSchema().dump(file)
|
return FileSchema().dump(file)
|
||||||
|
|
||||||
|
|
||||||
def add_file(spec_id):
|
def add_file(process_model_id):
|
||||||
"""Add_file."""
|
"""Add_file."""
|
||||||
workflow_spec_service = ProcessModelService()
|
process_model_service = ProcessModelService()
|
||||||
process_model = workflow_spec_service.get_spec(spec_id)
|
process_model = process_model_service.get_spec(process_model_id)
|
||||||
request_file = connexion.request.files["file"]
|
request_file = connexion.request.files["file"]
|
||||||
file = SpecFileService.add_file(
|
file = SpecFileService.add_file(
|
||||||
process_model, request_file.filename, request_file.stream.read()
|
process_model, request_file.filename, request_file.stream.read()
|
||||||
)
|
)
|
||||||
if not process_model.primary_process_id and file.type == FileType.bpmn.value:
|
if not process_model.primary_process_id and file.type == FileType.bpmn.value:
|
||||||
SpecFileService.set_primary_bpmn(process_model, file.name)
|
SpecFileService.set_primary_bpmn(process_model, file.name)
|
||||||
workflow_spec_service.update_spec(process_model)
|
process_model_service.update_spec(process_model)
|
||||||
return Response(
|
return Response(
|
||||||
json.dumps(FileSchema().dump(file)), status=201, mimetype="application/json"
|
json.dumps(FileSchema().dump(file)), status=201, mimetype="application/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def create_process_instance(spec_id):
|
def create_process_instance(process_model_id):
|
||||||
"""Create_process_instance."""
|
"""Create_process_instance."""
|
||||||
process_instance = ProcessInstanceService.create_process_instance(spec_id, g.user)
|
process_instance = ProcessInstanceService.create_process_instance(process_model_id, g.user)
|
||||||
processor = ProcessInstanceProcessor(process_instance)
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
|
|
||||||
processor.do_engine_steps()
|
processor.do_engine_steps()
|
||||||
|
@ -48,6 +48,20 @@ def test_add_new_process_model(app, client: FlaskClient, with_bpmn_file_cleanup)
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_file(app, client: FlaskClient, with_bpmn_file_cleanup):
|
||||||
|
user = find_or_create_user()
|
||||||
|
test_process_group_id = "group_id1"
|
||||||
|
process_model_dir_name = "hello_world"
|
||||||
|
load_test_spec(app, process_model_dir_name, process_group_id=test_process_group_id)
|
||||||
|
response = client.get(
|
||||||
|
f"/v1.0/process-models/{process_model_dir_name}/file/hello_world.bpmn", headers=logged_in_headers(user)
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json["name"] == "hello_world.bpmn"
|
||||||
|
assert response.json["process_group_id"] == "group_id1"
|
||||||
|
assert response.json["process_model_id"] == "hello_world"
|
||||||
|
|
||||||
|
|
||||||
def test_get_workflow_from_workflow_spec(
|
def test_get_workflow_from_workflow_spec(
|
||||||
app, client: FlaskClient, with_bpmn_file_cleanup
|
app, client: FlaskClient, with_bpmn_file_cleanup
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user