Mercurial > hg > orthanc
changeset 5674:74f3aab95886 find-refactoring
simplification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 06 Jul 2024 14:43:46 +0200 |
parents | ebcbb448bea8 |
children | 2b65f25cb1c8 |
files | OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/FindRequest.cpp OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/Database/FindResponse.cpp OrthancServer/Sources/Database/FindResponse.h OrthancServer/Sources/ResourceFinder.cpp |
diffstat | 6 files changed, 4 insertions(+), 112 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Sat Jul 06 14:43:46 2024 +0200 @@ -546,14 +546,6 @@ } } - for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin(); - it != request.GetRetrieveChildrenMetadata().end(); ++it) - { - std::list<std::string> values; - transaction_.GetChildrenMetadata(values, internalId, *it); - resource->AddChildrenMetadata(*it, values); - } - if (request.IsRetrieveOneInstanceIdentifier() && !request.GetChildrenRetrieveSpecification(ResourceType_Instance).IsRetrieveIdentifiers()) {
--- a/OrthancServer/Sources/Database/FindRequest.cpp Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/Database/FindRequest.cpp Sat Jul 06 14:43:46 2024 +0200 @@ -293,19 +293,6 @@ } - void FindRequest::AddRetrieveChildrenMetadata(MetadataType metadata) - { - if (IsRetrieveChildrenMetadata(metadata)) - { - throw OrthancException(ErrorCode_BadSequenceOfCalls); - } - else - { - retrieveChildrenMetadata_.insert(metadata); - } - } - - void FindRequest::SetRetrieveOneInstanceIdentifier(bool retrieve) { if (level_ == ResourceType_Instance)
--- a/OrthancServer/Sources/Database/FindRequest.h Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/Database/FindRequest.h Sat Jul 06 14:43:46 2024 +0200 @@ -269,7 +269,6 @@ ChildrenRetrieveSpecification retrieveChildrenStudies_; ChildrenRetrieveSpecification retrieveChildrenSeries_; ChildrenRetrieveSpecification retrieveChildrenInstances_; - std::set<MetadataType> retrieveChildrenMetadata_; bool retrieveOneInstanceIdentifier_; std::unique_ptr<MainDicomTagsRegistry> mainDicomTagsRegistry_; @@ -411,18 +410,6 @@ return const_cast<FindRequest&>(*this).GetChildrenRetrieveSpecification(level); } - void AddRetrieveChildrenMetadata(MetadataType metadata); - - bool IsRetrieveChildrenMetadata(MetadataType metadata) const - { - return retrieveChildrenMetadata_.find(metadata) != retrieveChildrenMetadata_.end(); - } - - const std::set<MetadataType>& GetRetrieveChildrenMetadata() const - { - return retrieveChildrenMetadata_; - } - void SetRetrieveOneInstanceIdentifier(bool retrieve); bool IsRetrieveOneInstanceIdentifier() const
--- a/OrthancServer/Sources/Database/FindResponse.cpp Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/Database/FindResponse.cpp Sat Jul 06 14:43:46 2024 +0200 @@ -377,16 +377,6 @@ } - FindResponse::Resource::~Resource() - { - for (ChildrenMetadata::iterator it = childrenMetadata_.begin(); it != childrenMetadata_.end(); ++it) - { - assert(it->second != NULL); - delete it->second; - } - } - - void FindResponse::Resource::SetParentIdentifier(const std::string& id) { if (level_ == ResourceType_Patient) @@ -475,37 +465,6 @@ } - void FindResponse::Resource::AddChildrenMetadata(MetadataType metadata, - const std::list<std::string>& values) - { - if (childrenMetadata_.find(metadata) == childrenMetadata_.end()) - { - childrenMetadata_[metadata] = new std::list<std::string>(values); - } - else - { - throw OrthancException(ErrorCode_BadSequenceOfCalls); - } - } - - - bool FindResponse::Resource::LookupChildrenMetadata(std::list<std::string>& values, - MetadataType metadata) const - { - ChildrenMetadata::const_iterator found = childrenMetadata_.find(metadata); - if (found == childrenMetadata_.end()) - { - return false; - } - else - { - assert(found->second != NULL); - values = *found->second; - return true; - } - } - - const std::string& FindResponse::Resource::GetOneInstanceIdentifier() const { const std::set<std::string>& instances = GetChildrenInformation(ResourceType_Instance).GetIdentifiers(); @@ -657,25 +616,6 @@ target["Attachments"] = v; } - for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin(); - it != request.GetRetrieveChildrenMetadata().end(); ++it) - { - std::list<std::string> l; - if (LookupChildrenMetadata(l, *it)) - { - Json::Value v = Json::arrayValue; - for (std::list<std::string>::const_iterator it2 = l.begin(); it2 != l.end(); ++it2) - { - v.append(*it2); - } - target["ChildrenMetadata"][EnumerationToString(*it)] = v; - } - else - { - throw OrthancException(ErrorCode_DatabasePlugin); - } - } - if (request.IsRetrieveOneInstanceIdentifier()) { target["OneInstance"] = GetOneInstanceIdentifier();
--- a/OrthancServer/Sources/Database/FindResponse.h Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/Database/FindResponse.h Sat Jul 06 14:43:46 2024 +0200 @@ -123,7 +123,6 @@ ChildrenInformation childrenInstancesInformation_; std::set<std::string> labels_; std::map<FileContentType, FileInfo> attachments_; - ChildrenMetadata childrenMetadata_; // TODO-FIND: REMOVE MainDicomTagsAtLevel& GetMainDicomTagsAtLevel(ResourceType level); @@ -149,8 +148,6 @@ { } - ~Resource(); - ResourceType GetLevel() const { return level_; @@ -269,14 +266,6 @@ return attachments_; } - // TODO-FIND: REMOVE - void AddChildrenMetadata(MetadataType metadata, - const std::list<std::string>& values); - - // TODO-FIND: REMOVE - bool LookupChildrenMetadata(std::list<std::string>& values, - MetadataType metadata) const; - const std::string& GetOneInstanceIdentifier() const; bool HasOneInstanceIdentifier() const
--- a/OrthancServer/Sources/ResourceFinder.cpp Sat Jul 06 14:31:22 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.cpp Sat Jul 06 14:43:46 2024 +0200 @@ -132,15 +132,12 @@ return SeriesStatus_Unknown; } - std::list<std::string> values; - if (!resource.LookupChildrenMetadata(values, MetadataType_Instance_IndexInSeries)) - { - throw OrthancException(ErrorCode_BadSequenceOfCalls); - } + std::set<std::string> values; + resource.GetChildrenMetadataValues(values, ResourceType_Instance, MetadataType_Instance_IndexInSeries); std::set<int64_t> instances; - for (std::list<std::string>::const_iterator + for (std::set<std::string>::const_iterator it = values.begin(); it != values.end(); ++it) { int64_t index; @@ -438,7 +435,7 @@ break; case ResourceType_Series: - request_.AddRetrieveChildrenMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus + request_.GetChildrenRetrieveSpecification(ResourceType_Instance).AddMetadata(MetadataType_Instance_IndexInSeries); // required for the SeriesStatus request_.GetChildrenRetrieveSpecification(ResourceType_Instance).SetRetrieveIdentifiers(true); request_.SetRetrieveParentIdentifier(true); break;