Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5595:a87f2a56257d find-refactoring
implemented FindRequest::retrieveChildrenMetadata_
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 May 2024 12:53:12 +0200 |
parents | a906dc19264c |
children | 81a29ad7fb4b |
comparison
equal
deleted
inserted
replaced
5594:a906dc19264c | 5595:a87f2a56257d |
---|---|
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 level; | 67 ResourceType level; |
68 if (!transaction_.LookupResource(internalId, level, identifier) || | 68 std::string parent; |
69 level != request.GetLevel()) | 69 |
70 if (request.IsRetrieveParentIdentifier()) | |
70 { | 71 { |
71 throw OrthancException(ErrorCode_InternalError); | 72 if (!transaction_.LookupResourceAndParent(internalId, level, parent, identifier)) |
73 { | |
74 return; // The resource is not available anymore | |
75 } | |
76 | |
77 if (level == ResourceType_Patient) | |
78 { | |
79 if (!parent.empty()) | |
80 { | |
81 throw OrthancException(ErrorCode_DatabasePlugin); | |
82 } | |
83 } | |
84 else | |
85 { | |
86 if (parent.empty()) | |
87 { | |
88 throw OrthancException(ErrorCode_DatabasePlugin); | |
89 } | |
90 } | |
91 } | |
92 else | |
93 { | |
94 if (!transaction_.LookupResource(internalId, level, identifier)) | |
95 { | |
96 return; // The resource is not available anymore | |
97 } | |
98 } | |
99 | |
100 if (level != request.GetLevel()) | |
101 { | |
102 throw OrthancException(ErrorCode_DatabasePlugin); | |
72 } | 103 } |
73 | 104 |
74 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier)); | 105 std::unique_ptr<FindResponse::Resource> resource(new FindResponse::Resource(request.GetLevel(), identifier)); |
106 | |
107 if (request.IsRetrieveParentIdentifier()) | |
108 { | |
109 assert(!parent.empty()); | |
110 resource->SetParentIdentifier(parent); | |
111 } | |
75 | 112 |
76 if (request.IsRetrieveMainDicomTags()) | 113 if (request.IsRetrieveMainDicomTags()) |
77 { | 114 { |
78 DicomMap m; | 115 DicomMap m; |
79 transaction_.GetMainDicomTags(m, internalId); | 116 transaction_.GetMainDicomTags(m, internalId); |
118 { | 155 { |
119 resource->AddAttachment(info); | 156 resource->AddAttachment(info); |
120 } | 157 } |
121 else | 158 else |
122 { | 159 { |
123 throw OrthancException(ErrorCode_InternalError); | 160 throw OrthancException(ErrorCode_DatabasePlugin); |
124 } | 161 } |
125 } | |
126 } | |
127 | |
128 if (request.IsRetrieveParentIdentifier()) | |
129 { | |
130 int64_t parentId; | |
131 if (transaction_.LookupParent(parentId, internalId)) | |
132 { | |
133 resource->SetParentIdentifier(transaction_.GetPublicId(parentId)); | |
134 } | |
135 else | |
136 { | |
137 throw OrthancException(ErrorCode_InternalError); | |
138 } | 162 } |
139 } | 163 } |
140 | 164 |
141 if (request.IsRetrieveChildrenIdentifiers()) | 165 if (request.IsRetrieveChildrenIdentifiers()) |
142 { | 166 { |
147 { | 171 { |
148 resource->AddChildIdentifier(GetChildResourceType(level), *it); | 172 resource->AddChildIdentifier(GetChildResourceType(level), *it); |
149 } | 173 } |
150 } | 174 } |
151 | 175 |
152 if (request.IsRetrieveChildrenMetadata()) | 176 for (std::set<MetadataType>::const_iterator it = request.GetRetrieveChildrenMetadata().begin(); |
177 it != request.GetRetrieveChildrenMetadata().end(); ++it) | |
153 { | 178 { |
154 // TODO-FIND | 179 std::list<std::string> values; |
155 throw OrthancException(ErrorCode_NotImplemented); | 180 transaction_.GetChildrenMetadata(values, internalId, *it); |
181 resource->AddChildrenMetadata(*it, values); | |
156 } | 182 } |
157 | 183 |
158 response.Add(resource.release()); | 184 response.Add(resource.release()); |
159 } | 185 } |
160 } | 186 } |