# HG changeset patch # User Sebastien Jodogne # Date 1680689386 -7200 # Node ID d14e6ff04a5cfdd57dfb5c7dcd57da980a6a7d54 # Parent eb80f7c5e7d831698a0203ce4b344ba682c355c2 added primitives to handle labels diff -r eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/DatabaseBackendAdapterV2.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV2.cpp Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV2.cpp Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/DatabaseBackendAdapterV3.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/IDatabaseBackend.h --- a/Framework/Plugins/IDatabaseBackend.h Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Wed Apr 05 11:18:08 2023 +0200 +++ b/Framework/Plugins/IndexBackend.h Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c MySQL/Plugins/MySQLIndex.h --- a/MySQL/Plugins/MySQLIndex.h Wed Apr 05 11:18:08 2023 +0200 +++ b/MySQL/Plugins/MySQLIndex.h Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c Odbc/Plugins/OdbcIndex.h --- a/Odbc/Plugins/OdbcIndex.h Wed Apr 05 11:18:08 2023 +0200 +++ b/Odbc/Plugins/OdbcIndex.h Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c PostgreSQL/Plugins/PostgreSQLIndex.h --- a/PostgreSQL/Plugins/PostgreSQLIndex.h Wed Apr 05 11:18:08 2023 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.h Wed Apr 05 12:09:46 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 eb80f7c5e7d8 -r d14e6ff04a5c SQLite/Plugins/SQLiteIndex.h --- a/SQLite/Plugins/SQLiteIndex.h Wed Apr 05 11:18:08 2023 +0200 +++ b/SQLite/Plugins/SQLiteIndex.h Wed Apr 05 12:09:46 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; + } }; }