comparison OrthancServer/Sources/ResourceFinder.cpp @ 5840:b24b61331566 find-refactoring tip

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
comparison
equal deleted inserted replaced
5837:82fc95cc168c 5840:b24b61331566
470 } 470 }
471 } 471 }
472 } 472 }
473 473
474 474
475 void ResourceFinder::UpdateRequestLimits() 475 void ResourceFinder::UpdateRequestLimits(ServerContext& context)
476 { 476 {
477 if (true) // simplified code by AM by probably missing a few things ... 477 if (context.GetIndex().HasFindSupport()) // in this case, limits are fully implemented in DB
478 { 478 {
479 // By default, use manual paging
480 pagingMode_ = PagingMode_FullDatabase; 479 pagingMode_ = PagingMode_FullDatabase;
481 480
482 if (hasLimitsSince_ || hasLimitsCount_) 481 if (hasLimitsSince_ || hasLimitsCount_)
483 { 482 {
484 pagingMode_ = PagingMode_FullDatabase; 483 pagingMode_ = PagingMode_FullDatabase;
564 isWarning002Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb); 563 isWarning002Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb);
565 isWarning004Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature); 564 isWarning004Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature);
566 isWarning005Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_005_RequestingTagFromLowerResourceLevel); 565 isWarning005Enabled_ = lock.GetConfiguration().IsWarningEnabled(Warnings_005_RequestingTagFromLowerResourceLevel);
567 } 566 }
568 567
569 UpdateRequestLimits();
570
571 request_.SetRetrieveMainDicomTags(responseContent_ & ResponseContentFlags_MainDicomTags); 568 request_.SetRetrieveMainDicomTags(responseContent_ & ResponseContentFlags_MainDicomTags);
572 request_.SetRetrieveMetadata((responseContent_ & ResponseContentFlags_Metadata) || (responseContent_ & ResponseContentFlags_MetadataLegacy)); 569 request_.SetRetrieveMetadata((responseContent_ & ResponseContentFlags_Metadata) || (responseContent_ & ResponseContentFlags_MetadataLegacy));
573 request_.SetRetrieveLabels(responseContent_ & ResponseContentFlags_Labels); 570 request_.SetRetrieveLabels(responseContent_ & ResponseContentFlags_Labels);
574 571
575 switch (level) 572 switch (level)
608 605
609 606
610 void ResourceFinder::SetDatabaseLimits(uint64_t limits) 607 void ResourceFinder::SetDatabaseLimits(uint64_t limits)
611 { 608 {
612 databaseLimits_ = limits; 609 databaseLimits_ = limits;
613 UpdateRequestLimits();
614 } 610 }
615 611
616 612
617 void ResourceFinder::SetLimitsSince(uint64_t since) 613 void ResourceFinder::SetLimitsSince(uint64_t since)
618 { 614 {
622 } 618 }
623 else 619 else
624 { 620 {
625 hasLimitsSince_ = true; 621 hasLimitsSince_ = true;
626 limitsSince_ = since; 622 limitsSince_ = since;
627 UpdateRequestLimits();
628 } 623 }
629 } 624 }
630 625
631 626
632 void ResourceFinder::SetLimitsCount(uint64_t count) 627 void ResourceFinder::SetLimitsCount(uint64_t count)
637 } 632 }
638 else 633 else
639 { 634 {
640 hasLimitsCount_ = true; 635 hasLimitsCount_ = true;
641 limitsCount_ = count; 636 limitsCount_ = count;
642 UpdateRequestLimits();
643 } 637 }
644 } 638 }
645 639
646 640
647 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup) 641 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup)
695 { 689 {
696 // Sanity check 690 // Sanity check
697 throw OrthancException(ErrorCode_InternalError); 691 throw OrthancException(ErrorCode_InternalError);
698 } 692 }
699 } 693 }
700
701 UpdateRequestLimits();
702 } 694 }
703 695
704 696
705 void ResourceFinder::AddRequestedTag(const DicomTag& tag) 697 void ResourceFinder::AddRequestedTag(const DicomTag& tag)
706 { 698 {
1021 return count; 1013 return count;
1022 } 1014 }
1023 1015
1024 1016
1025 void ResourceFinder::Execute(IVisitor& visitor, 1017 void ResourceFinder::Execute(IVisitor& visitor,
1026 ServerContext& context) const 1018 ServerContext& context)
1027 { 1019 {
1020 UpdateRequestLimits(context);
1021
1028 bool isWarning002Enabled = false; 1022 bool isWarning002Enabled = false;
1029 bool isWarning004Enabled = false; 1023 bool isWarning004Enabled = false;
1030 1024
1031 { 1025 {
1032 OrthancConfiguration::ReaderLock lock; 1026 OrthancConfiguration::ReaderLock lock;
1174 1168
1175 1169
1176 void ResourceFinder::Execute(Json::Value& target, 1170 void ResourceFinder::Execute(Json::Value& target,
1177 ServerContext& context, 1171 ServerContext& context,
1178 DicomToJsonFormat format, 1172 DicomToJsonFormat format,
1179 bool includeAllMetadata) const 1173 bool includeAllMetadata)
1180 { 1174 {
1181 class Visitor : public IVisitor 1175 class Visitor : public IVisitor
1182 { 1176 {
1183 private: 1177 private:
1184 const ResourceFinder& that_; 1178 const ResourceFinder& that_;
1230 virtual void MarkAsComplete() ORTHANC_OVERRIDE 1224 virtual void MarkAsComplete() ORTHANC_OVERRIDE
1231 { 1225 {
1232 } 1226 }
1233 }; 1227 };
1234 1228
1229 UpdateRequestLimits(context);
1230
1235 target = Json::arrayValue; 1231 target = Json::arrayValue;
1236 1232
1237 Visitor visitor(*this, context.GetIndex(), target, format, HasRequestedTags(), includeAllMetadata); 1233 Visitor visitor(*this, context.GetIndex(), target, format, HasRequestedTags(), includeAllMetadata);
1238 Execute(visitor, context); 1234 Execute(visitor, context);
1239 } 1235 }
1240 1236
1241 1237
1242 bool ResourceFinder::ExecuteOneResource(Json::Value& target, 1238 bool ResourceFinder::ExecuteOneResource(Json::Value& target,
1243 ServerContext& context, 1239 ServerContext& context,
1244 DicomToJsonFormat format, 1240 DicomToJsonFormat format,
1245 bool includeAllMetadata) const 1241 bool includeAllMetadata)
1246 { 1242 {
1247 Json::Value answer; 1243 Json::Value answer;
1248 Execute(answer, context, format, includeAllMetadata); 1244 Execute(answer, context, format, includeAllMetadata);
1249 1245
1250 if (answer.type() != Json::arrayValue) 1246 if (answer.type() != Json::arrayValue)