# HG changeset patch # User Sebastien Jodogne # Date 1730205971 0 # Node ID 08e47734328eb50ebdefa92efeb0c1294e042d40 # Parent 57ab63fe91083019fbce606f1e5ee50e0e281347 StatelessDatabaseOperations: reimplementing GetAllUuids() and GetAllMetadata() diff -r 57ab63fe9108 -r 08e47734328e OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- 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&, 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& target, ResourceType resourceType) { - class Operations : public ReadOnlyOperationsT2&, 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()); + } }