# HG changeset patch # User Sebastien Jodogne # Date 1680690664 -7200 # Node ID d941568543a0cf260e49e2963b3b84c53e218e67 # Parent d14e6ff04a5cfdd57dfb5c7dcd57da980a6a7d54# Parent 743cf36fb051b990ecb08d07faf14e1fda214a13 integration mainline->db-protobuf diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/DatabaseBackendAdapterV2.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV2.cpp Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV2.cpp Wed Apr 05 12:31:04 2023 +0200 @@ -1419,7 +1419,10 @@ lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); } - adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, limit, (requestSomeInstance != 0)); + std::set noLabels; + adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, + noLabels, noLabels, limit, (requestSomeInstance != 0)); + return OrthancPluginErrorCode_Success; } ORTHANC_PLUGINS_DATABASE_CATCH; diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/DatabaseBackendAdapterV3.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp Wed Apr 05 12:31:04 2023 +0200 @@ -1646,7 +1646,9 @@ lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); } - t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, limit, (requestSomeInstanceId != 0)); + std::set noLabels; + t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, + noLabels, noLabels, limit, (requestSomeInstanceId != 0)); return OrthancPluginErrorCode_Success; } ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Apr 05 12:31:04 2023 +0200 @@ -567,9 +567,21 @@ assert(values.size() == countValues); + std::set withLabels, withoutLabels; + + for (int i = 0; i < request.with_labels().size(); i++) + { + withLabels.insert(request.with_labels(i)); + } + + for (int i = 0; i < request.without_labels().size(); i++) + { + withoutLabels.insert(request.without_labels(i)); + } + Output output(response); backend.LookupResources(output, manager, lookup, Convert(request.query_level()), - request.limit(), request.retrieve_instances_ids()); + withLabels, withoutLabels, request.limit(), request.retrieve_instances_ids()); } diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/IDatabaseBackend.h --- a/Framework/Plugins/IDatabaseBackend.h Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Wed Apr 05 12:31:04 2023 +0200 @@ -271,6 +271,8 @@ DatabaseManager& manager, const std::vector& lookup, OrthancPluginResourceType queryLevel, + const std::set& withLabels, // New in Orthanc 1.12.0 + const std::set& withoutLabels, // New in Orthanc 1.12.0 uint32_t limit, bool requestSomeInstance) = 0; #endif @@ -307,23 +309,30 @@ virtual void TagMostRecentPatient(DatabaseManager& manager, int64_t patientId) = 0; -#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 -# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) // NB: "parentPublicId" must be cleared if the resource has no parent virtual bool LookupResourceAndParent(int64_t& id, OrthancPluginResourceType& type, std::string& parentPublicId, DatabaseManager& manager, const char* publicId) = 0; -# endif -#endif -#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 -# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) virtual void GetAllMetadata(std::map& result, DatabaseManager& manager, int64_t id) = 0; -# endif -#endif + + // New in Orthanc 1.12.0 + virtual bool HasLabelsSupport() const = 0; + + // New in Orthanc 1.12.0 + virtual void AddLabel(int64_t resource, + const std::string& label) = 0; + + // New in Orthanc 1.12.0 + virtual void RemoveLabel(int64_t resource, + const std::string& label) = 0; + + // New in Orthanc 1.12.0 + virtual void ListLabels(std::set& target, + int64_t resource) = 0; }; } diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Wed Apr 05 12:31:04 2023 +0200 @@ -2065,9 +2065,17 @@ DatabaseManager& manager, const std::vector& lookup, OrthancPluginResourceType queryLevel, + const std::set& withLabels, + const std::set& withoutLabels, uint32_t limit, bool requestSomeInstance) { + if (!withLabels.empty() || + !withoutLabels.empty()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + } + LookupFormatter formatter(manager.GetDialect()); std::string sql; @@ -2609,6 +2617,27 @@ #endif + void IndexBackend::AddLabel(int64_t resource, + const std::string& label) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + } + + + void IndexBackend::RemoveLabel(int64_t resource, + const std::string& label) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + } + + + void IndexBackend::ListLabels(std::set& target, + int64_t resource) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); + } + + void IndexBackend::Register(IndexBackend* backend, size_t countConnections, unsigned int maxDatabaseRetries) diff -r 743cf36fb051 -r d941568543a0 Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Wed Apr 05 12:29:40 2023 +0200 +++ b/Framework/Plugins/IndexBackend.h Wed Apr 05 12:31:04 2023 +0200 @@ -302,6 +302,8 @@ DatabaseManager& manager, const std::vector& lookup, OrthancPluginResourceType queryLevel, + const std::set& withLabels, + const std::set& withoutLabels, uint32_t limit, bool requestSomeInstance) ORTHANC_OVERRIDE; #endif @@ -327,25 +329,17 @@ virtual void TagMostRecentPatient(DatabaseManager& manager, int64_t patient) ORTHANC_OVERRIDE; -#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 -# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) // New primitive since Orthanc 1.5.4 virtual bool LookupResourceAndParent(int64_t& id, OrthancPluginResourceType& type, std::string& parentPublicId, DatabaseManager& manager, const char* publicId) ORTHANC_OVERRIDE; -# endif -#endif -#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 -# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) // New primitive since Orthanc 1.5.4 virtual void GetAllMetadata(std::map& result, DatabaseManager& manager, int64_t id) ORTHANC_OVERRIDE; -# endif -#endif virtual bool HasCreateInstance() const ORTHANC_OVERRIDE { @@ -387,6 +381,15 @@ int32_t property, int value); + virtual void AddLabel(int64_t resource, + const std::string& label) ORTHANC_OVERRIDE; + + virtual void RemoveLabel(int64_t resource, + const std::string& label) ORTHANC_OVERRIDE; + + virtual void ListLabels(std::set& target, + int64_t resource) ORTHANC_OVERRIDE; + /** * "maxDatabaseRetries" is to handle * "OrthancPluginErrorCode_DatabaseCannotSerialize" if there is a diff -r 743cf36fb051 -r d941568543a0 MySQL/Plugins/MySQLIndex.h --- a/MySQL/Plugins/MySQLIndex.h Wed Apr 05 12:29:40 2023 +0200 +++ b/MySQL/Plugins/MySQLIndex.h Wed Apr 05 12:31:04 2023 +0200 @@ -76,5 +76,11 @@ const char* hashInstance) ORTHANC_OVERRIDE; #endif + + // New primitive since Orthanc 1.12.0 + virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE + { + return false; + } }; } diff -r 743cf36fb051 -r d941568543a0 Odbc/CMakeLists.txt --- a/Odbc/CMakeLists.txt Wed Apr 05 12:29:40 2023 +0200 +++ b/Odbc/CMakeLists.txt Wed Apr 05 12:31:04 2023 +0200 @@ -24,14 +24,14 @@ set(ORTHANC_PLUGIN_VERSION "mainline") set(ORTHANC_OPTIMAL_VERSION_MAJOR 1) -set(ORTHANC_OPTIMAL_VERSION_MINOR 9) -set(ORTHANC_OPTIMAL_VERSION_REVISION 2) +set(ORTHANC_OPTIMAL_VERSION_MINOR 12) +set(ORTHANC_OPTIMAL_VERSION_REVISION 0) if (ORTHANC_PLUGIN_VERSION STREQUAL "mainline") set(ORTHANC_FRAMEWORK_VERSION "mainline") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "hg") else() - set(ORTHANC_FRAMEWORK_VERSION "1.9.6") + set(ORTHANC_FRAMEWORK_VERSION "1.12.0") set(ORTHANC_FRAMEWORK_DEFAULT_SOURCE "web") endif() @@ -79,6 +79,23 @@ ODBC_PREPARE_STORAGE ${CMAKE_SOURCE_DIR}/Plugins/PrepareStorage.sql ) +if (EXISTS ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto) + add_custom_command( + COMMAND + ${PROTOC_EXECUTABLE} ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto --cpp_out=${AUTOGENERATED_DIR} -I${ORTHANC_SDK_ROOT}/orthanc/ + DEPENDS + ProtobufCompiler + ${ORTHANC_SDK_ROOT}/orthanc/OrthancDatabasePlugin.proto + OUTPUT + ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc + ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.h + ) + + list(APPEND AUTOGENERATED_SOURCES + ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc + ) +endif() + add_custom_target( AutogeneratedTarget DEPENDS diff -r 743cf36fb051 -r d941568543a0 Odbc/NEWS --- a/Odbc/NEWS Wed Apr 05 12:29:40 2023 +0200 +++ b/Odbc/NEWS Wed Apr 05 12:31:04 2023 +0200 @@ -1,6 +1,9 @@ Pending changes in the mainline =============================== +* Compatibility with Orthanc SDK 1.12.0 (communications between the + Orthanc core and the database plugin using Google Protocol Buffers) + Release 1.1 (2021-12-06) ======================== diff -r 743cf36fb051 -r d941568543a0 Odbc/Plugins/IndexPlugin.cpp --- a/Odbc/Plugins/IndexPlugin.cpp Wed Apr 05 12:29:40 2023 +0200 +++ b/Odbc/Plugins/IndexPlugin.cpp Wed Apr 05 12:31:04 2023 +0200 @@ -42,6 +42,9 @@ #endif +#include + + static const char* const KEY_ODBC = "Odbc"; @@ -54,6 +57,8 @@ ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) { + GOOGLE_PROTOBUF_VERIFY_VERSION; + if (!OrthancDatabases::InitializePlugin(context, "ODBC", true)) { return -1; @@ -130,6 +135,7 @@ { LOG(WARNING) << "ODBC index is finalizing"; OrthancDatabases::IndexBackend::Finalize(); + google::protobuf::ShutdownProtobufLibrary(); } diff -r 743cf36fb051 -r d941568543a0 Odbc/Plugins/OdbcIndex.h --- a/Odbc/Plugins/OdbcIndex.h Wed Apr 05 12:29:40 2023 +0200 +++ b/Odbc/Plugins/OdbcIndex.h Wed Apr 05 12:31:04 2023 +0200 @@ -83,5 +83,11 @@ DatabaseManager& manager, int64_t id, int32_t attachment) ORTHANC_OVERRIDE; + + // New primitive since Orthanc 1.12.0 + virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE + { + return false; + } }; } diff -r 743cf36fb051 -r d941568543a0 PostgreSQL/Plugins/PostgreSQLIndex.h --- a/PostgreSQL/Plugins/PostgreSQLIndex.h Wed Apr 05 12:29:40 2023 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.h Wed Apr 05 12:31:04 2023 +0200 @@ -82,5 +82,11 @@ virtual void TagMostRecentPatient(DatabaseManager& manager, int64_t patient) ORTHANC_OVERRIDE; + + // New primitive since Orthanc 1.12.0 + virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE + { + return false; + } }; } diff -r 743cf36fb051 -r d941568543a0 SQLite/Plugins/SQLiteIndex.h --- a/SQLite/Plugins/SQLiteIndex.h Wed Apr 05 12:29:40 2023 +0200 +++ b/SQLite/Plugins/SQLiteIndex.h Wed Apr 05 12:31:04 2023 +0200 @@ -58,5 +58,11 @@ // New primitive since Orthanc 1.5.2 virtual int64_t GetLastChangeIndex(DatabaseManager& manager) ORTHANC_OVERRIDE; + + // New primitive since Orthanc 1.12.0 + virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE + { + return false; + } }; }