Mercurial > hg > orthanc
changeset 4698:d16c3c7f11ef
new route "/tools/bulk-content" to get the content of a set of resources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Jun 2021 16:37:12 +0200 |
parents | 569d9ef165b1 |
children | facea16b055b |
files | NEWS OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp |
diffstat | 3 files changed, 65 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Fri Jun 18 16:08:35 2021 +0200 +++ b/NEWS Fri Jun 18 16:37:12 2021 +0200 @@ -18,10 +18,11 @@ -------- * API version upgraded to 13 -* New routes: - - "/tools/bulk-anonymize" to anonymize a group of multiple, unrelated resources at once - - "/tools/bulk-delete" to delete a group of multiple, unrelated resources at once - - "/tools/bulk-modify" to modify a group of multiple, unrelated resources at once +* New routes to handle groups of multiple, unrelated DICOM resources at once: + - "/tools/bulk-anonymize" to anonymize a set of resources + - "/tools/bulk-content" to get the content of a set of resources + - "/tools/bulk-delete" to delete a set of resources + - "/tools/bulk-modify" to modify a set of resources * ZIP archive/media generated in synchronous mode are now streamed by default * "Replace" tags in "/modify" and "/anonymize" now supports value representation AT * "/jobs/..." has new field "ErrorDetails" to help identify the cause of an error
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Jun 18 16:08:35 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Jun 18 16:37:12 2021 +0200 @@ -471,11 +471,10 @@ static const std::string POST_SHORT = "Short"; static const std::string DOCUMENT_SIMPLIFY = - "report the DICOM tags indexed in human-readable format " - "(using the symbolic name of the tags)"; + "report the DICOM tags in human-readable format (using the symbolic name of the tags)"; static const std::string DOCUMENT_SHORT = - "report the DICOM tags indexed in hexadecimal format"; + "report the DICOM tags in hexadecimal format"; static const std::string DOCUMENT_FULL = "report the DICOM tags in full format (tags indexed by their hexadecimal " @@ -564,13 +563,13 @@ if (defaultFormat != DicomToJsonFormat_Short) { call.GetDocumentation().SetRequestField(POST_SHORT, RestApiCallDocumentation::Type_Boolean, - "If set to `true`, " + DOCUMENT_SIMPLIFY, false); + "If set to `true`, " + DOCUMENT_SHORT, false); } if (defaultFormat != DicomToJsonFormat_Full) { call.GetDocumentation().SetRequestField(POST_FULL, RestApiCallDocumentation::Type_Boolean, - "If set to `true`, " + DOCUMENT_SIMPLIFY, false); + "If set to `true`, " + DOCUMENT_FULL, false); } } }
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Jun 18 16:08:35 2021 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Jun 18 16:37:12 2021 +0200 @@ -3092,6 +3092,60 @@ } + static void BulkContent(RestApiPostCall& call) + { + if (call.IsDocumentation()) + { + OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); + + call.GetDocumentation() + .SetTag("System") + .SetSummary("Describe a set of instances") + .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, + "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", 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; + } + + Json::Value request; + if (!call.ParseJsonRequest(request) || + request.type() != Json::objectValue) + { + throw OrthancException(ErrorCode_BadRequest, + "The body must contain a JSON object"); + } + else + { + const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); + + ServerIndex& index = OrthancRestApi::GetIndex(call); + + std::list<std::string> resources; + SerializationToolbox::ReadListOfStrings(resources, request, "Resources"); + + Json::Value answer = Json::arrayValue; + for (std::list<std::string>::const_iterator + it = resources.begin(); it != resources.end(); ++it) + { + ResourceType type; + Json::Value item; + if (index.LookupResourceType(type, *it) && + index.ExpandResource(item, *it, type, format)) + { + answer.append(item); + } + else + { + CLOG(INFO, HTTP) << "Unknown resource during a bulk content retrieval: " << *it; + } + } + + call.GetOutput().AnswerJson(answer); + } + } + + static void BulkDelete(RestApiPostCall& call) { if (call.IsDocumentation()) @@ -3101,7 +3155,7 @@ .SetSummary("Delete a set of instances") .SetRequestField("Resources", RestApiCallDocumentation::Type_JsonListOfStrings, "List of the Orthanc identifiers of the patients/studies/series/instances of interest.", false) - .SetDescription("Dellete all the DICOM patients, studies, series or instances " + .SetDescription("Delete all the DICOM patients, studies, series or instances " "whose identifiers are provided in the `Resources` field."); return; } @@ -3257,6 +3311,7 @@ Register("/instances/{id}/reconstruct", ReconstructResource<ResourceType_Instance>); Register("/tools/reconstruct", ReconstructAllResources); + Register("/tools/bulk-content", BulkContent); Register("/tools/bulk-delete", BulkDelete); } }