Mercurial > hg > orthanc
diff OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5842:08e47734328e find-refactoring
StatelessDatabaseOperations: reimplementing GetAllUuids() and GetAllMetadata()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Oct 2024 12:46:11 +0000 |
parents | 82fc95cc168c |
children | 7df3d533c294 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Thu Oct 24 15:08:43 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Oct 29 12:46:11 2024 +0000 @@ -865,28 +865,25 @@ const std::string& publicId, ResourceType level) { - class Operations : public ReadOnlyOperationsT3<std::map<MetadataType, std::string>&, const std::string&, ResourceType> + FindRequest request(level); + request.SetOrthancId(level, publicId); + request.SetRetrieveMetadata(true); + + FindResponse response; + ExecuteFind(response, request); + + if (response.GetSize() == 0) { - public: - virtual void ApplyTuple(ReadOnlyTransaction& transaction, - const Tuple& tuple) ORTHANC_OVERRIDE - { - ResourceType type; - int64_t id; - if (!transaction.LookupResource(id, type, tuple.get<1>()) || - tuple.get<2>() != type) - { - throw OrthancException(ErrorCode_UnknownResource); - } - else - { - transaction.GetAllMetadata(tuple.get<0>(), id); - } - } - }; - - Operations operations; - operations.Apply(*this, target, publicId, level); + throw OrthancException(ErrorCode_UnknownResource); + } + else if (response.GetSize() == 1) + { + target = response.GetResourceByIndex(0).GetMetadata(level); + } + else + { + throw OrthancException(ErrorCode_DatabasePlugin); + } } @@ -929,19 +926,17 @@ void StatelessDatabaseOperations::GetAllUuids(std::list<std::string>& target, ResourceType resourceType) { - class Operations : public ReadOnlyOperationsT2<std::list<std::string>&, ResourceType> + // This method is tested by "orthanc-tests/Plugins/WebDav/Run.py" + FindRequest request(resourceType); + + FindResponse response; + ExecuteFind(response, request); + + target.clear(); + for (size_t i = 0; i < response.GetSize(); i++) { - public: - virtual void ApplyTuple(ReadOnlyTransaction& transaction, - const Tuple& tuple) ORTHANC_OVERRIDE - { - // TODO - CANDIDATE FOR "TransactionType_Implicit" - transaction.GetAllPublicIds(tuple.get<0>(), tuple.get<1>()); - } - }; - - Operations operations; - operations.Apply(*this, target, resourceType); + target.push_back(response.GetResourceByIndex(i).GetIdentifier()); + } }