Ver código fonte

Merge branch 'fix-xnat-resource-reconstruction-handling'

* fix-xnat-resource-reconstruction-handling:
  Fix unused parameter warning.
  Cleanup
  Fixed reconstruction to diplay content properly
  Added support for resources for all levels of the xnat data hierachy
Sascha Zelzer 11 anos atrás
pai
commit
dac347bd8c

+ 1 - 0
Libs/XNAT/Core/CMakeLists.txt

@@ -21,6 +21,7 @@ set(KIT_SRCS
   ctkXnatReconstruction.cpp
   ctkXnatReconstructionFolder.cpp
   ctkXnatReconstructionResource.cpp
+  ctkXnatResource.cpp
   ctkXnatScan.cpp
   ctkXnatScanFolder.cpp
   ctkXnatScanResource.cpp

+ 1 - 0
Libs/XNAT/Core/ctkXnatDefaultSchemaTypes.cpp

@@ -29,3 +29,4 @@ QString ctkXnatDefaultSchemaTypes::XSI_RECONSTRUCTION_RESOURCE = "xnat:reconstru
 QString ctkXnatDefaultSchemaTypes::XSI_SCAN = "xnat:imageScanData";
 QString ctkXnatDefaultSchemaTypes::XSI_SCAN_RESOURCE = "xnat:scanResource";
 QString ctkXnatDefaultSchemaTypes::XSI_SUBJECT = "xnat:subjectData";
+QString ctkXnatDefaultSchemaTypes::XSI_RESOURCE = "xnat:resource";

+ 1 - 0
Libs/XNAT/Core/ctkXnatDefaultSchemaTypes.h

@@ -39,6 +39,7 @@ struct CTK_XNAT_CORE_EXPORT ctkXnatDefaultSchemaTypes
   static QString XSI_SCAN; // = "xnat:imageScanData"
   static QString XSI_SCAN_RESOURCE; // = "xnat:scanResource"
   static QString XSI_SUBJECT; // = "xnat:subjectData"
+  static QString XSI_RESOURCE; // = "xnat:resource"
 };
 
 #endif // CTKXNATDEFAULTSCHEMATYPES_H

+ 1 - 0
Libs/XNAT/Core/ctkXnatExperiment.cpp

@@ -99,4 +99,5 @@ void ctkXnatExperiment::fetchImpl()
     ctkXnatReconstructionFolder* reconstructionFolder = new ctkXnatReconstructionFolder();
     this->add(reconstructionFolder);
   }
+  this->fetchResources();
 }

+ 23 - 1
Libs/XNAT/Core/ctkXnatObject.cpp

@@ -22,8 +22,9 @@
 #include "ctkXnatObject.h"
 #include "ctkXnatObjectPrivate.h"
 
-#include "ctkXnatSession.h"
 #include "ctkXnatDataModel.h"
+#include "ctkXnatSession.h"
+#include "ctkXnatDefaultSchemaTypes.h"
 
 #include <QDateTime>
 #include <QDebug>
@@ -311,6 +312,27 @@ void ctkXnatObject::save()
 }
 
 //----------------------------------------------------------------------------
+void ctkXnatObject::fetchResources()
+{
+  QString query = this->resourceUri() + "/resources";
+  ctkXnatSession* const session = this->session();
+  QUuid queryId = session->httpGet(query);
+
+  QList<ctkXnatObject*> resources = session->httpResults(queryId,
+                                                           ctkXnatDefaultSchemaTypes::XSI_RESOURCE);
+
+  foreach (ctkXnatObject* resource, resources)
+  {
+    QString label = resource->property("label");
+    if (!label.isEmpty())
+    {
+      resource->setProperty("ID", label);
+    }
+    this->add(resource);
+  }
+}
+
+//----------------------------------------------------------------------------
 void ctkXnatObject::erase()
 {
   this->session()->remove(this);

+ 3 - 0
Libs/XNAT/Core/ctkXnatObject.h

@@ -126,6 +126,9 @@ public:
   /// Deletes the object on the XNAT server and removes it from its parent.
   void erase();
 
+  /// Fetches the resources of the object
+  virtual void fetchResources();
+
   virtual void download(const QString&);
   virtual void upload(const QString&);
 

+ 1 - 0
Libs/XNAT/Core/ctkXnatProject.cpp

@@ -157,4 +157,5 @@ void ctkXnatProject::fetchImpl()
 
     this->add(subject);
   }
+  this->fetchResources();
 }

+ 4 - 4
Libs/XNAT/Core/ctkXnatReconstruction.cpp

@@ -61,7 +61,7 @@ ctkXnatReconstruction::~ctkXnatReconstruction()
 //----------------------------------------------------------------------------
 QString ctkXnatReconstruction::resourceUri() const
 {
-  return QString("%1/reconstructions/%2").arg(parent()->resourceUri(), this->id());
+  return QString("%1/%2").arg(parent()->resourceUri(), this->id());
 }
 
 //----------------------------------------------------------------------------
@@ -73,16 +73,16 @@ void ctkXnatReconstruction::reset()
 //----------------------------------------------------------------------------
 void ctkXnatReconstruction::fetchImpl()
 {
-  QString reconstructionResourcesUri = this->resourceUri() + "/resources";
+  QString reconstructionResourcesUri = this->resourceUri() + "/files";
   ctkXnatSession* const session = this->session();
   QUuid queryId = session->httpGet(reconstructionResourcesUri);
 
   QList<ctkXnatObject*> reconstructionResources = session->httpResults(queryId,
-                                                                       ctkXnatDefaultSchemaTypes::XSI_RECONSTRUCTION_RESOURCE);
+                                                                       ctkXnatDefaultSchemaTypes::XSI_FILE);
 
   foreach (ctkXnatObject* reconstructionResource, reconstructionResources)
   {
-    QString label = reconstructionResource->property("label");
+    QString label = reconstructionResource->property("Name");
     if (!label.isEmpty())
     {
       reconstructionResource->setProperty("ID", label);

+ 88 - 0
Libs/XNAT/Core/ctkXnatResource.cpp

@@ -0,0 +1,88 @@
+/*=============================================================================
+
+  Library: XNAT/Core
+
+  Copyright (c) University College London,
+    Centre for Medical Image Computing
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkXnatResource.h"
+
+#include "ctkXnatSession.h"
+#include "ctkXnatObjectPrivate.h"
+
+//----------------------------------------------------------------------------
+class ctkXnatResourcePrivate : public ctkXnatObjectPrivate
+{
+public:
+
+  ctkXnatResourcePrivate()
+  : ctkXnatObjectPrivate()
+  {
+  }
+
+};
+
+
+//----------------------------------------------------------------------------
+ctkXnatResource::ctkXnatResource(ctkXnatObject* parent, const QString& schemaType)
+: ctkXnatObject(*new ctkXnatResourcePrivate(), parent, schemaType)
+{
+}
+
+//----------------------------------------------------------------------------
+ctkXnatResource::~ctkXnatResource()
+{
+}
+
+//----------------------------------------------------------------------------
+QString ctkXnatResource::resourceUri() const
+{
+  return QString("%1/resources/%2").arg(parent()->resourceUri(), this->property("label"));
+}
+
+//----------------------------------------------------------------------------
+void ctkXnatResource::reset()
+{
+  ctkXnatObject::reset();
+}
+
+//----------------------------------------------------------------------------
+void ctkXnatResource::fetchImpl()
+{
+  QString resourceFilesUri = this->resourceUri() + "/files";
+  ctkXnatSession* const session = this->session();
+  QUuid queryId = session->httpGet(resourceFilesUri);
+
+  QList<ctkXnatObject*> files = session->httpResults(queryId,
+                                                     ctkXnatDefaultSchemaTypes::XSI_FILE);
+
+  foreach (ctkXnatObject* file, files)
+  {
+    QString label = file->property("Name");
+    if (!label.isEmpty())
+    {
+      file->setProperty("ID", label);
+    }
+    this->add(file);
+  }
+}
+
+//----------------------------------------------------------------------------
+void ctkXnatResource::download(const QString& /*filename*/)
+{
+//  this->session()->download(this, filename);
+}

+ 60 - 0
Libs/XNAT/Core/ctkXnatResource.h

@@ -0,0 +1,60 @@
+/*=============================================================================
+
+  Library: XNAT/Core
+
+  Copyright (c) University College London,
+    Centre for Medical Image Computing
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef ctkXnatResource_h
+#define ctkXnatResource_h
+
+#include "ctkXNATCoreExport.h"
+
+#include "ctkXnatObject.h"
+#include "ctkXnatDefaultSchemaTypes.h"
+
+class ctkXnatResourcePrivate;
+
+/**
+ * @ingroup XNAT_Core
+ */
+class CTK_XNAT_CORE_EXPORT ctkXnatResource : public ctkXnatObject
+{
+
+public:
+
+  ctkXnatResource(ctkXnatObject* parent = 0,
+                      const QString& schemaType = ctkXnatDefaultSchemaTypes::XSI_RESOURCE);
+
+  virtual ~ctkXnatResource();
+
+  QString resourceUri() const;
+
+  void reset();
+
+  void download(const QString& filename);
+
+private:
+
+  friend class qRestResult;
+  virtual void fetchImpl();
+
+  Q_DECLARE_PRIVATE(ctkXnatResource)
+
+};
+
+#endif

+ 2 - 0
Libs/XNAT/Core/ctkXnatSession.cpp

@@ -31,6 +31,7 @@
 #include "ctkXnatReconstruction.h"
 #include "ctkXnatReconstructionFolder.h"
 #include "ctkXnatReconstructionResource.h"
+#include "ctkXnatResource.h"
 #include "ctkXnatScan.h"
 #include "ctkXnatScanFolder.h"
 #include "ctkXnatScanResource.h"
@@ -319,6 +320,7 @@ ctkXnatSession::ctkXnatSession(const ctkXnatLoginProfile& loginProfile)
   qRegisterMetaType<ctkXnatScanResource>(qPrintable(ctkXnatDefaultSchemaTypes::XSI_SCAN_RESOURCE));
   qRegisterMetaType<ctkXnatFile>(qPrintable(ctkXnatDefaultSchemaTypes::XSI_FILE));
   qRegisterMetaType<ctkXnatReconstructionResource>(qPrintable(ctkXnatDefaultSchemaTypes::XSI_RECONSTRUCTION_RESOURCE));
+  qRegisterMetaType<ctkXnatResource>(qPrintable(ctkXnatDefaultSchemaTypes::XSI_RESOURCE));
 
   QString url = d->loginProfile.serverUrl().toString();
   d->xnat->setServerUrl(url);

+ 1 - 0
Libs/XNAT/Core/ctkXnatSubject.cpp

@@ -127,4 +127,5 @@ void ctkXnatSubject::fetchImpl()
 
     this->add(experiment);
   }
+  this->fetchResources();
 }