diff --git a/crc/api.yml b/crc/api.yml index 5bd1be74..6a4ff322 100755 --- a/crc/api.yml +++ b/crc/api.yml @@ -802,12 +802,6 @@ paths: /file: parameters: - - name: workflow_spec_id - in: query - required: false - description: The unique id of a workflow specification - schema: - type: string - name: workflow_id in: query required: false diff --git a/crc/api/file.py b/crc/api/file.py index 13ab8b50..ca438810 100644 --- a/crc/api/file.py +++ b/crc/api/file.py @@ -28,22 +28,21 @@ def to_file_api(file_model): DocumentService.get_dictionary()) -def get_files(workflow_spec_id=None, 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]): +def get_files(workflow_id=None, form_field_key=None,study_id=None): + if workflow_id is None: raise ApiError('missing_parameter', - 'Please specify either a workflow_spec_id or a ' - 'workflow_id with an optional form_field_key') + 'Please specify a workflow_id with an optional form_field_key') if study_id is not None: file_models = FileService.get_files_for_study(study_id=study_id, irb_doc_code=form_field_key) else: - file_models = FileService.get_files(workflow_spec_id=workflow_spec_id, - workflow_id=workflow_id, - irb_doc_code=form_field_key) + file_models = FileService.get_files(workflow_id=workflow_id, + irb_doc_code=form_field_key) files = (to_file_api(model) for model in file_models) return FileSchema(many=True).dump(files) + def get_spec_files(workflow_spec_id, include_libraries=False): if workflow_spec_id is None: raise ApiError(code='missing_spec_id', diff --git a/crc/services/file_service.py b/crc/services/file_service.py index 4b9b74e0..e3a4248f 100644 --- a/crc/services/file_service.py +++ b/crc/services/file_service.py @@ -16,7 +16,7 @@ from crc import session, app from crc.api.common import ApiError from crc.models.data_store import DataStoreModel 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.user_service import UserService import re @@ -163,35 +163,20 @@ class FileService(object): return query.all() @staticmethod - def get_files(workflow_spec_id=None, workflow_id=None, - name=None, is_reference=False, irb_doc_code=None, include_libraries=False): - query = session.query(FileModel).filter_by(is_reference=is_reference) - 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) + def get_files(workflow_id=None, name=None, irb_doc_code=None): + if workflow_id is not None: + query = session.query(FileModel).filter_by(workflow_id=workflow_id) if 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: - query = query.filter_by(name=name) + if 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 def get_workflow_data_files(workflow_id=None):