Mercurial > hg > orthanc
comparison OrthancServer/Sources/ResourceFinder.h @ 5809:023a99146dd0 attach-custom-data
merged find-refactoring -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 12:53:43 +0200 |
parents | 40ad08b75d84 |
children |
comparison
equal
deleted
inserted
replaced
5808:63c025cf6958 | 5809:023a99146dd0 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium | |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
8 * | |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "Database/FindRequest.h" | |
27 #include "Database/FindResponse.h" | |
28 | |
29 namespace Orthanc | |
30 { | |
31 class DatabaseLookup; | |
32 class ServerContext; | |
33 class ServerIndex; | |
34 | |
35 class ResourceFinder : public boost::noncopyable | |
36 { | |
37 public: | |
38 class IVisitor : public boost::noncopyable | |
39 { | |
40 public: | |
41 virtual ~IVisitor() | |
42 { | |
43 } | |
44 | |
45 virtual void Apply(const FindResponse::Resource& resource, | |
46 const DicomMap& requestedTags) = 0; | |
47 | |
48 virtual void MarkAsComplete() = 0; | |
49 }; | |
50 | |
51 private: | |
52 enum PagingMode | |
53 { | |
54 PagingMode_FullDatabase, | |
55 PagingMode_FullManual, | |
56 PagingMode_ManualSkip | |
57 }; | |
58 | |
59 FindRequest request_; | |
60 uint64_t databaseLimits_; | |
61 std::unique_ptr<DatabaseLookup> lookup_; | |
62 bool isSimpleLookup_; | |
63 PagingMode pagingMode_; | |
64 bool hasLimitsSince_; | |
65 bool hasLimitsCount_; | |
66 uint64_t limitsSince_; | |
67 uint64_t limitsCount_; | |
68 bool expand_; | |
69 bool allowStorageAccess_; | |
70 std::set<DicomTag> requestedTags_; | |
71 std::set<DicomTag> requestedComputedTags_; | |
72 | |
73 bool isWarning002Enabled_; | |
74 bool isWarning004Enabled_; | |
75 bool isWarning005Enabled_; | |
76 | |
77 bool IsRequestedComputedTag(const DicomTag& tag) const | |
78 { | |
79 return requestedComputedTags_.find(tag) != requestedComputedTags_.end(); | |
80 } | |
81 | |
82 void ConfigureChildrenCountComputedTag(DicomTag tag, | |
83 ResourceType parentLevel, | |
84 ResourceType childLevel); | |
85 | |
86 void InjectChildrenCountComputedTag(DicomMap& requestedTags, | |
87 DicomTag tag, | |
88 const FindResponse::Resource& resource, | |
89 ResourceType level) const; | |
90 | |
91 static SeriesStatus GetSeriesStatus(uint32_t& expectedNumberOfInstances, | |
92 const FindResponse::Resource& resource); | |
93 | |
94 void InjectComputedTags(DicomMap& requestedTags, | |
95 const FindResponse::Resource& resource) const; | |
96 | |
97 void UpdateRequestLimits(); | |
98 | |
99 bool HasRequestedTags() const | |
100 { | |
101 return requestedTags_.size() > 0; | |
102 } | |
103 | |
104 public: | |
105 ResourceFinder(ResourceType level, | |
106 bool expand); | |
107 | |
108 void SetDatabaseLimits(uint64_t limits); | |
109 | |
110 bool IsAllowStorageAccess() const | |
111 { | |
112 return allowStorageAccess_; | |
113 } | |
114 | |
115 void SetAllowStorageAccess(bool allow) | |
116 { | |
117 allowStorageAccess_ = allow; | |
118 } | |
119 | |
120 void SetOrthancId(ResourceType level, | |
121 const std::string& id) | |
122 { | |
123 request_.SetOrthancId(level, id); | |
124 } | |
125 | |
126 void SetLimitsSince(uint64_t since); | |
127 | |
128 void SetLimitsCount(uint64_t count); | |
129 | |
130 void SetDatabaseLookup(const DatabaseLookup& lookup); | |
131 | |
132 void AddRequestedTag(const DicomTag& tag); | |
133 | |
134 void AddRequestedTags(const std::set<DicomTag>& tags); | |
135 | |
136 void SetLabels(const std::set<std::string>& labels) | |
137 { | |
138 request_.SetLabels(labels); | |
139 } | |
140 | |
141 void AddLabel(const std::string& label) | |
142 { | |
143 request_.AddLabel(label); | |
144 } | |
145 | |
146 void SetLabelsConstraint(LabelsConstraint constraint) | |
147 { | |
148 request_.SetLabelsConstraint(constraint); | |
149 } | |
150 | |
151 void SetRetrieveOneInstanceMetadataAndAttachments(bool retrieve) | |
152 { | |
153 request_.SetRetrieveOneInstanceMetadataAndAttachments(retrieve); | |
154 } | |
155 | |
156 void SetRetrieveMetadata(bool retrieve) | |
157 { | |
158 request_.SetRetrieveMetadata(retrieve); | |
159 } | |
160 | |
161 void SetRetrieveAttachments(bool retrieve) | |
162 { | |
163 request_.SetRetrieveAttachments(retrieve); | |
164 } | |
165 | |
166 // NB: "index" is only used in this method to fill the "IsStable" information | |
167 void Expand(Json::Value& target, | |
168 const FindResponse::Resource& resource, | |
169 ServerIndex& index, | |
170 DicomToJsonFormat format, | |
171 bool includeAllMetadata /* Same as: ExpandResourceFlags_IncludeAllMetadata */) const; | |
172 | |
173 void Execute(IVisitor& visitor, | |
174 ServerContext& context) const; | |
175 | |
176 void Execute(Json::Value& target, | |
177 ServerContext& context, | |
178 DicomToJsonFormat format, | |
179 bool includeAllMetadata) const; | |
180 | |
181 bool ExecuteOneResource(Json::Value& target, | |
182 ServerContext& context, | |
183 DicomToJsonFormat format, | |
184 bool includeAllMetadata) const; | |
185 }; | |
186 } |