diff OrthancServer/ServerIndex.cpp @ 190:b6cef9d45cc3

getallpublicids
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Nov 2012 11:20:50 +0100
parents ccbc2cf64a0d
children bff0b77b02fa
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp	Mon Nov 12 18:03:48 2012 +0100
+++ b/OrthancServer/ServerIndex.cpp	Tue Nov 13 11:20:50 2012 +0100
@@ -537,13 +537,14 @@
         return StoreStatus_AlreadyStored;
       }
 
-      // Create the patient/study/series/instance hierarchy
+      // Create the instance
       instance = db2_->CreateResource(hasher.HashInstance(), ResourceType_Instance);
 
       DicomMap dicom;
       dicomSummary.ExtractInstanceInformation(dicom);
       db2_->SetMainDicomTags(instance, dicom);
 
+      // Create the patient/study/series/instance hierarchy
       if (!db2_->LookupResource(hasher.HashSeries(), series, type))
       {
         // This is a new series
@@ -980,10 +981,35 @@
 
 
   void ServerIndex::GetAllUuids(Json::Value& target,
-                                const std::string& tableName)
+                                ResourceType resourceType)
   {
+    boost::mutex::scoped_lock scoped_lock(mutex_);
+
+    std::string tableName;
+
+    switch (resourceType)
+    {
+    case ResourceType_Patient:
+      tableName = "Patients";
+      break;
+
+    case ResourceType_Study:
+      tableName = "Studies";
+      break;
+
+    case ResourceType_Series:
+      tableName = "Series";
+      break;
+
+    case ResourceType_Instance:
+      tableName = "Instances";
+      break;
+
+    default:
+      throw OrthancException(ErrorCode_InternalError);
+    }
+
     assert(target.type() == Json::arrayValue);
-    boost::mutex::scoped_lock scoped_lock(mutex_);
 
     std::string query = "SELECT uuid FROM " + tableName;
     SQLite::Statement s(db_, query);