Mercurial > hg > orthanc-databases
annotate Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 403:91124cc8a8c7 db-protobuf
database plugins are informed about the identifier tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Apr 2023 11:10:19 +0200 |
parents | a8774581adfc |
children | ecd0b719cff5 |
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 { | |
403
91124cc8a8c7
database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
803 std::list<IdentifierTag> identifierTags; |
91124cc8a8c7
database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
804 pool->OpenConnections(false, identifierTags); |
212 | 805 return OrthancPluginErrorCode_Success; |
806 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
807 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 808 } |
809 | |
810 | |
811 static OrthancPluginErrorCode Close(void* database) | |
812 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
813 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 814 |
815 try | |
816 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
817 pool->CloseConnections(); |
212 | 818 return OrthancPluginErrorCode_Success; |
819 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
820 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 821 } |
822 | |
823 | |
824 static OrthancPluginErrorCode DestructDatabase(void* database) | |
825 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
826 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
827 |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
828 if (pool == NULL) |
212 | 829 { |
830 return OrthancPluginErrorCode_InternalError; | |
831 } | |
832 else | |
833 { | |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
834 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
835 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
836 isBackendInUse_ = false; |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
837 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
838 else |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
839 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
840 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
|
841 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
842 |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
843 delete pool; |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
844 |
212 | 845 return OrthancPluginErrorCode_Success; |
846 } | |
847 } | |
848 | |
849 | |
850 static OrthancPluginErrorCode GetDatabaseVersion(void* database, | |
851 uint32_t* version) | |
852 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
853 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 854 |
855 try | |
856 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
857 IndexConnectionsPool::Accessor accessor(*pool); |
233 | 858 *version = accessor.GetBackend().GetDatabaseVersion(accessor.GetManager()); |
212 | 859 return OrthancPluginErrorCode_Success; |
860 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
861 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 862 } |
863 | |
864 | |
865 static OrthancPluginErrorCode UpgradeDatabase(void* database, | |
866 OrthancPluginStorageArea* storageArea, | |
867 uint32_t targetVersion) | |
868 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
869 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 870 |
871 try | |
872 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
873 IndexConnectionsPool::Accessor accessor(*pool); |
233 | 874 accessor.GetBackend().UpgradeDatabase(accessor.GetManager(), targetVersion, storageArea); |
212 | 875 return OrthancPluginErrorCode_Success; |
876 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
877 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 878 } |
879 | |
880 | |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
881 static OrthancPluginErrorCode HasRevisionsSupport(void* database, |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
882 uint8_t* target) |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
883 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
884 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
|
885 |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
886 try |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
887 { |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
888 IndexConnectionsPool::Accessor accessor(*pool); |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
889 *target = (accessor.GetBackend().HasRevisionsSupport() ? 1 : 0); |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
890 return OrthancPluginErrorCode_Success; |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
891 } |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
892 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
|
893 } |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
894 |
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
895 |
212 | 896 static OrthancPluginErrorCode StartTransaction(void* database, |
897 OrthancPluginDatabaseTransaction** target /* out */, | |
898 OrthancPluginDatabaseTransactionType type) | |
899 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
900 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database); |
212 | 901 |
902 try | |
903 { | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
904 std::unique_ptr<DatabaseBackendAdapterV3::Transaction> transaction(new DatabaseBackendAdapterV3::Transaction(*pool)); |
212 | 905 |
906 switch (type) | |
907 { | |
908 case OrthancPluginDatabaseTransactionType_ReadOnly: | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
909 transaction->GetManager().StartTransaction(TransactionType_ReadOnly); |
212 | 910 break; |
911 | |
912 case OrthancPluginDatabaseTransactionType_ReadWrite: | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
913 transaction->GetManager().StartTransaction(TransactionType_ReadWrite); |
212 | 914 break; |
915 | |
916 default: | |
917 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
918 } | |
919 | |
920 *target = reinterpret_cast<OrthancPluginDatabaseTransaction*>(transaction.release()); | |
921 | |
922 return OrthancPluginErrorCode_Success; | |
923 } | |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
924 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext()); |
212 | 925 } |
926 | |
927 | |
928 static OrthancPluginErrorCode DestructTransaction(OrthancPluginDatabaseTransaction* transaction) | |
929 { | |
930 if (transaction == NULL) | |
931 { | |
932 return OrthancPluginErrorCode_NullPointer; | |
933 } | |
934 else | |
935 { | |
936 delete reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
937 return OrthancPluginErrorCode_Success; | |
938 } | |
939 } | |
940 | |
941 | |
942 static OrthancPluginErrorCode Rollback(OrthancPluginDatabaseTransaction* transaction) | |
943 { | |
944 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
945 | |
946 try | |
947 { | |
948 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
949 t->GetManager().RollbackTransaction(); |
212 | 950 return OrthancPluginErrorCode_Success; |
951 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
952 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 953 } |
954 | |
955 | |
956 static OrthancPluginErrorCode Commit(OrthancPluginDatabaseTransaction* transaction, | |
957 int64_t fileSizeDelta /* TODO - not used? */) | |
958 { | |
959 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
960 | |
961 try | |
962 { | |
963 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
964 t->GetManager().CommitTransaction(); |
212 | 965 return OrthancPluginErrorCode_Success; |
966 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
967 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 968 } |
969 | |
970 | |
971 static OrthancPluginErrorCode AddAttachment(OrthancPluginDatabaseTransaction* transaction, | |
972 int64_t id, | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
973 const OrthancPluginAttachment* attachment, |
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
974 int64_t revision) |
212 | 975 { |
976 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
977 | |
978 try | |
979 { | |
980 t->GetOutput().Clear(); | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
981 t->GetBackend().AddAttachment(t->GetManager(), id, *attachment, revision); |
212 | 982 return OrthancPluginErrorCode_Success; |
983 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
984 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 985 } |
986 | |
987 | |
988 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction) | |
989 { | |
990 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
991 | |
992 try | |
993 { | |
994 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
995 t->GetBackend().ClearChanges(t->GetManager()); |
212 | 996 return OrthancPluginErrorCode_Success; |
997 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
998 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 999 } |
1000 | |
1001 | |
1002 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction) | |
1003 { | |
1004 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1005 | |
1006 try | |
1007 { | |
1008 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1009 t->GetBackend().ClearExportedResources(t->GetManager()); |
212 | 1010 return OrthancPluginErrorCode_Success; |
1011 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1012 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1013 } |
1014 | |
1015 | |
1016 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
1017 int64_t resourceId) | |
1018 { | |
1019 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1020 | |
1021 try | |
1022 { | |
1023 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1024 t->GetBackend().ClearMainDicomTags(t->GetManager(), resourceId); |
212 | 1025 return OrthancPluginErrorCode_Success; |
1026 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1027 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1028 } |
1029 | |
1030 | |
1031 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction, | |
1032 OrthancPluginCreateInstanceResult* target /* out */, | |
1033 const char* hashPatient, | |
1034 const char* hashStudy, | |
1035 const char* hashSeries, | |
1036 const char* hashInstance) | |
1037 { | |
1038 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1039 | |
1040 try | |
1041 { | |
1042 t->GetOutput().Clear(); | |
1043 | |
1044 if (t->GetBackend().HasCreateInstance()) | |
1045 { | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1046 t->GetBackend().CreateInstance(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance); |
212 | 1047 } |
1048 else | |
1049 { | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1050 t->GetBackend().CreateInstanceGeneric(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance); |
212 | 1051 } |
1052 | |
1053 return OrthancPluginErrorCode_Success; | |
1054 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1055 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1056 } |
1057 | |
1058 | |
1059 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction, | |
1060 int64_t id, | |
1061 int32_t contentType) | |
1062 { | |
1063 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1064 | |
1065 try | |
1066 { | |
1067 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1068 t->GetBackend().DeleteAttachment(t->GetOutput(), t->GetManager(), id, contentType); |
212 | 1069 return OrthancPluginErrorCode_Success; |
1070 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1071 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1072 } |
1073 | |
1074 | |
1075 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1076 int64_t id, | |
1077 int32_t metadataType) | |
1078 { | |
1079 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1080 | |
1081 try | |
1082 { | |
1083 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1084 t->GetBackend().DeleteMetadata(t->GetManager(), id, metadataType); |
212 | 1085 return OrthancPluginErrorCode_Success; |
1086 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1087 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1088 } |
1089 | |
1090 | |
1091 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction, | |
1092 int64_t id) | |
1093 { | |
1094 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1095 | |
1096 try | |
1097 { | |
1098 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1099 t->GetBackend().DeleteResource(t->GetOutput(), t->GetManager(), id); |
212 | 1100 return OrthancPluginErrorCode_Success; |
1101 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1102 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1103 } |
1104 | |
1105 | |
1106 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1107 int64_t id) | |
1108 { | |
1109 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1110 | |
1111 try | |
1112 { | |
1113 t->GetOutput().Clear(); | |
1114 | |
1115 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
|
1116 t->GetBackend().GetAllMetadata(values, t->GetManager(), id); |
212 | 1117 |
1118 for (std::map<int32_t, std::string>::const_iterator it = values.begin(); it != values.end(); ++it) | |
1119 { | |
1120 t->GetOutput().AnswerMetadata(it->first, it->second); | |
1121 } | |
1122 | |
1123 return OrthancPluginErrorCode_Success; | |
1124 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1125 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1126 } |
1127 | |
1128 | |
1129 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction, | |
1130 OrthancPluginResourceType resourceType) | |
1131 { | |
1132 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1133 | |
1134 try | |
1135 { | |
1136 t->GetOutput().Clear(); | |
1137 | |
1138 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1139 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType); |
212 | 1140 t->GetOutput().AnswerStrings(values); |
1141 | |
1142 return OrthancPluginErrorCode_Success; | |
1143 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1144 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1145 } |
1146 | |
1147 | |
1148 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction, | |
1149 OrthancPluginResourceType resourceType, | |
1150 uint64_t since, | |
1151 uint64_t limit) | |
1152 { | |
1153 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1154 | |
1155 try | |
1156 { | |
1157 t->GetOutput().Clear(); | |
1158 | |
1159 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1160 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType, since, limit); |
212 | 1161 t->GetOutput().AnswerStrings(values); |
1162 | |
1163 return OrthancPluginErrorCode_Success; | |
1164 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1165 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1166 } |
1167 | |
1168 | |
1169 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction, | |
1170 uint8_t* targetDone /* out */, | |
1171 int64_t since, | |
1172 uint32_t maxResults) | |
1173 { | |
1174 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1175 | |
1176 try | |
1177 { | |
1178 t->GetOutput().Clear(); | |
1179 | |
1180 bool done; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1181 t->GetBackend().GetChanges(t->GetOutput(), done, t->GetManager(), since, maxResults); |
212 | 1182 *targetDone = (done ? 1 : 0); |
1183 | |
1184 return OrthancPluginErrorCode_Success; | |
1185 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1186 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1187 } |
1188 | |
1189 | |
1190 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseTransaction* transaction, | |
1191 int64_t id) | |
1192 { | |
1193 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1194 | |
1195 try | |
1196 { | |
1197 t->GetOutput().Clear(); | |
1198 | |
1199 std::list<int64_t> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1200 t->GetBackend().GetChildrenInternalId(values, t->GetManager(), id); |
212 | 1201 t->GetOutput().AnswerIntegers64(values); |
1202 | |
1203 return OrthancPluginErrorCode_Success; | |
1204 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1205 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1206 } |
1207 | |
1208 | |
1209 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1210 int64_t resourceId, | |
1211 int32_t metadata) | |
1212 { | |
1213 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1214 | |
1215 try | |
1216 { | |
1217 t->GetOutput().Clear(); | |
1218 | |
1219 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1220 t->GetBackend().GetChildrenMetadata(values, t->GetManager(), resourceId, metadata); |
212 | 1221 t->GetOutput().AnswerStrings(values); |
1222 | |
1223 return OrthancPluginErrorCode_Success; | |
1224 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1225 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1226 } |
1227 | |
1228 | |
1229 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseTransaction* transaction, | |
1230 int64_t id) | |
1231 { | |
1232 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1233 | |
1234 try | |
1235 { | |
1236 t->GetOutput().Clear(); | |
1237 | |
1238 std::list<std::string> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1239 t->GetBackend().GetChildrenPublicId(values, t->GetManager(), id); |
212 | 1240 t->GetOutput().AnswerStrings(values); |
1241 | |
1242 return OrthancPluginErrorCode_Success; | |
1243 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1244 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1245 } |
1246 | |
1247 | |
1248 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseTransaction* transaction, | |
1249 uint8_t* targetDone /* out */, | |
1250 int64_t since, | |
1251 uint32_t maxResults) | |
1252 { | |
1253 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1254 | |
1255 try | |
1256 { | |
1257 t->GetOutput().Clear(); | |
1258 | |
1259 bool done; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1260 t->GetBackend().GetExportedResources(t->GetOutput(), done, t->GetManager(), since, maxResults); |
212 | 1261 *targetDone = (done ? 1 : 0); |
1262 | |
1263 return OrthancPluginErrorCode_Success; | |
1264 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1265 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1266 } |
1267 | |
1268 | |
1269 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseTransaction* transaction) | |
1270 { | |
1271 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1272 | |
1273 try | |
1274 { | |
1275 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1276 t->GetBackend().GetLastChange(t->GetOutput(), t->GetManager()); |
212 | 1277 return OrthancPluginErrorCode_Success; |
1278 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1279 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1280 } |
1281 | |
1282 | |
1283 static OrthancPluginErrorCode GetLastChangeIndex(OrthancPluginDatabaseTransaction* transaction, | |
1284 int64_t* target) | |
1285 { | |
1286 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1287 | |
1288 try | |
1289 { | |
1290 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1291 *target = t->GetBackend().GetLastChangeIndex(t->GetManager()); |
212 | 1292 return OrthancPluginErrorCode_Success; |
1293 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1294 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1295 } |
1296 | |
1297 | |
1298 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseTransaction* transaction) | |
1299 { | |
1300 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1301 | |
1302 try | |
1303 { | |
1304 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1305 t->GetBackend().GetLastExportedResource(t->GetOutput(), t->GetManager()); |
212 | 1306 return OrthancPluginErrorCode_Success; |
1307 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1308 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1309 } |
1310 | |
1311 | |
1312 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseTransaction* transaction, | |
1313 int64_t id) | |
1314 { | |
1315 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1316 | |
1317 try | |
1318 { | |
1319 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1320 t->GetBackend().GetMainDicomTags(t->GetOutput(), t->GetManager(), id); |
212 | 1321 return OrthancPluginErrorCode_Success; |
1322 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1323 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1324 } |
1325 | |
1326 | |
1327 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseTransaction* transaction, | |
1328 int64_t id) | |
1329 { | |
1330 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1331 | |
1332 try | |
1333 { | |
1334 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1335 t->GetOutput().AnswerString(t->GetBackend().GetPublicId(t->GetManager(), id)); |
212 | 1336 return OrthancPluginErrorCode_Success; |
1337 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1338 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1339 } |
1340 | |
1341 | |
1342 static OrthancPluginErrorCode GetResourcesCount(OrthancPluginDatabaseTransaction* transaction, | |
1343 uint64_t* target /* out */, | |
1344 OrthancPluginResourceType resourceType) | |
1345 { | |
1346 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1347 | |
1348 try | |
1349 { | |
1350 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1351 *target = t->GetBackend().GetResourcesCount(t->GetManager(), resourceType); |
212 | 1352 return OrthancPluginErrorCode_Success; |
1353 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1354 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1355 } |
1356 | |
1357 | |
1358 static OrthancPluginErrorCode GetResourceType(OrthancPluginDatabaseTransaction* transaction, | |
1359 OrthancPluginResourceType* target /* out */, | |
1360 uint64_t resourceId) | |
1361 { | |
1362 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1363 | |
1364 try | |
1365 { | |
1366 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1367 *target = t->GetBackend().GetResourceType(t->GetManager(), resourceId); |
212 | 1368 return OrthancPluginErrorCode_Success; |
1369 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1370 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1371 } |
1372 | |
1373 | |
1374 static OrthancPluginErrorCode GetTotalCompressedSize(OrthancPluginDatabaseTransaction* transaction, | |
1375 uint64_t* target /* out */) | |
1376 { | |
1377 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1378 | |
1379 try | |
1380 { | |
1381 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1382 *target = t->GetBackend().GetTotalCompressedSize(t->GetManager()); |
212 | 1383 return OrthancPluginErrorCode_Success; |
1384 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1385 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1386 } |
1387 | |
1388 | |
1389 static OrthancPluginErrorCode GetTotalUncompressedSize(OrthancPluginDatabaseTransaction* transaction, | |
1390 uint64_t* target /* out */) | |
1391 { | |
1392 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1393 | |
1394 try | |
1395 { | |
1396 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1397 *target = t->GetBackend().GetTotalUncompressedSize(t->GetManager()); |
212 | 1398 return OrthancPluginErrorCode_Success; |
1399 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1400 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1401 } |
1402 | |
1403 | |
1404 static OrthancPluginErrorCode IsDiskSizeAbove(OrthancPluginDatabaseTransaction* transaction, | |
1405 uint8_t* target, | |
1406 uint64_t threshold) | |
1407 { | |
1408 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1409 | |
1410 try | |
1411 { | |
1412 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1413 bool above = (t->GetBackend().GetTotalCompressedSize(t->GetManager()) >= threshold); |
212 | 1414 *target = (above ? 1 : 0); |
1415 return OrthancPluginErrorCode_Success; | |
1416 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1417 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1418 } |
1419 | |
1420 | |
1421 static OrthancPluginErrorCode IsExistingResource(OrthancPluginDatabaseTransaction* transaction, | |
1422 uint8_t* target, | |
1423 int64_t resourceId) | |
1424 { | |
1425 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1426 | |
1427 try | |
1428 { | |
1429 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1430 bool exists = t->GetBackend().IsExistingResource(t->GetManager(), resourceId); |
212 | 1431 *target = (exists ? 1 : 0); |
1432 return OrthancPluginErrorCode_Success; | |
1433 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1434 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1435 } |
1436 | |
1437 | |
1438 static OrthancPluginErrorCode IsProtectedPatient(OrthancPluginDatabaseTransaction* transaction, | |
1439 uint8_t* target, | |
1440 int64_t resourceId) | |
1441 { | |
1442 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1443 | |
1444 try | |
1445 { | |
1446 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1447 bool isProtected = t->GetBackend().IsProtectedPatient(t->GetManager(), resourceId); |
212 | 1448 *target = (isProtected ? 1 : 0); |
1449 return OrthancPluginErrorCode_Success; | |
1450 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1451 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1452 } |
1453 | |
1454 | |
1455 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseTransaction* transaction, | |
1456 int64_t resourceId) | |
1457 { | |
1458 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1459 | |
1460 try | |
1461 { | |
1462 t->GetOutput().Clear(); | |
1463 | |
1464 std::list<int32_t> values; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1465 t->GetBackend().ListAvailableAttachments(values, t->GetManager(), resourceId); |
212 | 1466 t->GetOutput().AnswerIntegers32(values); |
1467 return OrthancPluginErrorCode_Success; | |
1468 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1469 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1470 } |
1471 | |
1472 | |
1473 static OrthancPluginErrorCode LogChange(OrthancPluginDatabaseTransaction* transaction, | |
1474 int32_t changeType, | |
1475 int64_t resourceId, | |
1476 OrthancPluginResourceType resourceType, | |
1477 const char* date) | |
1478 { | |
1479 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1480 | |
1481 try | |
1482 { | |
1483 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1484 t->GetBackend().LogChange(t->GetManager(), changeType, resourceId, resourceType, date); |
212 | 1485 return OrthancPluginErrorCode_Success; |
1486 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1487 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1488 } |
1489 | |
1490 | |
1491 static OrthancPluginErrorCode LogExportedResource(OrthancPluginDatabaseTransaction* transaction, | |
1492 OrthancPluginResourceType resourceType, | |
1493 const char* publicId, | |
1494 const char* modality, | |
1495 const char* date, | |
1496 const char* patientId, | |
1497 const char* studyInstanceUid, | |
1498 const char* seriesInstanceUid, | |
1499 const char* sopInstanceUid) | |
1500 { | |
1501 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1502 | |
1503 try | |
1504 { | |
1505 t->GetOutput().Clear(); | |
378
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
1506 t->GetBackend().LogExportedResource(t->GetManager(), resourceType, publicId, modality, date, |
9db9e0275ec0
refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
374
diff
changeset
|
1507 patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid); |
212 | 1508 return OrthancPluginErrorCode_Success; |
1509 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1510 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1511 } |
1512 | |
1513 | |
1514 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseTransaction* transaction, | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1515 int64_t* revision /* out */, |
212 | 1516 int64_t resourceId, |
1517 int32_t contentType) | |
1518 { | |
1519 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1520 | |
1521 try | |
1522 { | |
1523 t->GetOutput().Clear(); | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1524 t->GetBackend().LookupAttachment(t->GetOutput(), *revision, t->GetManager(), resourceId, contentType); |
212 | 1525 return OrthancPluginErrorCode_Success; |
1526 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1527 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1528 } |
1529 | |
1530 | |
1531 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
|
1532 const char* serverIdentifier, |
212 | 1533 int32_t property) |
1534 { | |
1535 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1536 | |
1537 try | |
1538 { | |
1539 t->GetOutput().Clear(); | |
1540 | |
1541 std::string s; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1542 if (t->GetBackend().LookupGlobalProperty(s, t->GetManager(), serverIdentifier, property)) |
212 | 1543 { |
1544 t->GetOutput().AnswerString(s); | |
1545 } | |
1546 | |
1547 return OrthancPluginErrorCode_Success; | |
1548 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1549 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1550 } |
1551 | |
1552 | |
1553 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseTransaction* transaction, | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1554 int64_t* revision /* out */, |
212 | 1555 int64_t id, |
1556 int32_t metadata) | |
1557 { | |
1558 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1559 | |
1560 try | |
1561 { | |
1562 t->GetOutput().Clear(); | |
1563 | |
1564 std::string s; | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1565 if (t->GetBackend().LookupMetadata(s, *revision, t->GetManager(), id, metadata)) |
212 | 1566 { |
1567 t->GetOutput().AnswerString(s); | |
1568 } | |
1569 | |
1570 return OrthancPluginErrorCode_Success; | |
1571 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1572 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1573 } |
1574 | |
1575 | |
1576 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
|
1577 uint8_t* existing /* out */, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1578 int64_t* parentId /* out */, |
212 | 1579 int64_t id) |
1580 { | |
1581 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1582 | |
1583 try | |
1584 { | |
1585 t->GetOutput().Clear(); | |
1586 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1587 if (t->GetBackend().LookupParent(*parentId, t->GetManager(), id)) |
212 | 1588 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1589 *existing = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1590 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1591 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1592 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1593 *existing = 0; |
212 | 1594 } |
1595 | |
1596 return OrthancPluginErrorCode_Success; | |
1597 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1598 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1599 } |
1600 | |
1601 | |
1602 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseTransaction* transaction, | |
1603 uint8_t* isExisting /* out */, | |
1604 int64_t* id /* out */, | |
1605 OrthancPluginResourceType* type /* out */, | |
1606 const char* publicId) | |
1607 { | |
1608 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1609 | |
1610 try | |
1611 { | |
1612 t->GetOutput().Clear(); | |
1613 | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1614 if (t->GetBackend().LookupResource(*id, *type, t->GetManager(), publicId)) |
212 | 1615 { |
1616 *isExisting = 1; | |
1617 } | |
1618 else | |
1619 { | |
1620 *isExisting = 0; | |
1621 } | |
1622 | |
1623 return OrthancPluginErrorCode_Success; | |
1624 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1625 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1626 } |
1627 | |
1628 | |
1629 static OrthancPluginErrorCode LookupResources(OrthancPluginDatabaseTransaction* transaction, | |
1630 uint32_t constraintsCount, | |
1631 const OrthancPluginDatabaseConstraint* constraints, | |
1632 OrthancPluginResourceType queryLevel, | |
1633 uint32_t limit, | |
1634 uint8_t requestSomeInstanceId) | |
1635 { | |
1636 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1637 | |
1638 try | |
1639 { | |
1640 t->GetOutput().Clear(); | |
1641 | |
1642 std::vector<Orthanc::DatabaseConstraint> lookup; | |
1643 lookup.reserve(constraintsCount); | |
1644 | |
1645 for (uint32_t i = 0; i < constraintsCount; i++) | |
1646 { | |
1647 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); | |
1648 } | |
1649 | |
401
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
1650 std::set<std::string> noLabel; |
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
1651 t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, noLabel, |
a8774581adfc
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
391
diff
changeset
|
1652 Orthanc::LabelsConstraint_All, limit, (requestSomeInstanceId != 0)); |
212 | 1653 return OrthancPluginErrorCode_Success; |
1654 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1655 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1656 } |
1657 | |
1658 | |
1659 static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseTransaction* transaction, | |
1660 uint8_t* isExisting /* out */, | |
1661 int64_t* id /* out */, | |
1662 OrthancPluginResourceType* type /* out */, | |
1663 const char* publicId) | |
1664 { | |
1665 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1666 | |
1667 try | |
1668 { | |
1669 t->GetOutput().Clear(); | |
1670 | |
1671 std::string parent; | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1672 if (t->GetBackend().LookupResourceAndParent(*id, *type, parent, t->GetManager(), publicId)) |
212 | 1673 { |
1674 *isExisting = 1; | |
1675 | |
1676 if (!parent.empty()) | |
1677 { | |
1678 t->GetOutput().AnswerString(parent); | |
1679 } | |
1680 } | |
1681 else | |
1682 { | |
1683 *isExisting = 0; | |
1684 } | |
1685 | |
1686 return OrthancPluginErrorCode_Success; | |
1687 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1688 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1689 } |
1690 | |
1691 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1692 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseTransaction* transaction, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1693 uint8_t* patientAvailable, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1694 int64_t* patientId) |
212 | 1695 { |
1696 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1697 | |
1698 try | |
1699 { | |
1700 t->GetOutput().Clear(); | |
1701 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1702 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager())) |
212 | 1703 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1704 *patientAvailable = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1705 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1706 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1707 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1708 *patientAvailable = 0; |
212 | 1709 } |
1710 | |
1711 return OrthancPluginErrorCode_Success; | |
1712 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1713 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1714 } |
1715 | |
1716 | |
1717 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
|
1718 uint8_t* patientAvailable, |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1719 int64_t* patientId, |
212 | 1720 int64_t patientIdToAvoid) |
1721 { | |
1722 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1723 | |
1724 try | |
1725 { | |
1726 t->GetOutput().Clear(); | |
1727 | |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1728 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager(), patientIdToAvoid)) |
212 | 1729 { |
251
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1730 *patientAvailable = 1; |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1731 } |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1732 else |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1733 { |
ed12248ad791
implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
237
diff
changeset
|
1734 *patientAvailable = 0; |
212 | 1735 } |
1736 | |
1737 return OrthancPluginErrorCode_Success; | |
1738 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1739 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1740 } |
1741 | |
1742 | |
1743 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
|
1744 const char* serverIdentifier, |
212 | 1745 int32_t property, |
1746 const char* value) | |
1747 { | |
1748 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1749 | |
1750 try | |
1751 { | |
1752 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1753 t->GetBackend().SetGlobalProperty(t->GetManager(), serverIdentifier, property, value); |
212 | 1754 return OrthancPluginErrorCode_Success; |
1755 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1756 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1757 } |
1758 | |
1759 | |
1760 static OrthancPluginErrorCode SetMetadata(OrthancPluginDatabaseTransaction* transaction, | |
1761 int64_t id, | |
1762 int32_t metadata, | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1763 const char* value, |
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1764 int64_t revision) |
212 | 1765 { |
1766 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1767 | |
1768 try | |
1769 { | |
1770 t->GetOutput().Clear(); | |
256
e184dcadf163
handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
255
diff
changeset
|
1771 t->GetBackend().SetMetadata(t->GetManager(), id, metadata, value, revision); |
212 | 1772 return OrthancPluginErrorCode_Success; |
1773 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1774 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1775 } |
1776 | |
1777 | |
1778 static OrthancPluginErrorCode SetProtectedPatient(OrthancPluginDatabaseTransaction* transaction, | |
1779 int64_t id, | |
1780 uint8_t isProtected) | |
1781 { | |
1782 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1783 | |
1784 try | |
1785 { | |
1786 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1787 t->GetBackend().SetProtectedPatient(t->GetManager(), id, (isProtected != 0)); |
212 | 1788 return OrthancPluginErrorCode_Success; |
1789 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1790 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1791 } |
1792 | |
1793 | |
1794 static OrthancPluginErrorCode SetResourcesContent(OrthancPluginDatabaseTransaction* transaction, | |
1795 uint32_t countIdentifierTags, | |
1796 const OrthancPluginResourcesContentTags* identifierTags, | |
1797 uint32_t countMainDicomTags, | |
1798 const OrthancPluginResourcesContentTags* mainDicomTags, | |
1799 uint32_t countMetadata, | |
1800 const OrthancPluginResourcesContentMetadata* metadata) | |
1801 { | |
1802 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction); | |
1803 | |
1804 try | |
1805 { | |
1806 t->GetOutput().Clear(); | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1807 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
|
1808 countMainDicomTags, mainDicomTags, countMetadata, metadata); |
212 | 1809 return OrthancPluginErrorCode_Success; |
1810 } | |
225
94c9908e6aca
removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
223
diff
changeset
|
1811 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext()); |
212 | 1812 } |
1813 | |
1814 | |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1815 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
|
1816 size_t countConnections, |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1817 unsigned int maxDatabaseRetries) |
212 | 1818 { |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1819 std::unique_ptr<IndexBackend> protection(backend); |
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1820 |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1821 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1822 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1823 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1824 } |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1825 |
222
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1826 if (backend == NULL) |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1827 { |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1828 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1829 } |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1830 |
212 | 1831 OrthancPluginDatabaseBackendV3 params; |
1832 memset(¶ms, 0, sizeof(params)); | |
1833 | |
1834 params.readAnswersCount = ReadAnswersCount; | |
1835 params.readAnswerAttachment = ReadAnswerAttachment; | |
1836 params.readAnswerChange = ReadAnswerChange; | |
1837 params.readAnswerDicomTag = ReadAnswerDicomTag; | |
1838 params.readAnswerExportedResource = ReadAnswerExportedResource; | |
1839 params.readAnswerInt32 = ReadAnswerInt32; | |
1840 params.readAnswerInt64 = ReadAnswerInt64; | |
1841 params.readAnswerMatchingResource = ReadAnswerMatchingResource; | |
1842 params.readAnswerMetadata = ReadAnswerMetadata; | |
1843 params.readAnswerString = ReadAnswerString; | |
1844 | |
1845 params.readEventsCount = ReadEventsCount; | |
1846 params.readEvent = ReadEvent; | |
1847 | |
1848 params.open = Open; | |
1849 params.close = Close; | |
1850 params.destructDatabase = DestructDatabase; | |
1851 params.getDatabaseVersion = GetDatabaseVersion; | |
1852 params.upgradeDatabase = UpgradeDatabase; | |
264
7ec412af11cb
implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
262
diff
changeset
|
1853 params.hasRevisionsSupport = HasRevisionsSupport; |
212 | 1854 params.startTransaction = StartTransaction; |
1855 params.destructTransaction = DestructTransaction; | |
1856 params.rollback = Rollback; | |
1857 params.commit = Commit; | |
1858 | |
262
b0c65094b299
adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
261
diff
changeset
|
1859 params.addAttachment = AddAttachment; |
212 | 1860 params.clearChanges = ClearChanges; |
1861 params.clearExportedResources = ClearExportedResources; | |
1862 params.clearMainDicomTags = ClearMainDicomTags; | |
1863 params.createInstance = CreateInstance; | |
1864 params.deleteAttachment = DeleteAttachment; | |
1865 params.deleteMetadata = DeleteMetadata; | |
1866 params.deleteResource = DeleteResource; | |
1867 params.getAllMetadata = GetAllMetadata; | |
1868 params.getAllPublicIds = GetAllPublicIds; | |
1869 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1870 params.getChanges = GetChanges; | |
1871 params.getChildrenInternalId = GetChildrenInternalId; | |
1872 params.getChildrenMetadata = GetChildrenMetadata; | |
1873 params.getChildrenPublicId = GetChildrenPublicId; | |
1874 params.getExportedResources = GetExportedResources; | |
1875 params.getLastChange = GetLastChange; | |
1876 params.getLastChangeIndex = GetLastChangeIndex; | |
1877 params.getLastExportedResource = GetLastExportedResource; | |
1878 params.getMainDicomTags = GetMainDicomTags; | |
1879 params.getPublicId = GetPublicId; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1880 params.getResourceType = GetResourceType; |
212 | 1881 params.getResourcesCount = GetResourcesCount; |
1882 params.getTotalCompressedSize = GetTotalCompressedSize; | |
1883 params.getTotalUncompressedSize = GetTotalUncompressedSize; | |
1884 params.isDiskSizeAbove = IsDiskSizeAbove; | |
1885 params.isExistingResource = IsExistingResource; | |
1886 params.isProtectedPatient = IsProtectedPatient; | |
1887 params.listAvailableAttachments = ListAvailableAttachments; | |
1888 params.logChange = LogChange; | |
1889 params.logExportedResource = LogExportedResource; | |
1890 params.lookupAttachment = LookupAttachment; | |
1891 params.lookupGlobalProperty = LookupGlobalProperty; | |
1892 params.lookupMetadata = LookupMetadata; | |
1893 params.lookupParent = LookupParent; | |
1894 params.lookupResource = LookupResource; | |
261
34e2b93a7ac1
implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
260
diff
changeset
|
1895 params.lookupResourceAndParent = LookupResourceAndParent; |
212 | 1896 params.lookupResources = LookupResources; |
1897 params.selectPatientToRecycle = SelectPatientToRecycle; | |
1898 params.selectPatientToRecycle2 = SelectPatientToRecycle2; | |
1899 params.setGlobalProperty = SetGlobalProperty; | |
1900 params.setMetadata = SetMetadata; | |
1901 params.setProtectedPatient = SetProtectedPatient; | |
1902 params.setResourcesContent = SetResourcesContent; | |
1903 | |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1904 OrthancPluginContext* context = protection->GetContext(); |
212 | 1905 |
234
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1906 if (OrthancPluginRegisterDatabaseBackendV3( |
d1b124d116c1
PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1907 context, ¶ms, sizeof(params), maxDatabaseRetries, |
374
4a3985088723
moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
373
diff
changeset
|
1908 new IndexConnectionsPool(protection.release(), countConnections)) != OrthancPluginErrorCode_Success) |
212 | 1909 { |
373
be7de633695c
started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
359
diff
changeset
|
1910 delete backend; |
212 | 1911 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend"); |
1912 } | |
1913 | |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1914 backend->SetOutputFactory(new Factory); |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1915 |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1916 isBackendInUse_ = true; |
222
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 |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1920 void DatabaseBackendAdapterV3::Finalize() |
c8e06b41feec
refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
221
diff
changeset
|
1921 { |
223
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1922 if (isBackendInUse_) |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1923 { |
af049cd66661
removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
222
diff
changeset
|
1924 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
|
1925 } |
212 | 1926 } |
1927 } | |
1928 | |
1929 # endif | |
1930 #endif |