When you create a study, all possible workflows are then associated with that study.

This commit is contained in:
Dan Funk 2020-01-30 09:11:17 -05:00
parent e3a9cd8e04
commit 3fb831bae4
3 changed files with 20 additions and 13 deletions

View File

@ -200,7 +200,7 @@ paths:
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.
tags:
- Workflows and Tasks
- Workflow Specifications
responses:
'200':
description: An array of workflow specifications
@ -220,7 +220,7 @@ paths:
operationId: crc.api.workflow.add_workflow_specification
summary: Creates a new workflow specification with the given parameters.
tags:
- Workflows and Tasks
- Workflow Specifications
requestBody:
content:
application/json:
@ -251,7 +251,7 @@ paths:
operationId: crc.api.workflow.get_workflow_specification
summary: Returns a single workflow specification
tags:
- Workflows and Tasks
- Workflow Specifications
responses:
'200':
description: Workflow specification.
@ -263,7 +263,7 @@ paths:
operationId: crc.api.workflow.update_workflow_specification
summary: Modifies an existing workflow specification with the given parameters.
tags:
- Workflows and Tasks
- Workflow Specifications
requestBody:
content:
application/json:
@ -286,7 +286,7 @@ paths:
operationId: crc.api.workflow.delete_workflow_specification
summary: Removes an existing workflow specification
tags:
- Workflows and Tasks
- Workflow Specifications
responses:
'204':
description: The workflow specification has been removed.
@ -547,13 +547,11 @@ paths:
capital_assyria: Assur
responses:
'201':
description: Null response
default:
description: unexpected error
description: Returns the updated workflow with the task completed.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
$ref: "#/components/schemas/Workflow"
components:
schemas:

View File

@ -17,6 +17,11 @@ def add_study(body):
study = StudyModelSchema().load(body, session=session)
session.add(study)
session.commit()
# FIXME: We need to ask the protocol builder what workflows to add to the study, not just add them all.
for spec in session.query(WorkflowSpecModel).all():
workflow = __get_workflow_instance(study.id, spec)
session.add(workflow)
session.commit()
return StudyModelSchema().dump(study)
@ -61,12 +66,15 @@ def add_workflow_to_study(study_id, body):
if workflow_spec_model is None:
error = ApiError('unknown_spec', 'The specification "' + body['id'] + '" is not recognized.')
return ApiErrorSchema.dump(error), 404
workflow = __get_workflow_instance(study_id, workflow_spec_model)
session.add(workflow)
session.commit()
return WorkflowModelSchema().dump(workflow)
def __get_workflow_instance(study_id, workflow_spec_model):
processor = WorkflowProcessor.create(workflow_spec_model.id)
workflow = WorkflowModel(bpmn_workflow_json=processor.serialize(),
status=processor.get_status(),
study_id=study_id,
workflow_spec_id=workflow_spec_model.id)
session.add(workflow)
session.commit()
return WorkflowModelSchema().dump(workflow)
return workflow

View File

@ -74,7 +74,7 @@ def get_workflow(workflow_id):
def delete(workflow_id):
session.query(WorkflowModel).filter_by(id=workflow_id).delete()
session.commit()
3
def get_tasks(workflow_id):
workflow = session.query(WorkflowModel).filter_by(id=workflow_id).first()
@ -101,3 +101,4 @@ def update_task(workflow_id, task_id, body):
workflow.bpmn_workflow_json = processor.serialize()
session.add(workflow)
session.commit()
return WorkflowModelSchema().dump(workflow)