Mercurial > hg > orthanc
changeset 5579:77570cce8855 find-refactoring
removed redundant FindResponse::resourceId_
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 27 Apr 2024 11:31:39 +0200 |
parents | 9e74e761b108 |
children | df7324d6e728 |
files | OrthancServer/Sources/Database/FindResponse.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h |
diffstat | 7 files changed, 21 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- 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> dicomMap_; std::list<std::string> 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_;
--- 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); }
--- 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),
--- 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)
--- 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 */); } }
--- 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<DicomTag>& 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))
--- 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<DicomTag>& requestedTags,