ctkXnatReconstructionResource.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*=============================================================================
  2. Library: XNAT/Core
  3. Copyright (c) University College London,
  4. Centre for Medical Image Computing
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkXnatReconstructionResource.h"
  16. #include "ctkXnatSession.h"
  17. #include "ctkXnatObjectPrivate.h"
  18. #include "ctkXnatReconstruction.h"
  19. #include "ctkXnatDefaultSchemaTypes.h"
  20. //----------------------------------------------------------------------------
  21. class ctkXnatReconstructionResourcePrivate : public ctkXnatObjectPrivate
  22. {
  23. public:
  24. ctkXnatReconstructionResourcePrivate()
  25. : ctkXnatObjectPrivate()
  26. {
  27. }
  28. void reset()
  29. {
  30. // uri.clear();
  31. }
  32. // QString uri;
  33. };
  34. //----------------------------------------------------------------------------
  35. ctkXnatReconstructionResource::ctkXnatReconstructionResource(ctkXnatObject* parent, const QString& schemaType)
  36. : ctkXnatObject(*new ctkXnatReconstructionResourcePrivate(), parent, schemaType)
  37. {
  38. }
  39. //----------------------------------------------------------------------------
  40. ctkXnatReconstructionResource::~ctkXnatReconstructionResource()
  41. {
  42. }
  43. //----------------------------------------------------------------------------
  44. QString ctkXnatReconstructionResource::resourceUri() const
  45. {
  46. return QString("%1/resources/%2").arg(parent()->resourceUri(), this->property("label"));
  47. }
  48. //----------------------------------------------------------------------------
  49. void ctkXnatReconstructionResource::reset()
  50. {
  51. ctkXnatObject::reset();
  52. }
  53. //----------------------------------------------------------------------------
  54. void ctkXnatReconstructionResource::fetchImpl()
  55. {
  56. QString reconstructionResourceFilesUri = this->resourceUri() + "/files";
  57. ctkXnatSession* const session = this->session();
  58. QUuid queryId = session->httpGet(reconstructionResourceFilesUri);
  59. QList<ctkXnatObject*> files = session->httpResults(queryId,
  60. ctkXnatDefaultSchemaTypes::XSI_FILE);
  61. foreach (ctkXnatObject* file, files)
  62. {
  63. QString label = file->property("Name");
  64. if (label.isEmpty())
  65. {
  66. file->setProperty("ID", label);
  67. }
  68. this->add(file);
  69. }
  70. }
  71. //----------------------------------------------------------------------------
  72. void ctkXnatReconstructionResource::download(const QString& filename)
  73. {
  74. this->session()->download(this, filename);
  75. }