# HG changeset patch # User Sebastien Jodogne # Date 1734446448 -3600 # Node ID 73d5b77e5d62d214ea794151efab3abd580faeda # Parent 5e5069357246fd649a06bd0e9d97169827daf9a5 "CaseSensitive" is not available in "/tools/count-resources diff -r 5e5069357246 -r 73d5b77e5d62 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Dec 17 10:13:42 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Dec 17 15:40:48 2024 +0100 @@ -3214,6 +3214,18 @@ } }; + class Compatibility : public ReadOnlyOperationsT3 + { + public: + virtual void ApplyTuple(ReadOnlyTransaction& transaction, + const Tuple& tuple) ORTHANC_OVERRIDE + { + std::list identifiers; + transaction.ExecuteFind(identifiers, tuple.get<2>(), tuple.get<1>()); + tuple.get<0>() = identifiers.size(); + } + }; + IDatabaseWrapper::Capabilities capabilities = db_.GetDatabaseCapabilities(); if (db_.HasIntegratedFind()) @@ -3223,7 +3235,8 @@ } else { - throw OrthancException(ErrorCode_NotImplemented); + Compatibility operations; + operations.Apply(*this, count, request, capabilities); } } diff -r 5e5069357246 -r 73d5b77e5d62 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Dec 17 10:13:42 2024 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Dec 17 15:40:48 2024 +0100 @@ -3101,8 +3101,6 @@ RestApiCallDocumentation& doc = call.GetDocumentation(); doc.SetTag("System") - .SetRequestField(KEY_CASE_SENSITIVE, RestApiCallDocumentation::Type_Boolean, - "Enable case-sensitive search for PN value representations (defaults to configuration option `CaseSensitivePN`)", false) .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String, "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true) .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject, @@ -3124,6 +3122,8 @@ { case FindType_Find: doc.SetSummary("Look for local resources") + .SetRequestField(KEY_CASE_SENSITIVE, RestApiCallDocumentation::Type_Boolean, + "Enable case-sensitive search for PN value representations (defaults to configuration option `CaseSensitivePN`)", false) .SetDescription("This URI can be used to perform a search on the content of the local Orthanc server, " "in a way that is similar to querying remote DICOM modalities using C-FIND SCU: " "https://orthanc.uclouvain.be/book/users/rest.html#performing-finds-within-orthanc") @@ -3141,7 +3141,7 @@ break; case FindType_Count: doc.SetSummary("Count local resources") - .SetDescription("This URI can be used to count the resources that are matching criterias on the content of the local Orthanc server, " + .SetDescription("This URI can be used to count the resources that are matching criteria on the content of the local Orthanc server, " "in a way that is similar to tools/find") .AddAnswerType(MimeType_Json, "A JSON object with the `Count` of matching resources"); break; @@ -3281,6 +3281,12 @@ if (request.isMember(KEY_CASE_SENSITIVE)) { caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); + + if (requestType == FindType_Count && caseSensitive) + { + throw OrthancException(ErrorCode_ParameterOutOfRange, "Setting \"" + std::string(KEY_CASE_SENSITIVE) + + "\" to \"true\" is not supported by /tools/count-resources"); + } } { // DICOM Tag query @@ -3552,7 +3558,10 @@ answer["Count"] = Json::Value::UInt64(count); call.GetOutput().AnswerJson(answer); } - + else + { + throw OrthancException(ErrorCode_InternalError); + } } } @@ -4343,10 +4352,7 @@ Register("/tools/lookup", Lookup); Register("/tools/find", Find); - if (context_.GetIndex().HasFindSupport()) - { - Register("/tools/count-resources", Find); - } + Register("/tools/count-resources", Find); Register("/patients/{id}/studies", GetChildResources); Register("/patients/{id}/series", GetChildResources);