comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5405:62bb63346185

All 'expand' GET arguments now accepts expand=true and expand=false values + /studies/../instances now supports expand=false
author Alain Mazy <am@osimis.io>
date Tue, 17 Oct 2023 15:06:11 +0200
parents c5c00bee291a
children 630d0195e3bb
comparison
equal deleted inserted replaced
5404:7bae5f7ebe6a 5405:62bb63346185
252 else 252 else
253 { 253 {
254 index.GetAllUuids(result, resourceType); 254 index.GetAllUuids(result, resourceType);
255 } 255 }
256 256
257 AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand"), 257 AnswerListOfResources(call.GetOutput(), context, result, resourceType, call.HasArgument("expand") && call.GetBooleanArgument("expand", true),
258 OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human), 258 OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human),
259 requestedTags, 259 requestedTags,
260 true /* allowStorageAccess */); 260 true /* allowStorageAccess */);
261 } 261 }
262 262
1699 1699
1700 Json::Value result; 1700 Json::Value result;
1701 1701
1702 bool isNumeric = call.HasArgument("numeric"); 1702 bool isNumeric = call.HasArgument("numeric");
1703 1703
1704 if (call.HasArgument("expand")) 1704 if (call.HasArgument("expand") && call.GetBooleanArgument("expand", true))
1705 { 1705 {
1706 result = Json::objectValue; 1706 result = Json::objectValue;
1707 1707
1708 for (Metadata::const_iterator it = metadata.begin(); it != metadata.end(); ++it) 1708 for (Metadata::const_iterator it = metadata.begin(); it != metadata.end(); ++it)
1709 { 1709 {
3322 .SetTag(GetResourceTypeText(start, true /* plural */, true /* upper case */)) 3322 .SetTag(GetResourceTypeText(start, true /* plural */, true /* upper case */))
3323 .SetSummary("Get child " + children) 3323 .SetSummary("Get child " + children)
3324 .SetDescription("Get detailed information about the child " + children + " of the DICOM " + 3324 .SetDescription("Get detailed information about the child " + children + " of the DICOM " +
3325 resource + " whose Orthanc identifier is provided in the URL") 3325 resource + " whose Orthanc identifier is provided in the URL")
3326 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest") 3326 .SetUriArgument("id", "Orthanc identifier of the " + resource + " of interest")
3327 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String,
3328 "If false or missing, only retrieve the list of child " + children, false)
3327 .AddAnswerType(MimeType_Json, "JSON array containing information about the child DICOM " + children) 3329 .AddAnswerType(MimeType_Json, "JSON array containing information about the child DICOM " + children)
3328 .SetTruncatedJsonHttpGetSample(GetDocumentationSampleResource(start) + "/" + children, 5); 3330 .SetTruncatedJsonHttpGetSample(GetDocumentationSampleResource(start) + "/" + children, 5);
3329 return; 3331 return;
3330 } 3332 }
3331 3333
3332 ServerIndex& index = OrthancRestApi::GetIndex(call); 3334 ServerIndex& index = OrthancRestApi::GetIndex(call);
3335 ServerContext& context = OrthancRestApi::GetContext(call);
3333 3336
3334 std::set<DicomTag> requestedTags; 3337 std::set<DicomTag> requestedTags;
3335 OrthancRestApi::GetRequestedTags(requestedTags, call); 3338 OrthancRestApi::GetRequestedTags(requestedTags, call);
3336 3339
3337 std::list<std::string> a, b, c; 3340 std::list<std::string> a, b, c;
3353 3356
3354 a.clear(); 3357 a.clear();
3355 a.splice(a.begin(), b); 3358 a.splice(a.begin(), b);
3356 } 3359 }
3357 3360
3358 Json::Value result = Json::arrayValue; 3361 AnswerListOfResources(call.GetOutput(), context, a, type, !call.HasArgument("expand") || call.GetBooleanArgument("expand", false), // this "expand" is the only one to have a false default value to keep backward compatibility
3359 3362 OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human),
3360 const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(call, DicomToJsonFormat_Human); 3363 requestedTags,
3361 3364 true /* allowStorageAccess */);
3362 for (std::list<std::string>::const_iterator
3363 it = a.begin(); it != a.end(); ++it)
3364 {
3365 Json::Value resource;
3366 if (OrthancRestApi::GetContext(call).ExpandResource(resource, *it, end, format, requestedTags, true /* allowStorageAccess */))
3367 {
3368 result.append(resource);
3369 }
3370 }
3371
3372 call.GetOutput().AnswerJson(result);
3373 } 3365 }
3374 3366
3375 3367
3376 static void GetChildInstancesTags(RestApiGetCall& call) 3368 static void GetChildInstancesTags(RestApiGetCall& call)
3377 { 3369 {