ctkXnatReconstruction.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 "ctkXnatSession.h"
  17. #include "ctkXnatObjectPrivate.h"
  18. #include "ctkXnatReconstructionFolder.h"
  19. #include "ctkXnatReconstructionResource.h"
  20. #include "ctkXnatDefaultSchemaTypes.h"
  21. //----------------------------------------------------------------------------
  22. class ctkXnatReconstructionPrivate : public ctkXnatObjectPrivate
  23. {
  24. public:
  25. ctkXnatReconstructionPrivate()
  26. : ctkXnatObjectPrivate()
  27. {
  28. }
  29. void reset()
  30. {
  31. uri.clear();
  32. }
  33. QString uri;
  34. };
  35. //----------------------------------------------------------------------------
  36. ctkXnatReconstruction::ctkXnatReconstruction(ctkXnatObject* parent, const QString& schemaType)
  37. : ctkXnatObject(*new ctkXnatReconstructionPrivate(), parent, schemaType)
  38. {
  39. }
  40. //----------------------------------------------------------------------------
  41. ctkXnatReconstruction::~ctkXnatReconstruction()
  42. {
  43. }
  44. //----------------------------------------------------------------------------
  45. QString ctkXnatReconstruction::resourceUri() const
  46. {
  47. return QString("%1/reconstructions/%2").arg(parent()->resourceUri(), this->id());
  48. }
  49. //----------------------------------------------------------------------------
  50. void ctkXnatReconstruction::reset()
  51. {
  52. ctkXnatObject::reset();
  53. }
  54. //----------------------------------------------------------------------------
  55. void ctkXnatReconstruction::fetchImpl()
  56. {
  57. QString reconstructionResourcesUri = this->resourceUri() + "/resources";
  58. ctkXnatSession* const session = this->session();
  59. QUuid queryId = session->httpGet(reconstructionResourcesUri);
  60. QList<ctkXnatObject*> reconstructionResources = session->httpResults(queryId,
  61. ctkXnatDefaultSchemaTypes::XSI_RECONSTRUCTION_RESOURCE);
  62. foreach (ctkXnatObject* reconstructionResource, reconstructionResources)
  63. {
  64. QString label = reconstructionResource->property("label");
  65. if (!label.isEmpty())
  66. {
  67. reconstructionResource->setProperty("ID", label);
  68. }
  69. this->add(reconstructionResource);
  70. }
  71. }