# HG changeset patch # User Sebastien Jodogne # Date 1446031752 -3600 # Node ID 98abb8d7f9056357f6f70a9834c4f3ac19202ba0 # Parent 03b030680e3df77c99882f63fdb7ccee8bb8b136 ServerContext::Apply lookup diff -r 03b030680e3d -r 98abb8d7f905 NEWS --- a/NEWS Wed Oct 28 12:14:06 2015 +0100 +++ b/NEWS Wed Oct 28 12:29:12 2015 +0100 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Full indexation of the patient/study tags to speed up searches and C-Find * Add ".dcm" suffix to files in ZIP archives (cf. URI ".../archive") * "/tools/create-dicom": Support of binary tags encoded using data URI scheme * "/tools/create-dicom": Support of hierarchical structures (creation of sequences) @@ -24,6 +25,7 @@ Maintenance ----------- +* Full refactoring of the searching features * C-Move SCP for studies using AccessionNumber tag * Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change) * "/system" URI gives information about the plugins used for storage area and DB back-end diff -r 03b030680e3d -r 98abb8d7f905 OrthancServer/OrthancFindRequestHandler.cpp --- a/OrthancServer/OrthancFindRequestHandler.cpp Wed Oct 28 12:14:06 2015 +0100 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Wed Oct 28 12:29:12 2015 +0100 @@ -30,7 +30,7 @@ **/ -#define USE_LOOKUP_RESOURCE 0 +#define USE_LOOKUP_RESOURCE 1 diff -r 03b030680e3d -r 98abb8d7f905 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Wed Oct 28 12:14:06 2015 +0100 +++ b/OrthancServer/ServerContext.cpp Wed Oct 28 12:29:12 2015 +0100 @@ -543,4 +543,37 @@ return false; #endif } + + + bool ServerContext::Apply(std::vector& result, + const ::Orthanc::LookupResource& lookup, + size_t maxResults) + { + std::vector resources, instances; + GetIndex().FindCandidates(resources, instances, lookup); + + assert(resources.size() == instances.size()); + + for (size_t i = 0; i < instances.size(); i++) + { + Json::Value dicom; + ReadJson(dicom, instances[i]); + + if (lookup.IsMatch(dicom)) + { + if (maxResults != 0 && + result.size() >= maxResults) + { + return false; // too many results + } + else + { + result.push_back(resources[i]); + } + } + } + + return true; // finished + } + } diff -r 03b030680e3d -r 98abb8d7f905 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Wed Oct 28 12:14:06 2015 +0100 +++ b/OrthancServer/ServerContext.h Wed Oct 28 12:29:12 2015 +0100 @@ -47,6 +47,7 @@ #include "Scheduler/ServerScheduler.h" #include "ServerIndex.h" #include "OrthancHttpHandler.h" +#include "Search/LookupResource.h" #include #include @@ -245,6 +246,10 @@ void Stop(); + bool Apply(std::vector& result, + const ::Orthanc::LookupResource& lookup, + size_t maxResults); + /** * Management of the plugins diff -r 03b030680e3d -r 98abb8d7f905 OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Wed Oct 28 12:14:06 2015 +0100 +++ b/OrthancServer/ServerIndex.cpp Wed Oct 28 12:29:12 2015 +0100 @@ -2117,7 +2117,7 @@ void ServerIndex::FindCandidates(std::vector& resources, std::vector& instances, - ::Orthanc::LookupResource& lookup) + const ::Orthanc::LookupResource& lookup) { boost::mutex::scoped_lock lock(mutex_); diff -r 03b030680e3d -r 98abb8d7f905 OrthancServer/ServerIndex.h --- a/OrthancServer/ServerIndex.h Wed Oct 28 12:14:06 2015 +0100 +++ b/OrthancServer/ServerIndex.h Wed Oct 28 12:29:12 2015 +0100 @@ -265,6 +265,6 @@ void FindCandidates(std::vector& resources, std::vector& instances, - ::Orthanc::LookupResource& lookup); + const ::Orthanc::LookupResource& lookup); }; }