Mercurial > hg > orthanc
changeset 1757:98abb8d7f905 db-changes
ServerContext::Apply lookup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Oct 2015 12:29:12 +0100 |
parents | 03b030680e3d |
children | 318c2e83c2bd |
files | NEWS OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h OrthancServer/ServerIndex.cpp OrthancServer/ServerIndex.h |
diffstat | 6 files changed, 43 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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<std::string>& result, + const ::Orthanc::LookupResource& lookup, + size_t maxResults) + { + std::vector<std::string> 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 + } + }
--- 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 <boost/filesystem.hpp> #include <boost/thread.hpp> @@ -245,6 +246,10 @@ void Stop(); + bool Apply(std::vector<std::string>& result, + const ::Orthanc::LookupResource& lookup, + size_t maxResults); + /** * Management of the plugins
--- 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<std::string>& resources, std::vector<std::string>& instances, - ::Orthanc::LookupResource& lookup) + const ::Orthanc::LookupResource& lookup) { boost::mutex::scoped_lock lock(mutex_);
--- 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<std::string>& resources, std::vector<std::string>& instances, - ::Orthanc::LookupResource& lookup); + const ::Orthanc::LookupResource& lookup); }; }