Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4937:3f9b9865c8cc more-tags
include requested tags from storage if needed
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 14 Mar 2022 13:13:29 +0100 |
parents | 8422e4f99a18 |
children | dad71e6da406 |
comparison
equal
deleted
inserted
replaced
4936:8422e4f99a18 | 4937:3f9b9865c8cc |
---|---|
42 #include "../ServerToolbox.h" | 42 #include "../ServerToolbox.h" |
43 #include "../SliceOrdering.h" | 43 #include "../SliceOrdering.h" |
44 | 44 |
45 // This "include" is mandatory for Release builds using Linux Standard Base | 45 // This "include" is mandatory for Release builds using Linux Standard Base |
46 #include <boost/math/special_functions/round.hpp> | 46 #include <boost/math/special_functions/round.hpp> |
47 | 47 #include <boost/shared_ptr.hpp> |
48 | 48 |
49 /** | 49 /** |
50 * This semaphore is used to limit the number of concurrent HTTP | 50 * This semaphore is used to limit the number of concurrent HTTP |
51 * requests on CPU-intensive routes of the REST API, in order to | 51 * requests on CPU-intensive routes of the REST API, in order to |
52 * prevent exhaustion of resources (new in Orthanc 1.7.0). | 52 * prevent exhaustion of resources (new in Orthanc 1.7.0). |
126 // List all the patients, studies, series or instances ---------------------- | 126 // List all the patients, studies, series or instances ---------------------- |
127 | 127 |
128 static void AnswerListOfResources(RestApiOutput& output, | 128 static void AnswerListOfResources(RestApiOutput& output, |
129 ServerContext& context, | 129 ServerContext& context, |
130 const std::list<std::string>& resources, | 130 const std::list<std::string>& resources, |
131 const std::map<std::string, std::string>& instancesIds, // optional: the id of an instance for each found resource. | |
132 const std::map<std::string, boost::shared_ptr<DicomMap> >& resourcesMainDicomTags, // optional: all tags read from DB for a resource (current level and upper levels) | |
133 const std::map<std::string, Json::Value>& resourcesDicomAsJson, // optional: the dicom-as-json for each resource | |
131 ResourceType level, | 134 ResourceType level, |
132 bool expand, | 135 bool expand, |
133 DicomToJsonFormat format, | 136 DicomToJsonFormat format, |
134 const std::set<DicomTag>& requestedTags) | 137 const std::set<DicomTag>& requestedTags) |
135 { | 138 { |
151 answer.append(*resource); | 154 answer.append(*resource); |
152 } | 155 } |
153 } | 156 } |
154 | 157 |
155 output.AnswerJson(answer); | 158 output.AnswerJson(answer); |
159 } | |
160 | |
161 | |
162 static void AnswerListOfResources(RestApiOutput& output, | |
163 ServerContext& context, | |
164 const std::list<std::string>& resources, | |
165 ResourceType level, | |
166 bool expand, | |
167 DicomToJsonFormat format, | |
168 const std::set<DicomTag>& requestedTags) | |
169 { | |
170 std::map<std::string, std::string> unusedInstancesIds; | |
171 std::map<std::string, boost::shared_ptr<DicomMap> > unusedResourcesMainDicomTags; | |
172 std::map<std::string, Json::Value> unusedResourcesDicomAsJson; | |
173 | |
174 AnswerListOfResources(output, context, resources, unusedInstancesIds, unusedResourcesMainDicomTags, unusedResourcesDicomAsJson, level, expand, format, requestedTags); | |
156 } | 175 } |
157 | 176 |
158 | 177 |
159 template <enum ResourceType resourceType> | 178 template <enum ResourceType resourceType> |
160 static void ListResources(RestApiGetCall& call) | 179 static void ListResources(RestApiGetCall& call) |
2826 class FindVisitor : public ServerContext::ILookupVisitor | 2845 class FindVisitor : public ServerContext::ILookupVisitor |
2827 { | 2846 { |
2828 private: | 2847 private: |
2829 bool isComplete_; | 2848 bool isComplete_; |
2830 std::list<std::string> resources_; | 2849 std::list<std::string> resources_; |
2850 | |
2851 // cache the data we used during lookup and that we could reuse when building the answers | |
2852 std::map<std::string, std::string> instancesIds_; // the id of an instance for each found resource. | |
2853 std::map<std::string, boost::shared_ptr<DicomMap> > resourcesMainDicomTags_; // all tags read from DB for a resource (current level and upper levels) | |
2854 std::map<std::string, Json::Value> resourcesDicomAsJson_; // the dicom-as-json for a resource | |
2855 | |
2831 DicomToJsonFormat format_; | 2856 DicomToJsonFormat format_; |
2832 | 2857 |
2833 public: | 2858 public: |
2834 explicit FindVisitor(DicomToJsonFormat format) : | 2859 explicit FindVisitor(DicomToJsonFormat format) : |
2835 isComplete_(false), | 2860 isComplete_(false), |
2846 { | 2871 { |
2847 isComplete_ = true; // Unused information as of Orthanc 1.5.0 | 2872 isComplete_ = true; // Unused information as of Orthanc 1.5.0 |
2848 } | 2873 } |
2849 | 2874 |
2850 virtual void Visit(const std::string& publicId, | 2875 virtual void Visit(const std::string& publicId, |
2851 const std::string& instanceId /* unused */, | 2876 const std::string& instanceId, |
2852 const DicomMap& mainDicomTags /* unused */, | 2877 const DicomMap& mainDicomTags, |
2853 const Json::Value* dicomAsJson /* unused (*) */) ORTHANC_OVERRIDE | 2878 const Json::Value* dicomAsJson) ORTHANC_OVERRIDE |
2854 { | 2879 { |
2855 resources_.push_back(publicId); | 2880 resources_.push_back(publicId); |
2881 instancesIds_[publicId] = instanceId; | |
2882 resourcesMainDicomTags_[publicId].reset(mainDicomTags.Clone()); | |
2883 resourcesDicomAsJson_[publicId] = dicomAsJson; | |
2856 } | 2884 } |
2857 | 2885 |
2858 void Answer(RestApiOutput& output, | 2886 void Answer(RestApiOutput& output, |
2859 ServerContext& context, | 2887 ServerContext& context, |
2860 ResourceType level, | 2888 ResourceType level, |