Mercurial > hg > orthanc
comparison OrthancServer/Sources/ResourceFinder.cpp @ 5682:fd4c5e064cbe find-refactoring
started refactoring of ServerContext::Apply()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jul 2024 11:17:34 +0200 |
parents | b744a2cf408a |
children | 11575590e493 |
comparison
equal
deleted
inserted
replaced
5681:77875b51cf95 | 5682:fd4c5e064cbe |
---|---|
27 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | 27 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
28 #include "../../OrthancFramework/Sources/Logging.h" | 28 #include "../../OrthancFramework/Sources/Logging.h" |
29 #include "../../OrthancFramework/Sources/OrthancException.h" | 29 #include "../../OrthancFramework/Sources/OrthancException.h" |
30 #include "../../OrthancFramework/Sources/SerializationToolbox.h" | 30 #include "../../OrthancFramework/Sources/SerializationToolbox.h" |
31 #include "OrthancConfiguration.h" | 31 #include "OrthancConfiguration.h" |
32 #include "Search/DatabaseLookup.h" | |
32 #include "ServerContext.h" | 33 #include "ServerContext.h" |
33 #include "ServerIndex.h" | 34 #include "ServerIndex.h" |
34 | 35 |
35 | 36 |
36 namespace Orthanc | 37 namespace Orthanc |
450 } | 451 } |
451 } | 452 } |
452 } | 453 } |
453 | 454 |
454 | 455 |
456 void ResourceFinder::SetDatabaseLookup(const DatabaseLookup& lookup) | |
457 { | |
458 MainDicomTagsRegistry registry; | |
459 registry.NormalizeLookup(request_.GetDicomTagConstraints(), lookup, request_.GetLevel()); | |
460 } | |
461 | |
462 | |
455 void ResourceFinder::AddRequestedTags(const DicomTag& tag) | 463 void ResourceFinder::AddRequestedTags(const DicomTag& tag) |
456 { | 464 { |
457 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient)) | 465 if (DicomMap::IsMainDicomTag(tag, ResourceType_Patient)) |
458 { | 466 { |
459 if (request_.GetLevel() == ResourceType_Patient) | 467 if (request_.GetLevel() == ResourceType_Patient) |
698 } | 706 } |
699 } | 707 } |
700 } | 708 } |
701 | 709 |
702 | 710 |
711 void ResourceFinder::Execute(FindResponse& response, | |
712 ServerIndex& index) const | |
713 { | |
714 if (hasRequestedTags_) | |
715 { | |
716 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
717 } | |
718 else | |
719 { | |
720 index.ExecuteFind(response, request_); | |
721 } | |
722 } | |
723 | |
724 | |
703 void ResourceFinder::Execute(Json::Value& target, | 725 void ResourceFinder::Execute(Json::Value& target, |
704 ServerContext& context) const | 726 ServerContext& context) const |
705 { | 727 { |
706 FindResponse response; | 728 FindResponse response; |
707 context.GetIndex().ExecuteFind(response, request_); | 729 context.GetIndex().ExecuteFind(response, request_); |
709 target = Json::arrayValue; | 731 target = Json::arrayValue; |
710 | 732 |
711 for (size_t i = 0; i < response.GetSize(); i++) | 733 for (size_t i = 0; i < response.GetSize(); i++) |
712 { | 734 { |
713 const FindResponse::Resource& resource = response.GetResourceByIndex(i); | 735 const FindResponse::Resource& resource = response.GetResourceByIndex(i); |
714 | |
715 { | |
716 Json::Value v; | |
717 resource.DebugExport(v, request_); | |
718 std::cout << v.toStyledString(); | |
719 } | |
720 | 736 |
721 if (expand_) | 737 if (expand_) |
722 { | 738 { |
723 Json::Value item; | 739 Json::Value item; |
724 Expand(item, resource, context.GetIndex()); | 740 Expand(item, resource, context.GetIndex()); |