Mercurial > hg > orthanc
changeset 5847:70a879a7b658 find-refactoring
introduction of IDatabaseWrapper::ICompatibilityTransaction
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2024 13:46:29 +0000 |
parents | c1b9eb21bd61 |
children | b8fb95937f22 |
files | OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Sources/Database/BaseDatabaseWrapper.cpp OrthancServer/Sources/Database/BaseDatabaseWrapper.h OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/Compatibility/GenericFind.h OrthancServer/Sources/Database/IDatabaseWrapper.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp |
diffstat | 9 files changed, 52 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -49,7 +49,8 @@ public Compatibility::IGetChildrenMetadata, public Compatibility::ILookupResources, public Compatibility::ILookupResourceAndParent, - public Compatibility::ISetResourcesContent + public Compatibility::ISetResourcesContent, + public IDatabaseWrapper::ICompatibilityTransaction { private: typedef std::pair<int64_t, ResourceType> AnswerResource; @@ -806,10 +807,10 @@ } - virtual void GetAllPublicIds(std::list<std::string>& target, - ResourceType resourceType, - int64_t since, - uint32_t limit) ORTHANC_OVERRIDE + virtual void GetAllPublicIdsCompatibility(std::list<std::string>& target, + ResourceType resourceType, + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { if (that_.extensions_.getAllPublicIdsWithLimit != NULL) {
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -46,7 +46,9 @@ namespace Orthanc { - class OrthancPluginDatabaseV3::Transaction : public BaseDatabaseWrapper::BaseTransaction + class OrthancPluginDatabaseV3::Transaction : + public BaseDatabaseWrapper::BaseTransaction, + public IDatabaseWrapper::ICompatibilityTransaction { private: OrthancPluginDatabaseV3& that_; @@ -386,10 +388,10 @@ } - virtual void GetAllPublicIds(std::list<std::string>& target, - ResourceType resourceType, - int64_t since, - uint32_t limit) ORTHANC_OVERRIDE + virtual void GetAllPublicIdsCompatibility(std::list<std::string>& target, + ResourceType resourceType, + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { CheckSuccess(that_.backend_.getAllPublicIdsWithLimit( transaction_, Plugins::Convert(resourceType),
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -398,7 +398,9 @@ } - class OrthancPluginDatabaseV4::Transaction : public IDatabaseWrapper::ITransaction + class OrthancPluginDatabaseV4::Transaction : + public IDatabaseWrapper::ITransaction, + public IDatabaseWrapper::ICompatibilityTransaction { private: OrthancPluginDatabaseV4& database_; @@ -673,10 +675,10 @@ } - virtual void GetAllPublicIds(std::list<std::string>& target, - ResourceType resourceType, - int64_t since, - uint32_t limit) ORTHANC_OVERRIDE + virtual void GetAllPublicIdsCompatibility(std::list<std::string>& target, + ResourceType resourceType, + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { DatabasePluginMessages::TransactionRequest request; request.mutable_get_all_public_ids_with_limits()->set_resource_type(Convert(resourceType)); @@ -1762,7 +1764,7 @@ } else { - Compatibility::GenericFind find(*this); + Compatibility::GenericFind find(*this, *this); find.ExecuteFind(identifiers, capabilities, request); } } @@ -1780,7 +1782,7 @@ } else { - Compatibility::GenericFind find(*this); + Compatibility::GenericFind find(*this, *this); find.ExecuteExpand(response, capabilities, request, identifier); } }
--- a/OrthancServer/Sources/Database/BaseDatabaseWrapper.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/BaseDatabaseWrapper.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -77,7 +77,7 @@ const Capabilities& capabilities, const FindRequest& request) { - Compatibility::GenericFind find(*this); + Compatibility::GenericFind find(*this, *this); find.ExecuteFind(identifiers, capabilities, request); } @@ -87,7 +87,7 @@ const FindRequest& request, const std::string& identifier) { - Compatibility::GenericFind find(*this); + Compatibility::GenericFind find(*this, *this); find.ExecuteExpand(response, capabilities, request, identifier); }
--- a/OrthancServer/Sources/Database/BaseDatabaseWrapper.h Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/BaseDatabaseWrapper.h Tue Oct 29 13:46:29 2024 +0000 @@ -34,7 +34,9 @@ class BaseDatabaseWrapper : public IDatabaseWrapper { public: - class BaseTransaction : public IDatabaseWrapper::ITransaction + class BaseTransaction : + public IDatabaseWrapper::ITransaction, + public IDatabaseWrapper::ICompatibilityTransaction { public: virtual int64_t IncrementGlobalProperty(GlobalProperty property,
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -140,7 +140,7 @@ } else if (request.GetLimitsCount() != 0) { - transaction_.GetAllPublicIds(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount()); + compatibilityTransaction_.GetAllPublicIdsCompatibility(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount()); } else {
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.h Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.h Tue Oct 29 13:46:29 2024 +0000 @@ -33,14 +33,17 @@ { private: IDatabaseWrapper::ITransaction& transaction_; + IDatabaseWrapper::ICompatibilityTransaction& compatibilityTransaction_; void RetrieveMainDicomTags(FindResponse::Resource& target, ResourceType level, int64_t internalId); public: - explicit GenericFind(IDatabaseWrapper::ITransaction& transaction) : - transaction_(transaction) + explicit GenericFind(IDatabaseWrapper::ITransaction& transaction, + IDatabaseWrapper::ICompatibilityTransaction& compatibilityTransaction) : + transaction_(transaction), + compatibilityTransaction_(compatibilityTransaction) { }
--- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Tue Oct 29 13:46:29 2024 +0000 @@ -202,11 +202,6 @@ virtual void GetAllPublicIds(std::list<std::string>& target, ResourceType resourceType) = 0; - virtual void GetAllPublicIds(std::list<std::string>& target, - ResourceType resourceType, - int64_t since, - uint32_t limit) = 0; - virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, bool& done /*out*/, int64_t since, @@ -422,6 +417,21 @@ }; + // TODO-FIND: Could this interface be removed? + class ICompatibilityTransaction : public boost::noncopyable + { + public: + virtual ~ICompatibilityTransaction() + { + } + + virtual void GetAllPublicIdsCompatibility(std::list<std::string>& target, + ResourceType resourceType, + int64_t since, + uint32_t limit) = 0; + }; + + virtual ~IDatabaseWrapper() { }
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Oct 29 13:29:43 2024 +0000 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Tue Oct 29 13:46:29 2024 +0000 @@ -1256,10 +1256,10 @@ } - virtual void GetAllPublicIds(std::list<std::string>& target, - ResourceType resourceType, - int64_t since, - uint32_t limit) ORTHANC_OVERRIDE + virtual void GetAllPublicIdsCompatibility(std::list<std::string>& target, + ResourceType resourceType, + int64_t since, + uint32_t limit) ORTHANC_OVERRIDE { SQLite::Statement s(db_, SQLITE_FROM_HERE, "SELECT publicId FROM Resources WHERE "