Returns workflow spec id with Workflow schema
This commit is contained in:
parent
d0454da644
commit
872f3fca1b
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue