Mercurial > hg > orthanc-databases
annotate Framework/Plugins/IndexBackend.cpp @ 401:a8774581adfc db-protobuf
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Apr 2023 22:32:15 +0200 |
parents | 897253c21208 |
children | 82921a29349a |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
389
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
385
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
385
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #include "IndexBackend.h" | |
24 | |
25 #include "../Common/BinaryStringValue.h" | |
26 #include "../Common/Integer64Value.h" | |
27 #include "../Common/Utf8StringValue.h" | |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
28 #include "DatabaseBackendAdapterV2.h" |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
29 #include "DatabaseBackendAdapterV3.h" |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
30 #include "DatabaseBackendAdapterV4.h" |
0 | 31 #include "GlobalProperties.h" |
32 | |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
33 #include <Compatibility.h> // For std::unique_ptr<> |
152 | 34 #include <Logging.h> |
35 #include <OrthancException.h> | |
0 | 36 |
37 | |
38 namespace OrthancDatabases | |
39 { | |
40 static std::string ConvertWildcardToLike(const std::string& query) | |
41 { | |
42 std::string s = query; | |
43 | |
44 for (size_t i = 0; i < s.size(); i++) | |
45 { | |
46 if (s[i] == '*') | |
47 { | |
48 s[i] = '%'; | |
49 } | |
50 else if (s[i] == '?') | |
51 { | |
52 s[i] = '_'; | |
53 } | |
54 } | |
55 | |
65 | 56 // TODO Escape underscores and percents |
57 | |
0 | 58 return s; |
59 } | |
60 | |
61 | |
62 template <typename T> | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
63 static void ReadListOfIntegers(std::list<T>& target, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
64 DatabaseManager::CachedStatement& statement, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
65 const Dictionary& args) |
0 | 66 { |
67 statement.Execute(args); | |
68 | |
69 target.clear(); | |
70 | |
71 if (!statement.IsDone()) | |
72 { | |
73 if (statement.GetResultFieldsCount() != 1) | |
74 { | |
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
76 } | |
77 | |
78 statement.SetResultFieldType(0, ValueType_Integer64); | |
79 | |
80 while (!statement.IsDone()) | |
81 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
82 target.push_back(static_cast<T>(statement.ReadInteger64(0))); |
0 | 83 statement.Next(); |
84 } | |
85 } | |
86 } | |
87 | |
88 | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
89 static void ReadListOfStrings(std::list<std::string>& target, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
90 DatabaseManager::CachedStatement& statement, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
91 const Dictionary& args) |
0 | 92 { |
93 statement.Execute(args); | |
94 | |
95 target.clear(); | |
96 | |
97 if (!statement.IsDone()) | |
98 { | |
99 if (statement.GetResultFieldsCount() != 1) | |
100 { | |
101 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
102 } | |
103 | |
104 while (!statement.IsDone()) | |
105 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
106 target.push_back(statement.ReadString(0)); |
0 | 107 statement.Next(); |
108 } | |
109 } | |
110 } | |
111 | |
112 | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
113 void IndexBackend::ReadChangesInternal(IDatabaseBackendOutput& output, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
114 bool& done, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
115 DatabaseManager& manager, |
0 | 116 DatabaseManager::CachedStatement& statement, |
117 const Dictionary& args, | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
118 uint32_t limit) |
0 | 119 { |
120 statement.Execute(args); | |
121 | |
122 uint32_t count = 0; | |
123 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
124 while (count < limit && |
0 | 125 !statement.IsDone()) |
126 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
127 output.AnswerChange( |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
128 statement.ReadInteger64(0), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
129 statement.ReadInteger32(1), |
310
f3eac614b32e
fixed two DatabaseManager::CachedStatement in the same scope
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
130 static_cast<OrthancPluginResourceType>(statement.ReadInteger32(2)), |
f3eac614b32e
fixed two DatabaseManager::CachedStatement in the same scope
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
131 statement.ReadString(3), |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
132 statement.ReadString(4)); |
0 | 133 |
134 statement.Next(); | |
135 count++; | |
136 } | |
137 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
138 done = (count < limit || |
0 | 139 statement.IsDone()); |
140 } | |
141 | |
142 | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
143 void IndexBackend::ReadExportedResourcesInternal(IDatabaseBackendOutput& output, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
144 bool& done, |
0 | 145 DatabaseManager::CachedStatement& statement, |
146 const Dictionary& args, | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
147 uint32_t limit) |
0 | 148 { |
149 statement.Execute(args); | |
150 | |
151 uint32_t count = 0; | |
152 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
153 while (count < limit && |
0 | 154 !statement.IsDone()) |
155 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
156 int64_t seq = statement.ReadInteger64(0); |
0 | 157 OrthancPluginResourceType resourceType = |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
158 static_cast<OrthancPluginResourceType>(statement.ReadInteger32(1)); |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
159 std::string publicId = statement.ReadString(2); |
0 | 160 |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
161 output.AnswerExportedResource(seq, |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
162 resourceType, |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
163 publicId, |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
164 statement.ReadString(3), // modality |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
165 statement.ReadString(8), // date |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
166 statement.ReadString(4), // patient ID |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
167 statement.ReadString(5), // study instance UID |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
168 statement.ReadString(6), // series instance UID |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
169 statement.ReadString(7)); // sop instance UID |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
170 |
0 | 171 statement.Next(); |
172 count++; | |
173 } | |
174 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
175 done = (count < limit || |
0 | 176 statement.IsDone()); |
177 } | |
178 | |
179 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
180 void IndexBackend::ClearDeletedFiles(DatabaseManager& manager) |
0 | 181 { |
182 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
183 STATEMENT_FROM_HERE, manager, |
0 | 184 "DELETE FROM DeletedFiles"); |
185 | |
186 statement.Execute(); | |
187 } | |
188 | |
189 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
190 void IndexBackend::ClearDeletedResources(DatabaseManager& manager) |
0 | 191 { |
192 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
193 STATEMENT_FROM_HERE, manager, |
0 | 194 "DELETE FROM DeletedResources"); |
195 | |
196 statement.Execute(); | |
197 } | |
198 | |
199 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
200 void IndexBackend::SignalDeletedFiles(IDatabaseBackendOutput& output, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
201 DatabaseManager& manager) |
0 | 202 { |
203 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
204 STATEMENT_FROM_HERE, manager, |
314
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
205 "SELECT uuid, fileType, uncompressedSize, uncompressedHash, compressionType, " |
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
206 "compressedSize, compressedHash FROM DeletedFiles"); |
0 | 207 |
208 statement.SetReadOnly(true); | |
209 statement.Execute(); | |
210 | |
211 while (!statement.IsDone()) | |
212 { | |
314
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
213 output.SignalDeletedAttachment(statement.ReadString(0), |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
214 statement.ReadInteger32(1), |
314
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
215 statement.ReadInteger64(2), |
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
216 statement.ReadString(3), |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
217 statement.ReadInteger32(4), |
314
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
218 statement.ReadInteger64(5), |
64763998cdff
clarification in IndexBackend::SignalDeletedFiles()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
310
diff
changeset
|
219 statement.ReadString(6)); |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
220 |
0 | 221 statement.Next(); |
222 } | |
223 } | |
224 | |
225 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
226 void IndexBackend::SignalDeletedResources(IDatabaseBackendOutput& output, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
227 DatabaseManager& manager) |
0 | 228 { |
229 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
230 STATEMENT_FROM_HERE, manager, |
307
8de3a1ecac11
MySQL: Added missing calls to OrthancPluginDatabaseSignalDeletedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
306
diff
changeset
|
231 "SELECT resourceType, publicId FROM DeletedResources"); |
0 | 232 |
233 statement.SetReadOnly(true); | |
234 statement.Execute(); | |
235 | |
236 while (!statement.IsDone()) | |
237 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
238 output.SignalDeletedResource( |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
239 statement.ReadString(1), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
240 static_cast<OrthancPluginResourceType>(statement.ReadInteger32(0))); |
0 | 241 |
242 statement.Next(); | |
243 } | |
244 } | |
245 | |
246 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
247 IndexBackend::IndexBackend(OrthancPluginContext* context) : |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
248 context_(context) |
0 | 249 { |
250 } | |
251 | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
252 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
253 void IndexBackend::SetOutputFactory(IDatabaseBackendOutput::IFactory* factory) |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
254 { |
232
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
255 boost::unique_lock<boost::shared_mutex> lock(outputFactoryMutex_); |
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
256 |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
257 if (factory == NULL) |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
258 { |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
259 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
260 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
261 else if (outputFactory_.get() != NULL) |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
262 { |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
263 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
264 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
265 else |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
266 { |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
267 outputFactory_.reset(factory); |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
268 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
269 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
270 |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
271 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
272 IDatabaseBackendOutput* IndexBackend::CreateOutput() |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
273 { |
232
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
274 boost::shared_lock<boost::shared_mutex> lock(outputFactoryMutex_); |
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
275 |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
276 if (outputFactory_.get() == NULL) |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
277 { |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
278 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
279 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
280 else |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
281 { |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
282 return outputFactory_->CreateOutput(); |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
283 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
284 } |
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
285 |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
286 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
287 static void ExecuteAddAttachment(DatabaseManager::CachedStatement& statement, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
288 Dictionary& args, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
289 int64_t id, |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
290 const OrthancPluginAttachment& attachment) |
0 | 291 { |
292 statement.SetParameterType("id", ValueType_Integer64); | |
293 statement.SetParameterType("type", ValueType_Integer64); | |
294 statement.SetParameterType("uuid", ValueType_Utf8String); | |
295 statement.SetParameterType("compressed", ValueType_Integer64); | |
296 statement.SetParameterType("uncompressed", ValueType_Integer64); | |
297 statement.SetParameterType("compression", ValueType_Integer64); | |
298 statement.SetParameterType("hash", ValueType_Utf8String); | |
299 statement.SetParameterType("hash-compressed", ValueType_Utf8String); | |
300 | |
301 args.SetIntegerValue("id", id); | |
302 args.SetIntegerValue("type", attachment.contentType); | |
303 args.SetUtf8Value("uuid", attachment.uuid); | |
304 args.SetIntegerValue("compressed", attachment.compressedSize); | |
305 args.SetIntegerValue("uncompressed", attachment.uncompressedSize); | |
306 args.SetIntegerValue("compression", attachment.compressionType); | |
307 args.SetUtf8Value("hash", attachment.uncompressedHash); | |
308 args.SetUtf8Value("hash-compressed", attachment.compressedHash); | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
309 |
0 | 310 statement.Execute(args); |
311 } | |
312 | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
313 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
314 void IndexBackend::AddAttachment(DatabaseManager& manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
315 int64_t id, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
316 const OrthancPluginAttachment& attachment, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
317 int64_t revision) |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
318 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
319 if (HasRevisionsSupport()) |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
320 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
321 DatabaseManager::CachedStatement statement( |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
322 STATEMENT_FROM_HERE, manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
323 "INSERT INTO AttachedFiles VALUES(${id}, ${type}, ${uuid}, ${compressed}, " |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
324 "${uncompressed}, ${compression}, ${hash}, ${hash-compressed}, ${revision})"); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
325 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
326 Dictionary args; |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
327 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
328 statement.SetParameterType("revision", ValueType_Integer64); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
329 args.SetIntegerValue("revision", revision); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
330 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
331 ExecuteAddAttachment(statement, args, id, attachment); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
332 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
333 else |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
334 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
335 DatabaseManager::CachedStatement statement( |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
336 STATEMENT_FROM_HERE, manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
337 "INSERT INTO AttachedFiles VALUES(${id}, ${type}, ${uuid}, ${compressed}, " |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
338 "${uncompressed}, ${compression}, ${hash}, ${hash-compressed})"); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
339 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
340 Dictionary args; |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
341 ExecuteAddAttachment(statement, args, id, attachment); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
342 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
343 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
344 |
0 | 345 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
346 void IndexBackend::AttachChild(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
347 int64_t parent, |
0 | 348 int64_t child) |
349 { | |
350 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
351 STATEMENT_FROM_HERE, manager, |
0 | 352 "UPDATE Resources SET parentId = ${parent} WHERE internalId = ${child}"); |
353 | |
354 statement.SetParameterType("parent", ValueType_Integer64); | |
355 statement.SetParameterType("child", ValueType_Integer64); | |
356 | |
357 Dictionary args; | |
358 args.SetIntegerValue("parent", parent); | |
359 args.SetIntegerValue("child", child); | |
360 | |
361 statement.Execute(args); | |
362 } | |
363 | |
364 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
365 void IndexBackend::ClearChanges(DatabaseManager& manager) |
0 | 366 { |
367 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
368 STATEMENT_FROM_HERE, manager, |
0 | 369 "DELETE FROM Changes"); |
370 | |
371 statement.Execute(); | |
372 } | |
373 | |
374 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
375 void IndexBackend::ClearExportedResources(DatabaseManager& manager) |
0 | 376 { |
377 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
378 STATEMENT_FROM_HERE, manager, |
0 | 379 "DELETE FROM ExportedResources"); |
380 | |
381 statement.Execute(); | |
382 } | |
383 | |
384 | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
385 void IndexBackend::DeleteAttachment(IDatabaseBackendOutput& output, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
386 DatabaseManager& manager, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
387 int64_t id, |
0 | 388 int32_t attachment) |
389 { | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
390 ClearDeletedFiles(manager); |
0 | 391 |
392 { | |
393 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
394 STATEMENT_FROM_HERE, manager, |
0 | 395 "DELETE FROM AttachedFiles WHERE id=${id} AND fileType=${type}"); |
396 | |
397 statement.SetParameterType("id", ValueType_Integer64); | |
398 statement.SetParameterType("type", ValueType_Integer64); | |
399 | |
400 Dictionary args; | |
401 args.SetIntegerValue("id", id); | |
402 args.SetIntegerValue("type", static_cast<int>(attachment)); | |
403 | |
404 statement.Execute(args); | |
405 } | |
406 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
407 SignalDeletedFiles(output, manager); |
0 | 408 } |
409 | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
410 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
411 void IndexBackend::DeleteMetadata(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
412 int64_t id, |
0 | 413 int32_t metadataType) |
414 { | |
415 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
416 STATEMENT_FROM_HERE, manager, |
0 | 417 "DELETE FROM Metadata WHERE id=${id} and type=${type}"); |
418 | |
419 statement.SetParameterType("id", ValueType_Integer64); | |
420 statement.SetParameterType("type", ValueType_Integer64); | |
421 | |
422 Dictionary args; | |
423 args.SetIntegerValue("id", id); | |
424 args.SetIntegerValue("type", static_cast<int>(metadataType)); | |
425 | |
426 statement.Execute(args); | |
427 } | |
428 | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
429 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
430 void IndexBackend::DeleteResource(IDatabaseBackendOutput& output, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
431 DatabaseManager& manager, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
432 int64_t id) |
0 | 433 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
434 ClearDeletedFiles(manager); |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
435 ClearDeletedResources(manager); |
0 | 436 |
437 { | |
438 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
439 STATEMENT_FROM_HERE, manager, |
0 | 440 "DELETE FROM RemainingAncestor"); |
441 | |
442 statement.Execute(); | |
443 } | |
444 | |
445 { | |
446 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
447 STATEMENT_FROM_HERE, manager, |
0 | 448 "DELETE FROM Resources WHERE internalId=${id}"); |
449 | |
450 statement.SetParameterType("id", ValueType_Integer64); | |
451 | |
452 Dictionary args; | |
453 args.SetIntegerValue("id", id); | |
454 | |
455 statement.Execute(args); | |
456 } | |
457 | |
458 | |
459 { | |
460 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
461 STATEMENT_FROM_HERE, manager, |
0 | 462 "SELECT * FROM RemainingAncestor"); |
463 | |
464 statement.Execute(); | |
465 | |
466 if (!statement.IsDone()) | |
467 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
468 output.SignalRemainingAncestor( |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
469 statement.ReadString(1), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
470 static_cast<OrthancPluginResourceType>(statement.ReadInteger32(0))); |
0 | 471 |
472 // There is at most 1 remaining ancestor | |
473 assert((statement.Next(), statement.IsDone())); | |
474 } | |
475 } | |
476 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
477 SignalDeletedFiles(output, manager); |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
478 SignalDeletedResources(output, manager); |
0 | 479 } |
480 | |
481 | |
482 void IndexBackend::GetAllInternalIds(std::list<int64_t>& target, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
483 DatabaseManager& manager, |
0 | 484 OrthancPluginResourceType resourceType) |
485 { | |
486 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
487 STATEMENT_FROM_HERE, manager, |
0 | 488 "SELECT internalId FROM Resources WHERE resourceType=${type}"); |
489 | |
490 statement.SetReadOnly(true); | |
491 statement.SetParameterType("type", ValueType_Integer64); | |
492 | |
493 Dictionary args; | |
494 args.SetIntegerValue("type", static_cast<int>(resourceType)); | |
495 | |
496 ReadListOfIntegers<int64_t>(target, statement, args); | |
497 } | |
498 | |
499 | |
500 void IndexBackend::GetAllPublicIds(std::list<std::string>& target, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
501 DatabaseManager& manager, |
0 | 502 OrthancPluginResourceType resourceType) |
503 { | |
504 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
505 STATEMENT_FROM_HERE, manager, |
0 | 506 "SELECT publicId FROM Resources WHERE resourceType=${type}"); |
507 | |
508 statement.SetReadOnly(true); | |
509 statement.SetParameterType("type", ValueType_Integer64); | |
510 | |
511 Dictionary args; | |
512 args.SetIntegerValue("type", static_cast<int>(resourceType)); | |
513 | |
514 ReadListOfStrings(target, statement, args); | |
515 } | |
516 | |
517 | |
518 void IndexBackend::GetAllPublicIds(std::list<std::string>& target, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
519 DatabaseManager& manager, |
0 | 520 OrthancPluginResourceType resourceType, |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
521 int64_t since, |
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
522 uint32_t limit) |
0 | 523 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
524 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
525 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
526 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
527 suffix = "OFFSET ${since} ROWS FETCH FIRST ${limit} ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
528 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
529 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
530 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
531 suffix = "LIMIT ${limit} OFFSET ${since}"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
532 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
533 |
0 | 534 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
535 STATEMENT_FROM_HERE, manager, |
0 | 536 "SELECT publicId FROM (SELECT publicId FROM Resources " |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
537 "WHERE resourceType=${type}) AS tmp ORDER BY tmp.publicId " + suffix); |
0 | 538 |
539 statement.SetReadOnly(true); | |
540 statement.SetParameterType("type", ValueType_Integer64); | |
541 statement.SetParameterType("limit", ValueType_Integer64); | |
542 statement.SetParameterType("since", ValueType_Integer64); | |
543 | |
544 Dictionary args; | |
545 args.SetIntegerValue("type", static_cast<int>(resourceType)); | |
546 args.SetIntegerValue("limit", limit); | |
547 args.SetIntegerValue("since", since); | |
548 | |
549 ReadListOfStrings(target, statement, args); | |
550 } | |
551 | |
552 | |
553 /* Use GetOutput().AnswerChange() */ | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
554 void IndexBackend::GetChanges(IDatabaseBackendOutput& output, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
555 bool& done /*out*/, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
556 DatabaseManager& manager, |
0 | 557 int64_t since, |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
558 uint32_t limit) |
0 | 559 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
560 std::string suffix; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
561 if (manager.GetDialect() == Dialect_MSSQL) |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
562 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
563 suffix = "OFFSET 0 ROWS FETCH FIRST ${limit} ROWS ONLY"; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
564 } |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
565 else |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
566 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
567 suffix = "LIMIT ${limit}"; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
568 } |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
569 |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
570 DatabaseManager::CachedStatement statement( |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
571 STATEMENT_FROM_HERE, manager, |
326
4454545bb265
Fix issue 200 (fields messed up in /changes route)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
314
diff
changeset
|
572 "SELECT Changes.seq, Changes.changeType, Changes.resourceType, Resources.publicId, " |
4454545bb265
Fix issue 200 (fields messed up in /changes route)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
314
diff
changeset
|
573 "Changes.date FROM Changes INNER JOIN Resources " |
310
f3eac614b32e
fixed two DatabaseManager::CachedStatement in the same scope
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
574 "ON Changes.internalId = Resources.internalId WHERE seq>${since} ORDER BY seq " + suffix); |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
575 |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
576 statement.SetReadOnly(true); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
577 statement.SetParameterType("limit", ValueType_Integer64); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
578 statement.SetParameterType("since", ValueType_Integer64); |
0 | 579 |
580 Dictionary args; | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
581 args.SetIntegerValue("limit", limit + 1); |
0 | 582 args.SetIntegerValue("since", since); |
583 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
584 ReadChangesInternal(output, done, manager, statement, args, limit); |
0 | 585 } |
586 | |
587 | |
588 void IndexBackend::GetChildrenInternalId(std::list<int64_t>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
589 DatabaseManager& manager, |
0 | 590 int64_t id) |
591 { | |
592 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
593 STATEMENT_FROM_HERE, manager, |
0 | 594 "SELECT a.internalId FROM Resources AS a, Resources AS b " |
595 "WHERE a.parentId = b.internalId AND b.internalId = ${id}"); | |
596 | |
597 statement.SetReadOnly(true); | |
598 statement.SetParameterType("id", ValueType_Integer64); | |
599 | |
600 Dictionary args; | |
601 args.SetIntegerValue("id", id); | |
602 | |
603 ReadListOfIntegers<int64_t>(target, statement, args); | |
604 } | |
605 | |
606 | |
607 void IndexBackend::GetChildrenPublicId(std::list<std::string>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
608 DatabaseManager& manager, |
0 | 609 int64_t id) |
610 { | |
611 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
612 STATEMENT_FROM_HERE, manager, |
0 | 613 "SELECT a.publicId FROM Resources AS a, Resources AS b " |
614 "WHERE a.parentId = b.internalId AND b.internalId = ${id}"); | |
615 | |
616 statement.SetReadOnly(true); | |
617 statement.SetParameterType("id", ValueType_Integer64); | |
618 | |
619 Dictionary args; | |
620 args.SetIntegerValue("id", id); | |
621 | |
622 ReadListOfStrings(target, statement, args); | |
623 } | |
624 | |
625 | |
626 /* Use GetOutput().AnswerExportedResource() */ | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
627 void IndexBackend::GetExportedResources(IDatabaseBackendOutput& output, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
628 bool& done /*out*/, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
629 DatabaseManager& manager, |
0 | 630 int64_t since, |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
631 uint32_t limit) |
0 | 632 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
633 std::string suffix; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
634 if (manager.GetDialect() == Dialect_MSSQL) |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
635 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
636 suffix = "OFFSET 0 ROWS FETCH FIRST ${limit} ROWS ONLY"; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
637 } |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
638 else |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
639 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
640 suffix = "LIMIT ${limit}"; |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
641 } |
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
642 |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
643 DatabaseManager::CachedStatement statement( |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
644 STATEMENT_FROM_HERE, manager, |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
645 "SELECT * FROM ExportedResources WHERE seq>${since} ORDER BY seq " + suffix); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
646 |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
647 statement.SetReadOnly(true); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
648 statement.SetParameterType("limit", ValueType_Integer64); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
649 statement.SetParameterType("since", ValueType_Integer64); |
0 | 650 |
651 Dictionary args; | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
652 args.SetIntegerValue("limit", limit + 1); |
0 | 653 args.SetIntegerValue("since", since); |
654 | |
385
346fe629d638
clarifying types of since/limit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
655 ReadExportedResourcesInternal(output, done, statement, args, limit); |
0 | 656 } |
657 | |
658 | |
659 /* Use GetOutput().AnswerChange() */ | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
660 void IndexBackend::GetLastChange(IDatabaseBackendOutput& output, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
661 DatabaseManager& manager) |
0 | 662 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
663 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
664 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
665 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
666 suffix = "OFFSET 0 ROWS FETCH FIRST 1 ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
667 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
668 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
669 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
670 suffix = "LIMIT 1"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
671 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
672 |
0 | 673 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
674 STATEMENT_FROM_HERE, manager, |
326
4454545bb265
Fix issue 200 (fields messed up in /changes route)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
314
diff
changeset
|
675 "SELECT Changes.seq, Changes.changeType, Changes.resourceType, Resources.publicId, " |
4454545bb265
Fix issue 200 (fields messed up in /changes route)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
314
diff
changeset
|
676 "Changes.date FROM Changes INNER JOIN Resources " |
310
f3eac614b32e
fixed two DatabaseManager::CachedStatement in the same scope
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
677 "ON Changes.internalId = Resources.internalId ORDER BY seq DESC " + suffix); |
0 | 678 |
679 statement.SetReadOnly(true); | |
680 | |
681 Dictionary args; | |
682 | |
683 bool done; // Ignored | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
684 ReadChangesInternal(output, done, manager, statement, args, 1); |
0 | 685 } |
686 | |
687 | |
688 /* Use GetOutput().AnswerExportedResource() */ | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
689 void IndexBackend::GetLastExportedResource(IDatabaseBackendOutput& output, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
690 DatabaseManager& manager) |
0 | 691 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
692 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
693 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
694 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
695 suffix = "OFFSET 0 ROWS FETCH FIRST 1 ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
696 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
697 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
698 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
699 suffix = "LIMIT 1"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
700 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
701 |
0 | 702 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
703 STATEMENT_FROM_HERE, manager, |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
704 "SELECT * FROM ExportedResources ORDER BY seq DESC " + suffix); |
0 | 705 |
706 statement.SetReadOnly(true); | |
707 | |
708 Dictionary args; | |
709 | |
710 bool done; // Ignored | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
711 ReadExportedResourcesInternal(output, done, statement, args, 1); |
0 | 712 } |
713 | |
714 | |
715 /* Use GetOutput().AnswerDicomTag() */ | |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
716 void IndexBackend::GetMainDicomTags(IDatabaseBackendOutput& output, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
717 DatabaseManager& manager, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
718 int64_t id) |
0 | 719 { |
720 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
721 STATEMENT_FROM_HERE, manager, |
0 | 722 "SELECT * FROM MainDicomTags WHERE id=${id}"); |
723 | |
724 statement.SetReadOnly(true); | |
725 statement.SetParameterType("id", ValueType_Integer64); | |
726 | |
727 Dictionary args; | |
728 args.SetIntegerValue("id", id); | |
729 | |
730 statement.Execute(args); | |
731 | |
732 while (!statement.IsDone()) | |
733 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
734 output.AnswerDicomTag(static_cast<uint16_t>(statement.ReadInteger64(1)), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
735 static_cast<uint16_t>(statement.ReadInteger64(2)), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
736 statement.ReadString(3)); |
0 | 737 statement.Next(); |
738 } | |
739 } | |
740 | |
741 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
742 std::string IndexBackend::GetPublicId(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
743 int64_t resourceId) |
0 | 744 { |
745 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
746 STATEMENT_FROM_HERE, manager, |
0 | 747 "SELECT publicId FROM Resources WHERE internalId=${id}"); |
748 | |
749 statement.SetReadOnly(true); | |
750 statement.SetParameterType("id", ValueType_Integer64); | |
751 | |
752 Dictionary args; | |
753 args.SetIntegerValue("id", resourceId); | |
754 | |
755 statement.Execute(args); | |
756 | |
757 if (statement.IsDone()) | |
758 { | |
759 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
760 } | |
761 else | |
762 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
763 return statement.ReadString(0); |
0 | 764 } |
765 } | |
766 | |
767 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
768 uint64_t IndexBackend::GetResourcesCount(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
769 OrthancPluginResourceType resourceType) |
0 | 770 { |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
771 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 772 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
773 switch (manager.GetDialect()) |
0 | 774 { |
775 case Dialect_MySQL: | |
776 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
777 STATEMENT_FROM_HERE, manager, |
0 | 778 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources WHERE resourceType=${type}")); |
779 break; | |
780 | |
781 case Dialect_PostgreSQL: | |
782 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
783 STATEMENT_FROM_HERE, manager, |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
784 "SELECT CAST(COUNT(*) AS BIGINT) FROM Resources WHERE resourceType=${type}")); |
0 | 785 break; |
786 | |
301 | 787 case Dialect_MSSQL: |
0 | 788 case Dialect_SQLite: |
789 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
790 STATEMENT_FROM_HERE, manager, |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
791 "SELECT COUNT(*) FROM Resources WHERE resourceType=${type}")); |
0 | 792 break; |
793 | |
794 default: | |
795 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
796 } | |
797 | |
798 statement->SetReadOnly(true); | |
799 statement->SetParameterType("type", ValueType_Integer64); | |
800 | |
801 Dictionary args; | |
802 args.SetIntegerValue("type", resourceType); | |
803 | |
804 statement->Execute(args); | |
805 | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
806 return static_cast<uint64_t>(statement->ReadInteger64(0)); |
0 | 807 } |
808 | |
809 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
810 OrthancPluginResourceType IndexBackend::GetResourceType(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
811 int64_t resourceId) |
0 | 812 { |
813 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
814 STATEMENT_FROM_HERE, manager, |
0 | 815 "SELECT resourceType FROM Resources WHERE internalId=${id}"); |
816 | |
817 statement.SetReadOnly(true); | |
818 statement.SetParameterType("id", ValueType_Integer64); | |
819 | |
820 Dictionary args; | |
821 args.SetIntegerValue("id", resourceId); | |
822 | |
823 statement.Execute(args); | |
824 | |
825 if (statement.IsDone()) | |
826 { | |
827 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | |
828 } | |
829 else | |
830 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
831 return static_cast<OrthancPluginResourceType>(statement.ReadInteger32(0)); |
0 | 832 } |
833 } | |
834 | |
835 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
836 uint64_t IndexBackend::GetTotalCompressedSize(DatabaseManager& manager) |
0 | 837 { |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
838 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 839 |
840 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty | |
841 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
842 switch (manager.GetDialect()) |
0 | 843 { |
844 case Dialect_MySQL: | |
845 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
846 STATEMENT_FROM_HERE, manager, |
0 | 847 "SELECT CAST(COALESCE(SUM(compressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles")); |
848 break; | |
849 | |
850 case Dialect_PostgreSQL: | |
851 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
852 STATEMENT_FROM_HERE, manager, |
0 | 853 "SELECT CAST(COALESCE(SUM(compressedSize), 0) AS BIGINT) FROM AttachedFiles")); |
854 break; | |
855 | |
301 | 856 case Dialect_MSSQL: |
0 | 857 case Dialect_SQLite: |
858 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
859 STATEMENT_FROM_HERE, manager, |
0 | 860 "SELECT COALESCE(SUM(compressedSize), 0) FROM AttachedFiles")); |
861 break; | |
862 | |
863 default: | |
864 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
865 } | |
866 | |
867 statement->SetReadOnly(true); | |
868 statement->Execute(); | |
869 | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
870 return static_cast<uint64_t>(statement->ReadInteger64(0)); |
0 | 871 } |
872 | |
873 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
874 uint64_t IndexBackend::GetTotalUncompressedSize(DatabaseManager& manager) |
0 | 875 { |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
876 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 877 |
878 // NB: "COALESCE" is used to replace "NULL" by "0" if the number of rows is empty | |
879 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
880 switch (manager.GetDialect()) |
0 | 881 { |
882 case Dialect_MySQL: | |
883 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
884 STATEMENT_FROM_HERE, manager, |
0 | 885 "SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS UNSIGNED INTEGER) FROM AttachedFiles")); |
886 break; | |
887 | |
888 case Dialect_PostgreSQL: | |
889 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
890 STATEMENT_FROM_HERE, manager, |
0 | 891 "SELECT CAST(COALESCE(SUM(uncompressedSize), 0) AS BIGINT) FROM AttachedFiles")); |
892 break; | |
893 | |
301 | 894 case Dialect_MSSQL: |
0 | 895 case Dialect_SQLite: |
896 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
897 STATEMENT_FROM_HERE, manager, |
0 | 898 "SELECT COALESCE(SUM(uncompressedSize), 0) FROM AttachedFiles")); |
899 break; | |
900 | |
901 default: | |
902 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
903 } | |
904 | |
905 statement->SetReadOnly(true); | |
906 statement->Execute(); | |
907 | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
908 return static_cast<uint64_t>(statement->ReadInteger64(0)); |
0 | 909 } |
910 | |
911 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
912 bool IndexBackend::IsExistingResource(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
913 int64_t internalId) |
0 | 914 { |
915 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
916 STATEMENT_FROM_HERE, manager, |
0 | 917 "SELECT * FROM Resources WHERE internalId=${id}"); |
918 | |
919 statement.SetReadOnly(true); | |
920 statement.SetParameterType("id", ValueType_Integer64); | |
921 | |
922 Dictionary args; | |
923 args.SetIntegerValue("id", internalId); | |
924 | |
925 statement.Execute(args); | |
926 | |
927 return !statement.IsDone(); | |
928 } | |
929 | |
930 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
931 bool IndexBackend::IsProtectedPatient(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
932 int64_t internalId) |
0 | 933 { |
934 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
935 STATEMENT_FROM_HERE, manager, |
0 | 936 "SELECT * FROM PatientRecyclingOrder WHERE patientId = ${id}"); |
937 | |
938 statement.SetReadOnly(true); | |
939 statement.SetParameterType("id", ValueType_Integer64); | |
940 | |
941 Dictionary args; | |
942 args.SetIntegerValue("id", internalId); | |
943 | |
944 statement.Execute(args); | |
945 | |
946 return statement.IsDone(); | |
947 } | |
948 | |
949 | |
950 void IndexBackend::ListAvailableMetadata(std::list<int32_t>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
951 DatabaseManager& manager, |
0 | 952 int64_t id) |
953 { | |
954 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
955 STATEMENT_FROM_HERE, manager, |
0 | 956 "SELECT type FROM Metadata WHERE id=${id}"); |
957 | |
958 statement.SetReadOnly(true); | |
959 statement.SetParameterType("id", ValueType_Integer64); | |
960 | |
961 Dictionary args; | |
962 args.SetIntegerValue("id", id); | |
963 | |
964 ReadListOfIntegers<int32_t>(target, statement, args); | |
965 } | |
966 | |
967 | |
968 void IndexBackend::ListAvailableAttachments(std::list<int32_t>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
969 DatabaseManager& manager, |
0 | 970 int64_t id) |
971 { | |
972 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
973 STATEMENT_FROM_HERE, manager, |
0 | 974 "SELECT fileType FROM AttachedFiles WHERE id=${id}"); |
975 | |
976 statement.SetReadOnly(true); | |
977 statement.SetParameterType("id", ValueType_Integer64); | |
978 | |
979 Dictionary args; | |
980 args.SetIntegerValue("id", id); | |
981 | |
982 ReadListOfIntegers<int32_t>(target, statement, args); | |
983 } | |
984 | |
985 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
986 void IndexBackend::LogChange(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
987 int32_t changeType, |
209 | 988 int64_t resourceId, |
989 OrthancPluginResourceType resourceType, | |
990 const char* date) | |
0 | 991 { |
992 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
993 STATEMENT_FROM_HERE, manager, |
302
3a52e27a2d80
in GenericFormatter, replaced ${} by ${AUTOINCREMENT}
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
994 "INSERT INTO Changes VALUES(${AUTOINCREMENT} ${changeType}, ${id}, ${resourceType}, ${date})"); |
0 | 995 |
996 statement.SetParameterType("changeType", ValueType_Integer64); | |
997 statement.SetParameterType("id", ValueType_Integer64); | |
998 statement.SetParameterType("resourceType", ValueType_Integer64); | |
999 statement.SetParameterType("date", ValueType_Utf8String); | |
1000 | |
1001 Dictionary args; | |
209 | 1002 args.SetIntegerValue("changeType", changeType); |
1003 args.SetIntegerValue("id", resourceId); | |
1004 args.SetIntegerValue("resourceType", resourceType); | |
1005 args.SetUtf8Value("date", date); | |
0 | 1006 |
1007 statement.Execute(args); | |
1008 } | |
1009 | |
1010 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1011 void IndexBackend::LogExportedResource(DatabaseManager& manager, |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1012 OrthancPluginResourceType resourceType, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1013 const char* publicId, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1014 const char* modality, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1015 const char* date, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1016 const char* patientId, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1017 const char* studyInstanceUid, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1018 const char* seriesInstanceUid, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1019 const char* sopInstanceUid) |
0 | 1020 { |
1021 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1022 STATEMENT_FROM_HERE, manager, |
302
3a52e27a2d80
in GenericFormatter, replaced ${} by ${AUTOINCREMENT}
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
1023 "INSERT INTO ExportedResources VALUES(${AUTOINCREMENT} ${type}, ${publicId}, " |
0 | 1024 "${modality}, ${patient}, ${study}, ${series}, ${instance}, ${date})"); |
1025 | |
1026 statement.SetParameterType("type", ValueType_Integer64); | |
1027 statement.SetParameterType("publicId", ValueType_Utf8String); | |
1028 statement.SetParameterType("modality", ValueType_Utf8String); | |
1029 statement.SetParameterType("patient", ValueType_Utf8String); | |
1030 statement.SetParameterType("study", ValueType_Utf8String); | |
1031 statement.SetParameterType("series", ValueType_Utf8String); | |
1032 statement.SetParameterType("instance", ValueType_Utf8String); | |
1033 statement.SetParameterType("date", ValueType_Utf8String); | |
1034 | |
1035 Dictionary args; | |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1036 args.SetIntegerValue("type", resourceType); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1037 args.SetUtf8Value("publicId", publicId); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1038 args.SetUtf8Value("modality", modality); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1039 args.SetUtf8Value("patient", patientId); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1040 args.SetUtf8Value("study", studyInstanceUid); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1041 args.SetUtf8Value("series", seriesInstanceUid); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1042 args.SetUtf8Value("instance", sopInstanceUid); |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1043 args.SetUtf8Value("date", date); |
0 | 1044 |
1045 statement.Execute(args); | |
1046 } | |
1047 | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1048 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1049 static bool ExecuteLookupAttachment(DatabaseManager::CachedStatement& statement, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1050 IDatabaseBackendOutput& output, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
1051 int64_t id, |
0 | 1052 int32_t contentType) |
1053 { | |
1054 statement.SetReadOnly(true); | |
1055 statement.SetParameterType("id", ValueType_Integer64); | |
1056 statement.SetParameterType("type", ValueType_Integer64); | |
1057 | |
1058 Dictionary args; | |
1059 args.SetIntegerValue("id", id); | |
1060 args.SetIntegerValue("type", static_cast<int>(contentType)); | |
1061 | |
1062 statement.Execute(args); | |
1063 | |
1064 if (statement.IsDone()) | |
1065 { | |
1066 return false; | |
1067 } | |
1068 else | |
1069 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1070 output.AnswerAttachment(statement.ReadString(0), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
1071 contentType, |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1072 statement.ReadInteger64(1), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1073 statement.ReadString(4), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1074 statement.ReadInteger32(2), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1075 statement.ReadInteger64(3), |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1076 statement.ReadString(5)); |
0 | 1077 return true; |
1078 } | |
1079 } | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1080 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1081 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1082 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1083 /* Use GetOutput().AnswerAttachment() */ |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1084 bool IndexBackend::LookupAttachment(IDatabaseBackendOutput& output, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1085 int64_t& revision /*out*/, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1086 DatabaseManager& manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1087 int64_t id, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1088 int32_t contentType) |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1089 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1090 if (HasRevisionsSupport()) |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1091 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1092 DatabaseManager::CachedStatement statement( |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1093 STATEMENT_FROM_HERE, manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1094 "SELECT uuid, uncompressedSize, compressionType, compressedSize, uncompressedHash, " |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1095 "compressedHash, revision FROM AttachedFiles WHERE id=${id} AND fileType=${type}"); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1096 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1097 if (ExecuteLookupAttachment(statement, output, id, contentType)) |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1098 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1099 if (statement.GetResultField(6).GetType() == ValueType_Null) |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1100 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1101 // "NULL" can happen with a database created by PostgreSQL |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1102 // plugin <= 3.3 (because of "ALTER TABLE AttachedFiles") |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1103 revision = 0; |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1104 } |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1105 else |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1106 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1107 revision = statement.ReadInteger64(6); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1108 } |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1109 |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1110 return true; |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1111 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1112 else |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1113 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1114 return false; |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1115 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1116 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1117 else |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1118 { |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1119 DatabaseManager::CachedStatement statement( |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1120 STATEMENT_FROM_HERE, manager, |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1121 "SELECT uuid, uncompressedSize, compressionType, compressedSize, uncompressedHash, " |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1122 "compressedHash FROM AttachedFiles WHERE id=${id} AND fileType=${type}"); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1123 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1124 revision = 0; |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1125 |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1126 return ExecuteLookupAttachment(statement, output, id, contentType); |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1127 } |
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1128 } |
0 | 1129 |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1130 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1131 static bool ReadGlobalProperty(std::string& target, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1132 DatabaseManager::CachedStatement& statement, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1133 const Dictionary& args) |
0 | 1134 { |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1135 statement.Execute(args); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1136 statement.SetResultFieldType(0, ValueType_Utf8String); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1137 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1138 if (statement.IsDone()) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1139 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1140 return false; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1141 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1142 else |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1143 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1144 ValueType type = statement.GetResultField(0).GetType(); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1145 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1146 if (type == ValueType_Null) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1147 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1148 return false; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1149 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1150 else if (type != ValueType_Utf8String) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1151 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1152 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1153 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1154 else |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1155 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1156 target = dynamic_cast<const Utf8StringValue&>(statement.GetResultField(0)).GetContent(); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1157 return true; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1158 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1159 } |
0 | 1160 } |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1161 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1162 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1163 bool IndexBackend::LookupGlobalProperty(std::string& target /*out*/, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1164 DatabaseManager& manager, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1165 const char* serverIdentifier, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1166 int32_t property) |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1167 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1168 if (serverIdentifier == NULL) |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1169 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1170 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1171 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1172 else |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1173 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1174 if (strlen(serverIdentifier) == 0) |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1175 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1176 DatabaseManager::CachedStatement statement( |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1177 STATEMENT_FROM_HERE, manager, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1178 "SELECT value FROM GlobalProperties WHERE property=${property}"); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1179 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1180 statement.SetReadOnly(true); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1181 statement.SetParameterType("property", ValueType_Integer64); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1182 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1183 Dictionary args; |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1184 args.SetIntegerValue("property", property); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1185 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1186 return ReadGlobalProperty(target, statement, args); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1187 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1188 else |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1189 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1190 DatabaseManager::CachedStatement statement( |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1191 STATEMENT_FROM_HERE, manager, |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1192 "SELECT value FROM ServerProperties WHERE server=${server} AND property=${property}"); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1193 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1194 statement.SetReadOnly(true); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1195 statement.SetParameterType("server", ValueType_Utf8String); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1196 statement.SetParameterType("property", ValueType_Integer64); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1197 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1198 Dictionary args; |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1199 args.SetUtf8Value("server", serverIdentifier); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1200 args.SetIntegerValue("property", property); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1201 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1202 return ReadGlobalProperty(target, statement, args); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1203 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1204 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1205 } |
0 | 1206 |
1207 | |
1208 void IndexBackend::LookupIdentifier(std::list<int64_t>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1209 DatabaseManager& manager, |
0 | 1210 OrthancPluginResourceType resourceType, |
1211 uint16_t group, | |
1212 uint16_t element, | |
1213 OrthancPluginIdentifierConstraint constraint, | |
1214 const char* value) | |
1215 { | |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
1216 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 1217 |
1218 std::string header = | |
1219 "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE " | |
1220 "d.id = r.internalId AND r.resourceType=${type} AND d.tagGroup=${group} " | |
1221 "AND d.tagElement=${element} AND "; | |
1222 | |
1223 switch (constraint) | |
1224 { | |
1225 case OrthancPluginIdentifierConstraint_Equal: | |
1226 header += "d.value = ${value}"; | |
1227 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1228 STATEMENT_FROM_HERE, manager, header.c_str())); |
0 | 1229 break; |
1230 | |
1231 case OrthancPluginIdentifierConstraint_SmallerOrEqual: | |
1232 header += "d.value <= ${value}"; | |
1233 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1234 STATEMENT_FROM_HERE, manager, header.c_str())); |
0 | 1235 break; |
1236 | |
1237 case OrthancPluginIdentifierConstraint_GreaterOrEqual: | |
1238 header += "d.value >= ${value}"; | |
1239 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1240 STATEMENT_FROM_HERE, manager, header.c_str())); |
0 | 1241 break; |
1242 | |
1243 case OrthancPluginIdentifierConstraint_Wildcard: | |
1244 header += "d.value LIKE ${value}"; | |
1245 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1246 STATEMENT_FROM_HERE, manager, header.c_str())); |
0 | 1247 break; |
1248 | |
1249 default: | |
1250 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | |
1251 } | |
1252 | |
1253 statement->SetReadOnly(true); | |
1254 statement->SetParameterType("type", ValueType_Integer64); | |
1255 statement->SetParameterType("group", ValueType_Integer64); | |
1256 statement->SetParameterType("element", ValueType_Integer64); | |
1257 statement->SetParameterType("value", ValueType_Utf8String); | |
1258 | |
1259 Dictionary args; | |
1260 args.SetIntegerValue("type", resourceType); | |
1261 args.SetIntegerValue("group", group); | |
1262 args.SetIntegerValue("element", element); | |
1263 | |
1264 if (constraint == OrthancPluginIdentifierConstraint_Wildcard) | |
1265 { | |
1266 args.SetUtf8Value("value", ConvertWildcardToLike(value)); | |
1267 } | |
1268 else | |
1269 { | |
1270 args.SetUtf8Value("value", value); | |
1271 } | |
1272 | |
1273 statement->Execute(args); | |
1274 | |
1275 target.clear(); | |
1276 while (!statement->IsDone()) | |
1277 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1278 target.push_back(statement->ReadInteger64(0)); |
0 | 1279 statement->Next(); |
1280 } | |
1281 } | |
1282 | |
1283 | |
1284 void IndexBackend::LookupIdentifierRange(std::list<int64_t>& target /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1285 DatabaseManager& manager, |
0 | 1286 OrthancPluginResourceType resourceType, |
1287 uint16_t group, | |
1288 uint16_t element, | |
1289 const char* start, | |
1290 const char* end) | |
1291 { | |
1292 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1293 STATEMENT_FROM_HERE, manager, |
0 | 1294 "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE " |
1295 "d.id = r.internalId AND r.resourceType=${type} AND d.tagGroup=${group} " | |
1296 "AND d.tagElement=${element} AND d.value>=${start} AND d.value<=${end}"); | |
1297 | |
1298 statement.SetReadOnly(true); | |
1299 statement.SetParameterType("type", ValueType_Integer64); | |
1300 statement.SetParameterType("group", ValueType_Integer64); | |
1301 statement.SetParameterType("element", ValueType_Integer64); | |
1302 statement.SetParameterType("start", ValueType_Utf8String); | |
1303 statement.SetParameterType("end", ValueType_Utf8String); | |
1304 | |
1305 Dictionary args; | |
1306 args.SetIntegerValue("type", resourceType); | |
1307 args.SetIntegerValue("group", group); | |
1308 args.SetIntegerValue("element", element); | |
1309 args.SetUtf8Value("start", start); | |
1310 args.SetUtf8Value("end", end); | |
1311 | |
1312 statement.Execute(args); | |
1313 | |
1314 target.clear(); | |
1315 while (!statement.IsDone()) | |
1316 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1317 target.push_back(statement.ReadInteger64(0)); |
0 | 1318 statement.Next(); |
1319 } | |
1320 } | |
1321 | |
1322 | |
1323 bool IndexBackend::LookupMetadata(std::string& target /*out*/, | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1324 int64_t& revision /*out*/, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1325 DatabaseManager& manager, |
0 | 1326 int64_t id, |
1327 int32_t metadataType) | |
1328 { | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1329 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1330 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1331 if (HasRevisionsSupport()) |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1332 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1333 statement.reset(new DatabaseManager::CachedStatement( |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1334 STATEMENT_FROM_HERE, manager, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1335 "SELECT value, revision FROM Metadata WHERE id=${id} and type=${type}")); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1336 } |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1337 else |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1338 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1339 statement.reset(new DatabaseManager::CachedStatement( |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1340 STATEMENT_FROM_HERE, manager, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1341 "SELECT value FROM Metadata WHERE id=${id} and type=${type}")); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1342 } |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1343 |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1344 statement->SetReadOnly(true); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1345 statement->SetParameterType("id", ValueType_Integer64); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1346 statement->SetParameterType("type", ValueType_Integer64); |
0 | 1347 |
1348 Dictionary args; | |
1349 args.SetIntegerValue("id", id); | |
1350 args.SetIntegerValue("type", metadataType); | |
1351 | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1352 statement->Execute(args); |
0 | 1353 |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1354 if (statement->IsDone()) |
0 | 1355 { |
1356 return false; | |
1357 } | |
1358 else | |
1359 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1360 target = statement->ReadString(0); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1361 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1362 if (HasRevisionsSupport()) |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1363 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1364 if (statement->GetResultField(1).GetType() == ValueType_Null) |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1365 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1366 // "NULL" can happen with a database created by PostgreSQL |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1367 // plugin <= 3.3 (because of "ALTER TABLE AttachedFiles") |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1368 revision = 0; |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1369 } |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1370 else |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1371 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1372 revision = statement->ReadInteger64(1); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1373 } |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1374 } |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1375 else |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1376 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1377 revision = 0; // No support for revisions |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1378 } |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1379 |
0 | 1380 return true; |
1381 } | |
1382 } | |
1383 | |
1384 | |
1385 bool IndexBackend::LookupParent(int64_t& parentId /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1386 DatabaseManager& manager, |
0 | 1387 int64_t resourceId) |
1388 { | |
1389 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1390 STATEMENT_FROM_HERE, manager, |
0 | 1391 "SELECT parentId FROM Resources WHERE internalId=${id}"); |
1392 | |
1393 statement.SetReadOnly(true); | |
1394 statement.SetParameterType("id", ValueType_Integer64); | |
1395 | |
1396 Dictionary args; | |
1397 args.SetIntegerValue("id", resourceId); | |
1398 | |
1399 statement.Execute(args); | |
1400 | |
1401 if (statement.IsDone() || | |
1402 statement.GetResultField(0).GetType() == ValueType_Null) | |
1403 { | |
1404 return false; | |
1405 } | |
1406 else | |
1407 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1408 parentId = statement.ReadInteger64(0); |
0 | 1409 return true; |
1410 } | |
1411 } | |
1412 | |
1413 | |
1414 bool IndexBackend::LookupResource(int64_t& id /*out*/, | |
1415 OrthancPluginResourceType& type /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1416 DatabaseManager& manager, |
0 | 1417 const char* publicId) |
1418 { | |
1419 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1420 STATEMENT_FROM_HERE, manager, |
0 | 1421 "SELECT internalId, resourceType FROM Resources WHERE publicId=${id}"); |
1422 | |
1423 statement.SetReadOnly(true); | |
1424 statement.SetParameterType("id", ValueType_Utf8String); | |
1425 | |
1426 Dictionary args; | |
1427 args.SetUtf8Value("id", publicId); | |
1428 | |
1429 statement.Execute(args); | |
1430 | |
1431 if (statement.IsDone()) | |
1432 { | |
1433 return false; | |
1434 } | |
1435 else | |
1436 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1437 id = statement.ReadInteger64(0); |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1438 type = static_cast<OrthancPluginResourceType>(statement.ReadInteger32(1)); |
0 | 1439 return true; |
1440 } | |
1441 } | |
1442 | |
1443 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1444 bool IndexBackend::SelectPatientToRecycle(int64_t& internalId /*out*/, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1445 DatabaseManager& manager) |
0 | 1446 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1447 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1448 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1449 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1450 suffix = "OFFSET 0 ROWS FETCH FIRST 1 ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1451 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1452 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1453 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1454 suffix = "LIMIT 1"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1455 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1456 |
0 | 1457 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1458 STATEMENT_FROM_HERE, manager, |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1459 "SELECT patientId FROM PatientRecyclingOrder ORDER BY seq ASC " + suffix); |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1460 |
0 | 1461 statement.SetReadOnly(true); |
1462 statement.Execute(); | |
1463 | |
1464 if (statement.IsDone()) | |
1465 { | |
1466 return false; | |
1467 } | |
1468 else | |
1469 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1470 internalId = statement.ReadInteger64(0); |
0 | 1471 return true; |
1472 } | |
1473 } | |
1474 | |
1475 | |
1476 bool IndexBackend::SelectPatientToRecycle(int64_t& internalId /*out*/, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1477 DatabaseManager& manager, |
0 | 1478 int64_t patientIdToAvoid) |
1479 { | |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1480 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1481 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1482 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1483 suffix = "OFFSET 0 ROWS FETCH FIRST 1 ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1484 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1485 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1486 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1487 suffix = "LIMIT 1"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1488 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1489 |
0 | 1490 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1491 STATEMENT_FROM_HERE, manager, |
0 | 1492 "SELECT patientId FROM PatientRecyclingOrder " |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1493 "WHERE patientId != ${id} ORDER BY seq ASC " + suffix); |
0 | 1494 |
1495 statement.SetReadOnly(true); | |
1496 statement.SetParameterType("id", ValueType_Integer64); | |
1497 | |
1498 Dictionary args; | |
1499 args.SetIntegerValue("id", patientIdToAvoid); | |
1500 | |
1501 statement.Execute(args); | |
1502 | |
1503 if (statement.IsDone()) | |
1504 { | |
1505 return false; | |
1506 } | |
1507 else | |
1508 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1509 internalId = statement.ReadInteger64(0); |
0 | 1510 return true; |
1511 } | |
1512 } | |
1513 | |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1514 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1515 static void RunSetGlobalPropertyStatement(DatabaseManager::CachedStatement& statement, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1516 bool hasServer, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1517 bool hasValue, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1518 const char* serverIdentifier, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1519 int32_t property, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1520 const char* utf8) |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1521 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1522 Dictionary args; |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1523 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1524 statement.SetParameterType("property", ValueType_Integer64); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1525 args.SetIntegerValue("property", static_cast<int>(property)); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1526 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1527 if (hasValue) |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1528 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1529 assert(utf8 != NULL); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1530 statement.SetParameterType("value", ValueType_Utf8String); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1531 args.SetUtf8Value("value", utf8); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1532 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1533 else |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1534 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1535 assert(utf8 == NULL); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1536 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1537 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1538 if (hasServer) |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1539 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1540 assert(serverIdentifier != NULL && strlen(serverIdentifier) > 0); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1541 statement.SetParameterType("server", ValueType_Utf8String); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1542 args.SetUtf8Value("server", serverIdentifier); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1543 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1544 else |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1545 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1546 assert(serverIdentifier == NULL); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1547 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1548 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1549 statement.Execute(args); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1550 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1551 |
0 | 1552 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1553 void IndexBackend::SetGlobalProperty(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1554 const char* serverIdentifier, |
221
73cc85f3d9c1
implementation of the "serverIdentifier" information for global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
220
diff
changeset
|
1555 int32_t property, |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1556 const char* utf8) |
0 | 1557 { |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1558 if (serverIdentifier == NULL) |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1559 { |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1560 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1561 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1562 else if (manager.GetDialect() == Dialect_SQLite) |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1563 { |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1564 bool hasServer = (strlen(serverIdentifier) != 0); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1565 |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1566 if (hasServer) |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1567 { |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1568 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1569 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1570 "INSERT OR REPLACE INTO ServerProperties VALUES (${server}, ${property}, ${value})"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1571 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1572 RunSetGlobalPropertyStatement(statement, true, true, serverIdentifier, property, utf8); |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1573 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1574 else |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1575 { |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1576 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1577 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1578 "INSERT OR REPLACE INTO GlobalProperties VALUES (${property}, ${value})"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1579 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1580 RunSetGlobalPropertyStatement(statement, false, true, NULL, property, utf8); |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1581 } |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1582 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1583 else |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1584 { |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1585 bool hasServer = (strlen(serverIdentifier) != 0); |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1586 |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1587 if (hasServer) |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1588 { |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1589 { |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1590 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1591 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1592 "DELETE FROM ServerProperties WHERE server=${server} AND property=${property}"); |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1593 |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1594 RunSetGlobalPropertyStatement(statement, true, false, serverIdentifier, property, NULL); |
238
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1595 } |
f033cc039264
new table: "ServerProperties"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1596 |
239
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1597 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1598 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1599 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1600 "INSERT INTO ServerProperties VALUES (${server}, ${property}, ${value})"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1601 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1602 RunSetGlobalPropertyStatement(statement, true, true, serverIdentifier, property, utf8); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1603 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1604 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1605 else |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1606 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1607 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1608 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1609 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1610 "DELETE FROM GlobalProperties WHERE property=${property}"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1611 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1612 RunSetGlobalPropertyStatement(statement, false, false, NULL, property, NULL); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1613 } |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1614 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1615 { |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1616 DatabaseManager::CachedStatement statement( |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1617 STATEMENT_FROM_HERE, manager, |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1618 "INSERT INTO GlobalProperties VALUES (${property}, ${value})"); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1619 |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1620 RunSetGlobalPropertyStatement(statement, false, true, NULL, property, utf8); |
e9ba888f371b
fix IndexBackend::SetGlobalProperty(), lighten GlobalProperty enum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
1621 } |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1622 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
1623 } |
0 | 1624 } |
1625 | |
1626 | |
1627 static void ExecuteSetTag(DatabaseManager::CachedStatement& statement, | |
1628 int64_t id, | |
1629 uint16_t group, | |
1630 uint16_t element, | |
1631 const char* value) | |
1632 { | |
1633 statement.SetParameterType("id", ValueType_Integer64); | |
1634 statement.SetParameterType("group", ValueType_Integer64); | |
1635 statement.SetParameterType("element", ValueType_Integer64); | |
1636 statement.SetParameterType("value", ValueType_Utf8String); | |
1637 | |
1638 Dictionary args; | |
1639 args.SetIntegerValue("id", id); | |
1640 args.SetIntegerValue("group", group); | |
1641 args.SetIntegerValue("element", element); | |
1642 args.SetUtf8Value("value", value); | |
1643 | |
1644 statement.Execute(args); | |
1645 } | |
1646 | |
1647 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1648 void IndexBackend::SetMainDicomTag(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1649 int64_t id, |
0 | 1650 uint16_t group, |
1651 uint16_t element, | |
1652 const char* value) | |
1653 { | |
1654 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1655 STATEMENT_FROM_HERE, manager, |
0 | 1656 "INSERT INTO MainDicomTags VALUES(${id}, ${group}, ${element}, ${value})"); |
1657 | |
1658 ExecuteSetTag(statement, id, group, element, value); | |
1659 } | |
1660 | |
1661 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1662 void IndexBackend::SetIdentifierTag(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1663 int64_t id, |
0 | 1664 uint16_t group, |
1665 uint16_t element, | |
1666 const char* value) | |
1667 { | |
1668 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1669 STATEMENT_FROM_HERE, manager, |
0 | 1670 "INSERT INTO DicomIdentifiers VALUES(${id}, ${group}, ${element}, ${value})"); |
1671 | |
1672 ExecuteSetTag(statement, id, group, element, value); | |
1673 } | |
1674 | |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1675 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1676 static void ExecuteSetMetadata(DatabaseManager::CachedStatement& statement, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1677 Dictionary& args, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1678 int64_t id, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1679 int32_t metadataType, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1680 const char* value) |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1681 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1682 statement.SetParameterType("id", ValueType_Integer64); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1683 statement.SetParameterType("type", ValueType_Integer64); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1684 statement.SetParameterType("value", ValueType_Utf8String); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1685 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1686 args.SetIntegerValue("id", id); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1687 args.SetIntegerValue("type", metadataType); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1688 args.SetUtf8Value("value", value); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1689 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1690 statement.Execute(args); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1691 } |
0 | 1692 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1693 void IndexBackend::SetMetadata(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1694 int64_t id, |
0 | 1695 int32_t metadataType, |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1696 const char* value, |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1697 int64_t revision) |
0 | 1698 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1699 if (manager.GetDialect() == Dialect_SQLite) |
0 | 1700 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1701 assert(HasRevisionsSupport()); |
0 | 1702 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1703 STATEMENT_FROM_HERE, manager, |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1704 "INSERT OR REPLACE INTO Metadata VALUES (${id}, ${type}, ${value}, ${revision})"); |
0 | 1705 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1706 Dictionary args; |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1707 statement.SetParameterType("revision", ValueType_Integer64); |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1708 args.SetIntegerValue("revision", revision); |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1709 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1710 ExecuteSetMetadata(statement, args, id, metadataType, value); |
0 | 1711 } |
1712 else | |
1713 { | |
1714 { | |
1715 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1716 STATEMENT_FROM_HERE, manager, |
0 | 1717 "DELETE FROM Metadata WHERE id=${id} AND type=${type}"); |
1718 | |
1719 statement.SetParameterType("id", ValueType_Integer64); | |
1720 statement.SetParameterType("type", ValueType_Integer64); | |
1721 | |
1722 Dictionary args; | |
1723 args.SetIntegerValue("id", id); | |
1724 args.SetIntegerValue("type", metadataType); | |
1725 | |
1726 statement.Execute(args); | |
1727 } | |
1728 | |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1729 if (HasRevisionsSupport()) |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1730 { |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1731 DatabaseManager::CachedStatement statement( |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1732 STATEMENT_FROM_HERE, manager, |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1733 "INSERT INTO Metadata VALUES (${id}, ${type}, ${value}, ${revision})"); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1734 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1735 Dictionary args; |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1736 statement.SetParameterType("revision", ValueType_Integer64); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1737 args.SetIntegerValue("revision", revision); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1738 |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1739 ExecuteSetMetadata(statement, args, id, metadataType, value); |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1740 } |
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1741 else |
0 | 1742 { |
1743 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1744 STATEMENT_FROM_HERE, manager, |
0 | 1745 "INSERT INTO Metadata VALUES (${id}, ${type}, ${value})"); |
1746 | |
1747 Dictionary args; | |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
1748 ExecuteSetMetadata(statement, args, id, metadataType, value); |
0 | 1749 } |
1750 } | |
1751 } | |
1752 | |
1753 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1754 void IndexBackend::SetProtectedPatient(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1755 int64_t internalId, |
0 | 1756 bool isProtected) |
1757 { | |
1758 if (isProtected) | |
1759 { | |
1760 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1761 STATEMENT_FROM_HERE, manager, |
0 | 1762 "DELETE FROM PatientRecyclingOrder WHERE patientId=${id}"); |
1763 | |
1764 statement.SetParameterType("id", ValueType_Integer64); | |
1765 | |
1766 Dictionary args; | |
1767 args.SetIntegerValue("id", internalId); | |
1768 | |
1769 statement.Execute(args); | |
1770 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1771 else if (IsProtectedPatient(manager, internalId)) |
0 | 1772 { |
1773 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1774 STATEMENT_FROM_HERE, manager, |
302
3a52e27a2d80
in GenericFormatter, replaced ${} by ${AUTOINCREMENT}
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
301
diff
changeset
|
1775 "INSERT INTO PatientRecyclingOrder VALUES(${AUTOINCREMENT} ${id})"); |
0 | 1776 |
1777 statement.SetParameterType("id", ValueType_Integer64); | |
1778 | |
1779 Dictionary args; | |
1780 args.SetIntegerValue("id", internalId); | |
1781 | |
1782 statement.Execute(args); | |
1783 } | |
1784 else | |
1785 { | |
1786 // Nothing to do: The patient is already unprotected | |
1787 } | |
1788 } | |
1789 | |
1790 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1791 uint32_t IndexBackend::GetDatabaseVersion(DatabaseManager& manager) |
0 | 1792 { |
220
492aa3edf572
use read-only, explicit transaction in IndexBackend::GetDatabaseVersion()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
219
diff
changeset
|
1793 // Create a read-only, explicit transaction to read the database |
492aa3edf572
use read-only, explicit transaction in IndexBackend::GetDatabaseVersion()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
219
diff
changeset
|
1794 // version (this was a read-write, implicit transaction in |
492aa3edf572
use read-only, explicit transaction in IndexBackend::GetDatabaseVersion()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
219
diff
changeset
|
1795 // PostgreSQL plugin <= 3.3 and MySQL plugin <= 3.0) |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1796 DatabaseManager::Transaction transaction(manager, TransactionType_ReadOnly); |
220
492aa3edf572
use read-only, explicit transaction in IndexBackend::GetDatabaseVersion()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
219
diff
changeset
|
1797 |
0 | 1798 std::string version = "unknown"; |
1799 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1800 if (LookupGlobalProperty(version, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabaseSchemaVersion)) |
0 | 1801 { |
1802 try | |
1803 { | |
1804 return boost::lexical_cast<unsigned int>(version); | |
1805 } | |
1806 catch (boost::bad_lexical_cast&) | |
1807 { | |
1808 } | |
1809 } | |
1810 | |
1811 LOG(ERROR) << "The database is corrupted. Drop it manually for Orthanc to recreate it"; | |
1812 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | |
1813 } | |
1814 | |
1815 | |
1816 /** | |
1817 * Upgrade the database to the specified version of the database | |
1818 * schema. The upgrade script is allowed to make calls to | |
1819 * OrthancPluginReconstructMainDicomTags(). | |
1820 **/ | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1821 void IndexBackend::UpgradeDatabase(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1822 uint32_t targetVersion, |
0 | 1823 OrthancPluginStorageArea* storageArea) |
1824 { | |
1825 LOG(ERROR) << "Upgrading database is not implemented by this plugin"; | |
1826 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1827 } | |
1828 | |
1829 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1830 void IndexBackend::ClearMainDicomTags(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1831 int64_t internalId) |
0 | 1832 { |
1833 { | |
1834 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1835 STATEMENT_FROM_HERE, manager, |
0 | 1836 "DELETE FROM MainDicomTags WHERE id=${id}"); |
1837 | |
1838 statement.SetParameterType("id", ValueType_Integer64); | |
1839 | |
1840 Dictionary args; | |
1841 args.SetIntegerValue("id", internalId); | |
1842 | |
1843 statement.Execute(args); | |
1844 } | |
1845 | |
1846 { | |
1847 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1848 STATEMENT_FROM_HERE, manager, |
0 | 1849 "DELETE FROM DicomIdentifiers WHERE id=${id}"); |
1850 | |
1851 statement.SetParameterType("id", ValueType_Integer64); | |
1852 | |
1853 Dictionary args; | |
1854 args.SetIntegerValue("id", internalId); | |
1855 | |
1856 statement.Execute(args); | |
1857 } | |
1858 } | |
1859 | |
1860 | |
1861 // For unit testing only! | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1862 uint64_t IndexBackend::GetAllResourcesCount(DatabaseManager& manager) |
0 | 1863 { |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
1864 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 1865 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1866 switch (manager.GetDialect()) |
0 | 1867 { |
1868 case Dialect_MySQL: | |
1869 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1870 STATEMENT_FROM_HERE, manager, |
0 | 1871 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM Resources")); |
1872 break; | |
1873 | |
1874 case Dialect_PostgreSQL: | |
1875 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1876 STATEMENT_FROM_HERE, manager, |
0 | 1877 "SELECT CAST(COUNT(*) AS BIGINT) FROM Resources")); |
1878 break; | |
1879 | |
1880 case Dialect_SQLite: | |
301 | 1881 case Dialect_MSSQL: |
0 | 1882 statement.reset(new DatabaseManager::CachedStatement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1883 STATEMENT_FROM_HERE, manager, |
0 | 1884 "SELECT COUNT(*) FROM Resources")); |
1885 break; | |
1886 | |
1887 default: | |
1888 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1889 } | |
1890 | |
1891 statement->SetReadOnly(true); | |
1892 statement->Execute(); | |
1893 | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1894 return static_cast<uint64_t>(statement->ReadInteger64(0)); |
0 | 1895 } |
1896 | |
1897 | |
1898 // For unit testing only! | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1899 uint64_t IndexBackend::GetUnprotectedPatientsCount(DatabaseManager& manager) |
0 | 1900 { |
157
275e14f57f1e
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
1901 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
0 | 1902 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1903 switch (manager.GetDialect()) |
0 | 1904 { |
1905 case Dialect_MySQL: | |
1906 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1907 STATEMENT_FROM_HERE, manager, |
0 | 1908 "SELECT CAST(COUNT(*) AS UNSIGNED INT) FROM PatientRecyclingOrder")); |
1909 break; | |
1910 | |
1911 case Dialect_PostgreSQL: | |
1912 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1913 STATEMENT_FROM_HERE, manager, |
0 | 1914 "SELECT CAST(COUNT(*) AS BIGINT) FROM PatientRecyclingOrder")); |
1915 break; | |
1916 | |
304
dd4b0edd1661
GenericFormatter::GetDialect()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
302
diff
changeset
|
1917 case Dialect_MSSQL: |
0 | 1918 case Dialect_SQLite: |
1919 statement.reset(new DatabaseManager::CachedStatement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1920 STATEMENT_FROM_HERE, manager, |
0 | 1921 "SELECT COUNT(*) FROM PatientRecyclingOrder")); |
1922 break; | |
1923 | |
1924 default: | |
1925 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
1926 } | |
1927 | |
1928 statement->SetReadOnly(true); | |
1929 statement->Execute(); | |
1930 | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1931 return static_cast<uint64_t>(statement->ReadInteger64(0)); |
0 | 1932 } |
1933 | |
1934 | |
1935 // For unit testing only! | |
1936 bool IndexBackend::GetParentPublicId(std::string& target, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1937 DatabaseManager& manager, |
0 | 1938 int64_t id) |
1939 { | |
1940 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1941 STATEMENT_FROM_HERE, manager, |
0 | 1942 "SELECT a.publicId FROM Resources AS a, Resources AS b " |
1943 "WHERE a.internalId = b.parentId AND b.internalId = ${id}"); | |
1944 | |
1945 statement.SetReadOnly(true); | |
1946 statement.SetParameterType("id", ValueType_Integer64); | |
1947 | |
1948 Dictionary args; | |
1949 args.SetIntegerValue("id", id); | |
1950 | |
1951 statement.Execute(args); | |
1952 | |
1953 if (statement.IsDone()) | |
1954 { | |
1955 return false; | |
1956 } | |
1957 else | |
1958 { | |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1959 target = statement.ReadString(0); |
0 | 1960 return true; |
1961 } | |
1962 } | |
1963 | |
1964 | |
1965 // For unit tests only! | |
1966 void IndexBackend::GetChildren(std::list<std::string>& childrenPublicIds, | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1967 DatabaseManager& manager, |
0 | 1968 int64_t id) |
1969 { | |
1970 DatabaseManager::CachedStatement statement( | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1971 STATEMENT_FROM_HERE, manager, |
0 | 1972 "SELECT publicId FROM Resources WHERE parentId=${id}"); |
1973 | |
1974 statement.SetReadOnly(true); | |
1975 statement.SetParameterType("id", ValueType_Integer64); | |
1976 | |
1977 Dictionary args; | |
1978 args.SetIntegerValue("id", id); | |
1979 | |
1980 ReadListOfStrings(childrenPublicIds, statement, args); | |
1981 } | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1982 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1983 |
78 | 1984 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1985 class IndexBackend::LookupFormatter : public Orthanc::ISqlLookupFormatter |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1986 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1987 private: |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1988 Dialect dialect_; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1989 size_t count_; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1990 Dictionary dictionary_; |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1991 |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1992 static std::string FormatParameter(size_t index) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1993 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1994 return "p" + boost::lexical_cast<std::string>(index); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1995 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1996 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1997 public: |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1998 LookupFormatter(Dialect dialect) : |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
1999 dialect_(dialect), |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2000 count_(0) |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2001 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2002 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2003 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2004 virtual std::string GenerateParameter(const std::string& value) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2005 { |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2006 const std::string key = FormatParameter(count_); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2007 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2008 count_ ++; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2009 dictionary_.SetUtf8Value(key, value); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2010 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2011 return "${" + key + "}"; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2012 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2013 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2014 virtual std::string FormatResourceType(Orthanc::ResourceType level) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2015 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2016 return boost::lexical_cast<std::string>(Orthanc::Plugins::Convert(level)); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2017 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2018 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2019 virtual std::string FormatWildcardEscape() |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2020 { |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2021 switch (dialect_) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2022 { |
310
f3eac614b32e
fixed two DatabaseManager::CachedStatement in the same scope
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
2023 case Dialect_MSSQL: |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2024 case Dialect_SQLite: |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2025 case Dialect_PostgreSQL: |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2026 return "ESCAPE '\\'"; |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2027 |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2028 case Dialect_MySQL: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2029 return "ESCAPE '\\\\'"; |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2030 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2031 default: |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2032 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2033 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2034 } |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2035 |
354
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2036 virtual bool IsEscapeBrackets() const |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2037 { |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2038 // This was initially done at a bad location by the following changeset: |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2039 // https://hg.orthanc-server.com/orthanc-databases/rev/389c037387ea |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2040 return (dialect_ == Dialect_MSSQL); |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2041 } |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
326
diff
changeset
|
2042 |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2043 void PrepareStatement(DatabaseManager::StandaloneStatement& statement) const |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2044 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2045 statement.SetReadOnly(true); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2046 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2047 for (size_t i = 0; i < count_; i++) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2048 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2049 statement.SetParameterType(FormatParameter(i), ValueType_Utf8String); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2050 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2051 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2052 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2053 const Dictionary& GetDictionary() const |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2054 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2055 return dictionary_; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2056 } |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2057 }; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2058 #endif |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2059 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2060 |
78 | 2061 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2062 // New primitive since Orthanc 1.5.2 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2063 void IndexBackend::LookupResources(IDatabaseBackendOutput& output, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2064 DatabaseManager& manager, |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
193
diff
changeset
|
2065 const std::vector<Orthanc::DatabaseConstraint>& lookup, |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2066 OrthancPluginResourceType queryLevel, |
401
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
400
diff
changeset
|
2067 const std::set<std::string>& labels, |
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
400
diff
changeset
|
2068 Orthanc::LabelsConstraint labelsConstraint, |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2069 uint32_t limit, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2070 bool requestSomeInstance) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2071 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2072 LookupFormatter formatter(manager.GetDialect()); |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2073 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2074 std::string sql; |
401
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
400
diff
changeset
|
2075 Orthanc::ISqlLookupFormatter::Apply(sql, formatter, lookup, Orthanc::Plugins::Convert(queryLevel), |
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
400
diff
changeset
|
2076 labels, labelsConstraint, limit); |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2077 |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2078 if (requestSomeInstance) |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2079 { |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2080 // Composite query to find some instance if requested |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2081 switch (queryLevel) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2082 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2083 case OrthancPluginResourceType_Patient: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2084 sql = ("SELECT patients.publicId, MIN(instances.publicId) FROM (" + sql + ") patients " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2085 "INNER JOIN Resources studies ON studies.parentId = patients.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2086 "INNER JOIN Resources series ON series.parentId = studies.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2087 "INNER JOIN Resources instances ON instances.parentId = series.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2088 "GROUP BY patients.publicId"); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2089 break; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2090 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2091 case OrthancPluginResourceType_Study: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2092 sql = ("SELECT studies.publicId, MIN(instances.publicId) FROM (" + sql + ") studies " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2093 "INNER JOIN Resources series ON series.parentId = studies.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2094 "INNER JOIN Resources instances ON instances.parentId = series.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2095 "GROUP BY studies.publicId"); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2096 break; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2097 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2098 case OrthancPluginResourceType_Series: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2099 sql = ("SELECT series.publicId, MIN(instances.publicId) FROM (" + sql + ") series " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2100 "INNER JOIN Resources instances ON instances.parentId = series.internalId " |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2101 "GROUP BY series.publicId"); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2102 break; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2103 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2104 case OrthancPluginResourceType_Instance: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2105 sql = ("SELECT instances.publicId, instances.publicId FROM (" + sql + ") instances"); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2106 break; |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2107 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2108 default: |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2109 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2110 } |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2111 } |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2112 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2113 DatabaseManager::StandaloneStatement statement(manager, sql); |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2114 formatter.PrepareStatement(statement); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2115 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2116 statement.Execute(formatter.GetDictionary()); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2117 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2118 while (!statement.IsDone()) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2119 { |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2120 if (requestSomeInstance) |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2121 { |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2122 output.AnswerMatchingResource(statement.ReadString(0), statement.ReadString(1)); |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2123 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2124 else |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2125 { |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2126 output.AnswerMatchingResource(statement.ReadString(0)); |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2127 } |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2128 |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2129 statement.Next(); |
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
2130 } |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2131 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
2132 #endif |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2133 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2134 |
78 | 2135 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2136 static void ExecuteSetResourcesContentTags( |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2137 DatabaseManager& manager, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2138 const std::string& table, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2139 const std::string& variablePrefix, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2140 uint32_t count, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2141 const OrthancPluginResourcesContentTags* tags) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2142 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2143 std::string sql; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2144 Dictionary args; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2145 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2146 for (uint32_t i = 0; i < count; i++) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2147 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2148 std::string name = variablePrefix + boost::lexical_cast<std::string>(i); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2149 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2150 args.SetUtf8Value(name, tags[i].value); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2151 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2152 std::string insert = ("(" + boost::lexical_cast<std::string>(tags[i].resource) + ", " + |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2153 boost::lexical_cast<std::string>(tags[i].group) + ", " + |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2154 boost::lexical_cast<std::string>(tags[i].element) + ", " + |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2155 "${" + name + "})"); |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2156 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2157 if (sql.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2158 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2159 sql = "INSERT INTO " + table + " VALUES " + insert; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2160 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2161 else |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2162 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2163 sql += ", " + insert; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2164 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2165 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2166 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2167 if (!sql.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2168 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2169 DatabaseManager::StandaloneStatement statement(manager, sql); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2170 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2171 for (uint32_t i = 0; i < count; i++) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2172 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2173 statement.SetParameterType(variablePrefix + boost::lexical_cast<std::string>(i), |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2174 ValueType_Utf8String); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2175 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2176 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2177 statement.Execute(args); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2178 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2179 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2180 #endif |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2181 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2182 |
78 | 2183 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2184 static void ExecuteSetResourcesContentMetadata( |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2185 DatabaseManager& manager, |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
2186 bool hasRevisionsSupport, |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2187 uint32_t count, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2188 const OrthancPluginResourcesContentMetadata* metadata) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2189 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2190 std::string sqlRemove; // To overwrite |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2191 std::string sqlInsert; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2192 Dictionary args; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2193 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2194 for (uint32_t i = 0; i < count; i++) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2195 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2196 std::string name = "m" + boost::lexical_cast<std::string>(i); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2197 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2198 args.SetUtf8Value(name, metadata[i].value); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2199 |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2200 std::string revisionSuffix; |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
2201 if (hasRevisionsSupport) |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2202 { |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
2203 revisionSuffix = ", 0"; |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2204 } |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2205 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2206 std::string insert = ("(" + boost::lexical_cast<std::string>(metadata[i].resource) + ", " + |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2207 boost::lexical_cast<std::string>(metadata[i].metadata) + ", " + |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2208 "${" + name + "}" + revisionSuffix + ")"); |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2209 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2210 std::string remove = ("(id=" + boost::lexical_cast<std::string>(metadata[i].resource) + |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2211 " AND type=" + boost::lexical_cast<std::string>(metadata[i].metadata) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2212 + ")"); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2213 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2214 if (sqlInsert.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2215 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2216 sqlInsert = "INSERT INTO Metadata VALUES " + insert; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2217 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2218 else |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2219 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2220 sqlInsert += ", " + insert; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2221 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2222 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2223 if (sqlRemove.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2224 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2225 sqlRemove = "DELETE FROM Metadata WHERE " + remove; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2226 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2227 else |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2228 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2229 sqlRemove += " OR " + remove; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2230 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2231 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2232 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2233 if (!sqlRemove.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2234 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2235 DatabaseManager::StandaloneStatement statement(manager, sqlRemove); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2236 statement.Execute(); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2237 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2238 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2239 if (!sqlInsert.empty()) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2240 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2241 DatabaseManager::StandaloneStatement statement(manager, sqlInsert); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2242 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2243 for (uint32_t i = 0; i < count; i++) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2244 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2245 statement.SetParameterType("m" + boost::lexical_cast<std::string>(i), |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2246 ValueType_Utf8String); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2247 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2248 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2249 statement.Execute(args); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2250 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2251 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2252 #endif |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2253 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2254 |
78 | 2255 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2256 // New primitive since Orthanc 1.5.2 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2257 void IndexBackend::SetResourcesContent( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2258 DatabaseManager& manager, |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2259 uint32_t countIdentifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2260 const OrthancPluginResourcesContentTags* identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2261 uint32_t countMainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2262 const OrthancPluginResourcesContentTags* mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2263 uint32_t countMetadata, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2264 const OrthancPluginResourcesContentMetadata* metadata) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2265 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2266 /** |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2267 * TODO - PostgreSQL doesn't allow multiple commands in a prepared |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2268 * statement, so we execute 3 separate commands (for identifiers, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2269 * main tags and metadata). Maybe MySQL does not suffer from the |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2270 * same limitation, to check. |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2271 **/ |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2272 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2273 ExecuteSetResourcesContentTags(manager, "DicomIdentifiers", "i", |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2274 countIdentifierTags, identifierTags); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2275 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2276 ExecuteSetResourcesContentTags(manager, "MainDicomTags", "t", |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2277 countMainDicomTags, mainDicomTags); |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
2278 |
266
cc7af42d4f23
Store revisions for metadata and attachments in PostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
265
diff
changeset
|
2279 ExecuteSetResourcesContentMetadata(manager, HasRevisionsSupport(), countMetadata, metadata); |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2280 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
2281 #endif |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2282 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2283 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2284 // New primitive since Orthanc 1.5.2 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2285 void IndexBackend::GetChildrenMetadata(std::list<std::string>& target, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2286 DatabaseManager& manager, |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2287 int64_t resourceId, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2288 int32_t metadata) |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2289 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2290 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2291 STATEMENT_FROM_HERE, manager, |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2292 "SELECT value FROM Metadata WHERE type=${metadata} AND " |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2293 "id IN (SELECT internalId FROM Resources WHERE parentId=${id})"); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2294 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2295 statement.SetReadOnly(true); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2296 statement.SetParameterType("id", ValueType_Integer64); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2297 statement.SetParameterType("metadata", ValueType_Integer64); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2298 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2299 Dictionary args; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2300 args.SetIntegerValue("id", static_cast<int>(resourceId)); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2301 args.SetIntegerValue("metadata", static_cast<int>(metadata)); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2302 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2303 ReadListOfStrings(target, statement, args); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
2304 } |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2305 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2306 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2307 // New primitive since Orthanc 1.5.2 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2308 void IndexBackend::TagMostRecentPatient(DatabaseManager& manager, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2309 int64_t patient) |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2310 { |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2311 std::string suffix; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2312 if (manager.GetDialect() == Dialect_MSSQL) |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2313 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2314 suffix = "OFFSET 0 ROWS FETCH FIRST 2 ROWS ONLY"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2315 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2316 else |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2317 { |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2318 suffix = "LIMIT 2"; |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2319 } |
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2320 |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2321 int64_t seq; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2322 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2323 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2324 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2325 STATEMENT_FROM_HERE, manager, |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2326 "SELECT * FROM PatientRecyclingOrder WHERE seq >= " |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2327 "(SELECT seq FROM PatientRecyclingOrder WHERE patientid=${id}) ORDER BY seq " + suffix); |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2328 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2329 statement.SetReadOnly(true); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2330 statement.SetParameterType("id", ValueType_Integer64); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2331 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2332 Dictionary args; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2333 args.SetIntegerValue("id", patient); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2334 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2335 statement.Execute(args); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2336 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2337 if (statement.IsDone()) |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2338 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2339 // The patient is protected, don't add it to the recycling order |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2340 return; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2341 } |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2342 |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2343 seq = statement.ReadInteger64(0); |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2344 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2345 statement.Next(); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2346 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2347 if (statement.IsDone()) |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2348 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2349 // The patient is already at the end of the recycling order |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2350 // (because of the "LIMIT 2" above), no need to modify the table |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2351 return; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2352 } |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2353 } |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2354 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2355 // Delete the old position of the patient in the recycling order |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2356 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2357 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2358 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2359 STATEMENT_FROM_HERE, manager, |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2360 "DELETE FROM PatientRecyclingOrder WHERE seq=${seq}"); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2361 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2362 statement.SetParameterType("seq", ValueType_Integer64); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2363 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2364 Dictionary args; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2365 args.SetIntegerValue("seq", seq); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2366 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2367 statement.Execute(args); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2368 } |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2369 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2370 // Add the patient to the end of the recycling order |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2371 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2372 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2373 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2374 STATEMENT_FROM_HERE, manager, |
306
544e0c943b40
added transact-sql dialect for LIMIT and OFFSET
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
2375 "INSERT INTO PatientRecyclingOrder VALUES(${AUTOINCREMENT} ${id})"); |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2376 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2377 statement.SetParameterType("id", ValueType_Integer64); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2378 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2379 Dictionary args; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2380 args.SetIntegerValue("id", patient); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2381 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2382 statement.Execute(args); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2383 } |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
2384 } |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2385 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2386 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2387 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2388 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2389 // New primitive since Orthanc 1.5.4 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2390 bool IndexBackend::LookupResourceAndParent(int64_t& id, |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2391 OrthancPluginResourceType& type, |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2392 std::string& parentPublicId, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2393 DatabaseManager& manager, |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2394 const char* publicId) |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2395 { |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2396 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2397 STATEMENT_FROM_HERE, manager, |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2398 "SELECT resource.internalId, resource.resourceType, parent.publicId " |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2399 "FROM Resources AS resource LEFT JOIN Resources parent ON parent.internalId=resource.parentId " |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2400 "WHERE resource.publicId=${id}"); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2401 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2402 statement.SetParameterType("id", ValueType_Utf8String); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2403 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2404 Dictionary args; |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2405 args.SetUtf8Value("id", publicId); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2406 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2407 statement.Execute(args); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2408 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2409 if (statement.IsDone()) |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2410 { |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2411 return false; |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2412 } |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2413 else |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2414 { |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2415 if (statement.GetResultFieldsCount() != 3) |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2416 { |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2417 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2418 } |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2419 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2420 statement.SetResultFieldType(0, ValueType_Integer64); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2421 statement.SetResultFieldType(1, ValueType_Integer64); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2422 statement.SetResultFieldType(2, ValueType_Utf8String); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2423 |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2424 id = statement.ReadInteger64(0); |
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2425 type = static_cast<OrthancPluginResourceType>(statement.ReadInteger32(1)); |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2426 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2427 const IValue& value = statement.GetResultField(2); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2428 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2429 switch (value.GetType()) |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2430 { |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2431 case ValueType_Null: |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2432 parentPublicId.clear(); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2433 break; |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2434 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2435 case ValueType_Utf8String: |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2436 parentPublicId = dynamic_cast<const Utf8StringValue&>(value).GetContent(); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2437 break; |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2438 |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2439 default: |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2440 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2441 } |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2442 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2443 assert((statement.Next(), statement.IsDone())); |
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2444 return true; |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2445 } |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
2446 } |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2447 # endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2448 #endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2449 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2450 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2451 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2452 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2453 // New primitive since Orthanc 1.5.4 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2454 void IndexBackend::GetAllMetadata(std::map<int32_t, std::string>& result, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2455 DatabaseManager& manager, |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2456 int64_t id) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2457 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2458 DatabaseManager::CachedStatement statement( |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2459 STATEMENT_FROM_HERE, manager, |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2460 "SELECT type, value FROM Metadata WHERE id=${id}"); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2461 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2462 statement.SetReadOnly(true); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2463 statement.SetParameterType("id", ValueType_Integer64); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2464 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2465 Dictionary args; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2466 args.SetIntegerValue("id", id); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2467 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2468 statement.Execute(args); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2469 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2470 result.clear(); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2471 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2472 if (!statement.IsDone()) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2473 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2474 if (statement.GetResultFieldsCount() != 2) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2475 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2476 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2477 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2478 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2479 statement.SetResultFieldType(0, ValueType_Integer64); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2480 statement.SetResultFieldType(1, ValueType_Utf8String); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2481 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2482 while (!statement.IsDone()) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2483 { |
263
29d2b76516f6
fix mysql and postgresql builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
2484 result[statement.ReadInteger32(0)] = statement.ReadString(1); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2485 statement.Next(); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2486 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2487 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2488 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2489 # endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
2490 #endif |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2491 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2492 |
271
6b18d3fbee82
backward compatibility with Orthanc SDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
2493 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2494 void IndexBackend::CreateInstanceGeneric(OrthancPluginCreateInstanceResult& result, |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2495 DatabaseManager& manager, |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2496 const char* hashPatient, |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2497 const char* hashStudy, |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2498 const char* hashSeries, |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2499 const char* hashInstance) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2500 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2501 // Check out "OrthancServer/Sources/Database/Compatibility/ICreateInstance.cpp" |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2502 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2503 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2504 OrthancPluginResourceType type; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2505 int64_t tmp; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2506 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2507 if (LookupResource(tmp, type, manager, hashInstance)) |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2508 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2509 // The instance already exists |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2510 assert(type == OrthancPluginResourceType_Instance); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2511 result.instanceId = tmp; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2512 result.isNewInstance = false; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2513 return; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2514 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2515 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2516 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2517 result.instanceId = CreateResource(manager, hashInstance, OrthancPluginResourceType_Instance); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2518 result.isNewInstance = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2519 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2520 result.isNewPatient = false; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2521 result.isNewStudy = false; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2522 result.isNewSeries = false; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2523 result.patientId = -1; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2524 result.studyId = -1; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2525 result.seriesId = -1; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2526 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2527 // Detect up to which level the patient/study/series/instance |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2528 // hierarchy must be created |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2529 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2530 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2531 OrthancPluginResourceType dummy; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2532 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2533 if (LookupResource(result.seriesId, dummy, manager, hashSeries)) |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2534 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2535 assert(dummy == OrthancPluginResourceType_Series); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2536 // The patient, the study and the series already exist |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2537 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2538 bool ok = (LookupResource(result.patientId, dummy, manager, hashPatient) && |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2539 LookupResource(result.studyId, dummy, manager, hashStudy)); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2540 (void) ok; // Remove warning about unused variable in release builds |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2541 assert(ok); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2542 } |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2543 else if (LookupResource(result.studyId, dummy, manager, hashStudy)) |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2544 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2545 assert(dummy == OrthancPluginResourceType_Study); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2546 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2547 // New series: The patient and the study already exist |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2548 result.isNewSeries = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2549 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2550 bool ok = LookupResource(result.patientId, dummy, manager, hashPatient); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2551 (void) ok; // Remove warning about unused variable in release builds |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2552 assert(ok); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2553 } |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2554 else if (LookupResource(result.patientId, dummy, manager, hashPatient)) |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2555 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2556 assert(dummy == OrthancPluginResourceType_Patient); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2557 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2558 // New study and series: The patient already exist |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2559 result.isNewStudy = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2560 result.isNewSeries = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2561 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2562 else |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2563 { |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2564 // New patient, study and series: Nothing exists |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2565 result.isNewPatient = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2566 result.isNewStudy = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2567 result.isNewSeries = true; |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2568 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2569 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2570 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2571 // Create the series if needed |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2572 if (result.isNewSeries) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2573 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2574 result.seriesId = CreateResource(manager, hashSeries, OrthancPluginResourceType_Series); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2575 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2576 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2577 // Create the study if needed |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2578 if (result.isNewStudy) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2579 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2580 result.studyId = CreateResource(manager, hashStudy, OrthancPluginResourceType_Study); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2581 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2582 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2583 // Create the patient if needed |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2584 if (result.isNewPatient) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2585 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2586 result.patientId = CreateResource(manager, hashPatient, OrthancPluginResourceType_Patient); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2587 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2588 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2589 // Create the parent-to-child links |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2590 AttachChild(manager, result.seriesId, result.instanceId); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2591 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2592 if (result.isNewSeries) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2593 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2594 AttachChild(manager, result.studyId, result.seriesId); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2595 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2596 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2597 if (result.isNewStudy) |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2598 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2599 AttachChild(manager, result.patientId, result.studyId); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2600 } |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2601 |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
2602 TagMostRecentPatient(manager, result.patientId); |
210
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2603 |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2604 // Sanity checks |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2605 assert(result.patientId != -1); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2606 assert(result.studyId != -1); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2607 assert(result.seriesId != -1); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2608 assert(result.instanceId != -1); |
a0c095a4ba7d
all the integration tests pass on SQLite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
2609 } |
271
6b18d3fbee82
backward compatibility with Orthanc SDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
266
diff
changeset
|
2610 #endif |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2611 |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2612 |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2613 void IndexBackend::AddLabel(DatabaseManager& manager, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2614 int64_t resource, |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2615 const std::string& label) |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2616 { |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2617 std::unique_ptr<DatabaseManager::CachedStatement> statement; |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2618 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2619 switch (manager.GetDialect()) |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2620 { |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2621 case Dialect_PostgreSQL: |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2622 statement.reset(new DatabaseManager::CachedStatement( |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2623 STATEMENT_FROM_HERE, manager, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2624 "INSERT INTO Labels VALUES(${id}, ${label}) ON CONFLICT DO NOTHING")); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2625 break; |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2626 |
399
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2627 case Dialect_SQLite: |
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2628 statement.reset(new DatabaseManager::CachedStatement( |
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2629 STATEMENT_FROM_HERE, manager, |
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2630 "INSERT OR IGNORE INTO Labels VALUES(${id}, ${label})")); |
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2631 break; |
19bd3ee1f0b3
support for labels in sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
398
diff
changeset
|
2632 |
400
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2633 case Dialect_MySQL: |
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2634 statement.reset(new DatabaseManager::CachedStatement( |
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2635 STATEMENT_FROM_HERE, manager, |
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2636 "INSERT IGNORE INTO Labels VALUES(${id}, ${label})")); |
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2637 break; |
897253c21208
support for labels in mysql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
2638 |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2639 default: |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2640 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2641 } |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2642 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2643 statement->SetParameterType("id", ValueType_Integer64); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2644 statement->SetParameterType("label", ValueType_Utf8String); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2645 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2646 Dictionary args; |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2647 args.SetIntegerValue("id", resource); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2648 args.SetUtf8Value("label", label); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2649 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2650 statement->Execute(args); |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2651 } |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2652 |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2653 |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2654 void IndexBackend::RemoveLabel(DatabaseManager& manager, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2655 int64_t resource, |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2656 const std::string& label) |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2657 { |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2658 DatabaseManager::CachedStatement statement( |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2659 STATEMENT_FROM_HERE, manager, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2660 "DELETE FROM Labels WHERE id=${id} AND label=${label}"); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2661 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2662 statement.SetParameterType("id", ValueType_Integer64); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2663 statement.SetParameterType("label", ValueType_Utf8String); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2664 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2665 Dictionary args; |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2666 args.SetIntegerValue("id", resource); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2667 args.SetUtf8Value("label", label); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2668 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2669 statement.Execute(args); |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2670 } |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2671 |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2672 |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2673 void IndexBackend::ListLabels(std::list<std::string>& target, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2674 DatabaseManager& manager, |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2675 int64_t resource) |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2676 { |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2677 DatabaseManager::CachedStatement statement( |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2678 STATEMENT_FROM_HERE, manager, |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2679 "SELECT label FROM Labels WHERE id=${id}"); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2680 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2681 statement.SetReadOnly(true); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2682 statement.SetParameterType("id", ValueType_Integer64); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2683 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2684 Dictionary args; |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2685 args.SetIntegerValue("id", resource); |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2686 |
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2687 ReadListOfStrings(target, statement, args); |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2688 } |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2689 |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
2690 |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
232
diff
changeset
|
2691 void IndexBackend::Register(IndexBackend* backend, |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
232
diff
changeset
|
2692 size_t countConnections, |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
232
diff
changeset
|
2693 unsigned int maxDatabaseRetries) |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2694 { |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2695 if (backend == NULL) |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2696 { |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2697 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2698 } |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2699 |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2700 LOG(WARNING) << "The index plugin will use " << countConnections << " connection(s) to the database, " |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2701 << "and will retry up to " << maxDatabaseRetries << " time(s) in the case of a collision"; |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2702 |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2703 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2704 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2705 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 12, 0) == 1) |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2706 { |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2707 OrthancDatabases::DatabaseBackendAdapterV4::Register(backend, countConnections, maxDatabaseRetries); |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2708 return; |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2709 } |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2710 # endif |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2711 #endif |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
372
diff
changeset
|
2712 |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2713 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2714 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2715 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1) |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2716 { |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
232
diff
changeset
|
2717 OrthancDatabases::DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries); |
372
b5e2c1e48828
created branch db-protobuf to take advantage of OrthancPluginRegisterDatabaseBackendV4()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
2718 return; |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2719 } |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2720 # endif |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2721 #endif |
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2722 |
372
b5e2c1e48828
created branch db-protobuf to take advantage of OrthancPluginRegisterDatabaseBackendV4()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
2723 LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers"; |
b5e2c1e48828
created branch db-protobuf to take advantage of OrthancPluginRegisterDatabaseBackendV4()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
2724 OrthancDatabases::DatabaseBackendAdapterV2::Register(backend); |
213
c2e4a909de0e
added IndexBackend::Register() to be used in all the index plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
210
diff
changeset
|
2725 } |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2726 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2727 |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2728 bool IndexBackend::LookupGlobalIntegerProperty(int& target, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2729 DatabaseManager& manager, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2730 const char* serverIdentifier, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2731 int32_t property) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2732 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2733 std::string value; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2734 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2735 if (LookupGlobalProperty(value, manager, serverIdentifier, property)) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2736 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2737 try |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2738 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2739 target = boost::lexical_cast<int>(value); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2740 return true; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2741 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2742 catch (boost::bad_lexical_cast&) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2743 { |
396
7b3acfa95bd8
implementation of list/add/remove labels in postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
2744 LOG(ERROR) << "Corrupted database"; |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2745 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2746 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2747 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2748 else |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2749 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2750 return false; |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2751 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2752 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2753 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2754 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2755 void IndexBackend::SetGlobalIntegerProperty(DatabaseManager& manager, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2756 const char* serverIdentifier, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2757 int32_t property, |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2758 int value) |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2759 { |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2760 std::string s = boost::lexical_cast<std::string>(value); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2761 SetGlobalProperty(manager, serverIdentifier, property, s.c_str()); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2762 } |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2763 |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2764 |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2765 void IndexBackend::Finalize() |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2766 { |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2767 OrthancDatabases::DatabaseBackendAdapterV2::Finalize(); |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2768 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2769 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2770 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2771 OrthancDatabases::DatabaseBackendAdapterV3::Finalize(); |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2772 # endif |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2773 #endif |
381
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2774 |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2775 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2776 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2777 OrthancDatabases::DatabaseBackendAdapterV4::Finalize(); |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2778 # endif |
9cde77ca9ad9
initializing and finalizing protobuf
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
2779 #endif |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
2780 } |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
2781 |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
2782 |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
2783 DatabaseManager* IndexBackend::CreateSingleDatabaseManager(IDatabaseBackend& backend) |
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
2784 { |
255
d663d9e44f8d
reintroduction of IDatabaseFactory into DatabaseManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
2785 std::unique_ptr<DatabaseManager> manager(new DatabaseManager(backend.CreateDatabaseFactory())); |
237
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2786 backend.ConfigureDatabase(*manager); |
35598014f140
refactoring to remove GlobalProperties.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
2787 return manager.release(); |
226
a4918d57435c
DatabaseManager doesn't IDatabaseFactory anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
2788 } |
0 | 2789 } |