# HG changeset patch # User Alain Mazy # Date 1725629493 -7200 # Node ID 25cfcb752af688cc1d8f5ec9a6cd14d5fe2e64ce # Parent 48aba35fe64e786ab56dc89c66bf9929b4ac3529# Parent 61338585e7f7a8bcf05e1bbe23fe1d47a2fe8ba1 merged find-refactoring -> large-queries diff -r 48aba35fe64e -r 25cfcb752af6 Framework/Common/DatabaseManager.cpp --- a/Framework/Common/DatabaseManager.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/Framework/Common/DatabaseManager.cpp Fri Sep 06 15:31:33 2024 +0200 @@ -663,13 +663,11 @@ statement_.reset(GetManager().GetDatabase().Compile(*query)); assert(statement_.get() != NULL); + std::unique_ptr result(GetTransaction().Execute(*statement_, parameters)); + if (withResults) { - SetResult(GetTransaction().Execute(*statement_, parameters)); - } - else - { - GetTransaction().Execute(*statement_, parameters); + SetResult(result.release()); } } catch (Orthanc::OrthancException& e) diff -r 48aba35fe64e -r 25cfcb752af6 Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Fri Sep 06 15:31:33 2024 +0200 @@ -439,9 +439,11 @@ response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency()); #endif -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 13, 0) - response.mutable_get_system_information()->set_has_extended_api_v1(accessor.GetBackend().HasExtendedApiV1()); +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) + response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport()); + response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges()); #endif + break; } @@ -786,15 +788,15 @@ response.mutable_get_changes()->set_done(done); break; } -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 13, 0) - case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_2: +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) + case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED: { Output output(*response.mutable_get_changes()); bool done; - backend.GetChanges2(output, done, manager, request.get_changes2().since(), request.get_changes2().to(), static_cast(request.get_changes2().change_type()), request.get_changes2().limit()); + backend.GetChangesExtended(output, done, manager, request.get_changes_extended().since(), request.get_changes_extended().to(), static_cast(request.get_changes_extended().change_type()), request.get_changes_extended().limit()); - response.mutable_get_changes()->set_done(done); + response.mutable_get_changes_extended()->set_done(done); break; } #endif @@ -1313,6 +1315,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); diff -r 48aba35fe64e -r 25cfcb752af6 Framework/Plugins/IDatabaseBackend.h --- a/Framework/Plugins/IDatabaseBackend.h Tue Jul 09 16:30:52 2024 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Fri Sep 06 15:31:33 2024 +0200 @@ -32,6 +32,14 @@ #include +#include + +#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 +# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) +# include // Include protobuf messages for "Find()" +# endif +#endif + namespace OrthancDatabases { class IDatabaseBackend : public boost::noncopyable @@ -110,13 +118,13 @@ int64_t since, uint32_t limit) = 0; - virtual void GetChanges2(IDatabaseBackendOutput& output, - bool& done /*out*/, - DatabaseManager& manager, - int64_t since, - int64_t to, - int32_t changeType, - uint32_t limit) = 0; + virtual void GetChangesExtended(IDatabaseBackendOutput& output, + bool& done /*out*/, + DatabaseManager& manager, + int64_t since, + int64_t to, + int32_t changeType, + uint32_t limit) = 0; virtual void GetChildrenInternalId(std::list& target /*out*/, DatabaseManager& manager, @@ -385,8 +393,16 @@ // New in Orthanc 1.12.3 virtual uint64_t MeasureLatency(DatabaseManager& manager) = 0; - // New in Orthanc 1.13.0 - virtual bool HasExtendedApiV1() = 0; +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) + virtual bool HasFindSupport() const = 0; + virtual bool HasExtendedChanges() 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 }; } diff -r 48aba35fe64e -r 25cfcb752af6 Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Fri Sep 06 15:31:33 2024 +0200 @@ -592,21 +592,21 @@ int64_t since, uint32_t limit) { -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 13, 0) - GetChanges2(output, done, manager, since, -1, _OrthancPluginChangeType_All, limit); +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) + GetChangesExtended(output, done, manager, since, -1, _OrthancPluginChangeType_All, limit); #else - GetChanges2(output, done, manager, since, -1, 65535, limit); + GetChangesExtended(output, done, manager, since, -1, 65535, limit); #endif } /* Use GetOutput().AnswerChange() */ - void IndexBackend::GetChanges2(IDatabaseBackendOutput& output, - bool& done /*out*/, - DatabaseManager& manager, - int64_t since, - int64_t to, - int32_t changeType, - uint32_t limit) + void IndexBackend::GetChangesExtended(IDatabaseBackendOutput& output, + bool& done /*out*/, + DatabaseManager& manager, + int64_t since, + int64_t to, + int32_t changeType, + uint32_t limit) { std::string limitSuffix; if (manager.GetDialect() == Dialect_MSSQL) diff -r 48aba35fe64e -r 25cfcb752af6 Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Tue Jul 09 16:30:52 2024 +0200 +++ b/Framework/Plugins/IndexBackend.h Fri Sep 06 15:31:33 2024 +0200 @@ -132,13 +132,13 @@ int64_t since, uint32_t limit) ORTHANC_OVERRIDE; - virtual void GetChanges2(IDatabaseBackendOutput& output, - bool& done /*out*/, - DatabaseManager& manager, - int64_t since, - int64_t to, - int32_t changeType, - uint32_t limit) ORTHANC_OVERRIDE; + virtual void GetChangesExtended(IDatabaseBackendOutput& output, + bool& done /*out*/, + DatabaseManager& manager, + int64_t since, + int64_t to, + int32_t changeType, + uint32_t limit) ORTHANC_OVERRIDE; virtual void GetChildrenInternalId(std::list& target /*out*/, DatabaseManager& manager, @@ -429,8 +429,8 @@ virtual uint64_t MeasureLatency(DatabaseManager& manager) ORTHANC_OVERRIDE; - // New primitive since Orthanc 1.13.0 - virtual bool HasExtendedApiV1() ORTHANC_OVERRIDE + // New primitive since Orthanc 1.12.5 + virtual bool HasExtendedChanges() const ORTHANC_OVERRIDE { return true; } diff -r 48aba35fe64e -r 25cfcb752af6 MySQL/Plugins/MySQLIndex.cpp --- a/MySQL/Plugins/MySQLIndex.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/MySQL/Plugins/MySQLIndex.cpp Fri Sep 06 15:31:33 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 } diff -r 48aba35fe64e -r 25cfcb752af6 MySQL/Plugins/MySQLIndex.h --- a/MySQL/Plugins/MySQLIndex.h Tue Jul 09 16:30:52 2024 +0200 +++ b/MySQL/Plugins/MySQLIndex.h Fri Sep 06 15:31:33 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 }; } diff -r 48aba35fe64e -r 25cfcb752af6 Odbc/Plugins/OdbcIndex.cpp --- a/Odbc/Plugins/OdbcIndex.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/Odbc/Plugins/OdbcIndex.cpp Fri Sep 06 15:31:33 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 } diff -r 48aba35fe64e -r 25cfcb752af6 Odbc/Plugins/OdbcIndex.h --- a/Odbc/Plugins/OdbcIndex.h Tue Jul 09 16:30:52 2024 +0200 +++ b/Odbc/Plugins/OdbcIndex.h Fri Sep 06 15:31:33 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 }; } diff -r 48aba35fe64e -r 25cfcb752af6 PostgreSQL/Plugins/PostgreSQLIndex.cpp --- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp Fri Sep 06 15:31:33 2024 +0200 @@ -682,4 +682,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 } diff -r 48aba35fe64e -r 25cfcb752af6 PostgreSQL/Plugins/PostgreSQLIndex.h --- a/PostgreSQL/Plugins/PostgreSQLIndex.h Tue Jul 09 16:30:52 2024 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.h Fri Sep 06 15:31:33 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 }; } diff -r 48aba35fe64e -r 25cfcb752af6 SQLite/Plugins/SQLiteIndex.cpp --- a/SQLite/Plugins/SQLiteIndex.cpp Tue Jul 09 16:30:52 2024 +0200 +++ b/SQLite/Plugins/SQLiteIndex.cpp Fri Sep 06 15:31:33 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 } diff -r 48aba35fe64e -r 25cfcb752af6 SQLite/Plugins/SQLiteIndex.h --- a/SQLite/Plugins/SQLiteIndex.h Tue Jul 09 16:30:52 2024 +0200 +++ b/SQLite/Plugins/SQLiteIndex.h Fri Sep 06 15:31:33 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 }; }