# HG changeset patch # User Sebastien Jodogne # Date 1714210299 -7200 # Node ID 77570cce8855c0579f7e6da51a3267cd1d9fcbb5 # Parent 9e74e761b108738be8af3667e01d309c9b8c7c84 removed redundant FindResponse::resourceId_ diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/Database/FindResponse.h --- a/OrthancServer/Sources/Database/FindResponse.h Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/Database/FindResponse.h Sat Apr 27 11:31:39 2024 +0200 @@ -84,8 +84,7 @@ private: FindRequest::ResponseContent responseContent_; // what has been requested ResourceType level_; - std::string resourceId_; - std::string parent_; + std::string parent_; // TODO-FIND: Remove this, as it is redundant with "identifiers_" OrthancIdentifiers identifiers_; // TODO-FIND: not convenient to use here. A simple resourceId seems enough std::unique_ptr dicomMap_; std::list children_; @@ -106,15 +105,6 @@ Item(FindRequest::ResponseContent responseContent, ResourceType level, - const std::string& resourceId) : - responseContent_(responseContent), - level_(level), - resourceId_(resourceId) - { - } - - Item(FindRequest::ResponseContent responseContent, - ResourceType level, DicomMap* dicomMap /* takes ownership */); ResourceType GetLevel() const @@ -122,11 +112,6 @@ return level_; } - const std::string& GetResourceId() const - { - return resourceId_; - } - const OrthancIdentifiers& GetIdentifiers() const { return identifiers_; diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp --- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp Sat Apr 27 11:31:39 2024 +0200 @@ -1173,9 +1173,11 @@ while (statement.Step()) { + OrthancIdentifiers id; + id.SetLevel(request.GetLevel(), statement.ColumnString(0)); + FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), - request.GetLevel(), - statement.ColumnString(0)); + request.GetLevel(), id); response.Add(item); } } @@ -1198,10 +1200,13 @@ while (statement.Step()) { - const std::string& resourceId = statement.ColumnString(0); + const std::string resourceId = statement.ColumnString(0); + + OrthancIdentifiers id; + id.SetLevel(request.GetLevel(), resourceId); + FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), - request.GetLevel(), - resourceId); + request.GetLevel(), id); items[resourceId] = item; response.Add(item); } diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Sat Apr 27 11:31:39 2024 +0200 @@ -3863,8 +3863,9 @@ // TODO-FIND: we reuse the ExpandedResource class to reuse Serialization code from ExpandedResource // But, finally, we might just get rid of ExpandedResource and replace it by FindResponse - ExpandedResource::ExpandedResource(const FindResponse::Item& item) : - id_(item.GetResourceId()), + ExpandedResource::ExpandedResource(ResourceType level, + const FindResponse::Item& item) : + id_(item.GetIdentifiers().GetLevel(level)), level_(item.GetLevel()), isStable_(false), expectedNumberOfInstances_(0), diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Sat Apr 27 11:31:39 2024 +0200 @@ -80,7 +80,8 @@ { } - ExpandedResource(const FindResponse::Item& item); + ExpandedResource(ResourceType level, + const FindResponse::Item& item); void SetResource(ResourceType level, const std::string& id) diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Sat Apr 27 11:31:39 2024 +0200 @@ -315,7 +315,7 @@ { for (size_t i = 0; i < response.GetSize(); i++) { - std::string resourceId = response.GetItem(i).GetResourceId(); + std::string resourceId = response.GetItem(i).GetIdentifiers().GetLevel(resourceType); answer.append(resourceId); } } @@ -323,7 +323,7 @@ { for (size_t i = 0; i < response.GetSize(); i++) { - context.AppendFindResponse(answer, response.GetItem(i), format, requestedTags, true /* allowStorageAccess */); + context.AppendFindResponse(answer, resourceType, response.GetItem(i), format, requestedTags, true /* allowStorageAccess */); } } diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Sat Apr 27 11:31:39 2024 +0200 @@ -2718,13 +2718,14 @@ } void ServerContext::AppendFindResponse(Json::Value& target, + ResourceType level, const FindResponse::Item& item, DicomToJsonFormat format, const std::set& requestedTags, bool allowStorageAccess) { // convert to ExpandedResource to re-use the serialization code TODO-FIND: check if this is the right way to do. shouldn't we copy the code and finally get rid of ExpandedResource ? - ExpandedResource resource(item); + ExpandedResource resource(level, item); ExpandResourceFlags expandFlags = ExpandResourceFlags_None; if (item.HasResponseContent(FindRequest::ResponseContent_Children)) diff -r 9e74e761b108 -r 77570cce8855 OrthancServer/Sources/ServerContext.h --- a/OrthancServer/Sources/ServerContext.h Fri Apr 26 17:43:22 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.h Sat Apr 27 11:31:39 2024 +0200 @@ -608,6 +608,7 @@ bool allowStorageAccess); void AppendFindResponse(Json::Value& target, + ResourceType level, const FindResponse::Item& item, DicomToJsonFormat format, const std::set& requestedTags,