Mercurial > hg > orthanc-authorization
diff 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 |
line wrap: on
line diff
--- a/Plugin/OrthancResource.cpp Mon Aug 14 10:25:40 2023 +0200 +++ b/Plugin/OrthancResource.cpp Fri Aug 18 12:08:49 2023 +0200 @@ -20,6 +20,8 @@ #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" +static const char* LABELS_KEY = "Labels"; + namespace OrthancPlugins { void OrthancResource::GetDicomUidInternal(std::string& result, @@ -157,7 +159,8 @@ bool OrthancResource::GetHierarchy(std::string& dicomUid /* out */, OrthancResource& parent /* out */, - std::list<OrthancResource>& children /* out */) const + std::list<OrthancResource>& children /* out */, + std::set<std::string>& labels) const { Json::Value content; @@ -235,7 +238,24 @@ children.push_back(OrthancResource(childrenType, child.asString())); } } - + + labels.clear(); + if (content.isMember(LABELS_KEY) || + content[LABELS_KEY].type() != Json::arrayValue) + { + for (Json::Value::ArrayIndex i = 0; i < content[LABELS_KEY].size(); i++) + { + const Json::Value& label = content[LABELS_KEY][i]; + + if (label.type() != Json::stringValue) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); + } + + labels.insert(label.asString()); + } + } + return true; }