ctkXnatAssessor.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 "ctkXnatAssessor.h"
  16. #include "ctkXnatSession.h"
  17. #include "ctkXnatObject.h"
  18. #include "ctkXnatObjectPrivate.h"
  19. #include "ctkXnatDefaultSchemaTypes.h"
  20. #include "ctkXnatAssessorResource.h"
  21. #include "ctkXnatScanResource.h"
  22. #include <qDebug>
  23. //----------------------------------------------------------------------------
  24. class ctkXnatAssessorPrivate : public ctkXnatObjectPrivate
  25. {
  26. public:
  27. ctkXnatAssessorPrivate()
  28. : ctkXnatObjectPrivate()
  29. {
  30. }
  31. void reset()
  32. {
  33. uri.clear();
  34. }
  35. QString uri;
  36. };
  37. //----------------------------------------------------------------------------
  38. ctkXnatAssessor::ctkXnatAssessor(ctkXnatObject* parent, const QString& schemaType)
  39. : ctkXnatObject(*new ctkXnatAssessorPrivate(), parent, schemaType)
  40. {
  41. qDebug() << " constructing the assessor";
  42. }
  43. //----------------------------------------------------------------------------
  44. ctkXnatAssessor::~ctkXnatAssessor()
  45. {
  46. }
  47. //----------------------------------------------------------------------------
  48. QString ctkXnatAssessor::resourceUri() const
  49. {
  50. return QString("%1/%2").arg(parent()->resourceUri(), this->id());
  51. }
  52. //----------------------------------------------------------------------------
  53. void ctkXnatAssessor::reset()
  54. {
  55. ctkXnatObject::reset();
  56. }
  57. //----------------------------------------------------------------------------
  58. void ctkXnatAssessor::fetchImpl()
  59. {
  60. QString assessorResourcesUri = this->resourceUri() + "/resources";
  61. ctkXnatSession* const session = this->session();
  62. QUuid queryId = session->httpGet(assessorResourcesUri);
  63. QList<ctkXnatObject*> assessorResources = session->httpResults(queryId,
  64. ctkXnatDefaultSchemaTypes::XSI_ASSESSOR_RESOURCE);
  65. foreach (ctkXnatObject* assessorResource, assessorResources)
  66. {
  67. QString label = assessorResource->property("label");
  68. if (!label.isEmpty())
  69. {
  70. assessorResource->setProperty("ID", label);
  71. }
  72. this->add(assessorResource);
  73. }
  74. assessorResourcesUri = this->resourceUri() + "/out/resources";
  75. queryId = session->httpGet(assessorResourcesUri);
  76. qDebug() << "retrieving assessor resources";
  77. assessorResources = session->httpResults(queryId,
  78. ctkXnatDefaultSchemaTypes::XSI_ASSESSOR_RESOURCE);
  79. foreach (ctkXnatObject* assessorResource, assessorResources)
  80. {
  81. QString label = assessorResource->property("label");
  82. if (!label.isEmpty())
  83. {
  84. assessorResource->setProperty("ID", label);
  85. qDebug() << " adding object, is it AssessorResource : " << (typeid(ctkXnatScanResource) == typeid(assessorResource));
  86. qDebug() << " adding assessor resource object with properties \n: " << assessorResource->properties();
  87. }
  88. this->add(assessorResource);
  89. }
  90. }