cr-connect-workflow/crc/models/workflow.py

59 lines
1.8 KiB
Python
Raw Normal View History

import enum
2020-03-18 19:16:15 +00:00
import marshmallow
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
from crc import db
2020-03-13 18:56:46 +00:00
class WorkflowSpecCategoryModel(db.Model):
__tablename__ = 'workflow_spec_category'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String)
display_name = db.Column(db.String)
class WorkflowSpecCategoryModelSchema(SQLAlchemyAutoSchema):
2020-03-13 18:56:46 +00:00
class Meta:
model = WorkflowSpecCategoryModel
load_instance = True
include_relationships = True
2020-03-13 18:56:46 +00:00
class WorkflowSpecModel(db.Model):
__tablename__ = 'workflow_spec'
id = db.Column(db.String, primary_key=True)
2020-01-21 20:22:44 +00:00
name = db.Column(db.String)
display_name = db.Column(db.String)
description = db.Column(db.Text)
primary_process_id = db.Column(db.String)
2020-03-16 16:10:32 +00:00
workflow_spec_category_id = db.Column(db.Integer, db.ForeignKey('workflow_spec_category.id'), nullable=True)
2020-03-13 18:56:46 +00:00
workflow_spec_category = db.relationship("WorkflowSpecCategoryModel")
is_status = db.Column(db.Boolean, default=False)
2020-02-18 15:14:03 +00:00
class WorkflowSpecModelSchema(SQLAlchemyAutoSchema):
class Meta:
model = WorkflowSpecModel
load_instance = True
include_relationships = True
2020-03-13 18:56:46 +00:00
include_fk = True # Includes foreign keys
2020-03-18 19:16:15 +00:00
workflow_spec_category = marshmallow.fields.Nested(WorkflowSpecCategoryModelSchema, dump_only=True)
class WorkflowStatus(enum.Enum):
new = "new"
user_input_required = "user_input_required"
waiting = "waiting"
complete = "complete"
class WorkflowModel(db.Model):
__tablename__ = 'workflow'
id = db.Column(db.Integer, primary_key=True)
2020-01-23 15:53:59 +00:00
bpmn_workflow_json = db.Column(db.JSON)
status = db.Column(db.Enum(WorkflowStatus))
study_id = db.Column(db.Integer, db.ForeignKey('study.id'))
workflow_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'))
spec_version = db.Column(db.String)