comparison OrthancServer/Sources/ResourceFinder.cpp @ 5709:476b1db52110 find-refactoring

removed the "format_" member from ResourceFinder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Jul 2024 18:41:44 +0200
parents 359a8adb3802
children d851a54e49b7
comparison
equal deleted inserted replaced
5708:1891a8c2dbb4 5709:476b1db52110
188 } 188 }
189 189
190 190
191 void ResourceFinder::Expand(Json::Value& target, 191 void ResourceFinder::Expand(Json::Value& target,
192 const FindResponse::Resource& resource, 192 const FindResponse::Resource& resource,
193 ServerIndex& index) const 193 ServerIndex& index,
194 DicomToJsonFormat format) const
194 { 195 {
195 /** 196 /**
196 * This method closely follows "SerializeExpandedResource()" in 197 * This method closely follows "SerializeExpandedResource()" in
197 * "ServerContext.cpp" from Orthanc 1.12.4. 198 * "ServerContext.cpp" from Orthanc 1.12.4.
198 **/ 199 **/
380 381
381 DicomMap levelMainDicomTags; 382 DicomMap levelMainDicomTags;
382 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel()); 383 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel());
383 384
384 target[MAIN_DICOM_TAGS] = Json::objectValue; 385 target[MAIN_DICOM_TAGS] = Json::objectValue;
385 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_); 386 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format);
386 387
387 if (resource.GetLevel() == ResourceType_Study) 388 if (resource.GetLevel() == ResourceType_Study)
388 { 389 {
389 DicomMap patientMainDicomTags; 390 DicomMap patientMainDicomTags;
390 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags); 391 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags);
391 392
392 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue; 393 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
393 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_); 394 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format);
394 } 395 }
395 } 396 }
396 397
397 { 398 {
398 Json::Value labels = Json::arrayValue; 399 Json::Value labels = Json::arrayValue;
479 hasLimitsSince_(false), 480 hasLimitsSince_(false),
480 hasLimitsCount_(false), 481 hasLimitsCount_(false),
481 limitsSince_(0), 482 limitsSince_(0),
482 limitsCount_(0), 483 limitsCount_(0),
483 expand_(expand), 484 expand_(expand),
484 format_(DicomToJsonFormat_Human),
485 allowStorageAccess_(true), 485 allowStorageAccess_(true),
486 hasRequestedTags_(false), 486 hasRequestedTags_(false),
487 includeAllMetadata_(false) 487 includeAllMetadata_(false)
488 { 488 {
489 UpdateRequestLimits(); 489 UpdateRequestLimits();
1000 } 1000 }
1001 } 1001 }
1002 1002
1003 1003
1004 void ResourceFinder::Execute(Json::Value& target, 1004 void ResourceFinder::Execute(Json::Value& target,
1005 ServerContext& context) const 1005 ServerContext& context,
1006 DicomToJsonFormat format) const
1006 { 1007 {
1007 class Visitor : public IVisitor 1008 class Visitor : public IVisitor
1008 { 1009 {
1009 private: 1010 private:
1010 const ResourceFinder& that_; 1011 const ResourceFinder& that_;
1011 ServerIndex& index_; 1012 ServerIndex& index_;
1012 Json::Value& target_; 1013 Json::Value& target_;
1013 bool hasRequestedTags_; 1014 DicomToJsonFormat format_;
1015 bool hasRequestedTags_;
1014 1016
1015 public: 1017 public:
1016 Visitor(const ResourceFinder& that, 1018 Visitor(const ResourceFinder& that,
1017 ServerIndex& index, 1019 ServerIndex& index,
1018 Json::Value& target, 1020 Json::Value& target,
1021 DicomToJsonFormat format,
1019 bool hasRequestedTags) : 1022 bool hasRequestedTags) :
1020 that_(that), 1023 that_(that),
1021 index_(index), 1024 index_(index),
1022 target_(target), 1025 target_(target),
1026 format_(format),
1023 hasRequestedTags_(hasRequestedTags) 1027 hasRequestedTags_(hasRequestedTags)
1024 { 1028 {
1025 } 1029 }
1026 1030
1027 virtual void Apply(const FindResponse::Resource& resource, 1031 virtual void Apply(const FindResponse::Resource& resource,
1028 const DicomMap& requestedTags) ORTHANC_OVERRIDE 1032 const DicomMap& requestedTags) ORTHANC_OVERRIDE
1029 { 1033 {
1030 if (that_.expand_) 1034 if (that_.expand_)
1031 { 1035 {
1032 Json::Value item; 1036 Json::Value item;
1033 that_.Expand(item, resource, index_); 1037 that_.Expand(item, resource, index_, format_);
1034 1038
1035 if (hasRequestedTags_) 1039 if (hasRequestedTags_)
1036 { 1040 {
1037 static const char* const REQUESTED_TAGS = "RequestedTags"; 1041 static const char* const REQUESTED_TAGS = "RequestedTags";
1038 item[REQUESTED_TAGS] = Json::objectValue; 1042 item[REQUESTED_TAGS] = Json::objectValue;
1039 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, that_.format_); 1043 FromDcmtkBridge::ToJson(item[REQUESTED_TAGS], requestedTags, format_);
1040 } 1044 }
1041 1045
1042 target_.append(item); 1046 target_.append(item);
1043 } 1047 }
1044 else 1048 else
1052 } 1056 }
1053 }; 1057 };
1054 1058
1055 target = Json::arrayValue; 1059 target = Json::arrayValue;
1056 1060
1057 Visitor visitor(*this, context.GetIndex(), target, hasRequestedTags_); 1061 Visitor visitor(*this, context.GetIndex(), target, format, hasRequestedTags_);
1058 Execute(visitor, context); 1062 Execute(visitor, context);
1059 } 1063 }
1060 1064
1061 1065
1062 bool ResourceFinder::ExecuteOneResource(Json::Value& target, 1066 bool ResourceFinder::ExecuteOneResource(Json::Value& target,
1063 ServerContext& context) const 1067 ServerContext& context,
1068 DicomToJsonFormat format) const
1064 { 1069 {
1065 Json::Value answer; 1070 Json::Value answer;
1066 Execute(answer, context); 1071 Execute(answer, context, format);
1067 1072
1068 if (answer.type() != Json::arrayValue) 1073 if (answer.type() != Json::arrayValue)
1069 { 1074 {
1070 throw OrthancException(ErrorCode_InternalError); 1075 throw OrthancException(ErrorCode_InternalError);
1071 } 1076 }