Mercurial > hg > orthanc
diff OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5595:a87f2a56257d find-refactoring
implemented FindRequest::retrieveChildrenMetadata_
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 May 2024 12:53:12 +0200 |
parents | a906dc19264c |
children | 81a29ad7fb4b |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Sat May 04 15:25:19 2024 +0200 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Tue May 07 12:53:12 2024 +0200 @@ -65,14 +65,51 @@ { int64_t internalId; ResourceType level; - if (!transaction_.LookupResource(internalId, level, identifier) || - level != request.GetLevel()) + std::string parent; + + if (request.IsRetrieveParentIdentifier()) { - throw OrthancException(ErrorCode_InternalError); + if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier)) + { + return; // The resource is not available anymore + } + + if (level == ResourceType_Patient) + { + if (!parent.empty()) + { + throw OrthancException(ErrorCode_DatabasePlugin); + } + } + else + { + if (parent.empty()) + { + throw OrthancException(ErrorCode_DatabasePlugin); + } + } + } + else + { + if (!transaction_.LookupResource(internalId, level, identifier)) + { + return; // The resource is not available anymore + } + } + + if (level != request.GetLevel()) + { + throw OrthancException(ErrorCode_DatabasePlugin); } std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier)); + if (request.IsRetrieveParentIdentifier()) + { + assert(!parent.empty()); + resource->SetParentIdentifier(parent); + } + if (request.IsRetrieveMainDicomTags()) { DicomMap m; @@ -120,24 +157,11 @@ } else { - throw OrthancException(ErrorCode_InternalError); + throw OrthancException(ErrorCode_DatabasePlugin); } } } - if (request.IsRetrieveParentIdentifier()) - { - int64_t parentId; - if (transaction_.LookupParent(parentId, internalId)) - { - resource->SetParentIdentifier(transaction_.GetPublicId(parentId)); - } - else - { - throw OrthancException(ErrorCode_InternalError); - } - } - if (request.IsRetrieveChildrenIdentifiers()) { std::list<std::string> children; @@ -149,10 +173,12 @@ } } - if (request.IsRetrieveChildrenMetadata()) + for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin(); + it != request.GetRetrieveChildrenMetadata().end(); ++it) { - // TODO-FIND - throw OrthancException(ErrorCode_NotImplemented); + std::list<std::string> values; + transaction_.GetChildrenMetadata(values, internalId, *it); + resource->AddChildrenMetadata(*it, values); } response.Add(resource.release());