changeset 264:7ec412af11cb

implementation of "hasRevisionsSupport" primitive in database SDK
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Apr 2021 15:56:22 +0200
parents 29d2b76516f6
children cd73e34d5411
files Framework/Plugins/DatabaseBackendAdapterV3.cpp
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Apr 20 15:08:09 2021 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Tue Apr 20 15:56:22 2021 +0200
@@ -1041,6 +1041,21 @@
   }
 
 
+  static OrthancPluginErrorCode HasRevisionsSupport(void* database,
+                                                    uint8_t* target)
+  {
+    DatabaseBackendAdapterV3::Adapter* adapter = reinterpret_cast<DatabaseBackendAdapterV3::Adapter*>(database);
+      
+    try
+    {
+      DatabaseBackendAdapterV3::Adapter::DatabaseAccessor accessor(*adapter);
+      *target = (accessor.GetBackend().HasRevisionsSupport() ? 1 : 0);
+      return OrthancPluginErrorCode_Success;
+    }
+    ORTHANC_PLUGINS_DATABASE_CATCH(adapter->GetContext());
+  }
+
+
   static OrthancPluginErrorCode StartTransaction(void* database,
                                                  OrthancPluginDatabaseTransaction** target /* out */,
                                                  OrthancPluginDatabaseTransactionType type)
@@ -2004,6 +2019,7 @@
     params.destructDatabase = DestructDatabase;
     params.getDatabaseVersion = GetDatabaseVersion;
     params.upgradeDatabase = UpgradeDatabase;
+    params.hasRevisionsSupport = HasRevisionsSupport;
     params.startTransaction = StartTransaction;
     params.destructTransaction = DestructTransaction;
     params.rollback = Rollback;
@@ -2063,15 +2079,6 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend");
     }
 
-    if (backend->HasRevisionsSupport())
-    {
-      LOG(INFO) << "The database backend *has* support for revisions of metadata and attachments";
-    }
-    else
-    {
-      LOG(WARNING) << "The database backend has *no* support for revisions of metadata and attachments";
-    }
-
     backend->SetOutputFactory(new Factory);
 
     isBackendInUse_ = true;