Mercurial > hg > orthanc
diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4717:783f8a048035 openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Jun 2021 16:23:23 +0200 |
parents | f0038043fb97 758fe3ffb336 |
children | 4b721432fa67 |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Jun 22 10:40:28 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Wed Jun 23 16:23:23 2021 +0200 @@ -2535,7 +2535,7 @@ DicomToJsonFormat format_; public: - FindVisitor(DicomToJsonFormat format) : + explicit FindVisitor(DicomToJsonFormat format) : isComplete_(false), format_(format) { @@ -3101,8 +3101,29 @@ } + static void AddMetadata(Json::Value& target, + ServerIndex& index, + const std::string& resource, + ResourceType level) + { + target = Json::objectValue; + + std::map<MetadataType, std::string> content; + index.GetAllMetadata(content, resource, level); + + for (std::map<MetadataType, std::string>::const_iterator + it = content.begin(); it != content.end(); ++it) + { + target[EnumerationToString(it->first)] = it->second; + } + } + + static void BulkContent(RestApiPostCall& call) { + static const char* const LEVEL = "Level"; + static const char* const METADATA = "Metadata"; + if (call.IsDocumentation()) { OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); @@ -3112,10 +3133,12 @@ .SetSummary("Describe a set of instances") .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", true) - .SetRequestField("Level", RestApiCallDocumentation::Type_String, + .SetRequestField(LEVEL, RestApiCallDocumentation::Type_String, "This optional argument specifies the level of interest (can be `Patient`, `Study`, `Series` or " "`Instance`). Orthanc will loop over the items inside `Resources`, and explorer upward or " "downward in the DICOM hierarchy in order to find the level of interest.", false) + .SetRequestField(METADATA, RestApiCallDocumentation::Type_Boolean, + "If set to `true` (default value), the metadata associated with the resources will also be retrieved.", false) .SetDescription("Get the content all the DICOM patients, studies, series or instances " "whose identifiers are provided in the `Resources` field, in one single call."); return; @@ -3130,10 +3153,14 @@ } else { - static const char* const LEVEL = "Level"; - const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); + bool metadata = true; + if (request.isMember(METADATA)) + { + metadata = SerializationToolbox::ReadBoolean(request, METADATA); + } + ServerIndex& index = OrthancRestApi::GetIndex(call); Json::Value answer = Json::arrayValue; @@ -3178,9 +3205,9 @@ if (type == level) { for (std::set<std::string>::const_iterator - it = children.begin(); it != children.end(); ++it) + it2 = children.begin(); it2 != children.end(); ++it2) { - interest.insert(*it); + interest.insert(*it2); } break; // done @@ -3231,6 +3258,11 @@ Json::Value item; if (index.ExpandResource(item, *it, level, format)) { + if (metadata) + { + AddMetadata(item[METADATA], index, *it, level); + } + answer.append(item); } } @@ -3244,11 +3276,16 @@ for (std::list<std::string>::const_iterator it = resources.begin(); it != resources.end(); ++it) { - ResourceType type; + ResourceType level; Json::Value item; - if (index.LookupResourceType(type, *it) && - index.ExpandResource(item, *it, type, format)) + if (index.LookupResourceType(level, *it) && + index.ExpandResource(item, *it, level, format)) { + if (metadata) + { + AddMetadata(item[METADATA], index, *it, level); + } + answer.append(item); } else