Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 1753:faf2ecab3472 db-changes
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 27 Oct 2015 20:31:34 +0100 |
parents | c3d8ec63a179 |
children | 39c37a994b2f |
comparison
equal
deleted
inserted
replaced
1752:c3d8ec63a179 | 1753:faf2ecab3472 |
---|---|
336 * Run the query. | 336 * Run the query. |
337 **/ | 337 **/ |
338 | 338 |
339 #if USE_LOOKUP_RESOURCE != 1 | 339 #if USE_LOOKUP_RESOURCE != 1 |
340 ResourceFinder finder(context_); | 340 ResourceFinder finder(context_); |
341 #endif | |
342 | 341 |
343 switch (level) | 342 switch (level) |
344 { | 343 { |
345 case ResourceType_Patient: | 344 case ResourceType_Patient: |
346 case ResourceType_Study: | 345 case ResourceType_Study: |
353 break; | 352 break; |
354 | 353 |
355 default: | 354 default: |
356 throw OrthancException(ErrorCode_InternalError); | 355 throw OrthancException(ErrorCode_InternalError); |
357 } | 356 } |
358 | 357 #else |
358 size_t maxResults = (level == ResourceType_Instance) ? maxInstances_ : maxResults_; | |
359 | |
360 #endif | |
361 | |
362 #if USE_LOOKUP_RESOURCE == 1 | |
363 std::vector<std::string> resources, instances; | |
364 context_.GetIndex().FindCandidates(resources, instances, finder); | |
365 | |
366 assert(resources.size() == instances.size()); | |
367 bool finished = true; | |
368 | |
369 for (size_t i = 0; i < instances.size(); i++) | |
370 { | |
371 Json::Value dicom; | |
372 context_.ReadJson(dicom, instances[i]); | |
373 | |
374 if (finder.IsMatch(dicom)) | |
375 { | |
376 if (maxResults != 0 && | |
377 answers.GetSize() >= maxResults) | |
378 { | |
379 finished = false; | |
380 break; | |
381 } | |
382 else | |
383 { | |
384 AddAnswer(answers, dicom, query); | |
385 } | |
386 } | |
387 } | |
388 | |
389 #else | |
359 std::list<std::string> tmp; | 390 std::list<std::string> tmp; |
360 | |
361 #if USE_LOOKUP_RESOURCE == 1 | |
362 bool finished = context_.Apply(tmp, finder); | |
363 | |
364 for (std::list<std::string>::const_iterator | |
365 it = tmp.begin(); it != tmp.end(); ++it) | |
366 { | |
367 // TODO | |
368 Json::Value resource; | |
369 context_.ReadJson(resource, *it); | |
370 AddAnswer(answers, resource, query); | |
371 } | |
372 | |
373 #else | |
374 bool finished = finder.Apply(tmp, findQuery); | 391 bool finished = finder.Apply(tmp, findQuery); |
375 #endif | 392 #endif |
376 | 393 |
377 LOG(INFO) << "Number of matching resources: " << tmp.size(); | 394 LOG(INFO) << "Number of matching resources: " << answers.GetSize(); |
378 | 395 |
379 return finished; | 396 return finished; |
380 } | 397 } |
381 } | 398 } |