Mercurial > hg > orthanc
changeset 5889:ec66569a742c find-refactoring
refactored StatelessDatabaseOperations::GetMainDicomTags()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 30 Nov 2024 15:34:55 +0100 |
parents | 1b6836f9ad28 |
children | 91d7c05eda4e |
files | OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp |
diffstat | 1 files changed, 39 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Nov 29 18:20:43 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Sat Nov 30 15:34:55 2024 +0100 @@ -1303,56 +1303,50 @@ throw OrthancException(ErrorCode_ParameterOutOfRange); } - - class Operations : public ReadOnlyOperationsT5<bool&, DicomMap&, const std::string&, ResourceType, ResourceType> + FindRequest request(expectedType); + request.SetOrthancId(expectedType, publicId); + request.SetRetrieveMainDicomTags(true); + + FindResponse response; + ExecuteFind(response, request); + + if (response.GetSize() == 0) { - public: - virtual void ApplyTuple(ReadOnlyTransaction& transaction, - const Tuple& tuple) ORTHANC_OVERRIDE + return false; + } + else if (response.GetSize() > 1) + { + throw OrthancException(ErrorCode_DatabasePlugin); + } + else + { + result.Clear(); + if (expectedType == ResourceType_Study) { - // Lookup for the requested resource - int64_t id; - ResourceType type; - if (!transaction.LookupResource(id, type, tuple.get<2>()) || - type != tuple.get<3>()) - { - tuple.get<0>() = false; - } - else if (type == ResourceType_Study) + DicomMap tmp; + response.GetResourceByIndex(0).GetMainDicomTags(tmp, expectedType); + + switch (levelOfInterest) { - DicomMap tmp; - transaction.GetMainDicomTags(tmp, id); - - switch (tuple.get<4>()) - { - case ResourceType_Patient: - tmp.ExtractPatientInformation(tuple.get<1>()); - tuple.get<0>() = true; - break; - - case ResourceType_Study: - tmp.ExtractStudyInformation(tuple.get<1>()); - tuple.get<0>() = true; - break; - - default: - throw OrthancException(ErrorCode_InternalError); - } + case ResourceType_Study: + tmp.ExtractStudyInformation(result); + break; + + case ResourceType_Patient: + tmp.ExtractPatientInformation(result); + break; + + default: + throw OrthancException(ErrorCode_InternalError); } - else - { - transaction.GetMainDicomTags(tuple.get<1>(), id); - tuple.get<0>() = true; - } } - }; - - result.Clear(); - - bool found; - Operations operations; - operations.Apply(*this, found, result, publicId, expectedType, levelOfInterest); - return found; + else + { + assert(expectedType == levelOfInterest); + response.GetResourceByIndex(0).GetMainDicomTags(result, expectedType); + } + return true; + } }