changeset 3121:f86ebf971a72 db-changes

fix unit tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 14 Jan 2019 16:23:08 +0100
parents a323b75e5b08
children c0d7aee8c3f8
files OrthancServer/Database/Compatibility/ICreateInstance.cpp OrthancServer/Database/Compatibility/ICreateInstance.h OrthancServer/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Database/SQLiteDatabaseWrapper.h Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Engine/OrthancPluginDatabase.h UnitTestsSources/ServerIndexTests.cpp
diffstat 7 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Database/Compatibility/ICreateInstance.cpp	Mon Jan 14 13:13:12 2019 +0100
+++ b/OrthancServer/Database/Compatibility/ICreateInstance.cpp	Mon Jan 14 16:23:08 2019 +0100
@@ -143,6 +143,8 @@
         database.AttachChild(result.patientId_, result.studyId_);
       }
 
+      database.TagAsMostRecentPatient(result.patientId_);
+      
       // Sanity checks
       assert(result.patientId_ != -1);
       assert(result.studyId_ != -1);
--- a/OrthancServer/Database/Compatibility/ICreateInstance.h	Mon Jan 14 13:13:12 2019 +0100
+++ b/OrthancServer/Database/Compatibility/ICreateInstance.h	Mon Jan 14 16:23:08 2019 +0100
@@ -51,6 +51,8 @@
 
       virtual void AttachChild(int64_t parent,
                                int64_t child) = 0;
+
+      virtual void TagAsMostRecentPatient(int64_t patientId) = 0;
       
       static bool Apply(ICreateInstance& database,
                         IDatabaseWrapper::CreateInstanceResult& result,
--- a/OrthancServer/Database/SQLiteDatabaseWrapper.cpp	Mon Jan 14 13:13:12 2019 +0100
+++ b/OrthancServer/Database/SQLiteDatabaseWrapper.cpp	Mon Jan 14 16:23:08 2019 +0100
@@ -330,7 +330,7 @@
 
 
   int SQLiteDatabaseWrapper::GetGlobalIntegerProperty(GlobalProperty property,
-                                                      unsigned int defaultValue)
+                                                      int defaultValue)
   {
     std::string tmp;
 
@@ -418,11 +418,6 @@
         }
       }
 
-      /*if (GetGlobalIntegerProperty(GlobalProperty_DatabasePatchLevel, 0) <= 0)
-      {
-        SetGlobalProperty(GlobalProperty_DatabasePatchLevel, "1");
-        }*/
-
       t.Commit();
     }
 
@@ -1326,4 +1321,10 @@
       return 0;
     }
   }
+
+
+  void SQLiteDatabaseWrapper::TagAsMostRecentPatient(int64_t patient)
+  {
+    // TODO
+  }
 }
--- a/OrthancServer/Database/SQLiteDatabaseWrapper.h	Mon Jan 14 13:13:12 2019 +0100
+++ b/OrthancServer/Database/SQLiteDatabaseWrapper.h	Mon Jan 14 16:23:08 2019 +0100
@@ -79,8 +79,9 @@
 
     void ClearTable(const std::string& tableName);
 
+    // Unused => could be removed
     int GetGlobalIntegerProperty(GlobalProperty property,
-                                 unsigned int defaultValue);
+                                 int defaultValue);
 
   public:
     SQLiteDatabaseWrapper(const std::string& path);
@@ -358,5 +359,7 @@
     }
 
     virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE;
+
+    virtual void TagAsMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE;
   };
 }
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Jan 14 13:13:12 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Jan 14 16:23:08 2019 +0100
@@ -1414,4 +1414,10 @@
       return result;
     }
   }
+
+  
+  void OrthancPluginDatabase::TagAsMostRecentPatient(int64_t patient)
+  {
+    // TODO
+  }
 }
--- a/Plugins/Engine/OrthancPluginDatabase.h	Mon Jan 14 13:13:12 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.h	Mon Jan 14 16:23:08 2019 +0100
@@ -362,6 +362,8 @@
       ORTHANC_OVERRIDE;
 
     virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE;
+  
+    virtual void TagAsMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE;
   };
 }
 
--- a/UnitTestsSources/ServerIndexTests.cpp	Mon Jan 14 13:13:12 2019 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Mon Jan 14 16:23:08 2019 +0100
@@ -395,7 +395,7 @@
 
   CheckTableRecordCount(0, "Resources");
   CheckTableRecordCount(0, "AttachedFiles");
-  CheckTableRecordCount(4, "GlobalProperties");  // 4 since 1.5.2 because of GlobalProperty_DatabasePatchLevel
+  CheckTableRecordCount(3, "GlobalProperties");
 
   std::string tmp;
   ASSERT_TRUE(index_->LookupGlobalProperty(tmp, GlobalProperty_DatabaseSchemaVersion));