UNDO my previous commit regarding `get_files needs to have workflow_spec_id`
We need to call `get_spec_files` instead now
This commit is contained in:
parent
f815add699
commit
ca54b850cd
|
@ -802,12 +802,6 @@ paths:
|
||||||
|
|
||||||
/file:
|
/file:
|
||||||
parameters:
|
parameters:
|
||||||
- name: workflow_spec_id
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
description: The unique id of a workflow specification
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- name: workflow_id
|
- name: workflow_id
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -28,22 +28,21 @@ def to_file_api(file_model):
|
||||||
DocumentService.get_dictionary())
|
DocumentService.get_dictionary())
|
||||||
|
|
||||||
|
|
||||||
def get_files(workflow_spec_id=None, workflow_id=None, form_field_key=None,study_id=None):
|
def get_files(workflow_id=None, form_field_key=None,study_id=None):
|
||||||
if all(v is None for v in [workflow_spec_id, workflow_id, form_field_key,study_id]):
|
if workflow_id is None:
|
||||||
raise ApiError('missing_parameter',
|
raise ApiError('missing_parameter',
|
||||||
'Please specify either a workflow_spec_id or a '
|
'Please specify a workflow_id with an optional form_field_key')
|
||||||
'workflow_id with an optional form_field_key')
|
|
||||||
|
|
||||||
if study_id is not None:
|
if study_id is not None:
|
||||||
file_models = FileService.get_files_for_study(study_id=study_id, irb_doc_code=form_field_key)
|
file_models = FileService.get_files_for_study(study_id=study_id, irb_doc_code=form_field_key)
|
||||||
else:
|
else:
|
||||||
file_models = FileService.get_files(workflow_spec_id=workflow_spec_id,
|
file_models = FileService.get_files(workflow_id=workflow_id,
|
||||||
workflow_id=workflow_id,
|
irb_doc_code=form_field_key)
|
||||||
irb_doc_code=form_field_key)
|
|
||||||
|
|
||||||
files = (to_file_api(model) for model in file_models)
|
files = (to_file_api(model) for model in file_models)
|
||||||
return FileSchema(many=True).dump(files)
|
return FileSchema(many=True).dump(files)
|
||||||
|
|
||||||
|
|
||||||
def get_spec_files(workflow_spec_id, include_libraries=False):
|
def get_spec_files(workflow_spec_id, include_libraries=False):
|
||||||
if workflow_spec_id is None:
|
if workflow_spec_id is None:
|
||||||
raise ApiError(code='missing_spec_id',
|
raise ApiError(code='missing_spec_id',
|
||||||
|
|
|
@ -16,7 +16,7 @@ from crc import session, app
|
||||||
from crc.api.common import ApiError
|
from crc.api.common import ApiError
|
||||||
from crc.models.data_store import DataStoreModel
|
from crc.models.data_store import DataStoreModel
|
||||||
from crc.models.file import FileType, FileDataModel, FileModel, LookupFileModel, LookupDataModel
|
from crc.models.file import FileType, FileDataModel, FileModel, LookupFileModel, LookupDataModel
|
||||||
from crc.models.workflow import WorkflowModel, WorkflowLibraryModel
|
from crc.models.workflow import WorkflowModel
|
||||||
from crc.services.cache_service import cache
|
from crc.services.cache_service import cache
|
||||||
from crc.services.user_service import UserService
|
from crc.services.user_service import UserService
|
||||||
import re
|
import re
|
||||||
|
@ -163,35 +163,20 @@ class FileService(object):
|
||||||
return query.all()
|
return query.all()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_files(workflow_spec_id=None, workflow_id=None,
|
def get_files(workflow_id=None, name=None, irb_doc_code=None):
|
||||||
name=None, is_reference=False, irb_doc_code=None, include_libraries=False):
|
if workflow_id is not None:
|
||||||
query = session.query(FileModel).filter_by(is_reference=is_reference)
|
query = session.query(FileModel).filter_by(workflow_id=workflow_id)
|
||||||
if workflow_spec_id:
|
|
||||||
if include_libraries:
|
|
||||||
libraries = session.query(WorkflowLibraryModel).filter(
|
|
||||||
WorkflowLibraryModel.workflow_spec_id==workflow_spec_id).all()
|
|
||||||
library_workflow_specs = [x.library_spec_id for x in libraries]
|
|
||||||
library_workflow_specs.append(workflow_spec_id)
|
|
||||||
query = query.filter(FileModel.workflow_spec_id.in_(library_workflow_specs))
|
|
||||||
else:
|
|
||||||
query = query.filter(FileModel.workflow_spec_id == workflow_spec_id)
|
|
||||||
|
|
||||||
elif workflow_id:
|
|
||||||
query = query.filter_by(workflow_id=workflow_id)
|
|
||||||
if irb_doc_code:
|
if irb_doc_code:
|
||||||
query = query.filter_by(irb_doc_code=irb_doc_code)
|
query = query.filter_by(irb_doc_code=irb_doc_code)
|
||||||
elif is_reference:
|
|
||||||
query = query.filter_by(is_reference=True)
|
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
query = query.filter_by(name=name)
|
query = query.filter_by(name=name)
|
||||||
|
|
||||||
query = query.filter(FileModel.archived == False)
|
query = query.filter(FileModel.archived == False)
|
||||||
|
query = query.order_by(FileModel.id)
|
||||||
|
|
||||||
query = query.order_by(FileModel.id)
|
results = query.all()
|
||||||
|
return results
|
||||||
results = query.all()
|
|
||||||
return results
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_workflow_data_files(workflow_id=None):
|
def get_workflow_data_files(workflow_id=None):
|
||||||
|
|
Loading…
Reference in New Issue