Mercurial > hg > orthanc-databases
changeset 402:82921a29349a db-protobuf
implemented IDatabaseBackend::ListAllLabels()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 08 Apr 2023 10:26:03 +0200 |
parents | a8774581adfc |
children | 91124cc8a8c7 |
files | Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/Plugins/IDatabaseBackend.h Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexBackend.h |
diffstat | 4 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Fri Apr 07 22:32:15 2023 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Sat Apr 08 10:26:03 2023 +0200 @@ -1196,7 +1196,15 @@ case Orthanc::DatabasePluginMessages::OPERATION_LIST_LABELS: { std::list<std::string> labels; - backend.ListLabels(labels, manager, request.list_labels().id()); + + if (request.list_labels().single_resource()) + { + backend.ListLabels(labels, manager, request.list_labels().id()); + } + else + { + backend.ListAllLabels(labels, manager); + } response.mutable_list_available_attachments()->mutable_attachments()->Reserve(labels.size()); for (std::list<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it)
--- a/Framework/Plugins/IDatabaseBackend.h Fri Apr 07 22:32:15 2023 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Sat Apr 08 10:26:03 2023 +0200 @@ -338,5 +338,9 @@ virtual void ListLabels(std::list<std::string>& target, DatabaseManager& manager, int64_t resource) = 0; + + // New in Orthanc 1.12.0 + virtual void ListAllLabels(std::list<std::string>& target, + DatabaseManager& manager) = 0; }; }
--- a/Framework/Plugins/IndexBackend.cpp Fri Apr 07 22:32:15 2023 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Sat Apr 08 10:26:03 2023 +0200 @@ -2688,6 +2688,18 @@ } + void IndexBackend::ListAllLabels(std::list<std::string>& target, + DatabaseManager& manager) + { + DatabaseManager::CachedStatement statement( + STATEMENT_FROM_HERE, manager, + "SELECT DISTINCT label FROM Labels"); + + Dictionary args; + ReadListOfStrings(target, statement, args); + } + + void IndexBackend::Register(IndexBackend* backend, size_t countConnections, unsigned int maxDatabaseRetries)
--- a/Framework/Plugins/IndexBackend.h Fri Apr 07 22:32:15 2023 +0200 +++ b/Framework/Plugins/IndexBackend.h Sat Apr 08 10:26:03 2023 +0200 @@ -392,6 +392,9 @@ virtual void ListLabels(std::list<std::string>& target, DatabaseManager& manager, int64_t resource) ORTHANC_OVERRIDE; + + virtual void ListAllLabels(std::list<std::string>& target, + DatabaseManager& manager) ORTHANC_OVERRIDE; /** * "maxDatabaseRetries" is to handle