diff Plugins/Samples/DatabasePlugin/Database.cpp @ 1673:0bbcfd9695e5 db-changes

UpgradeDatabase in the sample plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Oct 2015 13:26:05 +0200
parents 4c5a85c3ff43
children 3926e6317a43
line wrap: on
line diff
--- a/Plugins/Samples/DatabasePlugin/Database.cpp	Fri Oct 02 12:20:49 2015 +0200
+++ b/Plugins/Samples/DatabasePlugin/Database.cpp	Fri Oct 02 13:26:05 2015 +0200
@@ -540,4 +540,21 @@
 void Database::UpgradeDatabase(uint32_t  targetVersion,
                                OrthancPluginStorageArea* storageArea)
 {
+  if (targetVersion == 6)
+  {
+    OrthancPluginErrorCode code = OrthancPluginReconstructMainDicomTags(GetOutput().GetContext(), storageArea, 
+                                                                        OrthancPluginResourceType_Study);
+    if (code == OrthancPluginErrorCode_Success)
+    {
+      code = OrthancPluginReconstructMainDicomTags(GetOutput().GetContext(), storageArea, 
+                                                   OrthancPluginResourceType_Series);
+    }
+
+    if (code != OrthancPluginErrorCode_Success)
+    {
+      throw OrthancPlugins::DatabaseException(code);
+    }
+
+    base_.SetGlobalProperty(Orthanc::GlobalProperty_DatabaseSchemaVersion, "6");
+  }
 }