Mercurial > hg > orthanc-authorization
comparison Plugin/OrthancResource.cpp @ 109:7381a7674b36
wip: adding labels
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 18 Aug 2023 12:08:49 +0200 |
parents | 1a13c4fbc9a1 |
children | 9be1ee2b8fe1 |
comparison
equal
deleted
inserted
replaced
108:68ce6fd8b22a | 109:7381a7674b36 |
---|---|
18 | 18 |
19 #include "OrthancResource.h" | 19 #include "OrthancResource.h" |
20 | 20 |
21 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | 21 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
22 | 22 |
23 static const char* LABELS_KEY = "Labels"; | |
24 | |
23 namespace OrthancPlugins | 25 namespace OrthancPlugins |
24 { | 26 { |
25 void OrthancResource::GetDicomUidInternal(std::string& result, | 27 void OrthancResource::GetDicomUidInternal(std::string& result, |
26 Orthanc::ResourceType level, | 28 Orthanc::ResourceType level, |
27 const Json::Value& content) | 29 const Json::Value& content) |
155 } | 157 } |
156 | 158 |
157 | 159 |
158 bool OrthancResource::GetHierarchy(std::string& dicomUid /* out */, | 160 bool OrthancResource::GetHierarchy(std::string& dicomUid /* out */, |
159 OrthancResource& parent /* out */, | 161 OrthancResource& parent /* out */, |
160 std::list<OrthancResource>& children /* out */) const | 162 std::list<OrthancResource>& children /* out */, |
163 std::set<std::string>& labels) const | |
161 { | 164 { |
162 Json::Value content; | 165 Json::Value content; |
163 | 166 |
164 if (!GetContent(content)) | 167 if (!GetContent(content)) |
165 { | 168 { |
233 } | 236 } |
234 | 237 |
235 children.push_back(OrthancResource(childrenType, child.asString())); | 238 children.push_back(OrthancResource(childrenType, child.asString())); |
236 } | 239 } |
237 } | 240 } |
238 | 241 |
242 labels.clear(); | |
243 if (content.isMember(LABELS_KEY) || | |
244 content[LABELS_KEY].type() != Json::arrayValue) | |
245 { | |
246 for (Json::Value::ArrayIndex i = 0; i < content[LABELS_KEY].size(); i++) | |
247 { | |
248 const Json::Value& label = content[LABELS_KEY][i]; | |
249 | |
250 if (label.type() != Json::stringValue) | |
251 { | |
252 throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); | |
253 } | |
254 | |
255 labels.insert(label.asString()); | |
256 } | |
257 } | |
258 | |
239 return true; | 259 return true; |
240 } | 260 } |
241 | 261 |
242 | 262 |
243 bool OrthancResource::LookupOrthancId(std::string& result, | 263 bool OrthancResource::LookupOrthancId(std::string& result, |