comparison OrthancServer/OrthancFindRequestHandler.cpp @ 947:c2c28dd17e87 query-retrieve

integration mainline -> query-retrieve
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 12:09:38 +0200
parents 67e6400fca03 83489fddd8c5
children 111e23bb4904
comparison
equal deleted inserted replaced
758:67e6400fca03 947:c2c28dd17e87
27 * 27 *
28 * You should have received a copy of the GNU General Public License 28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. 29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 **/ 30 **/
31 31
32
33 #include "PrecompiledHeadersServer.h"
32 #include "OrthancFindRequestHandler.h" 34 #include "OrthancFindRequestHandler.h"
33 35
34 #include <glog/logging.h> 36 #include <glog/logging.h>
35 #include <boost/regex.hpp> 37 #include <boost/regex.hpp>
36 38
37 #include "../Core/DicomFormat/DicomArray.h" 39 #include "../Core/DicomFormat/DicomArray.h"
38 #include "ServerToolbox.h" 40 #include "ServerToolbox.h"
39 #include "OrthancInitialization.h" 41 #include "OrthancInitialization.h"
42 #include "FromDcmtkBridge.h"
40 43
41 namespace Orthanc 44 namespace Orthanc
42 { 45 {
43 static bool IsWildcard(const std::string& constraint) 46 static bool IsWildcard(const std::string& constraint)
44 { 47 {
437 } 440 }
438 }; 441 };
439 } 442 }
440 443
441 444
442 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, 445 bool OrthancFindRequestHandler::HasReachedLimit(const DicomFindAnswers& answers,
446 ResourceType level) const
447 {
448 switch (level)
449 {
450 case ResourceType_Patient:
451 case ResourceType_Study:
452 case ResourceType_Series:
453 return (maxResults_ != 0 && answers.GetSize() >= maxResults_);
454
455 case ResourceType_Instance:
456 return (maxInstances_ != 0 && answers.GetSize() >= maxInstances_);
457
458 default:
459 throw OrthancException(ErrorCode_InternalError);
460 }
461 }
462
463
464 bool OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
443 const DicomMap& input, 465 const DicomMap& input,
444 const std::string& callingAETitle) 466 const std::string& callingAETitle)
445 { 467 {
446 /** 468 /**
447 * Retrieve the manufacturer of this modality. 469 * Retrieve the manufacturer of this modality.
448 **/ 470 **/
449 471
450 ModalityManufacturer manufacturer; 472 ModalityManufacturer manufacturer;
451 473
452 { 474 {
453 std::string symbolicName, address; 475 RemoteModalityParameters modality;
454 int port; 476
455 477 if (!Configuration::LookupDicomModalityUsingAETitle(modality, callingAETitle))
456 if (!LookupDicomModalityUsingAETitle(callingAETitle, symbolicName, address, port, manufacturer))
457 { 478 {
458 throw OrthancException("Unknown modality"); 479 throw OrthancException("Unknown modality");
459 } 480 }
481
482 manufacturer = modality.GetManufacturer();
460 } 483 }
461 484
462 485
463 /** 486 /**
464 * Retrieve the query level. 487 * Retrieve the query level.
574 Json::Value info; 597 Json::Value info;
575 context_.ReadJson(info, instance); 598 context_.ReadJson(info, instance);
576 599
577 if (Matches(info, query)) 600 if (Matches(info, query))
578 { 601 {
602 if (HasReachedLimit(answers, level))
603 {
604 // Too many results, stop before recording this new match
605 return false;
606 }
607
579 AddAnswer(answers, info, query); 608 AddAnswer(answers, info, query);
580 } 609 }
581 } 610 }
582 } 611 }
583 catch (OrthancException&) 612 catch (OrthancException&)
584 { 613 {
585 // This resource has probably been deleted during the find request 614 // This resource has probably been deleted during the find request
586 } 615 }
587 } 616 }
617
618 return true; // All the matching resources have been returned
588 } 619 }
589 } 620 }
590 621
591 622
592 623