comparison OrthancServer/Sources/ResourceFinder.cpp @ 5696:0f8b6214308a find-refactoring

preparing to use ResourceFinder in OrthancFindRequestHandler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Jul 2024 10:56:33 +0200
parents 4a85ee2cbe1f
children f375e9983943
comparison
equal deleted inserted replaced
5695:380a71e0d7e7 5696:0f8b6214308a
947 947
948 if (match) 948 if (match)
949 { 949 {
950 if (pagingMode_ == PagingMode_FullDatabase) 950 if (pagingMode_ == PagingMode_FullDatabase)
951 { 951 {
952 visitor.Apply(resource, hasRequestedTags_, requestedTags); 952 visitor.Apply(resource, requestedTags);
953 } 953 }
954 else 954 else
955 { 955 {
956 if (hasLimitsSince_ && 956 if (hasLimitsSince_ &&
957 skipped < limitsSince_) 957 skipped < limitsSince_)
965 complete = false; 965 complete = false;
966 break; 966 break;
967 } 967 }
968 else 968 else
969 { 969 {
970 visitor.Apply(resource, hasRequestedTags_, requestedTags); 970 visitor.Apply(resource, requestedTags);
971 countResults++; 971 countResults++;
972 } 972 }
973 } 973 }
974 } 974 }
975 } 975 }
988 { 988 {
989 private: 989 private:
990 const ResourceFinder& that_; 990 const ResourceFinder& that_;
991 ServerIndex& index_; 991 ServerIndex& index_;
992 Json::Value& target_; 992 Json::Value& target_;
993 bool hasRequestedTags_;
993 994
994 public: 995 public:
995 Visitor(const ResourceFinder& that, 996 Visitor(const ResourceFinder& that,
996 ServerIndex& index, 997 ServerIndex& index,
997 Json::Value& target) : 998 Json::Value& target,
999 bool hasRequestedTags) :
998 that_(that), 1000 that_(that),
999 index_(index), 1001 index_(index),
1000 target_(target) 1002 target_(target),
1003 hasRequestedTags_(hasRequestedTags)
1001 { 1004 {
1002 } 1005 }
1003 1006
1004 virtual void Apply(const FindResponse::Resource& resource, 1007 virtual void Apply(const FindResponse::Resource& resource,
1005 bool hasRequestedTags,
1006 const DicomMap& requestedTags) ORTHANC_OVERRIDE 1008 const DicomMap& requestedTags) ORTHANC_OVERRIDE
1007 { 1009 {
1008 if (that_.expand_) 1010 if (that_.expand_)
1009 { 1011 {
1010 Json::Value item; 1012 Json::Value item;
1011 that_.Expand(item, resource, index_); 1013 that_.Expand(item, resource, index_);
1012 1014
1013 if (hasRequestedTags) 1015 if (hasRequestedTags_)
1014 { 1016 {
1015 static const char* const REQUESTED_TAGS = "RequestedTags"; 1017 static const char* const REQUESTED_TAGS = "RequestedTags";
1016 item[REQUESTED_TAGS] = Json::objectValue; 1018 item[REQUESTED_TAGS] = Json::objectValue;
1017 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, that_.format_); 1019 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, that_.format_);
1018 } 1020 }
1030 } 1032 }
1031 }; 1033 };
1032 1034
1033 target = Json::arrayValue; 1035 target = Json::arrayValue;
1034 1036
1035 Visitor visitor(*this, context.GetIndex(), target); 1037 Visitor visitor(*this, context.GetIndex(), target, hasRequestedTags_);
1036 Execute(visitor, context); 1038 Execute(visitor, context);
1037 } 1039 }
1038 1040
1039 1041
1040 bool ResourceFinder::ExecuteOneResource(Json::Value& target, 1042 bool ResourceFinder::ExecuteOneResource(Json::Value& target,