Mercurial > hg > orthanc
changeset 5714:2b05428843d2 find-refactoring
removed dangerous overload of ResourceFinder::Execute()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 13 Jul 2024 00:20:33 +0200 |
parents | d851a54e49b7 |
children | 593e110de3d8 8db85be7a445 |
files | OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ResourceFinder.cpp OrthancServer/Sources/ResourceFinder.h OrthancServer/Sources/ServerContext.cpp |
diffstat | 4 files changed, 7 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Sat Jul 13 00:03:42 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Sat Jul 13 00:20:33 2024 +0200 @@ -130,7 +130,7 @@ static bool ExpandResource(Json::Value& target, - ServerIndex& index, + ServerContext& context, ResourceType level, const std::string& identifier, DicomToJsonFormat format, @@ -140,19 +140,7 @@ finder.SetOrthancId(level, identifier); finder.SetRetrieveMetadata(retrieveMetadata); - FindResponse response; - finder.Execute(response, index); - - if (response.GetSize() != 1) - { - return false; - } - else - { - const FindResponse::Resource& resource = response.GetResourceByIndex(0); - finder.Expand(target, resource, index, format, retrieveMetadata); - return true; - } + return finder.ExecuteOneResource(target, context, format, retrieveMetadata); } @@ -3801,7 +3789,7 @@ /** * EXPERIMENTAL VERSION **/ - if (ExpandResource(resource, OrthancRestApi::GetIndex(call), currentType, current, format, false)) + if (ExpandResource(resource, OrthancRestApi::GetContext(call), currentType, current, format, false)) { call.GetOutput().AnswerJson(resource); } @@ -4251,7 +4239,7 @@ * EXPERIMENTAL VERSION **/ Json::Value item; - if (ExpandResource(item, OrthancRestApi::GetIndex(call), level, *it, format, metadata)) + if (ExpandResource(item, OrthancRestApi::GetContext(call), level, *it, format, metadata)) { answer.append(item); } @@ -4295,7 +4283,7 @@ * EXPERIMENTAL VERSION **/ if (index.LookupResourceType(level, *it) && - ExpandResource(item, OrthancRestApi::GetIndex(call), level, *it, format, metadata)) + ExpandResource(item, OrthancRestApi::GetContext(call), level, *it, format, metadata)) { answer.append(item); }
--- a/OrthancServer/Sources/ResourceFinder.cpp Sat Jul 13 00:03:42 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.cpp Sat Jul 13 00:20:33 2024 +0200 @@ -891,13 +891,6 @@ } - void ResourceFinder::Execute(FindResponse& response, - ServerIndex& index) const - { - index.ExecuteFind(response, request_); - } - - void ResourceFinder::Execute(IVisitor& visitor, ServerContext& context) const {
--- a/OrthancServer/Sources/ResourceFinder.h Sat Jul 13 00:03:42 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.h Sat Jul 13 00:20:33 2024 +0200 @@ -166,9 +166,6 @@ DicomToJsonFormat format, bool includeAllMetadata /* Same as: ExpandResourceFlags_IncludeAllMetadata */) const; - void Execute(FindResponse& target, - ServerIndex& index) const; - void Execute(IVisitor& visitor, ServerContext& context) const;
--- a/OrthancServer/Sources/ServerContext.cpp Sat Jul 13 00:03:42 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Sat Jul 13 00:20:33 2024 +0200 @@ -1556,53 +1556,8 @@ fastLookup->RemoveConstraint(DICOM_TAG_MODALITIES_IN_STUDY); } - if (true) - { - /** - * EXPERIMENTAL VERSION - **/ - - ResourceFinder finder(queryLevel, false /* TODO-FIND: don't expand for now */); - finder.SetDatabaseLimits(databaseLimit); - finder.SetDatabaseLookup(lookup); - finder.SetLabels(labels); - finder.SetLabelsConstraint(labelsConstraint); - - if (queryLevel != ResourceType_Instance) - { - finder.SetRetrieveOneInstanceIdentifier(true); - } - - FindResponse response; - finder.Execute(response, GetIndex()); - - resources.resize(response.GetSize()); - instances.resize(response.GetSize()); - - for (size_t i = 0; i < response.GetSize(); i++) - { - const FindResponse::Resource& resource = response.GetResourceByIndex(i); - resources[i] = resource.GetIdentifier(); - - if (queryLevel == ResourceType_Instance) - { - instances[i] = resource.GetIdentifier(); - } - else - { - instances[i] = resource.GetOneInstanceIdentifier(); - } - } - } - else - { - /** - * VERSION IN ORTHANC <= 1.12.4 - **/ - - const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1); - GetIndex().ApplyLookupResources(resources, &instances, *fastLookup, queryLevel, labels, labelsConstraint, lookupLimit); - } + const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1); + GetIndex().ApplyLookupResources(resources, &instances, *fastLookup, queryLevel, labels, labelsConstraint, lookupLimit); bool complete = (databaseLimit == 0 || resources.size() <= databaseLimit);