Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 4460:6831de40acd9
New metadata automatically computed at the series level: "RemoteAET"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 20 Jan 2021 14:20:37 +0100 |
parents | d9473bd5ed43 |
children | 68f52897c119 |
comparison
equal
deleted
inserted
replaced
4459:16392fe89ce0 | 4460:6831de40acd9 |
---|---|
1418 | 1418 |
1419 // Handling of metadata ----------------------------------------------------- | 1419 // Handling of metadata ----------------------------------------------------- |
1420 | 1420 |
1421 static void CheckValidResourceType(const RestApiCall& call) | 1421 static void CheckValidResourceType(const RestApiCall& call) |
1422 { | 1422 { |
1423 assert(!call.GetFullUri().empty()); | |
1423 const std::string resourceType = call.GetFullUri() [0]; | 1424 const std::string resourceType = call.GetFullUri() [0]; |
1424 StringToResourceType(resourceType.c_str()); | 1425 StringToResourceType(resourceType.c_str()); |
1425 } | 1426 } |
1426 | 1427 |
1427 | 1428 |
1442 "or JSON associative array mapping metadata to their values (if `expand` argument is provided)") | 1443 "or JSON associative array mapping metadata to their values (if `expand` argument is provided)") |
1443 .SetHttpGetSample(GetDocumentationSampleResource(t) + "/metadata", true); | 1444 .SetHttpGetSample(GetDocumentationSampleResource(t) + "/metadata", true); |
1444 return; | 1445 return; |
1445 } | 1446 } |
1446 | 1447 |
1447 CheckValidResourceType(call); | |
1448 | |
1449 std::string publicId = call.GetUriComponent("id", ""); | |
1450 std::map<MetadataType, std::string> metadata; | 1448 std::map<MetadataType, std::string> metadata; |
1451 | 1449 |
1452 OrthancRestApi::GetIndex(call).GetAllMetadata(metadata, publicId); | 1450 assert(!call.GetFullUri().empty()); |
1451 const std::string publicId = call.GetUriComponent("id", ""); | |
1452 const ResourceType level = StringToResourceType(call.GetFullUri() [0].c_str()); | |
1453 | |
1454 OrthancRestApi::GetIndex(call).GetAllMetadata(metadata, publicId, level); | |
1453 | 1455 |
1454 Json::Value result; | 1456 Json::Value result; |
1455 | 1457 |
1456 if (call.HasArgument("expand")) | 1458 if (call.HasArgument("expand")) |
1457 { | 1459 { |
1493 .SetUriArgument("name", "The name of the metadata, or its index (cf. `UserMetadata` configuration option)") | 1495 .SetUriArgument("name", "The name of the metadata, or its index (cf. `UserMetadata` configuration option)") |
1494 .AddAnswerType(MimeType_PlainText, "Value of the metadata"); | 1496 .AddAnswerType(MimeType_PlainText, "Value of the metadata"); |
1495 return; | 1497 return; |
1496 } | 1498 } |
1497 | 1499 |
1498 CheckValidResourceType(call); | 1500 assert(!call.GetFullUri().empty()); |
1499 | 1501 const std::string publicId = call.GetUriComponent("id", ""); |
1500 std::string publicId = call.GetUriComponent("id", ""); | 1502 const ResourceType level = StringToResourceType(call.GetFullUri() [0].c_str()); |
1503 | |
1501 std::string name = call.GetUriComponent("name", ""); | 1504 std::string name = call.GetUriComponent("name", ""); |
1502 MetadataType metadata = StringToMetadata(name); | 1505 MetadataType metadata = StringToMetadata(name); |
1503 | 1506 |
1504 std::string value; | 1507 std::string value; |
1505 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, metadata)) | 1508 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, level, metadata)) |
1506 { | 1509 { |
1507 call.GetOutput().AnswerBuffer(value, MimeType_PlainText); | 1510 call.GetOutput().AnswerBuffer(value, MimeType_PlainText); |
1508 } | 1511 } |
1509 } | 1512 } |
1510 | 1513 |