ctkXnatAssessorResource.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 "ctkXnatAssessorResource.h"
  16. #include "ctkXnatSession.h"
  17. #include "ctkXnatObjectPrivate.h"
  18. #include "ctkXnatDefaultSchemaTypes.h"
  19. #include <qDebug>
  20. //----------------------------------------------------------------------------
  21. class ctkXnatAssessorResourcePrivate : public ctkXnatObjectPrivate
  22. {
  23. public:
  24. ctkXnatAssessorResourcePrivate()
  25. : ctkXnatObjectPrivate()
  26. {
  27. }
  28. void reset()
  29. {
  30. }
  31. };
  32. //----------------------------------------------------------------------------
  33. ctkXnatAssessorResource::ctkXnatAssessorResource(ctkXnatObject* parent, const QString& schemaType)
  34. : ctkXnatObject(*new ctkXnatAssessorResourcePrivate(), parent, schemaType)
  35. {
  36. qDebug() << " constructing the assessor resource";
  37. }
  38. //----------------------------------------------------------------------------
  39. ctkXnatAssessorResource::~ctkXnatAssessorResource()
  40. {
  41. }
  42. //----------------------------------------------------------------------------
  43. QString ctkXnatAssessorResource::resourceUri() const
  44. {
  45. return QString("%1/resources/%2").arg(parent()->resourceUri(), this->property("xnat_abstractresource_id"));
  46. }
  47. //----------------------------------------------------------------------------
  48. void ctkXnatAssessorResource::reset()
  49. {
  50. ctkXnatObject::reset();
  51. }
  52. //----------------------------------------------------------------------------
  53. void ctkXnatAssessorResource::fetchImpl()
  54. {
  55. QString assessorResourceFilesUri = this->resourceUri() + "/files";
  56. ctkXnatSession* const session = this->session();
  57. QUuid queryId = session->httpGet(assessorResourceFilesUri);
  58. QList<ctkXnatObject*> files = session->httpResults(queryId,
  59. ctkXnatDefaultSchemaTypes::XSI_FILE);
  60. qDebug() << " trying to get things from : " << this->resourceUri() << "/files";
  61. foreach (ctkXnatObject* file, files)
  62. {
  63. QString label = file->property("Name");
  64. qDebug() << " got a assessment file called : " << label << ".";
  65. qDebug() << " with properties : " << file->properties() << ".";
  66. if (!label.isEmpty())
  67. {
  68. file->setProperty("ID", label);
  69. }
  70. this->add(file);
  71. }
  72. }
  73. //----------------------------------------------------------------------------
  74. void ctkXnatAssessorResource::download(const QString& filename)
  75. {
  76. this->session()->download(this, filename);
  77. }