Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5594:a906dc19264c find-refactoring
created FindResponse::Resource::Format()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 04 May 2024 15:25:19 +0200 |
parents | 862b54b4cfe2 |
children | a87f2a56257d |
comparison
equal
deleted
inserted
replaced
5593:862b54b4cfe2 | 5594:a906dc19264c |
---|---|
38 !request.GetOrthancIdentifiers().HasStudyId() && | 38 !request.GetOrthancIdentifiers().HasStudyId() && |
39 !request.GetOrthancIdentifiers().HasSeriesId() && | 39 !request.GetOrthancIdentifiers().HasSeriesId() && |
40 !request.GetOrthancIdentifiers().HasInstanceId() && | 40 !request.GetOrthancIdentifiers().HasInstanceId() && |
41 request.GetDicomTagConstraintsCount() == 0 && | 41 request.GetDicomTagConstraintsCount() == 0 && |
42 request.GetMetadataConstraintsCount() == 0 && | 42 request.GetMetadataConstraintsCount() == 0 && |
43 request.GetOrdering().empty() && | 43 request.GetLabels().empty() && |
44 request.GetLabels().empty()) | 44 request.GetOrdering().empty()) |
45 { | 45 { |
46 if (request.HasLimits()) | 46 if (request.HasLimits()) |
47 { | 47 { |
48 transaction_.GetAllPublicIds(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount()); | 48 transaction_.GetAllPublicIds(identifiers, request.GetLevel(), request.GetLimitsSince(), request.GetLimitsCount()); |
49 } | 49 } |
62 void GenericFind::ExecuteExpand(FindResponse& response, | 62 void GenericFind::ExecuteExpand(FindResponse& response, |
63 const FindRequest& request, | 63 const FindRequest& request, |
64 const std::string& identifier) | 64 const std::string& identifier) |
65 { | 65 { |
66 int64_t internalId; | 66 int64_t internalId; |
67 ResourceType t; | 67 ResourceType level; |
68 if (!transaction_.LookupResource(internalId, t, identifier) || | 68 if (!transaction_.LookupResource(internalId, level, identifier) || |
69 t != request.GetLevel()) | 69 level != request.GetLevel()) |
70 { | 70 { |
71 throw OrthancException(ErrorCode_InternalError); | 71 throw OrthancException(ErrorCode_InternalError); |
72 } | 72 } |
73 | 73 |
74 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier)); | 74 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier)); |
92 throw OrthancException(ErrorCode_BadParameterType); | 92 throw OrthancException(ErrorCode_BadParameterType); |
93 } | 93 } |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 if (request.IsRetrieveMetadata()) | |
98 { | |
99 transaction_.GetAllMetadata(resource->GetMetadata(), internalId); | |
100 } | |
101 | |
102 if (request.IsRetrieveLabels()) | |
103 { | |
104 transaction_.ListLabels(resource->GetLabels(), internalId); | |
105 } | |
106 | |
107 if (request.IsRetrieveAttachments()) | |
108 { | |
109 std::set<FileContentType> attachments; | |
110 transaction_.ListAvailableAttachments(attachments, internalId); | |
111 | |
112 for (std::set<FileContentType>::const_iterator it = attachments.begin(); it != attachments.end(); ++it) | |
113 { | |
114 FileInfo info; | |
115 int64_t revision; | |
116 if (transaction_.LookupAttachment(info, revision, internalId, *it) && | |
117 info.GetContentType() == *it) | |
118 { | |
119 resource->AddAttachment(info); | |
120 } | |
121 else | |
122 { | |
123 throw OrthancException(ErrorCode_InternalError); | |
124 } | |
125 } | |
126 } | |
127 | |
97 if (request.IsRetrieveParentIdentifier()) | 128 if (request.IsRetrieveParentIdentifier()) |
98 { | 129 { |
99 int64_t parentId; | 130 int64_t parentId; |
100 if (transaction_.LookupParent(parentId, internalId)) | 131 if (transaction_.LookupParent(parentId, internalId)) |
101 { | 132 { |
105 { | 136 { |
106 throw OrthancException(ErrorCode_InternalError); | 137 throw OrthancException(ErrorCode_InternalError); |
107 } | 138 } |
108 } | 139 } |
109 | 140 |
110 // TODO-FIND: Continue | 141 if (request.IsRetrieveChildrenIdentifiers()) |
142 { | |
143 std::list<std::string> children; | |
144 transaction_.GetChildrenPublicId(children, internalId); | |
111 | 145 |
112 | 146 for (std::list<std::string>::const_iterator it = children.begin(); it != children.end(); ++it) |
113 /** | |
114 * Sanity checks | |
115 **/ | |
116 | |
117 if (request.IsRetrieveMainDicomTags()) | |
118 { | |
119 DicomMap tmp; | |
120 resource->GetMainDicomTags(tmp); | |
121 if (tmp.GetSize() == 0) | |
122 { | 147 { |
123 throw OrthancException(ErrorCode_InternalError); | 148 resource->AddChildIdentifier(GetChildResourceType(level), *it); |
124 } | 149 } |
125 } | 150 } |
126 | 151 |
152 if (request.IsRetrieveChildrenMetadata()) | |
153 { | |
154 // TODO-FIND | |
155 throw OrthancException(ErrorCode_NotImplemented); | |
156 } | |
127 | 157 |
128 response.Add(resource.release()); | 158 response.Add(resource.release()); |
129 } | 159 } |
130 } | 160 } |
131 } | 161 } |