2019-12-18 19:02:17 +00:00
|
|
|
import enum
|
|
|
|
|
2020-03-18 19:16:15 +00:00
|
|
|
import marshmallow
|
2020-03-20 11:54:01 +00:00
|
|
|
from marshmallow import EXCLUDE
|
2020-03-16 17:37:31 +00:00
|
|
|
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
|
2019-12-18 19:02:17 +00:00
|
|
|
|
2020-03-05 16:18:20 +00:00
|
|
|
from crc import db
|
2019-12-18 19:02:17 +00:00
|
|
|
|
2020-03-18 20:58:50 +00:00
|
|
|
|
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)
|
2020-03-26 19:29:52 +00:00
|
|
|
display_order = db.Column(db.Integer)
|
2020-03-13 18:56:46 +00:00
|
|
|
|
|
|
|
|
2020-03-16 17:37:31 +00:00
|
|
|
class WorkflowSpecCategoryModelSchema(SQLAlchemyAutoSchema):
|
2020-03-13 18:56:46 +00:00
|
|
|
class Meta:
|
|
|
|
model = WorkflowSpecCategoryModel
|
2020-03-16 17:37:31 +00:00
|
|
|
load_instance = True
|
|
|
|
include_relationships = True
|
2020-03-13 18:56:46 +00:00
|
|
|
|
2019-12-18 19:02:17 +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)
|
2019-12-18 19:02:17 +00:00
|
|
|
display_name = db.Column(db.String)
|
2020-04-09 18:25:14 +00:00
|
|
|
display_order = db.Column(db.Integer, nullable=True)
|
2019-12-18 19:02:17 +00:00
|
|
|
description = db.Column(db.Text)
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
category_id = db.Column(db.Integer, db.ForeignKey('workflow_spec_category.id'), nullable=True)
|
|
|
|
category = db.relationship("WorkflowSpecCategoryModel")
|
2020-03-26 16:51:53 +00:00
|
|
|
is_master_spec = db.Column(db.Boolean, default=False)
|
2019-12-18 19:02:17 +00:00
|
|
|
|
2020-02-18 15:14:03 +00:00
|
|
|
|
2020-03-16 17:37:31 +00:00
|
|
|
class WorkflowSpecModelSchema(SQLAlchemyAutoSchema):
|
2019-12-18 19:02:17 +00:00
|
|
|
class Meta:
|
|
|
|
model = WorkflowSpecModel
|
2020-03-16 17:37:31 +00:00
|
|
|
load_instance = True
|
|
|
|
include_relationships = True
|
2020-03-13 18:56:46 +00:00
|
|
|
include_fk = True # Includes foreign keys
|
2020-03-20 11:54:01 +00:00
|
|
|
unknown = EXCLUDE
|
2019-12-18 19:02:17 +00:00
|
|
|
|
2020-03-30 14:12:10 +00:00
|
|
|
category = marshmallow.fields.Nested(WorkflowSpecCategoryModelSchema, dump_only=True)
|
2020-03-18 19:16:15 +00:00
|
|
|
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
|
2020-03-26 16:51:53 +00:00
|
|
|
class WorkflowState(enum.Enum):
|
|
|
|
hidden = "hidden"
|
|
|
|
disabled = "disabled"
|
|
|
|
required = "required"
|
|
|
|
optional = "optional"
|
|
|
|
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
@classmethod
|
|
|
|
def has_value(cls, value):
|
|
|
|
return value in cls._value2member_map_
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def list():
|
|
|
|
return list(map(lambda c: c.value, WorkflowState))
|
2020-01-03 16:44:24 +00:00
|
|
|
|
2020-05-04 14:57:09 +00:00
|
|
|
|
2019-12-18 19:02:17 +00:00
|
|
|
class WorkflowStatus(enum.Enum):
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
not_started = "not_started"
|
2019-12-18 19:02:17 +00:00
|
|
|
user_input_required = "user_input_required"
|
|
|
|
waiting = "waiting"
|
|
|
|
complete = "complete"
|
|
|
|
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
|
2019-12-18 19:02:17 +00:00
|
|
|
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)
|
2019-12-18 19:02:17 +00:00
|
|
|
status = db.Column(db.Enum(WorkflowStatus))
|
|
|
|
study_id = db.Column(db.Integer, db.ForeignKey('study.id'))
|
2020-01-06 14:18:13 +00:00
|
|
|
workflow_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'))
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
workflow_spec = db.relationship("WorkflowSpecModel")
|
2020-03-05 20:35:55 +00:00
|
|
|
spec_version = db.Column(db.String)
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
total_tasks = db.Column(db.Integer, default=0)
|
|
|
|
completed_tasks = db.Column(db.Integer, default=0)
|
2020-05-04 14:57:09 +00:00
|
|
|
# task_history = db.Column(db.ARRAY(db.String), default=[]) # The history stack of user completed tasks.
|
|
|
|
last_updated = db.Column(db.DateTime)
|