Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/Compatibility/DatabaseLookup.cpp @ 4591:ff8170d17d90 db-changes
moving all accesses to databases from IDatabaseWrapper to ITransaction
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Mar 2021 15:30:42 +0100 |
parents | d9473bd5ed43 |
children | f0038043fb97 7053502fbf97 |
comparison
equal
deleted
inserted
replaced
4590:4a0bf1019335 | 4591:ff8170d17d90 |
---|---|
159 candidates.Intersect(matches); | 159 candidates.Intersect(matches); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 static void ApplyLevel(SetOfResources& candidates, | 163 static void ApplyLevel(SetOfResources& candidates, |
164 IDatabaseWrapper& database, | 164 IDatabaseWrapper::ITransaction& transaction, |
165 ILookupResources& compatibility, | 165 ILookupResources& compatibility, |
166 const std::vector<DatabaseConstraint>& lookup, | 166 const std::vector<DatabaseConstraint>& lookup, |
167 ResourceType level) | 167 ResourceType level) |
168 { | 168 { |
169 typedef std::set<const DatabaseConstraint*> SetOfConstraints; | 169 typedef std::set<const DatabaseConstraint*> SetOfConstraints; |
265 std::list<int64_t> filtered; | 265 std::list<int64_t> filtered; |
266 for (std::list<int64_t>::const_iterator candidate = source.begin(); | 266 for (std::list<int64_t>::const_iterator candidate = source.begin(); |
267 candidate != source.end(); ++candidate) | 267 candidate != source.end(); ++candidate) |
268 { | 268 { |
269 DicomMap tags; | 269 DicomMap tags; |
270 database.GetMainDicomTags(tags, *candidate); | 270 transaction.GetMainDicomTags(tags, *candidate); |
271 | 271 |
272 bool match = true; | 272 bool match = true; |
273 | 273 |
274 for (size_t i = 0; i < c.GetSize(); i++) | 274 for (size_t i = 0; i < c.GetSize(); i++) |
275 { | 275 { |
289 candidates.Intersect(filtered); | 289 candidates.Intersect(filtered); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 | 293 |
294 static std::string GetOneInstance(IDatabaseWrapper& compatibility, | 294 static std::string GetOneInstance(IDatabaseWrapper::ITransaction& compatibility, |
295 int64_t resource, | 295 int64_t resource, |
296 ResourceType level) | 296 ResourceType level) |
297 { | 297 { |
298 for (int i = level; i < ResourceType_Instance; i++) | 298 for (int i = level; i < ResourceType_Instance; i++) |
299 { | 299 { |
346 } | 346 } |
347 | 347 |
348 assert(upperLevel <= queryLevel && | 348 assert(upperLevel <= queryLevel && |
349 queryLevel <= lowerLevel); | 349 queryLevel <= lowerLevel); |
350 | 350 |
351 SetOfResources candidates(database_, upperLevel); | 351 SetOfResources candidates(transaction_, upperLevel); |
352 | 352 |
353 for (int level = upperLevel; level <= lowerLevel; level++) | 353 for (int level = upperLevel; level <= lowerLevel; level++) |
354 { | 354 { |
355 ApplyLevel(candidates, database_, compatibility_, lookup, static_cast<ResourceType>(level)); | 355 ApplyLevel(candidates, transaction_, compatibility_, lookup, static_cast<ResourceType>(level)); |
356 | 356 |
357 if (level != lowerLevel) | 357 if (level != lowerLevel) |
358 { | 358 { |
359 candidates.GoDown(); | 359 candidates.GoDown(); |
360 } | 360 } |
370 std::list<int64_t> parents; | 370 std::list<int64_t> parents; |
371 for (std::list<int64_t>::const_iterator | 371 for (std::list<int64_t>::const_iterator |
372 it = resources.begin(); it != resources.end(); ++it) | 372 it = resources.begin(); it != resources.end(); ++it) |
373 { | 373 { |
374 int64_t parent; | 374 int64_t parent; |
375 if (database_.LookupParent(parent, *it)) | 375 if (transaction_.LookupParent(parent, *it)) |
376 { | 376 { |
377 parents.push_back(parent); | 377 parents.push_back(parent); |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
394 size_t pos = 0; | 394 size_t pos = 0; |
395 | 395 |
396 for (std::list<int64_t>::const_iterator | 396 for (std::list<int64_t>::const_iterator |
397 it = resources.begin(); it != resources.end(); ++it, pos++) | 397 it = resources.begin(); it != resources.end(); ++it, pos++) |
398 { | 398 { |
399 assert(database_.GetResourceType(*it) == queryLevel); | 399 assert(transaction_.GetResourceType(*it) == queryLevel); |
400 | 400 |
401 const std::string resource = database_.GetPublicId(*it); | 401 const std::string resource = transaction_.GetPublicId(*it); |
402 resourcesId.push_back(resource); | 402 resourcesId.push_back(resource); |
403 | 403 |
404 if (instancesId != NULL) | 404 if (instancesId != NULL) |
405 { | 405 { |
406 if (queryLevel == ResourceType_Instance) | 406 if (queryLevel == ResourceType_Instance) |
409 instancesId->push_back(resource); | 409 instancesId->push_back(resource); |
410 } | 410 } |
411 else | 411 else |
412 { | 412 { |
413 // Collect one child instance for each of the selected resources | 413 // Collect one child instance for each of the selected resources |
414 instancesId->push_back(GetOneInstance(database_, *it, queryLevel)); | 414 instancesId->push_back(GetOneInstance(transaction_, *it, queryLevel)); |
415 } | 415 } |
416 } | 416 } |
417 } | 417 } |
418 } | 418 } |
419 } | 419 } |