New service to get the `primary workflow` for a workflow_spec, using a workflow_spec_id.
This is necessary because `primary` is a file parameter, not a workflow_spec parameter. - you can ask a workflow file whether it is primary, but - you cannot ask a workflow_spec for its primary workflow file Now, you can use `workflow_service.get_primary_workflow(workflow_spec_id)`
This commit is contained in:
parent
620b9a5188
commit
8a6bef5af4
|
@ -22,7 +22,7 @@ from jinja2 import Template
|
|||
from crc import db, app
|
||||
from crc.api.common import ApiError
|
||||
from crc.models.api_models import Task, MultiInstanceType, WorkflowApi
|
||||
from crc.models.file import LookupDataModel
|
||||
from crc.models.file import LookupDataModel, FileModel
|
||||
from crc.models.study import StudyModel
|
||||
from crc.models.task_event import TaskEventModel
|
||||
from crc.models.user import UserModel, UserModelSchema
|
||||
|
@ -811,3 +811,12 @@ class WorkflowService(object):
|
|||
def get_standalone_workflow_specs():
|
||||
specs = db.session.query(WorkflowSpecModel).filter_by(standalone=True).all()
|
||||
return specs
|
||||
|
||||
@staticmethod
|
||||
def get_primary_workflow(workflow_spec_id):
|
||||
# Returns the FileModel of the primary workflow for a workflow_spec
|
||||
primary = None
|
||||
file = db.session.query(FileModel).filter(FileModel.workflow_spec_id==workflow_spec_id, FileModel.primary==True).first()
|
||||
if file:
|
||||
primary = file
|
||||
return primary
|
||||
|
|
Loading…
Reference in New Issue