Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5841:57ab63fe9108 find-refactoring tip
tools/find: Limit and Since are now forbidden when filtering on DICOM tags that are not stored in DB
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 24 Oct 2024 15:08:43 +0200 |
parents | 82fc95cc168c |
children |
comparison
equal
deleted
inserted
replaced
5840:b24b61331566 | 5841:57ab63fe9108 |
---|---|
3463 | 3463 |
3464 const ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString()); | 3464 const ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString()); |
3465 | 3465 |
3466 ResourceFinder finder(level, responseContent); | 3466 ResourceFinder finder(level, responseContent); |
3467 | 3467 |
3468 DatabaseLookup dicomTagLookup; | |
3469 | |
3468 { // common query code | 3470 { // common query code |
3469 bool caseSensitive = false; | 3471 bool caseSensitive = false; |
3470 if (request.isMember(KEY_CASE_SENSITIVE)) | 3472 if (request.isMember(KEY_CASE_SENSITIVE)) |
3471 { | 3473 { |
3472 caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); | 3474 caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); |
3473 } | 3475 } |
3474 | 3476 |
3475 { // DICOM Tag query | 3477 { // DICOM Tag query |
3476 DatabaseLookup dicomTagLookup; | |
3477 | 3478 |
3478 Json::Value::Members members = request[KEY_QUERY].getMemberNames(); | 3479 Json::Value::Members members = request[KEY_QUERY].getMemberNames(); |
3479 for (size_t i = 0; i < members.size(); i++) | 3480 for (size_t i = 0; i < members.size(); i++) |
3480 { | 3481 { |
3481 if (request[KEY_QUERY][members[i]].type() != Json::stringValue) | 3482 if (request[KEY_QUERY][members[i]].type() != Json::stringValue) |
3598 if (requestType == FindType_Find) | 3599 if (requestType == FindType_Find) |
3599 { | 3600 { |
3600 const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); | 3601 const DicomToJsonFormat format = OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human); |
3601 | 3602 |
3602 finder.SetDatabaseLimits(context.GetDatabaseLimits(level)); | 3603 finder.SetDatabaseLimits(context.GetDatabaseLimits(level)); |
3604 | |
3605 if ((request.isMember(KEY_LIMIT) || request.isMember(KEY_SINCE)) && | |
3606 !dicomTagLookup.HasOnlyMainDicomTags()) | |
3607 { | |
3608 throw OrthancException(ErrorCode_BadRequest, | |
3609 "Unable to use " + std::string(KEY_LIMIT) + " or " + std::string(KEY_SINCE) + " in tools/find when querying tags that are not stored as MainDicomTags in the Database"); | |
3610 } | |
3603 | 3611 |
3604 if (request.isMember(KEY_LIMIT)) | 3612 if (request.isMember(KEY_LIMIT)) |
3605 { | 3613 { |
3606 int64_t tmp = request[KEY_LIMIT].asInt64(); | 3614 int64_t tmp = request[KEY_LIMIT].asInt64(); |
3607 if (tmp < 0) | 3615 if (tmp < 0) |