Mercurial > hg > orthanc
changeset 5840:b24b61331566 find-refactoring
pagination: fixed compat with ODBC that does not support ExtendedFind
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 21 Oct 2024 18:24:09 +0200 |
parents | 82fc95cc168c |
children | 57ab63fe9108 |
files | OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/ResourceFinder.cpp OrthancServer/Sources/ResourceFinder.h |
diffstat | 3 files changed, 18 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Tue Oct 15 15:52:12 2024 +0200 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Mon Oct 21 18:24:09 2024 +0200 @@ -123,6 +123,11 @@ throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support labels"); } + if (!request.GetOrdering().empty()) + { + throw OrthancException(ErrorCode_NotImplemented, "The database backend doesn't support ordering"); + } + if (IsRequestWithoutContraint(request) && !request.GetOrthancIdentifiers().HasPatientId() && !request.GetOrthancIdentifiers().HasStudyId() &&
--- a/OrthancServer/Sources/ResourceFinder.cpp Tue Oct 15 15:52:12 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.cpp Mon Oct 21 18:24:09 2024 +0200 @@ -472,11 +472,10 @@ } - void ResourceFinder::UpdateRequestLimits() + void ResourceFinder::UpdateRequestLimits(ServerContext& context) { - if (true) // simplified code by AM by probably missing a few things ... + if (context.GetIndex().HasFindSupport()) // in this case, limits are fully implemented in DB { - // By default, use manual paging pagingMode_ = PagingMode_FullDatabase; if (hasLimitsSince_ || hasLimitsCount_) @@ -566,8 +565,6 @@ isWarning005Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_005_RequestingTagFromLowerResourceLevel); } - UpdateRequestLimits(); - request_.SetRetrieveMainDicomTags(responseContent_ & ResponseContentFlags_MainDicomTags); request_.SetRetrieveMetadata((responseContent_ & ResponseContentFlags_Metadata) || (responseContent_ & ResponseContentFlags_MetadataLegacy)); request_.SetRetrieveLabels(responseContent_ & ResponseContentFlags_Labels); @@ -610,7 +607,6 @@ void ResourceFinder::SetDatabaseLimits(uint64_t limits) { databaseLimits_ = limits; - UpdateRequestLimits(); } @@ -624,7 +620,6 @@ { hasLimitsSince_ = true; limitsSince_ = since; - UpdateRequestLimits(); } } @@ -639,7 +634,6 @@ { hasLimitsCount_ = true; limitsCount_ = count; - UpdateRequestLimits(); } } @@ -697,8 +691,6 @@ throw OrthancException(ErrorCode_InternalError); } } - - UpdateRequestLimits(); } @@ -1023,8 +1015,10 @@ void ResourceFinder::Execute(IVisitor& visitor, - ServerContext& context) const + ServerContext& context) { + UpdateRequestLimits(context); + bool isWarning002Enabled = false; bool isWarning004Enabled = false; @@ -1176,7 +1170,7 @@ void ResourceFinder::Execute(Json::Value& target, ServerContext& context, DicomToJsonFormat format, - bool includeAllMetadata) const + bool includeAllMetadata) { class Visitor : public IVisitor { @@ -1232,6 +1226,8 @@ } }; + UpdateRequestLimits(context); + target = Json::arrayValue; Visitor visitor(*this, context.GetIndex(), target, format, HasRequestedTags(), includeAllMetadata); @@ -1242,7 +1238,7 @@ bool ResourceFinder::ExecuteOneResource(Json::Value& target, ServerContext& context, DicomToJsonFormat format, - bool includeAllMetadata) const + bool includeAllMetadata) { Json::Value answer; Execute(answer, context, format, includeAllMetadata);
--- a/OrthancServer/Sources/ResourceFinder.h Tue Oct 15 15:52:12 2024 +0200 +++ b/OrthancServer/Sources/ResourceFinder.h Mon Oct 21 18:24:09 2024 +0200 @@ -94,7 +94,7 @@ void InjectComputedTags(DicomMap& requestedTags, const FindResponse::Resource& resource) const; - void UpdateRequestLimits(); + void UpdateRequestLimits(ServerContext& context); bool HasRequestedTags() const { @@ -187,17 +187,17 @@ DicomToJsonFormat format) const; void Execute(IVisitor& visitor, - ServerContext& context) const; + ServerContext& context); void Execute(Json::Value& target, ServerContext& context, DicomToJsonFormat format, - bool includeAllMetadata) const; + bool includeAllMetadata); bool ExecuteOneResource(Json::Value& target, ServerContext& context, DicomToJsonFormat format, - bool includeAllMetadata) const; + bool includeAllMetadata); uint64_t Count(ServerContext& context) const; };