diff --git a/sources/dicom/large_image_source_dicom/assetstore/rest.py b/sources/dicom/large_image_source_dicom/assetstore/rest.py index 7994a212e..3a9a47f49 100644 --- a/sources/dicom/large_image_source_dicom/assetstore/rest.py +++ b/sources/dicom/large_image_source_dicom/assetstore/rest.py @@ -1,10 +1,11 @@ import json from girder.api import access -from girder.api.describe import Description, describeRoute -from girder.api.rest import Resource, loadmodel +from girder.api.describe import Description, autoDescribeRoute +from girder.api.rest import Resource from girder.constants import TokenScope from girder.exceptions import RestException +from girder.models.assetstore import Assetstore from girder.utility import assetstore_utilities from girder.utility.model_importer import ModelImporter from girder.utility.progress import ProgressContext @@ -14,26 +15,24 @@ class DICOMwebAssetstoreResource(Resource): def __init__(self): super().__init__() self.resourceName = 'dicomweb_assetstore' - self.route('PUT', (':id', 'import'), self.importData) + self.route('POST', (':id', 'import'), self.importData) def _importData(self, assetstore, params): """ :param assetstore: the destination assetstore. - :param params: a dictionary of parameters including parentId, - parentType, progress, and filters. + :param params: a dictionary of parameters including destinationId, + destinationType, progress, and filters. """ - self.requireParams(('parentId'), params) - user = self.getCurrentUser() - parentType = params.get('parentType', 'folder') - if parentType not in ('folder', 'user', 'collection'): - msg = f'Invalid parentType: {parentType}' + destinationType = params.get('destinationType', 'folder') + if destinationType not in ('folder', 'user', 'collection'): + msg = f'Invalid destinationType: {destinationType}' raise RestException(msg) - parent = ModelImporter.model(parentType).load(params['parentId'], force=True, - exc=True) + parent = ModelImporter.model(destinationType).load(params['destinationId'], force=True, + exc=True) limit = params.get('limit') or None if limit is not None: @@ -61,7 +60,7 @@ def _importData(self, assetstore, params): ) as ctx: items = adapter.importData( parent, - parentType, + destinationType, { 'limit': limit, 'search_filters': search_filters, @@ -76,22 +75,21 @@ def _importData(self, assetstore, params): raise RestException(msg) @access.admin(scope=TokenScope.DATA_WRITE) - @loadmodel(model='assetstore') - @describeRoute( + @autoDescribeRoute( Description('Import references to DICOM objects from a DICOMweb server') - .param('id', 'The ID of the assetstore representing the DICOMweb server.', - paramType='path') - .param('parentId', 'The ID of the parent folder, collection, or user ' + .modelParam('id', 'The ID of the assetstore representing the DICOMweb server.', + model=Assetstore) + .param('destinationId', 'The ID of the parent folder, collection, or user ' 'in the Girder data hierarchy under which to import the files.') - .param('parentType', 'The type of the parent object to import into.', + .param('destinationType', 'The type of the parent object to import into.', enum=('folder', 'user', 'collection'), - required=False) + required=True) .param('limit', 'The maximum number of results to import.', required=False, dataType='int') .param('filters', 'Any search parameters to filter DICOM objects.', - required=False) + required=False, default={}) .param('progress', 'Whether to record progress on this operation (' - 'default=False)', required=False, dataType='boolean') + 'default=False)', required=False, default=False, dataType='boolean') .errorResponse() .errorResponse('You are not an administrator.', 403), ) diff --git a/sources/dicom/large_image_source_dicom/web_client/models/AssetstoreModel.js b/sources/dicom/large_image_source_dicom/web_client/models/AssetstoreModel.js index 016068ff3..c8313a140 100644 --- a/sources/dicom/large_image_source_dicom/web_client/models/AssetstoreModel.js +++ b/sources/dicom/large_image_source_dicom/web_client/models/AssetstoreModel.js @@ -7,7 +7,7 @@ import { restRequest } from '@girder/core/rest'; AssetstoreModel.prototype.dicomwebImport = function (params) { return restRequest({ url: 'dicomweb_assetstore/' + this.get('_id') + '/import', - type: 'PUT', + type: 'POST', data: params, error: null }).done(() => { diff --git a/sources/dicom/large_image_source_dicom/web_client/templates/dicomwebAssetstoreImportButton.pug b/sources/dicom/large_image_source_dicom/web_client/templates/dicomwebAssetstoreImportButton.pug index d508e1ceb..ca55a7747 100644 --- a/sources/dicom/large_image_source_dicom/web_client/templates/dicomwebAssetstoreImportButton.pug +++ b/sources/dicom/large_image_source_dicom/web_client/templates/dicomwebAssetstoreImportButton.pug @@ -1,5 +1,6 @@ -a.g-dwas-import-button.btn.btn-sm.btn-success( - href=`#dicomweb_assetstore/${assetstore.get('_id')}/import`, - title="Import references to DICOM objects from a DICOMweb server") - i.icon-link-ext - | Import +.g-assetstore-import-button-container + a.g-dwas-import-button.btn.btn-sm.btn-success( + href=`#dicomweb_assetstore/${assetstore.get('_id')}/import`, + title="Import references to DICOM objects from a DICOMweb server") + i.icon-link-ext + | Import data diff --git a/sources/dicom/large_image_source_dicom/web_client/views/AssetstoreImportView.js b/sources/dicom/large_image_source_dicom/web_client/views/AssetstoreImportView.js index 2d82ce35b..b49950fe6 100644 --- a/sources/dicom/large_image_source_dicom/web_client/views/AssetstoreImportView.js +++ b/sources/dicom/large_image_source_dicom/web_client/views/AssetstoreImportView.js @@ -13,25 +13,25 @@ const AssetstoreImportView = View.extend({ e.preventDefault(); this.$('.g-validation-failed-message').empty(); - const parentType = this.$('#g-dwas-import-dest-type').val(); - const parentId = this.$('#g-dwas-import-dest-id').val().trim().split(/\s/)[0]; + const destinationType = this.$('#g-dwas-import-dest-type').val(); + const destinationId = this.$('#g-dwas-import-dest-id').val().trim().split(/\s/)[0]; const filters = this.$('#g-dwas-import-filters').val().trim(); const limit = this.$('#g-dwas-import-limit').val().trim(); - if (!parentId) { + if (!destinationId) { this.$('.g-validation-failed-message').html('Invalid Destination ID'); return; } this.$('.g-submit-dwas-import').addClass('disabled'); this.model.off().on('g:imported', function () { - router.navigate(parentType + '/' + parentId, { trigger: true }); + router.navigate(destinationType + '/' + destinationId, { trigger: true }); }, this).on('g:error', function (err) { this.$('.g-submit-dwas-import').removeClass('disabled'); this.$('.g-validation-failed-message').html(err.responseJSON.message); }, this).dicomwebImport({ - parentId, - parentType, + destinationId, + destinationType, limit, filters, progress: true diff --git a/sources/dicom/test_dicom/web_client_specs/dicomWebSpec.js b/sources/dicom/test_dicom/web_client_specs/dicomWebSpec.js index 3895c067d..d8ecab991 100644 --- a/sources/dicom/test_dicom/web_client_specs/dicomWebSpec.js +++ b/sources/dicom/test_dicom/web_client_specs/dicomWebSpec.js @@ -11,8 +11,8 @@ describe('DICOMWeb assetstore', function () { 'Admin', 'adminpassword!')); it('Create an assetstore and import data', function () { - var parentId; - var parentType; + var destinationId; + var destinationType; // After importing, we will verify that this item exists const verifyItemName = '1.3.6.1.4.1.5962.99.1.3510881361.982628633.1635598486609.2.0'; @@ -54,7 +54,7 @@ describe('DICOMWeb assetstore', function () { }, 'DICOMweb assetstore to be created'); runs(function () { - // Select the parentId and parentType + // Select the destinationId and destinationType // Get the user ID const resp = girder.rest.restRequest({ url: 'user', @@ -77,8 +77,8 @@ describe('DICOMWeb assetstore', function () { }); // Use the user's public folder - parentType = 'folder'; - parentId = resp.responseJSON[0]._id; + destinationType = 'folder'; + destinationId = resp.responseJSON[0]._id; }); runs(function () { @@ -103,8 +103,8 @@ describe('DICOMWeb assetstore', function () { runs(function () { // Set dest type and dest id - $('#g-dwas-import-dest-type').val(parentType); - $('#g-dwas-import-dest-id').val(parentId); + $('#g-dwas-import-dest-type').val(destinationType); + $('#g-dwas-import-dest-id').val(destinationId); // Test error for an invalid limit $('#g-dwas-import-limit').val('1.3'); @@ -112,7 +112,7 @@ describe('DICOMWeb assetstore', function () { }); waitsFor(function () { - return $('.g-validation-failed-message').html() === 'Invalid limit'; + return $('.g-validation-failed-message').html().includes('Invalid value'); }, 'Invalid limit check (float)'); runs(function () {