Mercurial > hg > orthanc
diff OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5619:1864b16bc7b1 find-refactoring
added FindRequest::ParentRetrieveSpecification
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 11 May 2024 12:13:31 +0200 |
parents | 8905ffa45fc2 |
children | 732ec9feeea8 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Sat May 11 11:23:25 2024 +0200 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Sat May 11 12:13:31 2024 +0200 @@ -239,8 +239,8 @@ return ResourceType_Patient; case ResourceType_Study: - if (request.IsRetrieveMainDicomTags(ResourceType_Patient) || - request.IsRetrieveMetadata(ResourceType_Patient)) + if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata()) { return ResourceType_Patient; } @@ -250,13 +250,13 @@ } case ResourceType_Series: - if (request.IsRetrieveMainDicomTags(ResourceType_Patient) || - request.IsRetrieveMetadata(ResourceType_Patient)) + if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata()) { return ResourceType_Patient; } - else if (request.IsRetrieveMainDicomTags(ResourceType_Study) || - request.IsRetrieveMetadata(ResourceType_Study)) + else if (request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMetadata()) { return ResourceType_Study; } @@ -266,18 +266,18 @@ } case ResourceType_Instance: - if (request.IsRetrieveMainDicomTags(ResourceType_Patient) || - request.IsRetrieveMetadata(ResourceType_Patient)) + if (request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Patient).IsRetrieveMetadata()) { return ResourceType_Patient; } - else if (request.IsRetrieveMainDicomTags(ResourceType_Study) || - request.IsRetrieveMetadata(ResourceType_Study)) + else if (request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Study).IsRetrieveMetadata()) { return ResourceType_Study; } - else if (request.IsRetrieveMainDicomTags(ResourceType_Series) || - request.IsRetrieveMetadata(ResourceType_Series)) + else if (request.GetParentRetrieveSpecification(ResourceType_Series).IsRetrieveMainDicomTags() || + request.GetParentRetrieveSpecification(ResourceType_Series).IsRetrieveMetadata()) { return ResourceType_Series; } @@ -343,40 +343,44 @@ resource->SetParentIdentifier(parent); } + if (request.IsRetrieveMainDicomTags()) { + RetrieveMainDicomTags(*resource, level, internalId); + } + + if (request.IsRetrieveMetadata()) + { + transaction_.GetAllMetadata(resource->GetMetadata(level), internalId); + } + + { + const ResourceType topLevel = GetTopLevelOfInterest(request); + int64_t currentId = internalId; ResourceType currentLevel = level; - const ResourceType topLevel = GetTopLevelOfInterest(request); - for (;;) + while (currentLevel != topLevel) { - if (request.IsRetrieveMainDicomTags(currentLevel)) + int64_t parentId; + if (transaction_.LookupParent(parentId, currentId)) + { + currentId = parentId; + currentLevel = GetParentResourceType(currentLevel); + } + else + { + throw OrthancException(ErrorCode_DatabasePlugin); + } + + if (request.GetParentRetrieveSpecification(currentLevel).IsRetrieveMainDicomTags()) { RetrieveMainDicomTags(*resource, currentLevel, currentId); } - if (request.IsRetrieveMetadata(currentLevel)) + if (request.GetParentRetrieveSpecification(currentLevel).IsRetrieveMetadata()) { transaction_.GetAllMetadata(resource->GetMetadata(currentLevel), currentId); } - - if (currentLevel == topLevel) - { - break; - } - else - { - int64_t parentId; - if (transaction_.LookupParent(parentId, currentId)) - { - currentId = parentId; - currentLevel = GetParentResourceType(currentLevel); - } - else - { - throw OrthancException(ErrorCode_DatabasePlugin); - } - } } }