comparison OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5772:093a8693ba16 find-refactoring

replaced SetRetrieveOneInstanceIdentifier() by SetRetrieveOneInstanceMetadataAndAttachments()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 11 Sep 2024 20:49:34 +0200
parents 4db9f897df58
children 3b7dce0e43c6
comparison
equal deleted inserted replaced
5771:4db9f897df58 5772:093a8693ba16
564 564
565 currentLevel = childrenLevel; 565 currentLevel = childrenLevel;
566 } 566 }
567 } 567 }
568 568
569 if (request.IsRetrieveOneInstanceIdentifier() && 569 if (request.GetLevel() != ResourceType_Instance &&
570 !request.GetChildrenSpecification(ResourceType_Instance).IsRetrieveIdentifiers()) 570 request.IsRetrieveOneInstanceMetadataAndAttachments())
571 { 571 {
572 int64_t currentId = internalId; 572 int64_t currentId = internalId;
573 ResourceType currentLevel = level; 573 ResourceType currentLevel = level;
574 574
575 while (currentLevel != ResourceType_Instance) 575 while (currentLevel != ResourceType_Instance)
585 currentId = children.front(); 585 currentId = children.front();
586 currentLevel = GetChildResourceType(currentLevel); 586 currentLevel = GetChildResourceType(currentLevel);
587 } 587 }
588 } 588 }
589 589
590 resource->AddChildIdentifier(ResourceType_Instance, transaction_.GetPublicId(currentId)); 590 std::map<MetadataType, std::string> metadata;
591 transaction_.GetAllMetadata(metadata, currentId);
592
593 std::set<FileContentType> attachmentsType;
594 transaction_.ListAvailableAttachments(attachmentsType, currentId);
595
596 std::map<FileContentType, FileInfo> attachments;
597 for (std::set<FileContentType>::const_iterator it = attachmentsType.begin(); it != attachmentsType.end(); ++it)
598 {
599 FileInfo info;
600 int64_t revision; // Unused in this case
601 if (transaction_.LookupAttachment(info, revision, currentId, *it))
602 {
603 attachments[*it] = info;
604 }
605 else
606 {
607 throw OrthancException(ErrorCode_DatabasePlugin);
608 }
609 }
610
611 resource->SetOneInstanceMetadataAndAttachments(transaction_.GetPublicId(currentId), metadata, attachments);
591 } 612 }
592 613
593 response.Add(resource.release()); 614 response.Add(resource.release());
594 } 615 }
595 } 616 }