comparison OrthancServer/ServerContext.cpp @ 2304:563bf878407a

Argument "Since" in URI "/tools/find" (related to issue #53)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jul 2017 17:24:31 +0200
parents a3a65de1840f
children 96b3ec054b69
comparison
equal deleted inserted replaced
2303:692527245856 2304:563bf878407a
599 return false; 599 return false;
600 #endif 600 #endif
601 } 601 }
602 602
603 603
604 bool ServerContext::Apply(std::list<std::string>& result, 604 void ServerContext::Apply(std::list<std::string>& result,
605 const ::Orthanc::LookupResource& lookup, 605 const ::Orthanc::LookupResource& lookup,
606 size_t maxResults) 606 size_t since,
607 size_t limit)
607 { 608 {
608 result.clear(); 609 result.clear();
609 610
610 std::vector<std::string> resources, instances; 611 std::vector<std::string> resources, instances;
611 GetIndex().FindCandidates(resources, instances, lookup); 612 GetIndex().FindCandidates(resources, instances, lookup);
612 613
613 assert(resources.size() == instances.size()); 614 assert(resources.size() == instances.size());
614 615
616 size_t skipped = 0;
615 for (size_t i = 0; i < instances.size(); i++) 617 for (size_t i = 0; i < instances.size(); i++)
616 { 618 {
617 Json::Value dicom; 619 Json::Value dicom;
618 ReadDicomAsJson(dicom, instances[i]); 620 ReadDicomAsJson(dicom, instances[i]);
619 621
620 if (lookup.IsMatch(dicom)) 622 if (lookup.IsMatch(dicom))
621 { 623 {
622 if (maxResults != 0 && 624 if (skipped < since)
623 result.size() >= maxResults)
624 { 625 {
625 return false; // too many results 626 skipped++;
627 }
628 else if (limit != 0 &&
629 result.size() >= limit)
630 {
631 return; // too many results
626 } 632 }
627 else 633 else
628 { 634 {
629 result.push_back(resources[i]); 635 result.push_back(resources[i]);
630 } 636 }
631 } 637 }
632 } 638 }
633
634 return true; // finished
635 } 639 }
636 640
637 } 641 }