Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5589:b51ee994cd6f find-refactoring
renamed FindResponse::Item as FindResponse::Resource
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 03 May 2024 17:26:06 +0200 |
parents | fc3914c07dd3 |
children | 8b32213af23e |
comparison
equal
deleted
inserted
replaced
5588:1b0fc6685f57 | 5589:b51ee994cd6f |
---|---|
3862 } | 3862 } |
3863 | 3863 |
3864 // TODO-FIND: we reuse the ExpandedResource class to reuse Serialization code from ExpandedResource | 3864 // TODO-FIND: we reuse the ExpandedResource class to reuse Serialization code from ExpandedResource |
3865 // But, finally, we might just get rid of ExpandedResource and replace it by FindResponse | 3865 // But, finally, we might just get rid of ExpandedResource and replace it by FindResponse |
3866 ExpandedResource::ExpandedResource(const FindRequest& request, | 3866 ExpandedResource::ExpandedResource(const FindRequest& request, |
3867 const FindResponse::Item& item) : | 3867 const FindResponse::Resource& resource) : |
3868 id_(item.GetIdentifier()), | 3868 id_(resource.GetIdentifier()), |
3869 level_(request.GetLevel()), | 3869 level_(request.GetLevel()), |
3870 isStable_(false), | 3870 isStable_(false), |
3871 expectedNumberOfInstances_(0), | 3871 expectedNumberOfInstances_(0), |
3872 fileSize_(0), | 3872 fileSize_(0), |
3873 indexInSeries_(0) | 3873 indexInSeries_(0) |
3874 { | 3874 { |
3875 if (request.GetLevel() != resource.GetLevel()) | |
3876 { | |
3877 throw OrthancException(ErrorCode_InternalError); | |
3878 } | |
3879 | |
3875 if (request.HasResponseContent(FindRequest::ResponseContent_MainDicomTags)) | 3880 if (request.HasResponseContent(FindRequest::ResponseContent_MainDicomTags)) |
3876 { | 3881 { |
3877 item.GetDicomTagsAtLevel(tags_, request.GetLevel()); | 3882 resource.GetDicomTagsAtLevel(tags_, request.GetLevel()); |
3878 } | 3883 } |
3879 | 3884 |
3880 if (request.HasResponseContent(FindRequest::ResponseContent_Children)) | 3885 if (request.HasResponseContent(FindRequest::ResponseContent_Children)) |
3881 { | 3886 { |
3882 const std::set<std::string>& s = item.GetChildrenIdentifiers(GetChildResourceType(request.GetLevel())); | 3887 const std::set<std::string>& s = resource.GetChildrenIdentifiers(GetChildResourceType(request.GetLevel())); |
3883 for (std::set<std::string>::const_iterator it = s.begin(); it != s.end(); ++it) | 3888 for (std::set<std::string>::const_iterator it = s.begin(); it != s.end(); ++it) |
3884 { | 3889 { |
3885 childrenIds_.push_back(*it); | 3890 childrenIds_.push_back(*it); |
3886 } | 3891 } |
3887 } | 3892 } |
3888 | 3893 |
3889 if (request.HasResponseContent(FindRequest::ResponseContent_Parent)) | 3894 if (request.HasResponseContent(FindRequest::ResponseContent_Parent)) |
3890 { | 3895 { |
3891 parentId_ = item.GetParentIdentifier(); | 3896 parentId_ = resource.GetParentIdentifier(); |
3892 } | 3897 } |
3893 | 3898 |
3894 if (request.HasResponseContent(FindRequest::ResponseContent_Metadata)) | 3899 if (request.HasResponseContent(FindRequest::ResponseContent_Metadata)) |
3895 { | 3900 { |
3896 metadata_ = item.GetMetadata(); | 3901 metadata_ = resource.GetMetadata(); |
3897 std::string value; | 3902 std::string value; |
3898 if (item.LookupMetadata(value, MetadataType_MainDicomTagsSignature)) | 3903 if (resource.LookupMetadata(value, MetadataType_MainDicomTagsSignature)) |
3899 { | 3904 { |
3900 mainDicomTagsSignature_ = value; | 3905 mainDicomTagsSignature_ = value; |
3901 } | 3906 } |
3902 if (item.LookupMetadata(value, MetadataType_AnonymizedFrom)) | 3907 if (resource.LookupMetadata(value, MetadataType_AnonymizedFrom)) |
3903 { | 3908 { |
3904 anonymizedFrom_ = value; | 3909 anonymizedFrom_ = value; |
3905 } | 3910 } |
3906 if (item.LookupMetadata(value, MetadataType_ModifiedFrom)) | 3911 if (resource.LookupMetadata(value, MetadataType_ModifiedFrom)) |
3907 { | 3912 { |
3908 modifiedFrom_ = value; | 3913 modifiedFrom_ = value; |
3909 } | 3914 } |
3910 if (item.LookupMetadata(value, MetadataType_LastUpdate)) | 3915 if (resource.LookupMetadata(value, MetadataType_LastUpdate)) |
3911 { | 3916 { |
3912 lastUpdate_ = value; | 3917 lastUpdate_ = value; |
3913 } | 3918 } |
3914 if (request.GetLevel() == ResourceType_Series) | 3919 if (request.GetLevel() == ResourceType_Series) |
3915 { | 3920 { |
3916 if (item.LookupMetadata(value, MetadataType_Series_ExpectedNumberOfInstances)) | 3921 if (resource.LookupMetadata(value, MetadataType_Series_ExpectedNumberOfInstances)) |
3917 { | 3922 { |
3918 expectedNumberOfInstances_ = boost::lexical_cast<int>(value); | 3923 expectedNumberOfInstances_ = boost::lexical_cast<int>(value); |
3919 } | 3924 } |
3920 } | 3925 } |
3921 if (request.GetLevel() == ResourceType_Instance) | 3926 if (request.GetLevel() == ResourceType_Instance) |
3922 { | 3927 { |
3923 if (item.LookupMetadata(value, MetadataType_Instance_IndexInSeries)) | 3928 if (resource.LookupMetadata(value, MetadataType_Instance_IndexInSeries)) |
3924 { | 3929 { |
3925 indexInSeries_ = boost::lexical_cast<int>(value); | 3930 indexInSeries_ = boost::lexical_cast<int>(value); |
3926 } | 3931 } |
3927 } | 3932 } |
3928 } | 3933 } |
3929 | 3934 |
3930 if (request.HasResponseContent(FindRequest::ResponseContent_Labels)) | 3935 if (request.HasResponseContent(FindRequest::ResponseContent_Labels)) |
3931 { | 3936 { |
3932 labels_ = item.GetLabels(); | 3937 labels_ = resource.GetLabels(); |
3933 } | 3938 } |
3934 | 3939 |
3935 if (request.HasResponseContent(FindRequest::ResponseContent_Attachments)) | 3940 if (request.HasResponseContent(FindRequest::ResponseContent_Attachments)) |
3936 { | 3941 { |
3937 FileInfo attachment; | 3942 FileInfo attachment; |
3938 if (item.LookupAttachment(attachment, FileContentType_Dicom)) | 3943 if (resource.LookupAttachment(attachment, FileContentType_Dicom)) |
3939 { | 3944 { |
3940 fileSize_ = attachment.GetUncompressedSize(); | 3945 fileSize_ = attachment.GetUncompressedSize(); |
3941 fileUuid_ = attachment.GetUuid(); | 3946 fileUuid_ = attachment.GetUuid(); |
3942 } | 3947 } |
3943 } | 3948 } |