ctkXnatReconstruction.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 "ctkXnatReconstruction.h"
  16. #include "ctkXnatDefaultSchemaTypes.h"
  17. #include "ctkXnatFile.h"
  18. #include "ctkXnatObjectPrivate.h"
  19. #include "ctkXnatReconstructionFolder.h"
  20. #include "ctkXnatSession.h"
  21. #include <QDebug>
  22. //----------------------------------------------------------------------------
  23. class ctkXnatReconstructionPrivate : public ctkXnatObjectPrivate
  24. {
  25. public:
  26. ctkXnatReconstructionPrivate()
  27. : ctkXnatObjectPrivate()
  28. {
  29. }
  30. void reset()
  31. {
  32. uri.clear();
  33. }
  34. QString uri;
  35. };
  36. //----------------------------------------------------------------------------
  37. ctkXnatReconstruction::ctkXnatReconstruction(ctkXnatObject* parent, const QString& schemaType)
  38. : ctkXnatObject(*new ctkXnatReconstructionPrivate(), parent, schemaType)
  39. {
  40. }
  41. //----------------------------------------------------------------------------
  42. ctkXnatReconstruction::~ctkXnatReconstruction()
  43. {
  44. }
  45. //----------------------------------------------------------------------------
  46. QString ctkXnatReconstruction::resourceUri() const
  47. {
  48. return QString("%1/%2").arg(parent()->resourceUri(), this->id());
  49. }
  50. //----------------------------------------------------------------------------
  51. void ctkXnatReconstruction::reset()
  52. {
  53. ctkXnatObject::reset();
  54. }
  55. //----------------------------------------------------------------------------
  56. void ctkXnatReconstruction::fetchImpl()
  57. {
  58. QString reconstructionResourcesUri = this->resourceUri() + "/files";
  59. ctkXnatSession* const session = this->session();
  60. QUuid queryId = session->httpGet(reconstructionResourcesUri);
  61. QList<ctkXnatObject*> reconstructionResources = session->httpResults(queryId,
  62. ctkXnatDefaultSchemaTypes::XSI_FILE);
  63. foreach (ctkXnatObject* reconstructionResource, reconstructionResources)
  64. {
  65. QString label = reconstructionResource->name();
  66. if (!label.isEmpty())
  67. {
  68. reconstructionResource->setName(label);
  69. }
  70. this->add(reconstructionResource);
  71. }
  72. }
  73. //----------------------------------------------------------------------------
  74. void ctkXnatReconstruction::downloadImpl(const QString& filename)
  75. {
  76. qDebug() << "ctkXnatReconstruction::downloadImpl(const QString& filename) not yet tested";
  77. QString query = this->resourceUri() + "/files";
  78. ctkXnatSession::UrlParameters parameters;
  79. parameters["format"] = "zip";
  80. this->session()->download(filename, query, parameters);
  81. }