changeset 525:451125122692 find-refactoring

created branch find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Jul 2024 13:59:27 +0200
parents 586b80ea397c
children 61338585e7f7
files Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/Plugins/IDatabaseBackend.h MySQL/Plugins/MySQLIndex.cpp MySQL/Plugins/MySQLIndex.h Odbc/Plugins/OdbcIndex.cpp Odbc/Plugins/OdbcIndex.h PostgreSQL/Plugins/PostgreSQLIndex.cpp PostgreSQL/Plugins/PostgreSQLIndex.h SQLite/Plugins/SQLiteIndex.cpp SQLite/Plugins/SQLiteIndex.h
diffstat 10 files changed, 146 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Thu Jun 06 14:43:38 2024 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Fri Jul 19 13:59:27 2024 +0200
@@ -439,6 +439,10 @@
         response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency());
 #endif
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+        response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport());
+#endif
+
         break;
       }
 
@@ -1298,6 +1302,12 @@
         break;
       }
       
+      case Orthanc::DatabasePluginMessages::OPERATION_FIND:
+      {
+        backend.ExecuteFind(response, manager, request.find());
+        break;
+      }
+
       default:
         LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation();
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
--- a/Framework/Plugins/IDatabaseBackend.h	Thu Jun 06 14:43:38 2024 +0200
+++ b/Framework/Plugins/IDatabaseBackend.h	Fri Jul 19 13:59:27 2024 +0200
@@ -32,6 +32,14 @@
 
 #include <list>
 
+#include <orthanc/OrthancCPlugin.h>
+
+#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
+#  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+#    include <OrthancDatabasePlugin.pb.h>  // Include protobuf messages for "Find()"
+#  endif
+#endif
+
 namespace OrthancDatabases
 {
   class IDatabaseBackend : public boost::noncopyable
@@ -377,6 +385,15 @@
     // New in Orthanc 1.12.3
     virtual uint64_t MeasureLatency(DatabaseManager& manager) = 0;
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual bool HasFindSupport() const = 0;
+#endif
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    // New in Orthanc 1.12.5
+    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                             DatabaseManager& manager,
+                             const Orthanc::DatabasePluginMessages::Find_Request& request) = 0;
+#endif
   };
 }
--- a/MySQL/Plugins/MySQLIndex.cpp	Thu Jun 06 14:43:38 2024 +0200
+++ b/MySQL/Plugins/MySQLIndex.cpp	Fri Jul 19 13:59:27 2024 +0200
@@ -593,4 +593,24 @@
     }   
   }
 #endif
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  bool MySQLIndex::HasFindSupport() const
+  {
+    // TODO-FIND
+    return false;
+  }
+#endif
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  void MySQLIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                               DatabaseManager& manager,
+                               const Orthanc::DatabasePluginMessages::Find_Request& request)
+  {
+    // TODO-FIND
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  }
+#endif
 }
--- a/MySQL/Plugins/MySQLIndex.h	Thu Jun 06 14:43:38 2024 +0200
+++ b/MySQL/Plugins/MySQLIndex.h	Fri Jul 19 13:59:27 2024 +0200
@@ -85,5 +85,15 @@
     {
       return true;
     }
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual bool HasFindSupport() const ORTHANC_OVERRIDE;
+#endif
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                             DatabaseManager& manager,
+                             const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+#endif
   };
 }
--- a/Odbc/Plugins/OdbcIndex.cpp	Thu Jun 06 14:43:38 2024 +0200
+++ b/Odbc/Plugins/OdbcIndex.cpp	Fri Jul 19 13:59:27 2024 +0200
@@ -695,4 +695,24 @@
 
     SignalDeletedFiles(output, manager);
   }
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  bool OdbcIndex::HasFindSupport() const
+  {
+    // TODO-FIND
+    return false;
+  }
+#endif
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  void OdbcIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                              DatabaseManager& manager,
+                              const Orthanc::DatabasePluginMessages::Find_Request& request)
+  {
+    // TODO-FIND
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  }
+#endif
 }
--- a/Odbc/Plugins/OdbcIndex.h	Thu Jun 06 14:43:38 2024 +0200
+++ b/Odbc/Plugins/OdbcIndex.h	Fri Jul 19 13:59:27 2024 +0200
@@ -92,5 +92,15 @@
     {
       return false;
     }
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual bool HasFindSupport() const ORTHANC_OVERRIDE;
+#endif
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                             DatabaseManager& manager,
+                             const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+#endif
   };
 }
--- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp	Thu Jun 06 14:43:38 2024 +0200
+++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp	Fri Jul 19 13:59:27 2024 +0200
@@ -659,4 +659,24 @@
     // backward compatibility is necessary
     throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);
   }
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  bool PostgreSQLIndex::HasFindSupport() const
+  {
+    // TODO-FIND
+    return false;
+  }
+#endif
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  void PostgreSQLIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                                    DatabaseManager& manager,
+                                    const Orthanc::DatabasePluginMessages::Find_Request& request)
+  {
+    // TODO-FIND
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  }
+#endif
 }
--- a/PostgreSQL/Plugins/PostgreSQLIndex.h	Thu Jun 06 14:43:38 2024 +0200
+++ b/PostgreSQL/Plugins/PostgreSQLIndex.h	Fri Jul 19 13:59:27 2024 +0200
@@ -135,5 +135,14 @@
                                         int64_t& compressedSize,
                                         int64_t& uncompressedSize) ORTHANC_OVERRIDE;
 
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual bool HasFindSupport() const ORTHANC_OVERRIDE;
+#endif
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                             DatabaseManager& manager,
+                             const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+#endif
   };
 }
--- a/SQLite/Plugins/SQLiteIndex.cpp	Thu Jun 06 14:43:38 2024 +0200
+++ b/SQLite/Plugins/SQLiteIndex.cpp	Fri Jul 19 13:59:27 2024 +0200
@@ -259,4 +259,24 @@
       }
     }
   }
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  bool SQLiteIndex::HasFindSupport() const
+  {
+    // TODO-FIND
+    return false;
+  }
+#endif
+
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+  void SQLiteIndex::ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                                DatabaseManager& manager,
+                                const Orthanc::DatabasePluginMessages::Find_Request& request)
+  {
+    // TODO-FIND
+    throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
+  }
+#endif
 }
--- a/SQLite/Plugins/SQLiteIndex.h	Thu Jun 06 14:43:38 2024 +0200
+++ b/SQLite/Plugins/SQLiteIndex.h	Fri Jul 19 13:59:27 2024 +0200
@@ -67,5 +67,15 @@
     {
       return true;
     }
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual bool HasFindSupport() const ORTHANC_OVERRIDE;
+#endif
+
+#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5)
+    virtual void ExecuteFind(Orthanc::DatabasePluginMessages::TransactionResponse& response,
+                             DatabaseManager& manager,
+                             const Orthanc::DatabasePluginMessages::Find_Request& request) ORTHANC_OVERRIDE;
+#endif
   };
 }