Mercurial > hg > orthanc-databases
annotate Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 395:a7a029043670 db-protobuf
integration mainline->db-protobuf
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Apr 2023 14:53:57 +0200 |
parents | d14e6ff04a5c |
children | a8774581adfc |
rev | line source |
---|---|
212 | 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:
378
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
3d6886f3e5b3
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
212 | 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 "DatabaseBackendAdapterV3.h" | |
24 | |
25 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | |
26 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) | |
27 | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
28 #include "IndexConnectionsPool.h" |
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
29 |
260
793bbbe11287
IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
256
diff
changeset
|
30 #include <Logging.h> |
212 | 31 #include <OrthancException.h> |
32 | |
33 #include <stdexcept> | |
34 #include <list> | |
35 #include <string> | |
36 #include <cassert> | |
37 | |
38 | |
39 #define ORTHANC_PLUGINS_DATABASE_CATCH(context) \ | |
40 catch (::Orthanc::OrthancException& e) \ | |
41 { \ | |
42 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \ | |
43 } \ | |
44 catch (::std::runtime_error& e) \ | |
45 { \ | |
46 const std::string message = "Exception in database back-end: " + std::string(e.what()); \ | |
47 OrthancPluginLogError(context, message.c_str()); \ | |
48 return OrthancPluginErrorCode_DatabasePlugin; \ | |
49 } \ | |
50 catch (...) \ | |
51 { \ | |
52 OrthancPluginLogError(context, "Native exception"); \ | |
53 return OrthancPluginErrorCode_DatabasePlugin; \ | |
54 } | |
55 | |
56 | |
57 namespace OrthancDatabases | |
58 { | |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
59 static bool isBackendInUse_ = false; // Only for sanity checks |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
60 |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
61 |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
62 template <typename T> |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
63 static void CopyListToVector(std::vector<T>& target, |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
64 const std::list<T>& source) |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
65 { |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
66 /** |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
67 * This has the the same effect as: |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
68 * |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
69 * target.reserve(source.size()); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
70 * std::copy(std::begin(source), std::end(source), std::back_inserter(target)); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
71 * |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
72 * However, this implementation is compatible with C++03 (Linux |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
73 * Standard Base), whereas "std::back_inserter" requires C++11. |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
74 **/ |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
75 |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
76 target.clear(); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
77 target.reserve(source.size()); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
78 |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
79 for (typename std::list<T>::const_iterator it = source.begin(); it != source.end(); ++it) |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
80 { |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
81 target.push_back(*it); |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
82 } |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
83 } |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
84 |
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
85 |
212 | 86 class DatabaseBackendAdapterV3::Output : public IDatabaseBackendOutput |
87 { | |
88 private: | |
89 struct Metadata | |
90 { | |
91 int32_t metadata; | |
92 const char* value; | |
93 }; | |
94 | |
95 _OrthancPluginDatabaseAnswerType answerType_; | |
96 std::list<std::string> stringsStore_; | |
97 | |
98 std::vector<OrthancPluginAttachment> attachments_; | |
99 std::vector<OrthancPluginChange> changes_; | |
100 std::vector<OrthancPluginDicomTag> tags_; | |
101 std::vector<OrthancPluginExportedResource> exported_; | |
102 std::vector<OrthancPluginDatabaseEvent> events_; | |
103 std::vector<int32_t> integers32_; | |
104 std::vector<int64_t> integers64_; | |
105 std::vector<OrthancPluginMatchingResource> matches_; | |
106 std::vector<Metadata> metadata_; | |
107 std::vector<std::string> stringAnswers_; | |
108 | |
109 const char* StoreString(const std::string& s) | |
110 { | |
111 stringsStore_.push_back(s); | |
112 return stringsStore_.back().c_str(); | |
113 } | |
114 | |
115 void SetupAnswerType(_OrthancPluginDatabaseAnswerType type) | |
116 { | |
117 if (answerType_ == _OrthancPluginDatabaseAnswerType_None) | |
118 { | |
119 answerType_ = type; | |
120 } | |
121 else if (answerType_ != type) | |
122 { | |
123 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
124 } | |
125 } | |
126 | |
127 public: | |
128 Output() : | |
129 answerType_(_OrthancPluginDatabaseAnswerType_None) | |
130 { | |
131 } | |
132 | |
133 void Clear() | |
134 { | |
135 // We don't systematically clear all the vectors, in order to | |
136 // avoid spending unnecessary time | |
137 | |
138 switch (answerType_) | |
139 { | |
140 case _OrthancPluginDatabaseAnswerType_None: | |
141 break; | |
142 | |
143 case _OrthancPluginDatabaseAnswerType_Attachment: | |
144 attachments_.clear(); | |
145 break; | |
146 | |
147 case _OrthancPluginDatabaseAnswerType_Change: | |
148 changes_.clear(); | |
149 break; | |
150 | |
151 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
152 tags_.clear(); | |
153 break; | |
154 | |
155 case _OrthancPluginDatabaseAnswerType_ExportedResource: | |
156 exported_.clear(); | |
157 break; | |
158 | |
159 case _OrthancPluginDatabaseAnswerType_Int32: | |
160 integers32_.clear(); | |
161 break; | |
162 | |
163 case _OrthancPluginDatabaseAnswerType_Int64: | |
164 integers64_.clear(); | |
165 break; | |
166 | |
167 case _OrthancPluginDatabaseAnswerType_MatchingResource: | |
168 matches_.clear(); | |
169 break; | |
170 | |
171 case _OrthancPluginDatabaseAnswerType_Metadata: | |
172 metadata_.clear(); | |
173 break; | |
174 | |
175 case _OrthancPluginDatabaseAnswerType_String: | |
176 stringAnswers_.clear(); | |
177 break; | |
178 | |
179 default: | |
180 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
181 } | |
182 | |
183 answerType_ = _OrthancPluginDatabaseAnswerType_None; | |
184 stringsStore_.clear(); | |
185 events_.clear(); | |
186 | |
187 assert(attachments_.empty()); | |
188 assert(changes_.empty()); | |
189 assert(tags_.empty()); | |
190 assert(exported_.empty()); | |
191 assert(events_.empty()); | |
192 assert(integers32_.empty()); | |
193 assert(integers64_.empty()); | |
194 assert(matches_.empty()); | |
195 assert(metadata_.empty()); | |
196 assert(stringAnswers_.empty()); | |
197 } | |
198 | |
199 | |
200 OrthancPluginErrorCode ReadAnswersCount(uint32_t& target) const | |
201 { | |
202 switch (answerType_) | |
203 { | |
204 case _OrthancPluginDatabaseAnswerType_None: | |
205 target = static_cast<uint32_t>(0); | |
206 break; | |
207 | |
208 case _OrthancPluginDatabaseAnswerType_Attachment: | |
209 target = static_cast<uint32_t>(attachments_.size()); | |
210 break; | |
211 | |
212 case _OrthancPluginDatabaseAnswerType_Change: | |
213 target = static_cast<uint32_t>(changes_.size()); | |
214 break; | |
215 | |
216 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
217 target = static_cast<uint32_t>(tags_.size()); | |
218 break; | |
219 | |
220 case _OrthancPluginDatabaseAnswerType_ExportedResource: | |
221 target = static_cast<uint32_t>(exported_.size()); | |
222 break; | |
223 | |
224 case _OrthancPluginDatabaseAnswerType_Int32: | |
225 target = static_cast<uint32_t>(integers32_.size()); | |
226 break; | |
227 | |
228 case _OrthancPluginDatabaseAnswerType_Int64: | |
229 target = static_cast<uint32_t>(integers64_.size()); | |
230 break; | |
231 | |
232 case _OrthancPluginDatabaseAnswerType_MatchingResource: | |
233 target = static_cast<uint32_t>(matches_.size()); | |
234 break; | |
235 | |
236 case _OrthancPluginDatabaseAnswerType_Metadata: | |
237 target = static_cast<uint32_t>(metadata_.size()); | |
238 break; | |
239 | |
240 case _OrthancPluginDatabaseAnswerType_String: | |
241 target = static_cast<uint32_t>(stringAnswers_.size()); | |
242 break; | |
243 | |
244 default: | |
245 return OrthancPluginErrorCode_InternalError; | |
246 } | |
247 | |
248 return OrthancPluginErrorCode_Success; | |
249 } | |
250 | |
251 | |
252 OrthancPluginErrorCode ReadAnswerAttachment(OrthancPluginAttachment& target /* out */, | |
253 uint32_t index) const | |
254 { | |
255 if (index < attachments_.size()) | |
256 { | |
257 target = attachments_[index]; | |
258 return OrthancPluginErrorCode_Success; | |
259 } | |
260 else | |
261 { | |
262 return OrthancPluginErrorCode_ParameterOutOfRange; | |
263 } | |
264 } | |
265 | |
266 | |
267 OrthancPluginErrorCode ReadAnswerChange(OrthancPluginChange& target /* out */, | |
268 uint32_t index) const | |
269 { | |
270 if (index < changes_.size()) | |
271 { | |
272 target = changes_[index]; | |
273 return OrthancPluginErrorCode_Success; | |
274 } | |
275 else | |
276 { | |
277 return OrthancPluginErrorCode_ParameterOutOfRange; | |
278 } | |
279 } | |
280 | |
281 | |
282 OrthancPluginErrorCode ReadAnswerDicomTag(uint16_t& group, | |
283 uint16_t& element, | |
284 const char*& value, | |
285 uint32_t index) const | |
286 { | |
287 if (index < tags_.size()) | |
288 { | |
289 const OrthancPluginDicomTag& tag = tags_[index]; | |
290 group = tag.group; | |
291 element = tag.element; | |
292 value = tag.value; | |
293 return OrthancPluginErrorCode_Success; | |
294 } | |
295 else | |
296 { | |
297 return OrthancPluginErrorCode_ParameterOutOfRange; | |
298 } | |
299 } | |
300 | |
301 | |
302 OrthancPluginErrorCode ReadAnswerExportedResource(OrthancPluginExportedResource& target /* out */, | |
303 uint32_t index) const | |
304 { | |
305 if (index < exported_.size()) | |
306 { | |
307 target = exported_[index]; | |
308 return OrthancPluginErrorCode_Success; | |
309 } | |
310 else | |
311 { | |
312 return OrthancPluginErrorCode_ParameterOutOfRange; | |
313 } | |
314 } | |
315 | |
316 | |
317 OrthancPluginErrorCode ReadAnswerInt32(int32_t& target, | |
318 uint32_t index) const | |
319 { | |
320 if (index < integers32_.size()) | |
321 { | |
322 target = integers32_[index]; | |
323 return OrthancPluginErrorCode_Success; | |
324 } | |
325 else | |
326 { | |
327 return OrthancPluginErrorCode_ParameterOutOfRange; | |
328 } | |
329 } | |
330 | |
331 | |
332 OrthancPluginErrorCode ReadAnswerInt64(int64_t& target, | |
333 uint32_t index) const | |
334 { | |
335 if (index < integers64_.size()) | |
336 { | |
337 target = integers64_[index]; | |
338 return OrthancPluginErrorCode_Success; | |
339 } | |
340 else | |
341 { | |
342 return OrthancPluginErrorCode_ParameterOutOfRange; | |
343 } | |
344 } | |
345 | |
346 | |
347 OrthancPluginErrorCode ReadAnswerMatchingResource(OrthancPluginMatchingResource& target, | |
348 uint32_t index) const | |
349 { | |
350 if (index < matches_.size()) | |
351 { | |
352 target = matches_[index]; | |
353 return OrthancPluginErrorCode_Success; | |
354 } | |
355 else | |
356 { | |
357 return OrthancPluginErrorCode_ParameterOutOfRange; | |
358 } | |
359 } | |
360 | |
361 | |
362 OrthancPluginErrorCode ReadAnswerMetadata(int32_t& metadata, | |
363 const char*& value, | |
364 uint32_t index) const | |
365 { | |
366 if (index < metadata_.size()) | |
367 { | |
368 const Metadata& tmp = metadata_[index]; | |
369 metadata = tmp.metadata; | |
370 value = tmp.value; | |
371 return OrthancPluginErrorCode_Success; | |
372 } | |
373 else | |
374 { | |
375 return OrthancPluginErrorCode_ParameterOutOfRange; | |
376 } | |
377 } | |
378 | |
379 | |
380 OrthancPluginErrorCode ReadAnswerString(const char*& target, | |
381 uint32_t index) const | |
382 { | |
383 if (index < stringAnswers_.size()) | |
384 { | |
385 target = stringAnswers_[index].c_str(); | |
386 return OrthancPluginErrorCode_Success; | |
387 } | |
388 else | |
389 { | |
390 return OrthancPluginErrorCode_ParameterOutOfRange; | |
391 } | |
392 } | |
393 | |
394 | |
395 OrthancPluginErrorCode ReadEventsCount(uint32_t& target /* out */) const | |
396 { | |
397 target = static_cast<uint32_t>(events_.size()); | |
398 return OrthancPluginErrorCode_Success; | |
399 } | |
400 | |
401 | |
402 OrthancPluginErrorCode ReadEvent(OrthancPluginDatabaseEvent& event /* out */, | |
403 uint32_t index) const | |
404 { | |
405 if (index < events_.size()) | |
406 { | |
407 event = events_[index]; | |
408 return OrthancPluginErrorCode_Success; | |
409 } | |
410 else | |
411 { | |
412 return OrthancPluginErrorCode_ParameterOutOfRange; | |
413 } | |
414 } | |
415 | |
416 | |
417 virtual void SignalDeletedAttachment(const std::string& uuid, | |
418 int32_t contentType, | |
419 uint64_t uncompressedSize, | |
420 const std::string& uncompressedHash, | |
421 int32_t compressionType, | |
422 uint64_t compressedSize, | |
423 const std::string& compressedHash) ORTHANC_OVERRIDE | |
424 { | |
425 OrthancPluginDatabaseEvent event; | |
426 event.type = OrthancPluginDatabaseEventType_DeletedAttachment; | |
427 event.content.attachment.uuid = StoreString(uuid); | |
428 event.content.attachment.contentType = contentType; | |
429 event.content.attachment.uncompressedSize = uncompressedSize; | |
430 event.content.attachment.uncompressedHash = StoreString(uncompressedHash); | |
431 event.content.attachment.compressionType = compressionType; | |
432 event.content.attachment.compressedSize = compressedSize; | |
433 event.content.attachment.compressedHash = StoreString(compressedHash); | |
434 | |
435 events_.push_back(event); | |
436 } | |
437 | |
438 | |
439 virtual void SignalDeletedResource(const std::string& publicId, | |
440 OrthancPluginResourceType resourceType) ORTHANC_OVERRIDE | |
441 { | |
442 OrthancPluginDatabaseEvent event; | |
443 event.type = OrthancPluginDatabaseEventType_DeletedResource; | |
444 event.content.resource.level = resourceType; | |
445 event.content.resource.publicId = StoreString(publicId); | |
446 | |
447 events_.push_back(event); | |
448 } | |
449 | |
450 | |
451 virtual void SignalRemainingAncestor(const std::string& ancestorId, | |
452 OrthancPluginResourceType ancestorType) ORTHANC_OVERRIDE | |
453 { | |
454 OrthancPluginDatabaseEvent event; | |
455 event.type = OrthancPluginDatabaseEventType_RemainingAncestor; | |
456 event.content.resource.level = ancestorType; | |
457 event.content.resource.publicId = StoreString(ancestorId); | |
458 | |
459 events_.push_back(event); | |
460 } | |
461 | |
462 | |
463 virtual void AnswerAttachment(const std::string& uuid, | |
464 int32_t contentType, | |
465 uint64_t uncompressedSize, | |
466 const std::string& uncompressedHash, | |
467 int32_t compressionType, | |
468 uint64_t compressedSize, | |
469 const std::string& compressedHash) ORTHANC_OVERRIDE | |
470 { | |
471 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Attachment); | |
472 | |
473 OrthancPluginAttachment attachment; | |
474 attachment.uuid = StoreString(uuid); | |
475 attachment.contentType = contentType; | |
476 attachment.uncompressedSize = uncompressedSize; | |
477 attachment.uncompressedHash = StoreString(uncompressedHash); | |
478 attachment.compressionType = compressionType; | |
479 attachment.compressedSize = compressedSize; | |
480 attachment.compressedHash = StoreString(compressedHash); | |
481 | |
482 attachments_.push_back(attachment); | |
483 } | |
484 | |
485 | |
486 virtual void AnswerChange(int64_t seq, | |
487 int32_t changeType, | |
488 OrthancPluginResourceType resourceType, | |
489 const std::string& publicId, | |
490 const std::string& date) ORTHANC_OVERRIDE | |
491 { | |
492 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Change); | |
493 | |
494 OrthancPluginChange change; | |
495 change.seq = seq; | |
496 change.changeType = changeType; | |
497 change.resourceType = resourceType; | |
498 change.publicId = StoreString(publicId); | |
499 change.date = StoreString(date); | |
500 | |
501 changes_.push_back(change); | |
502 } | |
503 | |
504 | |
505 virtual void AnswerDicomTag(uint16_t group, | |
506 uint16_t element, | |
507 const std::string& value) ORTHANC_OVERRIDE | |
508 { | |
509 SetupAnswerType(_OrthancPluginDatabaseAnswerType_DicomTag); | |
510 | |
511 OrthancPluginDicomTag tag; | |
512 tag.group = group; | |
513 tag.element = element; | |
514 tag.value = StoreString(value); | |
515 | |
516 tags_.push_back(tag); | |
517 } | |
518 | |
519 | |
520 virtual void AnswerExportedResource(int64_t seq, | |
521 OrthancPluginResourceType resourceType, | |
522 const std::string& publicId, | |
523 const std::string& modality, | |
524 const std::string& date, | |
525 const std::string& patientId, | |
526 const std::string& studyInstanceUid, | |
527 const std::string& seriesInstanceUid, | |
528 const std::string& sopInstanceUid) ORTHANC_OVERRIDE | |
529 { | |
530 SetupAnswerType(_OrthancPluginDatabaseAnswerType_ExportedResource); | |
531 | |
532 OrthancPluginExportedResource exported; | |
533 exported.seq = seq; | |
534 exported.resourceType = resourceType; | |
535 exported.publicId = StoreString(publicId); | |
536 exported.modality = StoreString(modality); | |
537 exported.date = StoreString(date); | |
538 exported.patientId = StoreString(patientId); | |
539 exported.studyInstanceUid = StoreString(studyInstanceUid); | |
540 exported.seriesInstanceUid = StoreString(seriesInstanceUid); | |
541 exported.sopInstanceUid = StoreString(sopInstanceUid); | |
542 | |
543 exported_.push_back(exported); | |
544 } | |
545 | |
546 | |
547 virtual void AnswerMatchingResource(const std::string& resourceId) ORTHANC_OVERRIDE | |
548 { | |
549 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource); | |
550 | |
551 OrthancPluginMatchingResource match; | |
552 match.resourceId = StoreString(resourceId); | |
553 match.someInstanceId = NULL; | |
554 | |
555 matches_.push_back(match); | |
556 } | |
557 | |
558 | |
559 virtual void AnswerMatchingResource(const std::string& resourceId, | |
560 const std::string& someInstanceId) ORTHANC_OVERRIDE | |
561 { | |
562 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource); | |
563 | |
564 OrthancPluginMatchingResource match; | |
565 match.resourceId = StoreString(resourceId); | |
566 match.someInstanceId = StoreString(someInstanceId); | |
567 | |
568 matches_.push_back(match); | |
569 } | |
570 | |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
571 |
212 | 572 void AnswerIntegers32(const std::list<int32_t>& values) |
573 { | |
574 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int32); | |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
575 CopyListToVector(integers32_, values); |
212 | 576 } |
577 | |
578 | |
579 void AnswerIntegers64(const std::list<int64_t>& values) | |
580 { | |
581 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64); | |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
582 CopyListToVector(integers64_, values); |
212 | 583 } |
584 | |
585 | |
586 void AnswerInteger64(int64_t value) | |
587 { | |
588 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64); | |
589 | |
590 integers64_.resize(1); | |
591 integers64_[0] = value; | |
592 } | |
593 | |
594 | |
595 void AnswerMetadata(int32_t metadata, | |
596 const std::string& value) | |
597 { | |
598 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Metadata); | |
599 | |
600 Metadata tmp; | |
601 tmp.metadata = metadata; | |
602 tmp.value = StoreString(value); | |
603 | |
604 metadata_.push_back(tmp); | |
605 } | |
606 | |
607 | |
608 void AnswerStrings(const std::list<std::string>& values) | |
609 { | |
610 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String); | |
235
f2b32d31fc99
fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
234
diff
changeset
|
611 CopyListToVector(stringAnswers_, values); |
212 | 612 } |
613 | |
614 | |
615 void AnswerString(const std::string& value) | |
616 { | |
617 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String); | |
618 | |
619 if (stringAnswers_.empty()) | |
620 { | |
621 stringAnswers_.push_back(value); | |
622 } | |
623 else | |
624 { | |
625 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
626 } | |
627 } | |
628 }; | |
629 | |
630 | |
631 IDatabaseBackendOutput* DatabaseBackendAdapterV3::Factory::CreateOutput() | |
632 { | |
633 return new DatabaseBackendAdapterV3::Output; | |
634 } | |
635 | |
636 | |
637 class DatabaseBackendAdapterV3::Transaction : public boost::noncopyable | |
638 { | |
639 private: | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
640 IndexConnectionsPool& pool_; |
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
641 std::unique_ptr<IndexConnectionsPool::Accessor> accessor_; |
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
642 std::unique_ptr<Output> output_; |
232
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
643 |
212 | 644 public: |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
645 Transaction(IndexConnectionsPool& pool) : |
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
646 pool_(pool), |
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
647 accessor_(new IndexConnectionsPool::Accessor(pool)), |
212 | 648 output_(new Output) |
649 { | |
650 } | |
651 | |
652 ~Transaction() | |
653 { | |
654 } | |
655 | |
656 IndexBackend& GetBackend() const | |
657 { | |
232
4e15eace9b90
reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
658 return accessor_->GetBackend(); |
212 | 659 } |
660 | |
661 Output& GetOutput() const | |
662 { | |
663 return *output_; | |
664 } | |
665 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
666 DatabaseManager& GetManager() const |
212 | 667 { |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
668 return accessor_->GetManager(); |
212 | 669 } |
670 }; | |
671 | |
672 | |
673 static OrthancPluginErrorCode ReadAnswersCount(OrthancPluginDatabaseTransaction* transaction, | |
674 uint32_t* target /* out */) | |
675 { | |
676 assert(target != NULL); | |
677 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
678 return that.GetOutput().ReadAnswersCount(*target); | |
679 } | |
680 | |
681 | |
682 static OrthancPluginErrorCode ReadAnswerAttachment(OrthancPluginDatabaseTransaction* transaction, | |
683 OrthancPluginAttachment* target /* out */, | |
684 uint32_t index) | |
685 { | |
686 assert(target != NULL); | |
687 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
688 return that.GetOutput().ReadAnswerAttachment(*target, index); | |
689 } | |
690 | |
691 | |
692 static OrthancPluginErrorCode ReadAnswerChange(OrthancPluginDatabaseTransaction* transaction, | |
693 OrthancPluginChange* target /* out */, | |
694 uint32_t index) | |
695 { | |
696 assert(target != NULL); | |
697 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
698 return that.GetOutput().ReadAnswerChange(*target, index); | |
699 } | |
700 | |
701 | |
702 static OrthancPluginErrorCode ReadAnswerDicomTag(OrthancPluginDatabaseTransaction* transaction, | |
703 uint16_t* group, | |
704 uint16_t* element, | |
705 const char** value, | |
706 uint32_t index) | |
707 { | |
708 assert(group != NULL); | |
709 assert(element != NULL); | |
710 assert(value != NULL); | |
711 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
712 return that.GetOutput().ReadAnswerDicomTag(*group, *element, *value, index); | |
713 } | |
714 | |
715 | |
716 static OrthancPluginErrorCode ReadAnswerExportedResource(OrthancPluginDatabaseTransaction* transaction, | |
717 OrthancPluginExportedResource* target /* out */, | |
718 uint32_t index) | |
719 { | |
720 assert(target != NULL); | |
721 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
722 return that.GetOutput().ReadAnswerExportedResource(*target, index); | |
723 } | |
724 | |
725 | |
726 static OrthancPluginErrorCode ReadAnswerInt32(OrthancPluginDatabaseTransaction* transaction, | |
727 int32_t* target, | |
728 uint32_t index) | |
729 { | |
730 assert(target != NULL); | |
731 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
732 return that.GetOutput().ReadAnswerInt32(*target, index); | |
733 } | |
734 | |
735 | |
736 static OrthancPluginErrorCode ReadAnswerInt64(OrthancPluginDatabaseTransaction* transaction, | |
737 int64_t* target, | |
738 uint32_t index) | |
739 { | |
740 assert(target != NULL); | |
741 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
742 return that.GetOutput().ReadAnswerInt64(*target, index); | |
743 } | |
744 | |
745 | |
746 static OrthancPluginErrorCode ReadAnswerMatchingResource(OrthancPluginDatabaseTransaction* transaction, | |
747 OrthancPluginMatchingResource* target, | |
748 uint32_t index) | |
749 { | |
750 assert(target != NULL); | |
751 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
752 return that.GetOutput().ReadAnswerMatchingResource(*target, index); | |
753 } | |
754 | |
755 | |
756 static OrthancPluginErrorCode ReadAnswerMetadata(OrthancPluginDatabaseTransaction* transaction, | |
757 int32_t* metadata, | |
758 const char** value, | |
759 uint32_t index) | |
760 { | |
761 assert(metadata != NULL); | |
762 assert(value != NULL); | |
763 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
764 return that.GetOutput().ReadAnswerMetadata(*metadata, *value, index); | |
765 } | |
766 | |
767 | |
768 static OrthancPluginErrorCode ReadAnswerString(OrthancPluginDatabaseTransaction* transaction, | |
769 const char** target, | |
770 uint32_t index) | |
771 { | |
772 assert(target != NULL); | |
773 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
774 return that.GetOutput().ReadAnswerString(*target, index); | |
775 } | |
776 | |
777 | |
778 static OrthancPluginErrorCode ReadEventsCount(OrthancPluginDatabaseTransaction* transaction, | |
779 uint32_t* target /* out */) | |
780 { | |
781 assert(target != NULL); | |
782 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
783 return that.GetOutput().ReadEventsCount(*target); | |
784 } | |
785 | |
786 | |
787 static OrthancPluginErrorCode ReadEvent(OrthancPluginDatabaseTransaction* transaction, | |
788 OrthancPluginDatabaseEvent* event /* out */, | |
789 uint32_t index) | |
790 { | |
791 assert(event != NULL); | |
792 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction); | |
793 return that.GetOutput().ReadEvent(*event, index); | |
794 } | |
795 | |
796 | |
797 static OrthancPluginErrorCode Open(void* database) | |
798 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
799 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 800 |
801 try | |
802 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
803 pool->OpenConnections(); |
212 | 804 return OrthancPluginErrorCode_Success; |
805 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
806 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 807 } |
808 | |
809 | |
810 static OrthancPluginErrorCode Close(void* database) | |
811 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
812 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 813 |
814 try | |
815 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
816 pool->CloseConnections(); |
212 | 817 return OrthancPluginErrorCode_Success; |
818 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
819 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 820 } |
821 | |
822 | |
823 static OrthancPluginErrorCode DestructDatabase(void* database) | |
824 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
825 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
826 |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
827 if (pool == NULL) |
212 | 828 { |
829 return OrthancPluginErrorCode_InternalError; | |
830 } | |
831 else | |
832 { | |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
833 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
834 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
835 isBackendInUse_ = false; |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
836 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
837 else |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
838 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
839 OrthancPluginLogError(pool->GetContext(), "More than one index backend was registered, internal error"); |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
840 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
841 |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
842 delete pool; |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
843 |
212 | 844 return OrthancPluginErrorCode_Success; |
845 } | |
846 } | |
847 | |
848 | |
849 static OrthancPluginErrorCode GetDatabaseVersion(void* database, | |
850 uint32_t* version) | |
851 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
852 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 853 |
854 try | |
855 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
856 IndexConnectionsPool::Accessor accessor(*pool); |
233 | 857 *version = accessor.GetBackend().GetDatabaseVersion(accessor.GetManager()); |
212 | 858 return OrthancPluginErrorCode_Success; |
859 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
860 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 861 } |
862 | |
863 | |
864 static OrthancPluginErrorCode UpgradeDatabase(void* database, | |
865 OrthancPluginStorageArea* storageArea, | |
866 uint32_t targetVersion) | |
867 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
868 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 869 |
870 try | |
871 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
872 IndexConnectionsPool::Accessor accessor(*pool); |
233 | 873 accessor.GetBackend().UpgradeDatabase(accessor.GetManager(), targetVersion, storageArea); |
212 | 874 return OrthancPluginErrorCode_Success; |
875 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
876 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 877 } |
878 | |
879 | |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
880 static OrthancPluginErrorCode HasRevisionsSupport(void* database, |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
881 uint8_t* target) |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
882 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
883 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
884 |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
885 try |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
886 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
887 IndexConnectionsPool::Accessor accessor(*pool); |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
888 *target = (accessor.GetBackend().HasRevisionsSupport() ? 1 : 0); |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
889 return OrthancPluginErrorCode_Success; |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
890 } |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
891 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
892 } |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
893 |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
894 |
212 | 895 static OrthancPluginErrorCode StartTransaction(void* database, |
896 OrthancPluginDatabaseTransaction** target /* out */, | |
897 OrthancPluginDatabaseTransactionType type) | |
898 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
899 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 900 |
901 try | |
902 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
903 std::unique_ptr<DatabaseBackendAdapterV3::Transaction> transaction(new DatabaseBackendAdapterV3::Transaction(*pool)); |
212 | 904 |
905 switch (type) | |
906 { | |
907 case OrthancPluginDatabaseTransactionType_ReadOnly: | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
908 transaction->GetManager().StartTransaction(TransactionType_ReadOnly); |
212 | 909 break; |
910 | |
911 case OrthancPluginDatabaseTransactionType_ReadWrite: | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
912 transaction->GetManager().StartTransaction(TransactionType_ReadWrite); |
212 | 913 break; |
914 | |
915 default: | |
916 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
917 } | |
918 | |
919 *target = reinterpret_cast<OrthancPluginDatabaseTransaction*>(transaction.release()); | |
920 | |
921 return OrthancPluginErrorCode_Success; | |
922 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
923 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 924 } |
925 | |
926 | |
927 static OrthancPluginErrorCode DestructTransaction(OrthancPluginDatabaseTransaction* transaction) | |
928 { | |
929 if (transaction == NULL) | |
930 { | |
931 return OrthancPluginErrorCode_NullPointer; | |
932 } | |
933 else | |
934 { | |
935 delete reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
936 return OrthancPluginErrorCode_Success; | |
937 } | |
938 } | |
939 | |
940 | |
941 static OrthancPluginErrorCode Rollback(OrthancPluginDatabaseTransaction* transaction) | |
942 { | |
943 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
944 | |
945 try | |
946 { | |
947 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
948 t->GetManager().RollbackTransaction(); |
212 | 949 return OrthancPluginErrorCode_Success; |
950 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
951 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 952 } |
953 | |
954 | |
955 static OrthancPluginErrorCode Commit(OrthancPluginDatabaseTransaction* transaction, | |
956 int64_t fileSizeDelta /* TODO - not used? */) | |
957 { | |
958 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
959 | |
960 try | |
961 { | |
962 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
963 t->GetManager().CommitTransaction(); |
212 | 964 return OrthancPluginErrorCode_Success; |
965 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
966 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 967 } |
968 | |
969 | |
970 static OrthancPluginErrorCode AddAttachment(OrthancPluginDatabaseTransaction* transaction, | |
971 int64_t id, | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
972 const OrthancPluginAttachment* attachment, |
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
973 int64_t revision) |
212 | 974 { |
975 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
976 | |
977 try | |
978 { | |
979 t->GetOutput().Clear(); | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
980 t->GetBackend().AddAttachment(t->GetManager(), id, *attachment, revision); |
212 | 981 return OrthancPluginErrorCode_Success; |
982 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
983 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 984 } |
985 | |
986 | |
987 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction) | |
988 { | |
989 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
990 | |
991 try | |
992 { | |
993 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
994 t->GetBackend().ClearChanges(t->GetManager()); |
212 | 995 return OrthancPluginErrorCode_Success; |
996 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
997 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 998 } |
999 | |
1000 | |
1001 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction) | |
1002 { | |
1003 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1004 | |
1005 try | |
1006 { | |
1007 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1008 t->GetBackend().ClearExportedResources(t->GetManager()); |
212 | 1009 return OrthancPluginErrorCode_Success; |
1010 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1011 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1012 } |
1013 | |
1014 | |
1015 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
1016 int64_t resourceId) | |
1017 { | |
1018 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1019 | |
1020 try | |
1021 { | |
1022 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1023 t->GetBackend().ClearMainDicomTags(t->GetManager(), resourceId); |
212 | 1024 return OrthancPluginErrorCode_Success; |
1025 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1026 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1027 } |
1028 | |
1029 | |
1030 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction, | |
1031 OrthancPluginCreateInstanceResult* target /* out */, | |
1032 const char* hashPatient, | |
1033 const char* hashStudy, | |
1034 const char* hashSeries, | |
1035 const char* hashInstance) | |
1036 { | |
1037 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1038 | |
1039 try | |
1040 { | |
1041 t->GetOutput().Clear(); | |
1042 | |
1043 if (t->GetBackend().HasCreateInstance()) | |
1044 { | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1045 t->GetBackend().CreateInstance(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance); |
212 | 1046 } |
1047 else | |
1048 { | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1049 t->GetBackend().CreateInstanceGeneric(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance); |
212 | 1050 } |
1051 | |
1052 return OrthancPluginErrorCode_Success; | |
1053 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1054 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1055 } |
1056 | |
1057 | |
1058 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction, | |
1059 int64_t id, | |
1060 int32_t contentType) | |
1061 { | |
1062 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1063 | |
1064 try | |
1065 { | |
1066 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1067 t->GetBackend().DeleteAttachment(t->GetOutput(), t->GetManager(), id, contentType); |
212 | 1068 return OrthancPluginErrorCode_Success; |
1069 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1070 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1071 } |
1072 | |
1073 | |
1074 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1075 int64_t id, | |
1076 int32_t metadataType) | |
1077 { | |
1078 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1079 | |
1080 try | |
1081 { | |
1082 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1083 t->GetBackend().DeleteMetadata(t->GetManager(), id, metadataType); |
212 | 1084 return OrthancPluginErrorCode_Success; |
1085 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1086 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1087 } |
1088 | |
1089 | |
1090 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction, | |
1091 int64_t id) | |
1092 { | |
1093 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1094 | |
1095 try | |
1096 { | |
1097 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1098 t->GetBackend().DeleteResource(t->GetOutput(), t->GetManager(), id); |
212 | 1099 return OrthancPluginErrorCode_Success; |
1100 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1101 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1102 } |
1103 | |
1104 | |
1105 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1106 int64_t id) | |
1107 { | |
1108 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1109 | |
1110 try | |
1111 { | |
1112 t->GetOutput().Clear(); | |
1113 | |
1114 std::map<int32_t, std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1115 t->GetBackend().GetAllMetadata(values, t->GetManager(), id); |
212 | 1116 |
1117 for (std::map<int32_t, std::string>::const_iterator it = values.begin(); it != values.end(); ++it) | |
1118 { | |
1119 t->GetOutput().AnswerMetadata(it->first, it->second); | |
1120 } | |
1121 | |
1122 return OrthancPluginErrorCode_Success; | |
1123 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1124 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1125 } |
1126 | |
1127 | |
1128 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction, | |
1129 OrthancPluginResourceType resourceType) | |
1130 { | |
1131 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1132 | |
1133 try | |
1134 { | |
1135 t->GetOutput().Clear(); | |
1136 | |
1137 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1138 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType); |
212 | 1139 t->GetOutput().AnswerStrings(values); |
1140 | |
1141 return OrthancPluginErrorCode_Success; | |
1142 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1143 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1144 } |
1145 | |
1146 | |
1147 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction, | |
1148 OrthancPluginResourceType resourceType, | |
1149 uint64_t since, | |
1150 uint64_t limit) | |
1151 { | |
1152 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1153 | |
1154 try | |
1155 { | |
1156 t->GetOutput().Clear(); | |
1157 | |
1158 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1159 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType, since, limit); |
212 | 1160 t->GetOutput().AnswerStrings(values); |
1161 | |
1162 return OrthancPluginErrorCode_Success; | |
1163 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1164 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1165 } |
1166 | |
1167 | |
1168 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction, | |
1169 uint8_t* targetDone /* out */, | |
1170 int64_t since, | |
1171 uint32_t maxResults) | |
1172 { | |
1173 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1174 | |
1175 try | |
1176 { | |
1177 t->GetOutput().Clear(); | |
1178 | |
1179 bool done; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1180 t->GetBackend().GetChanges(t->GetOutput(), done, t->GetManager(), since, maxResults); |
212 | 1181 *targetDone = (done ? 1 : 0); |
1182 | |
1183 return OrthancPluginErrorCode_Success; | |
1184 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1185 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1186 } |
1187 | |
1188 | |
1189 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseTransaction* transaction, | |
1190 int64_t id) | |
1191 { | |
1192 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1193 | |
1194 try | |
1195 { | |
1196 t->GetOutput().Clear(); | |
1197 | |
1198 std::list<int64_t> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1199 t->GetBackend().GetChildrenInternalId(values, t->GetManager(), id); |
212 | 1200 t->GetOutput().AnswerIntegers64(values); |
1201 | |
1202 return OrthancPluginErrorCode_Success; | |
1203 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1204 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1205 } |
1206 | |
1207 | |
1208 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1209 int64_t resourceId, | |
1210 int32_t metadata) | |
1211 { | |
1212 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1213 | |
1214 try | |
1215 { | |
1216 t->GetOutput().Clear(); | |
1217 | |
1218 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1219 t->GetBackend().GetChildrenMetadata(values, t->GetManager(), resourceId, metadata); |
212 | 1220 t->GetOutput().AnswerStrings(values); |
1221 | |
1222 return OrthancPluginErrorCode_Success; | |
1223 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1224 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1225 } |
1226 | |
1227 | |
1228 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseTransaction* transaction, | |
1229 int64_t id) | |
1230 { | |
1231 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1232 | |
1233 try | |
1234 { | |
1235 t->GetOutput().Clear(); | |
1236 | |
1237 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1238 t->GetBackend().GetChildrenPublicId(values, t->GetManager(), id); |
212 | 1239 t->GetOutput().AnswerStrings(values); |
1240 | |
1241 return OrthancPluginErrorCode_Success; | |
1242 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1243 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1244 } |
1245 | |
1246 | |
1247 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseTransaction* transaction, | |
1248 uint8_t* targetDone /* out */, | |
1249 int64_t since, | |
1250 uint32_t maxResults) | |
1251 { | |
1252 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1253 | |
1254 try | |
1255 { | |
1256 t->GetOutput().Clear(); | |
1257 | |
1258 bool done; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1259 t->GetBackend().GetExportedResources(t->GetOutput(), done, t->GetManager(), since, maxResults); |
212 | 1260 *targetDone = (done ? 1 : 0); |
1261 | |
1262 return OrthancPluginErrorCode_Success; | |
1263 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1264 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1265 } |
1266 | |
1267 | |
1268 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseTransaction* transaction) | |
1269 { | |
1270 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1271 | |
1272 try | |
1273 { | |
1274 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1275 t->GetBackend().GetLastChange(t->GetOutput(), t->GetManager()); |
212 | 1276 return OrthancPluginErrorCode_Success; |
1277 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1278 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1279 } |
1280 | |
1281 | |
1282 static OrthancPluginErrorCode GetLastChangeIndex(OrthancPluginDatabaseTransaction* transaction, | |
1283 int64_t* target) | |
1284 { | |
1285 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1286 | |
1287 try | |
1288 { | |
1289 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1290 *target = t->GetBackend().GetLastChangeIndex(t->GetManager()); |
212 | 1291 return OrthancPluginErrorCode_Success; |
1292 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1293 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1294 } |
1295 | |
1296 | |
1297 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseTransaction* transaction) | |
1298 { | |
1299 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1300 | |
1301 try | |
1302 { | |
1303 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1304 t->GetBackend().GetLastExportedResource(t->GetOutput(), t->GetManager()); |
212 | 1305 return OrthancPluginErrorCode_Success; |
1306 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1307 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1308 } |
1309 | |
1310 | |
1311 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
1312 int64_t id) | |
1313 { | |
1314 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1315 | |
1316 try | |
1317 { | |
1318 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1319 t->GetBackend().GetMainDicomTags(t->GetOutput(), t->GetManager(), id); |
212 | 1320 return OrthancPluginErrorCode_Success; |
1321 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1322 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1323 } |
1324 | |
1325 | |
1326 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseTransaction* transaction, | |
1327 int64_t id) | |
1328 { | |
1329 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1330 | |
1331 try | |
1332 { | |
1333 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1334 t->GetOutput().AnswerString(t->GetBackend().GetPublicId(t->GetManager(), id)); |
212 | 1335 return OrthancPluginErrorCode_Success; |
1336 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1337 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1338 } |
1339 | |
1340 | |
1341 static OrthancPluginErrorCode GetResourcesCount(OrthancPluginDatabaseTransaction* transaction, | |
1342 uint64_t* target /* out */, | |
1343 OrthancPluginResourceType resourceType) | |
1344 { | |
1345 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1346 | |
1347 try | |
1348 { | |
1349 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1350 *target = t->GetBackend().GetResourcesCount(t->GetManager(), resourceType); |
212 | 1351 return OrthancPluginErrorCode_Success; |
1352 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1353 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1354 } |
1355 | |
1356 | |
1357 static OrthancPluginErrorCode GetResourceType(OrthancPluginDatabaseTransaction* transaction, | |
1358 OrthancPluginResourceType* target /* out */, | |
1359 uint64_t resourceId) | |
1360 { | |
1361 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1362 | |
1363 try | |
1364 { | |
1365 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1366 *target = t->GetBackend().GetResourceType(t->GetManager(), resourceId); |
212 | 1367 return OrthancPluginErrorCode_Success; |
1368 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1369 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1370 } |
1371 | |
1372 | |
1373 static OrthancPluginErrorCode GetTotalCompressedSize(OrthancPluginDatabaseTransaction* transaction, | |
1374 uint64_t* target /* out */) | |
1375 { | |
1376 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1377 | |
1378 try | |
1379 { | |
1380 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1381 *target = t->GetBackend().GetTotalCompressedSize(t->GetManager()); |
212 | 1382 return OrthancPluginErrorCode_Success; |
1383 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1384 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1385 } |
1386 | |
1387 | |
1388 static OrthancPluginErrorCode GetTotalUncompressedSize(OrthancPluginDatabaseTransaction* transaction, | |
1389 uint64_t* target /* out */) | |
1390 { | |
1391 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1392 | |
1393 try | |
1394 { | |
1395 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1396 *target = t->GetBackend().GetTotalUncompressedSize(t->GetManager()); |
212 | 1397 return OrthancPluginErrorCode_Success; |
1398 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1399 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1400 } |
1401 | |
1402 | |
1403 static OrthancPluginErrorCode IsDiskSizeAbove(OrthancPluginDatabaseTransaction* transaction, | |
1404 uint8_t* target, | |
1405 uint64_t threshold) | |
1406 { | |
1407 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1408 | |
1409 try | |
1410 { | |
1411 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1412 bool above = (t->GetBackend().GetTotalCompressedSize(t->GetManager()) >= threshold); |
212 | 1413 *target = (above ? 1 : 0); |
1414 return OrthancPluginErrorCode_Success; | |
1415 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1416 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1417 } |
1418 | |
1419 | |
1420 static OrthancPluginErrorCode IsExistingResource(OrthancPluginDatabaseTransaction* transaction, | |
1421 uint8_t* target, | |
1422 int64_t resourceId) | |
1423 { | |
1424 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1425 | |
1426 try | |
1427 { | |
1428 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1429 bool exists = t->GetBackend().IsExistingResource(t->GetManager(), resourceId); |
212 | 1430 *target = (exists ? 1 : 0); |
1431 return OrthancPluginErrorCode_Success; | |
1432 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1433 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1434 } |
1435 | |
1436 | |
1437 static OrthancPluginErrorCode IsProtectedPatient(OrthancPluginDatabaseTransaction* transaction, | |
1438 uint8_t* target, | |
1439 int64_t resourceId) | |
1440 { | |
1441 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1442 | |
1443 try | |
1444 { | |
1445 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1446 bool isProtected = t->GetBackend().IsProtectedPatient(t->GetManager(), resourceId); |
212 | 1447 *target = (isProtected ? 1 : 0); |
1448 return OrthancPluginErrorCode_Success; | |
1449 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1450 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1451 } |
1452 | |
1453 | |
1454 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseTransaction* transaction, | |
1455 int64_t resourceId) | |
1456 { | |
1457 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1458 | |
1459 try | |
1460 { | |
1461 t->GetOutput().Clear(); | |
1462 | |
1463 std::list<int32_t> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1464 t->GetBackend().ListAvailableAttachments(values, t->GetManager(), resourceId); |
212 | 1465 t->GetOutput().AnswerIntegers32(values); |
1466 return OrthancPluginErrorCode_Success; | |
1467 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1468 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1469 } |
1470 | |
1471 | |
1472 static OrthancPluginErrorCode LogChange(OrthancPluginDatabaseTransaction* transaction, | |
1473 int32_t changeType, | |
1474 int64_t resourceId, | |
1475 OrthancPluginResourceType resourceType, | |
1476 const char* date) | |
1477 { | |
1478 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1479 | |
1480 try | |
1481 { | |
1482 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1483 t->GetBackend().LogChange(t->GetManager(), changeType, resourceId, resourceType, date); |
212 | 1484 return OrthancPluginErrorCode_Success; |
1485 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1486 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1487 } |
1488 | |
1489 | |
1490 static OrthancPluginErrorCode LogExportedResource(OrthancPluginDatabaseTransaction* transaction, | |
1491 OrthancPluginResourceType resourceType, | |
1492 const char* publicId, | |
1493 const char* modality, | |
1494 const char* date, | |
1495 const char* patientId, | |
1496 const char* studyInstanceUid, | |
1497 const char* seriesInstanceUid, | |
1498 const char* sopInstanceUid) | |
1499 { | |
1500 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1501 | |
1502 try | |
1503 { | |
1504 t->GetOutput().Clear(); | |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
1505 t->GetBackend().LogExportedResource(t->GetManager(), resourceType, publicId, modality, date, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
1506 patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid); |
212 | 1507 return OrthancPluginErrorCode_Success; |
1508 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1509 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1510 } |
1511 | |
1512 | |
1513 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseTransaction* transaction, | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1514 int64_t* revision /* out */, |
212 | 1515 int64_t resourceId, |
1516 int32_t contentType) | |
1517 { | |
1518 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1519 | |
1520 try | |
1521 { | |
1522 t->GetOutput().Clear(); | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1523 t->GetBackend().LookupAttachment(t->GetOutput(), *revision, t->GetManager(), resourceId, contentType); |
212 | 1524 return OrthancPluginErrorCode_Success; |
1525 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1526 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1527 } |
1528 | |
1529 | |
1530 static OrthancPluginErrorCode LookupGlobalProperty(OrthancPluginDatabaseTransaction* transaction, | |
221
73cc85f3d9c1
implementation of the "serverIdentifier" information for global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1531 const char* serverIdentifier, |
212 | 1532 int32_t property) |
1533 { | |
1534 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1535 | |
1536 try | |
1537 { | |
1538 t->GetOutput().Clear(); | |
1539 | |
1540 std::string s; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1541 if (t->GetBackend().LookupGlobalProperty(s, t->GetManager(), serverIdentifier, property)) |
212 | 1542 { |
1543 t->GetOutput().AnswerString(s); | |
1544 } | |
1545 | |
1546 return OrthancPluginErrorCode_Success; | |
1547 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1548 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1549 } |
1550 | |
1551 | |
1552 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseTransaction* transaction, | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1553 int64_t* revision /* out */, |
212 | 1554 int64_t id, |
1555 int32_t metadata) | |
1556 { | |
1557 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1558 | |
1559 try | |
1560 { | |
1561 t->GetOutput().Clear(); | |
1562 | |
1563 std::string s; | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1564 if (t->GetBackend().LookupMetadata(s, *revision, t->GetManager(), id, metadata)) |
212 | 1565 { |
1566 t->GetOutput().AnswerString(s); | |
1567 } | |
1568 | |
1569 return OrthancPluginErrorCode_Success; | |
1570 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1571 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1572 } |
1573 | |
1574 | |
1575 static OrthancPluginErrorCode LookupParent(OrthancPluginDatabaseTransaction* transaction, | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1576 uint8_t* existing /* out */, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1577 int64_t* parentId /* out */, |
212 | 1578 int64_t id) |
1579 { | |
1580 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1581 | |
1582 try | |
1583 { | |
1584 t->GetOutput().Clear(); | |
1585 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1586 if (t->GetBackend().LookupParent(*parentId, t->GetManager(), id)) |
212 | 1587 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1588 *existing = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1589 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1590 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1591 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1592 *existing = 0; |
212 | 1593 } |
1594 | |
1595 return OrthancPluginErrorCode_Success; | |
1596 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1597 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1598 } |
1599 | |
1600 | |
1601 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseTransaction* transaction, | |
1602 uint8_t* isExisting /* out */, | |
1603 int64_t* id /* out */, | |
1604 OrthancPluginResourceType* type /* out */, | |
1605 const char* publicId) | |
1606 { | |
1607 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1608 | |
1609 try | |
1610 { | |
1611 t->GetOutput().Clear(); | |
1612 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1613 if (t->GetBackend().LookupResource(*id, *type, t->GetManager(), publicId)) |
212 | 1614 { |
1615 *isExisting = 1; | |
1616 } | |
1617 else | |
1618 { | |
1619 *isExisting = 0; | |
1620 } | |
1621 | |
1622 return OrthancPluginErrorCode_Success; | |
1623 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1624 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1625 } |
1626 | |
1627 | |
1628 static OrthancPluginErrorCode LookupResources(OrthancPluginDatabaseTransaction* transaction, | |
1629 uint32_t constraintsCount, | |
1630 const OrthancPluginDatabaseConstraint* constraints, | |
1631 OrthancPluginResourceType queryLevel, | |
1632 uint32_t limit, | |
1633 uint8_t requestSomeInstanceId) | |
1634 { | |
1635 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1636 | |
1637 try | |
1638 { | |
1639 t->GetOutput().Clear(); | |
1640 | |
1641 std::vector<Orthanc::DatabaseConstraint> lookup; | |
1642 lookup.reserve(constraintsCount); | |
1643 | |
1644 for (uint32_t i = 0; i < constraintsCount; i++) | |
1645 { | |
1646 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); | |
1647 } | |
1648 | |
391
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
1649 std::set<std::string> noLabels; |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
1650 t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, |
d14e6ff04a5c
added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
1651 noLabels, noLabels, limit, (requestSomeInstanceId != 0)); |
212 | 1652 return OrthancPluginErrorCode_Success; |
1653 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1654 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1655 } |
1656 | |
1657 | |
1658 static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseTransaction* transaction, | |
1659 uint8_t* isExisting /* out */, | |
1660 int64_t* id /* out */, | |
1661 OrthancPluginResourceType* type /* out */, | |
1662 const char* publicId) | |
1663 { | |
1664 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1665 | |
1666 try | |
1667 { | |
1668 t->GetOutput().Clear(); | |
1669 | |
1670 std::string parent; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1671 if (t->GetBackend().LookupResourceAndParent(*id, *type, parent, t->GetManager(), publicId)) |
212 | 1672 { |
1673 *isExisting = 1; | |
1674 | |
1675 if (!parent.empty()) | |
1676 { | |
1677 t->GetOutput().AnswerString(parent); | |
1678 } | |
1679 } | |
1680 else | |
1681 { | |
1682 *isExisting = 0; | |
1683 } | |
1684 | |
1685 return OrthancPluginErrorCode_Success; | |
1686 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1687 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1688 } |
1689 | |
1690 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1691 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseTransaction* transaction, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1692 uint8_t* patientAvailable, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1693 int64_t* patientId) |
212 | 1694 { |
1695 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1696 | |
1697 try | |
1698 { | |
1699 t->GetOutput().Clear(); | |
1700 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1701 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager())) |
212 | 1702 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1703 *patientAvailable = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1704 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1705 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1706 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1707 *patientAvailable = 0; |
212 | 1708 } |
1709 | |
1710 return OrthancPluginErrorCode_Success; | |
1711 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1712 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1713 } |
1714 | |
1715 | |
1716 static OrthancPluginErrorCode SelectPatientToRecycle2(OrthancPluginDatabaseTransaction* transaction, | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1717 uint8_t* patientAvailable, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1718 int64_t* patientId, |
212 | 1719 int64_t patientIdToAvoid) |
1720 { | |
1721 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1722 | |
1723 try | |
1724 { | |
1725 t->GetOutput().Clear(); | |
1726 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1727 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager(), patientIdToAvoid)) |
212 | 1728 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1729 *patientAvailable = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1730 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1731 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1732 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1733 *patientAvailable = 0; |
212 | 1734 } |
1735 | |
1736 return OrthancPluginErrorCode_Success; | |
1737 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1738 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1739 } |
1740 | |
1741 | |
1742 static OrthancPluginErrorCode SetGlobalProperty(OrthancPluginDatabaseTransaction* transaction, | |
221
73cc85f3d9c1
implementation of the "serverIdentifier" information for global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1743 const char* serverIdentifier, |
212 | 1744 int32_t property, |
1745 const char* value) | |
1746 { | |
1747 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1748 | |
1749 try | |
1750 { | |
1751 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1752 t->GetBackend().SetGlobalProperty(t->GetManager(), serverIdentifier, property, value); |
212 | 1753 return OrthancPluginErrorCode_Success; |
1754 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1755 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1756 } |
1757 | |
1758 | |
1759 static OrthancPluginErrorCode SetMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1760 int64_t id, | |
1761 int32_t metadata, | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1762 const char* value, |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1763 int64_t revision) |
212 | 1764 { |
1765 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1766 | |
1767 try | |
1768 { | |
1769 t->GetOutput().Clear(); | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1770 t->GetBackend().SetMetadata(t->GetManager(), id, metadata, value, revision); |
212 | 1771 return OrthancPluginErrorCode_Success; |
1772 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1773 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1774 } |
1775 | |
1776 | |
1777 static OrthancPluginErrorCode SetProtectedPatient(OrthancPluginDatabaseTransaction* transaction, | |
1778 int64_t id, | |
1779 uint8_t isProtected) | |
1780 { | |
1781 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1782 | |
1783 try | |
1784 { | |
1785 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1786 t->GetBackend().SetProtectedPatient(t->GetManager(), id, (isProtected != 0)); |
212 | 1787 return OrthancPluginErrorCode_Success; |
1788 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1789 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1790 } |
1791 | |
1792 | |
1793 static OrthancPluginErrorCode SetResourcesContent(OrthancPluginDatabaseTransaction* transaction, | |
1794 uint32_t countIdentifierTags, | |
1795 const OrthancPluginResourcesContentTags* identifierTags, | |
1796 uint32_t countMainDicomTags, | |
1797 const OrthancPluginResourcesContentTags* mainDicomTags, | |
1798 uint32_t countMetadata, | |
1799 const OrthancPluginResourcesContentMetadata* metadata) | |
1800 { | |
1801 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1802 | |
1803 try | |
1804 { | |
1805 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1806 t->GetBackend().SetResourcesContent(t->GetManager(), countIdentifierTags, identifierTags, |
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1807 countMainDicomTags, mainDicomTags, countMetadata, metadata); |
212 | 1808 return OrthancPluginErrorCode_Success; |
1809 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1810 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1811 } |
1812 | |
1813 | |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1814 void DatabaseBackendAdapterV3::Register(IndexBackend* backend, |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1815 size_t countConnections, |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1816 unsigned int maxDatabaseRetries) |
212 | 1817 { |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1818 std::unique_ptr<IndexBackend> protection(backend); |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1819 |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1820 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1821 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1822 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1823 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1824 |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1825 if (backend == NULL) |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1826 { |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1827 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1828 } |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1829 |
212 | 1830 OrthancPluginDatabaseBackendV3 params; |
1831 memset(¶ms, 0, sizeof(params)); | |
1832 | |
1833 params.readAnswersCount = ReadAnswersCount; | |
1834 params.readAnswerAttachment = ReadAnswerAttachment; | |
1835 params.readAnswerChange = ReadAnswerChange; | |
1836 params.readAnswerDicomTag = ReadAnswerDicomTag; | |
1837 params.readAnswerExportedResource = ReadAnswerExportedResource; | |
1838 params.readAnswerInt32 = ReadAnswerInt32; | |
1839 params.readAnswerInt64 = ReadAnswerInt64; | |
1840 params.readAnswerMatchingResource = ReadAnswerMatchingResource; | |
1841 params.readAnswerMetadata = ReadAnswerMetadata; | |
1842 params.readAnswerString = ReadAnswerString; | |
1843 | |
1844 params.readEventsCount = ReadEventsCount; | |
1845 params.readEvent = ReadEvent; | |
1846 | |
1847 params.open = Open; | |
1848 params.close = Close; | |
1849 params.destructDatabase = DestructDatabase; | |
1850 params.getDatabaseVersion = GetDatabaseVersion; | |
1851 params.upgradeDatabase = UpgradeDatabase; | |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1852 params.hasRevisionsSupport = HasRevisionsSupport; |
212 | 1853 params.startTransaction = StartTransaction; |
1854 params.destructTransaction = DestructTransaction; | |
1855 params.rollback = Rollback; | |
1856 params.commit = Commit; | |
1857 | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1858 params.addAttachment = AddAttachment; |
212 | 1859 params.clearChanges = ClearChanges; |
1860 params.clearExportedResources = ClearExportedResources; | |
1861 params.clearMainDicomTags = ClearMainDicomTags; | |
1862 params.createInstance = CreateInstance; | |
1863 params.deleteAttachment = DeleteAttachment; | |
1864 params.deleteMetadata = DeleteMetadata; | |
1865 params.deleteResource = DeleteResource; | |
1866 params.getAllMetadata = GetAllMetadata; | |
1867 params.getAllPublicIds = GetAllPublicIds; | |
1868 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1869 params.getChanges = GetChanges; | |
1870 params.getChildrenInternalId = GetChildrenInternalId; | |
1871 params.getChildrenMetadata = GetChildrenMetadata; | |
1872 params.getChildrenPublicId = GetChildrenPublicId; | |
1873 params.getExportedResources = GetExportedResources; | |
1874 params.getLastChange = GetLastChange; | |
1875 params.getLastChangeIndex = GetLastChangeIndex; | |
1876 params.getLastExportedResource = GetLastExportedResource; | |
1877 params.getMainDicomTags = GetMainDicomTags; | |
1878 params.getPublicId = GetPublicId; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1879 params.getResourceType = GetResourceType; |
212 | 1880 params.getResourcesCount = GetResourcesCount; |
1881 params.getTotalCompressedSize = GetTotalCompressedSize; | |
1882 params.getTotalUncompressedSize = GetTotalUncompressedSize; | |
1883 params.isDiskSizeAbove = IsDiskSizeAbove; | |
1884 params.isExistingResource = IsExistingResource; | |
1885 params.isProtectedPatient = IsProtectedPatient; | |
1886 params.listAvailableAttachments = ListAvailableAttachments; | |
1887 params.logChange = LogChange; | |
1888 params.logExportedResource = LogExportedResource; | |
1889 params.lookupAttachment = LookupAttachment; | |
1890 params.lookupGlobalProperty = LookupGlobalProperty; | |
1891 params.lookupMetadata = LookupMetadata; | |
1892 params.lookupParent = LookupParent; | |
1893 params.lookupResource = LookupResource; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1894 params.lookupResourceAndParent = LookupResourceAndParent; |
212 | 1895 params.lookupResources = LookupResources; |
1896 params.selectPatientToRecycle = SelectPatientToRecycle; | |
1897 params.selectPatientToRecycle2 = SelectPatientToRecycle2; | |
1898 params.setGlobalProperty = SetGlobalProperty; | |
1899 params.setMetadata = SetMetadata; | |
1900 params.setProtectedPatient = SetProtectedPatient; | |
1901 params.setResourcesContent = SetResourcesContent; | |
1902 | |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1903 OrthancPluginContext* context = protection->GetContext(); |
212 | 1904 |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1905 if (OrthancPluginRegisterDatabaseBackendV3( |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1906 context, ¶ms, sizeof(params), maxDatabaseRetries, |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1907 new IndexConnectionsPool(protection.release(), countConnections)) != OrthancPluginErrorCode_Success) |
212 | 1908 { |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1909 delete backend; |
212 | 1910 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend"); |
1911 } | |
1912 | |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1913 backend->SetOutputFactory(new Factory); |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1914 |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1915 isBackendInUse_ = true; |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1916 } |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1917 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1918 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1919 void DatabaseBackendAdapterV3::Finalize() |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1920 { |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1921 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1922 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1923 fprintf(stderr, "The Orthanc core has not destructed the index backend, internal error\n"); |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1924 } |
212 | 1925 } |
1926 } | |
1927 | |
1928 # endif | |
1929 #endif |