comparison OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5609:4690a0d2b01e find-refactoring

preliminary support of requestedTags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 May 2024 18:28:36 +0200
parents 6e2dad336446
children 4640b7ae9a11
comparison
equal deleted inserted replaced
5608:3d0aa94b44b3 5609:4690a0d2b01e
277 std::list<std::string> values; 277 std::list<std::string> values;
278 transaction_.GetChildrenMetadata(values, internalId, *it); 278 transaction_.GetChildrenMetadata(values, internalId, *it);
279 resource->AddChildrenMetadata(*it, values); 279 resource->AddChildrenMetadata(*it, values);
280 } 280 }
281 281
282 if (!request.GetRetrieveAttachmentOfOneInstance().empty()) 282 if (request.IsRetrieveOneInstanceIdentifier())
283 { 283 {
284 std::set<FileContentType> todo = request.GetRetrieveAttachmentOfOneInstance(); 284 int64_t currentId = internalId;
285 std::stack< std::pair<ResourceType, int64_t> > candidates; 285 ResourceType currentLevel = level;
286 candidates.push(std::make_pair(level, internalId)); 286
287 287 while (currentLevel != ResourceType_Instance)
288 while (!todo.empty() && 288 {
289 !candidates.empty()) 289 std::list<int64_t> children;
290 { 290 transaction_.GetChildrenInternalId(children, currentId);
291 std::pair<ResourceType, int64_t> top = candidates.top(); 291 if (children.empty())
292 candidates.pop(); 292 {
293 293 throw OrthancException(ErrorCode_DatabasePlugin);
294 if (top.first == ResourceType_Instance) 294 }
295 { 295 else
296 std::set<FileContentType> nextTodo; 296 {
297 297 currentId = children.front();
298 for (std::set<FileContentType>::const_iterator it = todo.begin(); it != todo.end(); ++it) 298 currentLevel = GetChildResourceType(currentLevel);
299 { 299 }
300 FileInfo attachment; 300 }
301 int64_t revision; 301
302 if (transaction_.LookupAttachment(attachment, revision, top.second, *it)) 302 resource->SetOneInstanceIdentifier(transaction_.GetPublicId(currentId));
303 {
304 resource->AddAttachmentOfOneInstance(attachment);
305 }
306 else
307 {
308 nextTodo.insert(*it);
309 }
310 }
311
312 todo = nextTodo;
313 }
314 else
315 {
316 std::list<int64_t> children;
317 transaction_.GetChildrenInternalId(children, top.second);
318 for (std::list<int64_t>::const_iterator it = children.begin(); it != children.end(); ++it)
319 {
320 candidates.push(std::make_pair(GetChildResourceType(top.first), *it));
321 }
322 }
323 }
324 } 303 }
325 304
326 response.Add(resource.release()); 305 response.Add(resource.release());
327 } 306 }
328 } 307 }