Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5618:824a5fb0774e find-refactoring
removed constructor of ExpandedResource with FindRequest
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 11 May 2024 11:23:25 +0200 |
parents | 4640b7ae9a11 |
children | 3f13db27b399 |
comparison
equal
deleted
inserted
replaced
5617:8905ffa45fc2 | 5618:824a5fb0774e |
---|---|
3767 **/ | 3767 **/ |
3768 expand.Apply(*this, response, request, *it); | 3768 expand.Apply(*this, response, request, *it); |
3769 } | 3769 } |
3770 } | 3770 } |
3771 } | 3771 } |
3772 | |
3773 // TODO-FIND: we reuse the ExpandedResource class to reuse Serialization code from ExpandedResource | |
3774 // But, finally, we might just get rid of ExpandedResource and replace it by FindResponse | |
3775 ExpandedResource::ExpandedResource(const FindRequest& request, | |
3776 const FindResponse::Resource& resource) : | |
3777 id_(resource.GetIdentifier()), | |
3778 level_(request.GetLevel()), | |
3779 isStable_(false), | |
3780 expectedNumberOfInstances_(0), | |
3781 fileSize_(0), | |
3782 indexInSeries_(0) | |
3783 { | |
3784 if (request.GetLevel() != resource.GetLevel()) | |
3785 { | |
3786 throw OrthancException(ErrorCode_InternalError); | |
3787 } | |
3788 | |
3789 if (request.IsRetrieveMainDicomTags(request.GetLevel())) | |
3790 { | |
3791 resource.GetMainDicomTags(tags_, request.GetLevel()); | |
3792 } | |
3793 | |
3794 if (request.IsRetrieveChildrenIdentifiers()) | |
3795 { | |
3796 const std::set<std::string>& children = resource.GetChildrenIdentifiers(); | |
3797 for (std::set<std::string>::const_iterator it = children.begin(); it != children.end(); ++it) | |
3798 { | |
3799 childrenIds_.push_back(*it); | |
3800 } | |
3801 } | |
3802 | |
3803 if (request.IsRetrieveParentIdentifier()) | |
3804 { | |
3805 parentId_ = resource.GetParentIdentifier(); | |
3806 } | |
3807 | |
3808 if (request.IsRetrieveMetadata(request.GetLevel())) | |
3809 { | |
3810 metadata_ = resource.GetMetadata(request.GetLevel()); | |
3811 std::string value; | |
3812 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_MainDicomTagsSignature)) | |
3813 { | |
3814 mainDicomTagsSignature_ = value; | |
3815 } | |
3816 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_AnonymizedFrom)) | |
3817 { | |
3818 anonymizedFrom_ = value; | |
3819 } | |
3820 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_ModifiedFrom)) | |
3821 { | |
3822 modifiedFrom_ = value; | |
3823 } | |
3824 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_LastUpdate)) | |
3825 { | |
3826 lastUpdate_ = value; | |
3827 } | |
3828 if (request.GetLevel() == ResourceType_Series) | |
3829 { | |
3830 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_Series_ExpectedNumberOfInstances)) | |
3831 { | |
3832 expectedNumberOfInstances_ = boost::lexical_cast<int>(value); | |
3833 } | |
3834 } | |
3835 if (request.GetLevel() == ResourceType_Instance) | |
3836 { | |
3837 if (resource.LookupMetadata(value, request.GetLevel(), MetadataType_Instance_IndexInSeries)) | |
3838 { | |
3839 indexInSeries_ = boost::lexical_cast<int>(value); | |
3840 } | |
3841 } | |
3842 } | |
3843 | |
3844 if (request.IsRetrieveLabels()) | |
3845 { | |
3846 labels_ = resource.GetLabels(); | |
3847 } | |
3848 | |
3849 if (request.IsRetrieveAttachments()) | |
3850 { | |
3851 FileInfo attachment; | |
3852 if (resource.LookupAttachment(attachment, FileContentType_Dicom)) | |
3853 { | |
3854 fileSize_ = attachment.GetUncompressedSize(); | |
3855 fileUuid_ = attachment.GetUuid(); | |
3856 } | |
3857 } | |
3858 | |
3859 //if (request.IsRetrieveChildrenMetadata()) | |
3860 { | |
3861 // TODO-FIND: the status_ is normally obtained from transaction.GetSeriesStatus(internalId, i) | |
3862 // but, that's an heavy operation for something that is rarely used -> we should have dedicated SQL code | |
3863 // to compute it AFAP and we should compute it only if the user request it ! | |
3864 } | |
3865 | |
3866 // TODO-FIND: continue: isStable_, status_ | |
3867 } | |
3868 } | 3772 } |