Returns workflow spec id with Workflow schema

This commit is contained in:
Aaron Louie 2020-01-06 09:18:13 -05:00
parent d0454da644
commit 872f3fca1b
4 changed files with 15 additions and 10 deletions

View File

@ -564,8 +564,9 @@ components:
study_id:
readOnly: true
type: integer
workflow_spec:
$ref: "#/components/schemas/WorkflowSpec"
workflow_spec_id:
readOnly: true
type: String
current_task_ids:
type: array
items:

View File

@ -36,9 +36,12 @@ def get_task(workflow_id, task_id):
def update_task(workflow_id, task_id, body):
workflow_spec_model = db.session.query(WorkflowSpecModel).filter_by(id=body["id"]).first()
task = TaskSchema().load(body)
if task.form:
for field in task.form["fields"]:
print("Setting " + field["id"] + " to " + field["value"])
workflow = db.session.query(WorkflowModel).filter_by(id=workflow_id).first()
task = workflow.bpmn_workflow().get_task(task_id)
if workflow and task and body:
print('workflow', workflow.id)
print('task', task.id)
print('body', body)
processor = WorkflowProcessor(workflow.workflow_spec_id, workflow.bpmn_workflow_json)
processor.complete_task(task)
return body

View File

@ -32,12 +32,13 @@ class WorkflowModel(db.Model):
bpmn_workflow_json = db.Column(db.TEXT)
status = db.Column(db.Enum(WorkflowStatus))
study_id = db.Column(db.Integer, db.ForeignKey('study.id'))
workflow_spec_id = db.Column(db.Integer, db.ForeignKey('workflow_spec.id'))
workflow_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'))
class WorkflowModelSchema(ModelSchema):
class Meta:
model = WorkflowModel
include_fk = True # Includes foreign keys
status = EnumField(WorkflowStatus)

View File

@ -103,8 +103,8 @@ class TestStudy(BaseTest, unittest.TestCase):
self.assertEqual(spec.id, workflow.workflow_spec_id)
json_data = json.loads(rv.get_data(as_text=True))
workflow = WorkflowModelSchema().load(json_data, session=db.session)
self.assertEqual(workflow.id, workflow.id)
workflow2 = WorkflowModelSchema().load(json_data, session=db.session)
self.assertEqual(workflow.id, workflow2.id)
def test_delete_workflow(self):
self.load_example_data()