ctkXnatSession.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*=============================================================================
  2. Plugin: org.commontk.xnat
  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. #ifndef CTKXNATSESSION_H
  16. #define CTKXNATSESSION_H
  17. #include "ctkXNATCoreExport.h"
  18. #include <QScopedPointer>
  19. #include <QString>
  20. #include <QObject>
  21. #include <QVariantMap>
  22. #include <QUuid>
  23. class QDateTime;
  24. class ctkXnatSessionPrivate;
  25. class ctkXnatFile;
  26. class ctkXnatLoginProfile;
  27. class ctkXnatDataModel;
  28. class ctkXnatObject;
  29. class ctkXnatScanResource;
  30. class ctkXnatReconstructionResource;
  31. class CTK_XNAT_CORE_EXPORT ctkXnatSession : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. typedef QMap<QString, QString> UrlParameters;
  36. typedef QMap<QByteArray, QByteArray> HttpRawHeaders;
  37. ctkXnatSession(const ctkXnatLoginProfile& loginProfile);
  38. ~ctkXnatSession();
  39. void open();
  40. void close();
  41. bool isOpen() const;
  42. QString version() const;
  43. QDateTime expirationDate() const;
  44. QDateTime renew();
  45. /**
  46. * @brief Get the current login profile for this session object.
  47. * @return A copy of the currently used login profile.
  48. */
  49. ctkXnatLoginProfile loginProfile() const;
  50. /**
  51. * @brief Get XNAT server url.
  52. *
  53. * The url is the one specified by the login profile.
  54. *
  55. * @return The XNAT server url.
  56. */
  57. QUrl url() const;
  58. /**
  59. * @brief Get the user name for this XNAT session.
  60. *
  61. * The user name is the one specified by the login profile.
  62. *
  63. * @return The XNAT session user name.
  64. */
  65. QString userName() const;
  66. /**
  67. * @brief Get the password for this XNAT session.
  68. *
  69. * The password is the one specified by the login profile.
  70. *
  71. * @return The XNAT session password.
  72. */
  73. QString password() const;
  74. ctkXnatDataModel* dataModel() const;
  75. QUuid httpGet(const QString& resource,
  76. const UrlParameters& parameters = UrlParameters(),
  77. const HttpRawHeaders& rawHeaders = HttpRawHeaders());
  78. QList<ctkXnatObject*> httpResults(const QUuid& uuid, const QString& schemaType);
  79. QList<QVariantMap> httpSync(const QUuid& uuid);
  80. bool exists(const ctkXnatObject* object);
  81. void save(ctkXnatObject* object);
  82. void remove(ctkXnatObject* object);
  83. void download(ctkXnatFile* file, const QString& fileName);
  84. // void downloadScanFiles(ctkXnatExperiment* experiment, const QString& zipFileName);
  85. // void downloadReconstructionFiles(ctkXnatExperiment* experiment, const QString& zipFileName);
  86. // void download(ctkXnatScan* scan, const QString& zipFileName);
  87. void download(ctkXnatScanResource* scanResource, const QString& zipFileName);
  88. void download(ctkXnatReconstructionResource* reconstructionResource, const QString& zipFileName);
  89. // void downloadReconstruction(ctkXnatReconstruction* reconstruction, const QString& zipFilename);
  90. // void downloadReconstructionResourceFiles(ctkXnatReconstructionResource* reconstructionResource, const QString& zipFilename);
  91. // void download(ctkXnatReconstructionResourceFile* reconstructionResourceFile, const QString& zipFileName);
  92. Q_SIGNAL void sessionRenewed(const QDateTime& expirationDate);
  93. public slots:
  94. void processResult(QUuid queryId, QList<QVariantMap> parameters);
  95. void progress(QUuid queryId, double progress);
  96. protected:
  97. QScopedPointer<ctkXnatSessionPrivate> d_ptr;
  98. private:
  99. Q_DECLARE_PRIVATE(ctkXnatSession)
  100. Q_DISABLE_COPY(ctkXnatSession)
  101. };
  102. #endif