changeset 1218:efece308018e

report database version in /system
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Nov 2014 15:58:13 +0100
parents 92ba9c7b431f
children c4ae92753d57
files OrthancServer/DatabaseWrapper.h OrthancServer/OrthancRestApi/OrthancRestSystem.cpp OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h UnitTestsSources/ServerIndexTests.cpp
diffstat 5 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.h	Tue Nov 04 16:09:35 2014 +0100
+++ b/OrthancServer/DatabaseWrapper.h	Thu Nov 06 15:58:13 2014 +0100
@@ -80,7 +80,7 @@
                               GlobalProperty property);
 
     std::string GetGlobalProperty(GlobalProperty property,
-                                  const std::string& defaultValue = "");
+                                  const std::string& defaultValue);
 
     int64_t CreateResource(const std::string& publicId,
                            ResourceType type);
--- a/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Tue Nov 04 16:09:35 2014 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestSystem.cpp	Thu Nov 06 15:58:13 2014 +0100
@@ -54,6 +54,7 @@
 
     result["Version"] = ORTHANC_VERSION;
     result["Name"] = Configuration::GetGlobalStringParameter("Name", "");
+    result["DatabaseVersion"] = boost::lexical_cast<int>(OrthancRestApi::GetIndex(call).GetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "0"));
 
     call.GetOutput().AnswerJson(result);
   }
--- a/OrthancServer/ServerIndex.cpp	Tue Nov 04 16:09:35 2014 +0100
+++ b/OrthancServer/ServerIndex.cpp	Thu Nov 06 15:58:13 2014 +0100
@@ -346,7 +346,7 @@
     try
     {
       boost::mutex::scoped_lock lock(that->mutex_);
-      std::string sleepString = that->db_->GetGlobalProperty(GlobalProperty_FlushSleep);
+      std::string sleepString = that->db_->GetGlobalProperty(GlobalProperty_FlushSleep, "");
 
       if (Toolbox::IsInteger(sleepString))
       {
@@ -1859,4 +1859,13 @@
 
     return true;
   }
+
+
+  std::string ServerIndex::GetGlobalProperty(GlobalProperty property,
+                                             const std::string& defaultValue)
+  {
+    boost::mutex::scoped_lock lock(mutex_);
+    return db_->GetGlobalProperty(property, defaultValue);
+  }
+
 }
--- a/OrthancServer/ServerIndex.h	Tue Nov 04 16:09:35 2014 +0100
+++ b/OrthancServer/ServerIndex.h	Thu Nov 06 15:58:13 2014 +0100
@@ -234,5 +234,8 @@
 
     void DeleteAttachment(const std::string& publicId,
                           FileContentType type);
+
+    std::string GetGlobalProperty(GlobalProperty property,
+                                  const std::string& defaultValue);
   };
 }
--- a/UnitTestsSources/ServerIndexTests.cpp	Tue Nov 04 16:09:35 2014 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Thu Nov 06 15:58:13 2014 +0100
@@ -274,7 +274,7 @@
   ASSERT_TRUE(index_->LookupGlobalProperty(s, GlobalProperty_FlushSleep));
   ASSERT_FALSE(index_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42)));
   ASSERT_EQ("World", s);
-  ASSERT_EQ("World", index_->GetGlobalProperty(GlobalProperty_FlushSleep));
+  ASSERT_EQ("World", index_->GetGlobalProperty(GlobalProperty_FlushSleep, ""));
   ASSERT_EQ("None", index_->GetGlobalProperty(static_cast<GlobalProperty>(42), "None"));
 
   FileInfo att;