ctkXnatScan.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 "ctkXnatScan.h"
  16. #include "ctkXnatDefaultSchemaTypes.h"
  17. #include "ctkXnatObject.h"
  18. #include "ctkXnatObjectPrivate.h"
  19. #include "ctkXnatScanFolder.h"
  20. #include "ctkXnatSession.h"
  21. const QString ctkXnatScan::QUALITY = "quality";
  22. const QString ctkXnatScan::SERIES_DESCRIPTION = "series_description";
  23. const QString ctkXnatScan::TYPE = "type";
  24. //----------------------------------------------------------------------------
  25. class ctkXnatScanPrivate : public ctkXnatObjectPrivate
  26. {
  27. public:
  28. ctkXnatScanPrivate()
  29. : ctkXnatObjectPrivate()
  30. {
  31. }
  32. void reset()
  33. {
  34. uri.clear();
  35. }
  36. QString uri;
  37. };
  38. //----------------------------------------------------------------------------
  39. ctkXnatScan::ctkXnatScan(ctkXnatObject* parent, const QString& schemaType)
  40. : ctkXnatObject(*new ctkXnatScanPrivate(), parent, schemaType)
  41. {
  42. }
  43. //----------------------------------------------------------------------------
  44. ctkXnatScan::~ctkXnatScan()
  45. {
  46. }
  47. //----------------------------------------------------------------------------
  48. void ctkXnatScan::setQuality(const QString &quality)
  49. {
  50. this->setProperty(QUALITY, quality);
  51. }
  52. //----------------------------------------------------------------------------
  53. QString ctkXnatScan::quality() const
  54. {
  55. return this->property(QUALITY);
  56. }
  57. //----------------------------------------------------------------------------
  58. void ctkXnatScan::setSeriesDescription(const QString &seriesDescription)
  59. {
  60. this->setProperty(SERIES_DESCRIPTION, seriesDescription);
  61. }
  62. //----------------------------------------------------------------------------
  63. QString ctkXnatScan::seriesDescription() const
  64. {
  65. return this->property(SERIES_DESCRIPTION);
  66. }
  67. //----------------------------------------------------------------------------
  68. void ctkXnatScan::setType(const QString &type)
  69. {
  70. this->setProperty(TYPE, type);
  71. }
  72. //----------------------------------------------------------------------------
  73. QString ctkXnatScan::type() const
  74. {
  75. return this->property(TYPE);
  76. }
  77. //----------------------------------------------------------------------------
  78. QString ctkXnatScan::resourceUri() const
  79. {
  80. return QString("%1/%2").arg(parent()->resourceUri(), this->id());
  81. }
  82. //----------------------------------------------------------------------------
  83. void ctkXnatScan::reset()
  84. {
  85. ctkXnatObject::reset();
  86. }
  87. //----------------------------------------------------------------------------
  88. void ctkXnatScan::fetchImpl()
  89. {
  90. this->fetchResources();
  91. }
  92. //----------------------------------------------------------------------------
  93. void ctkXnatScan::downloadImpl(const QString& filename)
  94. {
  95. QString query = this->resourceUri() + "/files";
  96. ctkXnatSession::UrlParameters parameters;
  97. parameters["format"] = "zip";
  98. this->session()->download(filename, query, parameters);
  99. }