Mercurial > hg > orthanc-databases
annotate Framework/Plugins/OrthancCppDatabasePlugin.h @ 204:7299410c3d61
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Mar 2021 18:22:30 +0100 |
parents | 2089d4071408 |
children |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
193
3236894320d6
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
152
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 | |
23 /** | |
24 * NOTE: Until Orthanc 1.4.0, this file was part of the Orthanc source | |
25 * distribution. This file is now part of "orthanc-databases", in | |
26 * order to uncouple its evolution from the Orthanc core. | |
27 **/ | |
28 | |
29 #pragma once | |
30 | |
202 | 31 #include "IDatabaseBackend.h" |
152 | 32 |
33 #include <OrthancException.h> | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
34 |
0 | 35 |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
36 |
200 | 37 #define ORTHANC_PLUGINS_DATABASE_CATCH \ |
38 catch (::Orthanc::OrthancException& e) \ | |
39 { \ | |
40 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \ | |
41 } \ | |
42 catch (::std::runtime_error& e) \ | |
43 { \ | |
44 LogError(backend, e); \ | |
45 return OrthancPluginErrorCode_DatabasePlugin; \ | |
46 } \ | |
47 catch (...) \ | |
48 { \ | |
199 | 49 OrthancPluginLogError(backend->GetContext(), "Native exception"); \ |
200 | 50 return OrthancPluginErrorCode_DatabasePlugin; \ |
0 | 51 } |
52 | |
53 | |
54 #include <stdexcept> | |
55 #include <list> | |
56 #include <string> | |
57 | |
204 | 58 |
203
2089d4071408
moving classes out of OrthancPlugins namespace, to OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
202
diff
changeset
|
59 namespace OrthancDatabases |
204 | 60 { |
0 | 61 /** |
62 * @brief Bridge between C and C++ database engines. | |
63 * | |
64 * Class creating the bridge between the C low-level primitives for | |
65 * custom database engines, and the high-level IDatabaseBackend C++ | |
204 | 66 * interface, for Orthanc <= 1.9.1. |
0 | 67 * |
68 * @ingroup Callbacks | |
69 **/ | |
200 | 70 class DatabaseBackendAdapterV2 |
0 | 71 { |
72 private: | |
204 | 73 class Output : public IDatabaseBackendOutput |
74 { | |
75 public: | |
76 enum AllowedAnswers | |
77 { | |
78 AllowedAnswers_All, | |
79 AllowedAnswers_None, | |
80 AllowedAnswers_Attachment, | |
81 AllowedAnswers_Change, | |
82 AllowedAnswers_DicomTag, | |
83 AllowedAnswers_ExportedResource, | |
84 AllowedAnswers_MatchingResource, | |
85 AllowedAnswers_String, | |
86 AllowedAnswers_Metadata | |
87 }; | |
88 | |
89 private: | |
90 OrthancPluginContext* context_; | |
91 OrthancPluginDatabaseContext* database_; | |
92 AllowedAnswers allowedAnswers_; | |
93 | |
94 public: | |
95 Output(OrthancPluginContext* context, | |
96 OrthancPluginDatabaseContext* database) : | |
97 context_(context), | |
98 database_(database), | |
99 allowedAnswers_(AllowedAnswers_All /* for unit tests */) | |
100 { | |
101 } | |
102 | |
103 void SetAllowedAnswers(AllowedAnswers allowed) | |
104 { | |
105 allowedAnswers_ = allowed; | |
106 } | |
107 | |
108 OrthancPluginDatabaseContext* GetDatabase() const | |
109 { | |
110 return database_; | |
111 } | |
112 | |
113 virtual void SignalDeletedAttachment(const std::string& uuid, | |
114 int32_t contentType, | |
115 uint64_t uncompressedSize, | |
116 const std::string& uncompressedHash, | |
117 int32_t compressionType, | |
118 uint64_t compressedSize, | |
119 const std::string& compressedHash) ORTHANC_OVERRIDE | |
120 { | |
121 OrthancPluginAttachment attachment; | |
122 attachment.uuid = uuid.c_str(); | |
123 attachment.contentType = contentType; | |
124 attachment.uncompressedSize = uncompressedSize; | |
125 attachment.uncompressedHash = uncompressedHash.c_str(); | |
126 attachment.compressionType = compressionType; | |
127 attachment.compressedSize = compressedSize; | |
128 attachment.compressedHash = compressedHash.c_str(); | |
129 | |
130 OrthancPluginDatabaseSignalDeletedAttachment(context_, database_, &attachment); | |
131 } | |
132 | |
133 virtual void SignalDeletedResource(const std::string& publicId, | |
134 OrthancPluginResourceType resourceType) ORTHANC_OVERRIDE | |
135 { | |
136 OrthancPluginDatabaseSignalDeletedResource(context_, database_, publicId.c_str(), resourceType); | |
137 } | |
138 | |
139 virtual void SignalRemainingAncestor(const std::string& ancestorId, | |
140 OrthancPluginResourceType ancestorType) ORTHANC_OVERRIDE | |
141 { | |
142 OrthancPluginDatabaseSignalRemainingAncestor(context_, database_, ancestorId.c_str(), ancestorType); | |
143 } | |
144 | |
145 virtual void AnswerAttachment(const std::string& uuid, | |
146 int32_t contentType, | |
147 uint64_t uncompressedSize, | |
148 const std::string& uncompressedHash, | |
149 int32_t compressionType, | |
150 uint64_t compressedSize, | |
151 const std::string& compressedHash) ORTHANC_OVERRIDE | |
152 { | |
153 if (allowedAnswers_ != AllowedAnswers_All && | |
154 allowedAnswers_ != AllowedAnswers_Attachment) | |
155 { | |
156 throw std::runtime_error("Cannot answer with an attachment in the current state"); | |
157 } | |
158 | |
159 OrthancPluginAttachment attachment; | |
160 attachment.uuid = uuid.c_str(); | |
161 attachment.contentType = contentType; | |
162 attachment.uncompressedSize = uncompressedSize; | |
163 attachment.uncompressedHash = uncompressedHash.c_str(); | |
164 attachment.compressionType = compressionType; | |
165 attachment.compressedSize = compressedSize; | |
166 attachment.compressedHash = compressedHash.c_str(); | |
167 | |
168 OrthancPluginDatabaseAnswerAttachment(context_, database_, &attachment); | |
169 } | |
170 | |
171 virtual void AnswerChange(int64_t seq, | |
172 int32_t changeType, | |
173 OrthancPluginResourceType resourceType, | |
174 const std::string& publicId, | |
175 const std::string& date) ORTHANC_OVERRIDE | |
176 { | |
177 if (allowedAnswers_ != AllowedAnswers_All && | |
178 allowedAnswers_ != AllowedAnswers_Change) | |
179 { | |
180 throw std::runtime_error("Cannot answer with a change in the current state"); | |
181 } | |
182 | |
183 OrthancPluginChange change; | |
184 change.seq = seq; | |
185 change.changeType = changeType; | |
186 change.resourceType = resourceType; | |
187 change.publicId = publicId.c_str(); | |
188 change.date = date.c_str(); | |
189 | |
190 OrthancPluginDatabaseAnswerChange(context_, database_, &change); | |
191 } | |
192 | |
193 virtual void AnswerDicomTag(uint16_t group, | |
194 uint16_t element, | |
195 const std::string& value) ORTHANC_OVERRIDE | |
196 { | |
197 if (allowedAnswers_ != AllowedAnswers_All && | |
198 allowedAnswers_ != AllowedAnswers_DicomTag) | |
199 { | |
200 throw std::runtime_error("Cannot answer with a DICOM tag in the current state"); | |
201 } | |
202 | |
203 OrthancPluginDicomTag tag; | |
204 tag.group = group; | |
205 tag.element = element; | |
206 tag.value = value.c_str(); | |
207 | |
208 OrthancPluginDatabaseAnswerDicomTag(context_, database_, &tag); | |
209 } | |
210 | |
211 virtual void AnswerExportedResource(int64_t seq, | |
212 OrthancPluginResourceType resourceType, | |
213 const std::string& publicId, | |
214 const std::string& modality, | |
215 const std::string& date, | |
216 const std::string& patientId, | |
217 const std::string& studyInstanceUid, | |
218 const std::string& seriesInstanceUid, | |
219 const std::string& sopInstanceUid) ORTHANC_OVERRIDE | |
220 { | |
221 if (allowedAnswers_ != AllowedAnswers_All && | |
222 allowedAnswers_ != AllowedAnswers_ExportedResource) | |
223 { | |
224 throw std::runtime_error("Cannot answer with an exported resource in the current state"); | |
225 } | |
226 | |
227 OrthancPluginExportedResource exported; | |
228 exported.seq = seq; | |
229 exported.resourceType = resourceType; | |
230 exported.publicId = publicId.c_str(); | |
231 exported.modality = modality.c_str(); | |
232 exported.date = date.c_str(); | |
233 exported.patientId = patientId.c_str(); | |
234 exported.studyInstanceUid = studyInstanceUid.c_str(); | |
235 exported.seriesInstanceUid = seriesInstanceUid.c_str(); | |
236 exported.sopInstanceUid = sopInstanceUid.c_str(); | |
237 | |
238 OrthancPluginDatabaseAnswerExportedResource(context_, database_, &exported); | |
239 } | |
240 | |
241 | |
242 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | |
243 virtual void AnswerMatchingResource(const std::string& resourceId) ORTHANC_OVERRIDE | |
244 { | |
245 if (allowedAnswers_ != AllowedAnswers_All && | |
246 allowedAnswers_ != AllowedAnswers_MatchingResource) | |
247 { | |
248 throw std::runtime_error("Cannot answer with an exported resource in the current state"); | |
249 } | |
250 | |
251 OrthancPluginMatchingResource match; | |
252 match.resourceId = resourceId.c_str(); | |
253 match.someInstanceId = NULL; | |
254 | |
255 OrthancPluginDatabaseAnswerMatchingResource(context_, database_, &match); | |
256 } | |
257 #endif | |
258 | |
259 | |
260 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | |
261 virtual void AnswerMatchingResource(const std::string& resourceId, | |
262 const std::string& someInstanceId) ORTHANC_OVERRIDE | |
263 { | |
264 if (allowedAnswers_ != AllowedAnswers_All && | |
265 allowedAnswers_ != AllowedAnswers_MatchingResource) | |
266 { | |
267 throw std::runtime_error("Cannot answer with an exported resource in the current state"); | |
268 } | |
269 | |
270 OrthancPluginMatchingResource match; | |
271 match.resourceId = resourceId.c_str(); | |
272 match.someInstanceId = someInstanceId.c_str(); | |
273 | |
274 OrthancPluginDatabaseAnswerMatchingResource(context_, database_, &match); | |
275 } | |
276 #endif | |
277 }; | |
278 | |
279 | |
0 | 280 // This class cannot be instantiated |
200 | 281 DatabaseBackendAdapterV2() |
0 | 282 { |
283 } | |
284 | |
285 static void LogError(IDatabaseBackend* backend, | |
286 const std::runtime_error& e) | |
287 { | |
198 | 288 const std::string message = "Exception in database back-end: " + std::string(e.what()); |
199 | 289 OrthancPluginLogError(backend->GetContext(), message.c_str()); |
0 | 290 } |
291 | |
292 | |
293 static OrthancPluginErrorCode AddAttachment(void* payload, | |
294 int64_t id, | |
295 const OrthancPluginAttachment* attachment) | |
296 { | |
297 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
298 | |
299 try | |
300 { | |
301 backend->AddAttachment(id, *attachment); | |
302 return OrthancPluginErrorCode_Success; | |
303 } | |
200 | 304 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 305 } |
306 | |
307 | |
308 static OrthancPluginErrorCode AttachChild(void* payload, | |
309 int64_t parent, | |
310 int64_t child) | |
311 { | |
312 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
313 | |
314 try | |
315 { | |
316 backend->AttachChild(parent, child); | |
317 return OrthancPluginErrorCode_Success; | |
318 } | |
200 | 319 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 320 } |
321 | |
322 | |
323 static OrthancPluginErrorCode ClearChanges(void* payload) | |
324 { | |
325 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
326 | |
327 try | |
328 { | |
329 backend->ClearChanges(); | |
330 return OrthancPluginErrorCode_Success; | |
331 } | |
200 | 332 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 333 } |
334 | |
335 | |
336 static OrthancPluginErrorCode ClearExportedResources(void* payload) | |
337 { | |
338 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
339 | |
340 try | |
341 { | |
342 backend->ClearExportedResources(); | |
343 return OrthancPluginErrorCode_Success; | |
344 } | |
200 | 345 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 346 } |
347 | |
348 | |
349 static OrthancPluginErrorCode CreateResource(int64_t* id, | |
350 void* payload, | |
351 const char* publicId, | |
352 OrthancPluginResourceType resourceType) | |
353 { | |
354 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
355 | |
356 try | |
357 { | |
358 *id = backend->CreateResource(publicId, resourceType); | |
359 return OrthancPluginErrorCode_Success; | |
360 } | |
200 | 361 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 362 } |
363 | |
364 | |
365 static OrthancPluginErrorCode DeleteAttachment(void* payload, | |
366 int64_t id, | |
367 int32_t contentType) | |
368 { | |
369 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 370 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
371 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 372 |
373 try | |
374 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
375 backend->DeleteAttachment(*output, id, contentType); |
0 | 376 return OrthancPluginErrorCode_Success; |
377 } | |
200 | 378 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 379 } |
380 | |
381 | |
382 static OrthancPluginErrorCode DeleteMetadata(void* payload, | |
383 int64_t id, | |
384 int32_t metadataType) | |
385 { | |
386 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
387 | |
388 try | |
389 { | |
390 backend->DeleteMetadata(id, metadataType); | |
391 return OrthancPluginErrorCode_Success; | |
392 } | |
200 | 393 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 394 } |
395 | |
396 | |
397 static OrthancPluginErrorCode DeleteResource(void* payload, | |
398 int64_t id) | |
399 { | |
400 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 401 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
402 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 403 |
404 try | |
405 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
406 backend->DeleteResource(*output, id); |
0 | 407 return OrthancPluginErrorCode_Success; |
408 } | |
200 | 409 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 410 } |
411 | |
412 | |
413 static OrthancPluginErrorCode GetAllInternalIds(OrthancPluginDatabaseContext* context, | |
414 void* payload, | |
415 OrthancPluginResourceType resourceType) | |
416 { | |
417 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 418 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
419 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 420 |
421 try | |
422 { | |
423 std::list<int64_t> target; | |
424 backend->GetAllInternalIds(target, resourceType); | |
425 | |
426 for (std::list<int64_t>::const_iterator | |
427 it = target.begin(); it != target.end(); ++it) | |
428 { | |
199 | 429 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
430 output->GetDatabase(), *it); |
0 | 431 } |
432 | |
433 return OrthancPluginErrorCode_Success; | |
434 } | |
200 | 435 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 436 } |
437 | |
438 | |
439 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseContext* context, | |
440 void* payload, | |
441 OrthancPluginResourceType resourceType) | |
442 { | |
443 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 444 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
445 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 446 |
447 try | |
448 { | |
449 std::list<std::string> ids; | |
450 backend->GetAllPublicIds(ids, resourceType); | |
451 | |
452 for (std::list<std::string>::const_iterator | |
453 it = ids.begin(); it != ids.end(); ++it) | |
454 { | |
199 | 455 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
456 output->GetDatabase(), |
0 | 457 it->c_str()); |
458 } | |
459 | |
460 return OrthancPluginErrorCode_Success; | |
461 } | |
200 | 462 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 463 } |
464 | |
465 | |
466 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseContext* context, | |
467 void* payload, | |
468 OrthancPluginResourceType resourceType, | |
469 uint64_t since, | |
470 uint64_t limit) | |
471 { | |
472 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 473 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
474 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 475 |
476 try | |
477 { | |
478 std::list<std::string> ids; | |
479 backend->GetAllPublicIds(ids, resourceType, since, limit); | |
480 | |
481 for (std::list<std::string>::const_iterator | |
482 it = ids.begin(); it != ids.end(); ++it) | |
483 { | |
199 | 484 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
485 output->GetDatabase(), |
0 | 486 it->c_str()); |
487 } | |
488 | |
489 return OrthancPluginErrorCode_Success; | |
490 } | |
200 | 491 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 492 } |
493 | |
494 | |
495 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseContext* context, | |
496 void* payload, | |
497 int64_t since, | |
498 uint32_t maxResult) | |
499 { | |
500 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 501 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
502 output->SetAllowedAnswers(Output::AllowedAnswers_Change); | |
0 | 503 |
504 try | |
505 { | |
506 bool done; | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
507 backend->GetChanges(*output, done, since, maxResult); |
0 | 508 |
509 if (done) | |
510 { | |
199 | 511 OrthancPluginDatabaseAnswerChangesDone(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
512 output->GetDatabase()); |
0 | 513 } |
514 | |
515 return OrthancPluginErrorCode_Success; | |
516 } | |
200 | 517 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 518 } |
519 | |
520 | |
521 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseContext* context, | |
522 void* payload, | |
523 int64_t id) | |
524 { | |
525 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 526 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
527 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 528 |
529 try | |
530 { | |
531 std::list<int64_t> target; | |
532 backend->GetChildrenInternalId(target, id); | |
533 | |
534 for (std::list<int64_t>::const_iterator | |
535 it = target.begin(); it != target.end(); ++it) | |
536 { | |
199 | 537 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
538 output->GetDatabase(), *it); |
0 | 539 } |
540 | |
541 return OrthancPluginErrorCode_Success; | |
542 } | |
200 | 543 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 544 } |
545 | |
546 | |
547 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseContext* context, | |
548 void* payload, | |
549 int64_t id) | |
550 { | |
551 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 552 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
553 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 554 |
555 try | |
556 { | |
557 std::list<std::string> ids; | |
558 backend->GetChildrenPublicId(ids, id); | |
559 | |
560 for (std::list<std::string>::const_iterator | |
561 it = ids.begin(); it != ids.end(); ++it) | |
562 { | |
199 | 563 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
564 output->GetDatabase(), |
0 | 565 it->c_str()); |
566 } | |
567 | |
568 return OrthancPluginErrorCode_Success; | |
569 } | |
200 | 570 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 571 } |
572 | |
573 | |
574 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseContext* context, | |
575 void* payload, | |
576 int64_t since, | |
577 uint32_t maxResult) | |
578 { | |
579 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 580 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
581 output->SetAllowedAnswers(Output::AllowedAnswers_ExportedResource); | |
0 | 582 |
583 try | |
584 { | |
585 bool done; | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
586 backend->GetExportedResources(*output, done, since, maxResult); |
0 | 587 |
588 if (done) | |
589 { | |
199 | 590 OrthancPluginDatabaseAnswerExportedResourcesDone(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
591 output->GetDatabase()); |
0 | 592 } |
593 return OrthancPluginErrorCode_Success; | |
594 } | |
200 | 595 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 596 } |
597 | |
598 | |
599 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseContext* context, | |
600 void* payload) | |
601 { | |
602 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 603 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
604 output->SetAllowedAnswers(Output::AllowedAnswers_Change); | |
0 | 605 |
606 try | |
607 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
608 backend->GetLastChange(*output); |
0 | 609 return OrthancPluginErrorCode_Success; |
610 } | |
200 | 611 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 612 } |
613 | |
614 | |
615 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseContext* context, | |
616 void* payload) | |
617 { | |
618 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 619 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
620 output->SetAllowedAnswers(Output::AllowedAnswers_ExportedResource); | |
0 | 621 |
622 try | |
623 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
624 backend->GetLastExportedResource(*output); |
0 | 625 return OrthancPluginErrorCode_Success; |
626 } | |
200 | 627 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 628 } |
629 | |
630 | |
631 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseContext* context, | |
632 void* payload, | |
633 int64_t id) | |
634 { | |
635 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 636 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
637 output->SetAllowedAnswers(Output::AllowedAnswers_DicomTag); | |
0 | 638 |
639 try | |
640 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
641 backend->GetMainDicomTags(*output, id); |
0 | 642 return OrthancPluginErrorCode_Success; |
643 } | |
200 | 644 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 645 } |
646 | |
647 | |
648 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseContext* context, | |
649 void* payload, | |
650 int64_t id) | |
651 { | |
652 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 653 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
654 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 655 |
656 try | |
657 { | |
658 std::string s = backend->GetPublicId(id); | |
199 | 659 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
660 output->GetDatabase(), |
0 | 661 s.c_str()); |
662 | |
663 return OrthancPluginErrorCode_Success; | |
664 } | |
200 | 665 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 666 } |
667 | |
668 | |
669 static OrthancPluginErrorCode GetResourceCount(uint64_t* target, | |
670 void* payload, | |
671 OrthancPluginResourceType resourceType) | |
672 { | |
673 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
674 | |
675 try | |
676 { | |
677 *target = backend->GetResourceCount(resourceType); | |
678 return OrthancPluginErrorCode_Success; | |
679 } | |
200 | 680 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 681 } |
682 | |
683 | |
684 static OrthancPluginErrorCode GetResourceType(OrthancPluginResourceType* resourceType, | |
685 void* payload, | |
686 int64_t id) | |
687 { | |
688 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
689 | |
690 try | |
691 { | |
692 *resourceType = backend->GetResourceType(id); | |
693 return OrthancPluginErrorCode_Success; | |
694 } | |
200 | 695 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 696 } |
697 | |
698 | |
699 static OrthancPluginErrorCode GetTotalCompressedSize(uint64_t* target, | |
700 void* payload) | |
701 { | |
702 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
703 | |
704 try | |
705 { | |
706 *target = backend->GetTotalCompressedSize(); | |
707 return OrthancPluginErrorCode_Success; | |
708 } | |
200 | 709 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 710 } |
711 | |
712 | |
713 static OrthancPluginErrorCode GetTotalUncompressedSize(uint64_t* target, | |
714 void* payload) | |
715 { | |
716 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
717 | |
718 try | |
719 { | |
720 *target = backend->GetTotalUncompressedSize(); | |
721 return OrthancPluginErrorCode_Success; | |
722 } | |
200 | 723 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 724 } |
725 | |
726 | |
727 static OrthancPluginErrorCode IsExistingResource(int32_t* existing, | |
728 void* payload, | |
729 int64_t id) | |
730 { | |
731 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
732 | |
733 try | |
734 { | |
735 *existing = backend->IsExistingResource(id); | |
736 return OrthancPluginErrorCode_Success; | |
737 } | |
200 | 738 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 739 } |
740 | |
741 | |
742 static OrthancPluginErrorCode IsProtectedPatient(int32_t* isProtected, | |
743 void* payload, | |
744 int64_t id) | |
745 { | |
746 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
747 | |
748 try | |
749 { | |
750 *isProtected = backend->IsProtectedPatient(id); | |
751 return OrthancPluginErrorCode_Success; | |
752 } | |
200 | 753 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 754 } |
755 | |
756 | |
757 static OrthancPluginErrorCode ListAvailableMetadata(OrthancPluginDatabaseContext* context, | |
758 void* payload, | |
759 int64_t id) | |
760 { | |
761 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 762 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
763 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 764 |
765 try | |
766 { | |
767 std::list<int32_t> target; | |
768 backend->ListAvailableMetadata(target, id); | |
769 | |
770 for (std::list<int32_t>::const_iterator | |
771 it = target.begin(); it != target.end(); ++it) | |
772 { | |
199 | 773 OrthancPluginDatabaseAnswerInt32(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
774 output->GetDatabase(), |
0 | 775 *it); |
776 } | |
777 | |
778 return OrthancPluginErrorCode_Success; | |
779 } | |
200 | 780 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 781 } |
782 | |
783 | |
784 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseContext* context, | |
785 void* payload, | |
786 int64_t id) | |
787 { | |
788 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 789 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
790 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 791 |
792 try | |
793 { | |
794 std::list<int32_t> target; | |
795 backend->ListAvailableAttachments(target, id); | |
796 | |
797 for (std::list<int32_t>::const_iterator | |
798 it = target.begin(); it != target.end(); ++it) | |
799 { | |
199 | 800 OrthancPluginDatabaseAnswerInt32(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
801 output->GetDatabase(), |
0 | 802 *it); |
803 } | |
804 | |
805 return OrthancPluginErrorCode_Success; | |
806 } | |
200 | 807 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 808 } |
809 | |
810 | |
811 static OrthancPluginErrorCode LogChange(void* payload, | |
812 const OrthancPluginChange* change) | |
813 { | |
814 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
815 | |
816 try | |
817 { | |
818 backend->LogChange(*change); | |
819 return OrthancPluginErrorCode_Success; | |
820 } | |
200 | 821 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 822 } |
823 | |
824 | |
825 static OrthancPluginErrorCode LogExportedResource(void* payload, | |
826 const OrthancPluginExportedResource* exported) | |
827 { | |
828 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
829 | |
830 try | |
831 { | |
832 backend->LogExportedResource(*exported); | |
833 return OrthancPluginErrorCode_Success; | |
834 } | |
200 | 835 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 836 } |
837 | |
838 | |
839 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseContext* context, | |
840 void* payload, | |
841 int64_t id, | |
842 int32_t contentType) | |
843 { | |
844 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 845 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
846 output->SetAllowedAnswers(Output::AllowedAnswers_Attachment); | |
0 | 847 |
848 try | |
849 { | |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
850 backend->LookupAttachment(*output, id, contentType); |
0 | 851 return OrthancPluginErrorCode_Success; |
852 } | |
200 | 853 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 854 } |
855 | |
856 | |
857 static OrthancPluginErrorCode LookupGlobalProperty(OrthancPluginDatabaseContext* context, | |
858 void* payload, | |
859 int32_t property) | |
860 { | |
861 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 862 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
863 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 864 |
865 try | |
866 { | |
867 std::string s; | |
868 if (backend->LookupGlobalProperty(s, property)) | |
869 { | |
199 | 870 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
871 output->GetDatabase(), |
0 | 872 s.c_str()); |
873 } | |
874 | |
875 return OrthancPluginErrorCode_Success; | |
876 } | |
200 | 877 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 878 } |
879 | |
880 | |
881 static OrthancPluginErrorCode LookupIdentifier3(OrthancPluginDatabaseContext* context, | |
882 void* payload, | |
883 OrthancPluginResourceType resourceType, | |
884 const OrthancPluginDicomTag* tag, | |
885 OrthancPluginIdentifierConstraint constraint) | |
886 { | |
887 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 888 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
889 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 890 |
891 try | |
892 { | |
893 std::list<int64_t> target; | |
894 backend->LookupIdentifier(target, resourceType, tag->group, tag->element, constraint, tag->value); | |
895 | |
896 for (std::list<int64_t>::const_iterator | |
897 it = target.begin(); it != target.end(); ++it) | |
898 { | |
199 | 899 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
900 output->GetDatabase(), *it); |
0 | 901 } |
902 | |
903 return OrthancPluginErrorCode_Success; | |
904 } | |
200 | 905 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 906 } |
907 | |
908 | |
909 static OrthancPluginErrorCode LookupIdentifierRange(OrthancPluginDatabaseContext* context, | |
910 void* payload, | |
911 OrthancPluginResourceType resourceType, | |
912 uint16_t group, | |
913 uint16_t element, | |
914 const char* start, | |
915 const char* end) | |
916 { | |
917 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 918 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
919 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 920 |
921 try | |
922 { | |
923 std::list<int64_t> target; | |
924 backend->LookupIdentifierRange(target, resourceType, group, element, start, end); | |
925 | |
926 for (std::list<int64_t>::const_iterator | |
927 it = target.begin(); it != target.end(); ++it) | |
928 { | |
199 | 929 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
930 output->GetDatabase(), *it); |
0 | 931 } |
932 | |
933 return OrthancPluginErrorCode_Success; | |
934 } | |
200 | 935 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 936 } |
937 | |
938 | |
939 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseContext* context, | |
940 void* payload, | |
941 int64_t id, | |
942 int32_t metadata) | |
943 { | |
944 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 945 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
946 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 947 |
948 try | |
949 { | |
950 std::string s; | |
951 if (backend->LookupMetadata(s, id, metadata)) | |
952 { | |
199 | 953 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
954 output->GetDatabase(), s.c_str()); |
0 | 955 } |
956 | |
957 return OrthancPluginErrorCode_Success; | |
958 } | |
200 | 959 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 960 } |
961 | |
962 | |
963 static OrthancPluginErrorCode LookupParent(OrthancPluginDatabaseContext* context, | |
964 void* payload, | |
965 int64_t id) | |
966 { | |
967 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 968 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
969 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 970 |
971 try | |
972 { | |
973 int64_t parent; | |
974 if (backend->LookupParent(parent, id)) | |
975 { | |
199 | 976 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
977 output->GetDatabase(), parent); |
0 | 978 } |
979 | |
980 return OrthancPluginErrorCode_Success; | |
981 } | |
200 | 982 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 983 } |
984 | |
985 | |
986 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseContext* context, | |
987 void* payload, | |
988 const char* publicId) | |
989 { | |
990 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 991 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
992 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 993 |
994 try | |
995 { | |
996 int64_t id; | |
997 OrthancPluginResourceType type; | |
998 if (backend->LookupResource(id, type, publicId)) | |
999 { | |
199 | 1000 OrthancPluginDatabaseAnswerResource(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1001 output->GetDatabase(), |
0 | 1002 id, type); |
1003 } | |
1004 | |
1005 return OrthancPluginErrorCode_Success; | |
1006 } | |
200 | 1007 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1008 } |
1009 | |
1010 | |
1011 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseContext* context, | |
1012 void* payload) | |
1013 { | |
1014 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 1015 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1016 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 1017 |
1018 try | |
1019 { | |
1020 int64_t id; | |
1021 if (backend->SelectPatientToRecycle(id)) | |
1022 { | |
199 | 1023 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1024 output->GetDatabase(), id); |
0 | 1025 } |
1026 | |
1027 return OrthancPluginErrorCode_Success; | |
1028 } | |
200 | 1029 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1030 } |
1031 | |
1032 | |
1033 static OrthancPluginErrorCode SelectPatientToRecycle2(OrthancPluginDatabaseContext* context, | |
1034 void* payload, | |
1035 int64_t patientIdToAvoid) | |
1036 { | |
1037 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
204 | 1038 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1039 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
0 | 1040 |
1041 try | |
1042 { | |
1043 int64_t id; | |
1044 if (backend->SelectPatientToRecycle(id, patientIdToAvoid)) | |
1045 { | |
199 | 1046 OrthancPluginDatabaseAnswerInt64(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1047 output->GetDatabase(), id); |
0 | 1048 } |
1049 | |
1050 return OrthancPluginErrorCode_Success; | |
1051 } | |
200 | 1052 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1053 } |
1054 | |
1055 | |
1056 static OrthancPluginErrorCode SetGlobalProperty(void* payload, | |
1057 int32_t property, | |
1058 const char* value) | |
1059 { | |
1060 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1061 | |
1062 try | |
1063 { | |
1064 backend->SetGlobalProperty(property, value); | |
1065 return OrthancPluginErrorCode_Success; | |
1066 } | |
200 | 1067 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1068 } |
1069 | |
1070 | |
1071 static OrthancPluginErrorCode SetMainDicomTag(void* payload, | |
1072 int64_t id, | |
1073 const OrthancPluginDicomTag* tag) | |
1074 { | |
1075 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1076 | |
1077 try | |
1078 { | |
1079 backend->SetMainDicomTag(id, tag->group, tag->element, tag->value); | |
1080 return OrthancPluginErrorCode_Success; | |
1081 } | |
200 | 1082 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1083 } |
1084 | |
1085 | |
1086 static OrthancPluginErrorCode SetIdentifierTag(void* payload, | |
1087 int64_t id, | |
1088 const OrthancPluginDicomTag* tag) | |
1089 { | |
1090 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1091 | |
1092 try | |
1093 { | |
1094 backend->SetIdentifierTag(id, tag->group, tag->element, tag->value); | |
1095 return OrthancPluginErrorCode_Success; | |
1096 } | |
200 | 1097 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1098 } |
1099 | |
1100 | |
1101 static OrthancPluginErrorCode SetMetadata(void* payload, | |
1102 int64_t id, | |
1103 int32_t metadata, | |
1104 const char* value) | |
1105 { | |
1106 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1107 | |
1108 try | |
1109 { | |
1110 backend->SetMetadata(id, metadata, value); | |
1111 return OrthancPluginErrorCode_Success; | |
1112 } | |
200 | 1113 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1114 } |
1115 | |
1116 | |
1117 static OrthancPluginErrorCode SetProtectedPatient(void* payload, | |
1118 int64_t id, | |
1119 int32_t isProtected) | |
1120 { | |
1121 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1122 | |
1123 try | |
1124 { | |
1125 backend->SetProtectedPatient(id, (isProtected != 0)); | |
1126 return OrthancPluginErrorCode_Success; | |
1127 } | |
200 | 1128 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1129 } |
1130 | |
1131 | |
1132 static OrthancPluginErrorCode StartTransaction(void* payload) | |
1133 { | |
1134 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1135 | |
1136 try | |
1137 { | |
1138 backend->StartTransaction(); | |
1139 return OrthancPluginErrorCode_Success; | |
1140 } | |
200 | 1141 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1142 } |
1143 | |
1144 | |
1145 static OrthancPluginErrorCode RollbackTransaction(void* payload) | |
1146 { | |
1147 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1148 | |
1149 try | |
1150 { | |
1151 backend->RollbackTransaction(); | |
1152 return OrthancPluginErrorCode_Success; | |
1153 } | |
200 | 1154 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1155 } |
1156 | |
1157 | |
1158 static OrthancPluginErrorCode CommitTransaction(void* payload) | |
1159 { | |
1160 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1161 | |
1162 try | |
1163 { | |
1164 backend->CommitTransaction(); | |
1165 return OrthancPluginErrorCode_Success; | |
1166 } | |
200 | 1167 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1168 } |
1169 | |
1170 | |
1171 static OrthancPluginErrorCode Open(void* payload) | |
1172 { | |
1173 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1174 | |
1175 try | |
1176 { | |
1177 backend->Open(); | |
1178 return OrthancPluginErrorCode_Success; | |
1179 } | |
200 | 1180 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1181 } |
1182 | |
1183 | |
1184 static OrthancPluginErrorCode Close(void* payload) | |
1185 { | |
1186 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1187 | |
1188 try | |
1189 { | |
1190 backend->Close(); | |
1191 return OrthancPluginErrorCode_Success; | |
1192 } | |
200 | 1193 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1194 } |
1195 | |
1196 | |
1197 static OrthancPluginErrorCode GetDatabaseVersion(uint32_t* version, | |
1198 void* payload) | |
1199 { | |
1200 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1201 | |
1202 try | |
1203 { | |
1204 *version = backend->GetDatabaseVersion(); | |
1205 return OrthancPluginErrorCode_Success; | |
1206 } | |
200 | 1207 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1208 } |
1209 | |
1210 | |
1211 static OrthancPluginErrorCode UpgradeDatabase(void* payload, | |
1212 uint32_t targetVersion, | |
1213 OrthancPluginStorageArea* storageArea) | |
1214 { | |
1215 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1216 | |
1217 try | |
1218 { | |
1219 backend->UpgradeDatabase(targetVersion, storageArea); | |
1220 return OrthancPluginErrorCode_Success; | |
1221 } | |
200 | 1222 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1223 } |
1224 | |
1225 | |
1226 static OrthancPluginErrorCode ClearMainDicomTags(void* payload, | |
1227 int64_t internalId) | |
1228 { | |
1229 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1230 | |
1231 try | |
1232 { | |
1233 backend->ClearMainDicomTags(internalId); | |
1234 return OrthancPluginErrorCode_Success; | |
1235 } | |
200 | 1236 ORTHANC_PLUGINS_DATABASE_CATCH; |
0 | 1237 } |
1238 | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1239 |
78 | 1240 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1241 /* Use GetOutput().AnswerResource() */ |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1242 static OrthancPluginErrorCode LookupResources( |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1243 OrthancPluginDatabaseContext* context, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1244 void* payload, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1245 uint32_t constraintsCount, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1246 const OrthancPluginDatabaseConstraint* constraints, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1247 OrthancPluginResourceType queryLevel, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1248 uint32_t limit, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1249 uint8_t requestSomeInstance) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1250 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1251 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
204 | 1252 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1253 output->SetAllowedAnswers(Output::AllowedAnswers_MatchingResource); | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1254 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1255 try |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1256 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1257 std::vector<Orthanc::DatabaseConstraint> lookup; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1258 lookup.reserve(constraintsCount); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1259 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1260 for (uint32_t i = 0; i < constraintsCount; i++) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1261 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1262 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1263 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1264 |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1265 backend->LookupResources(*output, lookup, queryLevel, limit, (requestSomeInstance != 0)); |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1266 return OrthancPluginErrorCode_Success; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1267 } |
200 | 1268 ORTHANC_PLUGINS_DATABASE_CATCH; |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1269 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1270 #endif |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1271 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1272 |
78 | 1273 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
200 | 1274 static OrthancPluginErrorCode CreateInstance(OrthancPluginCreateInstanceResult* target, |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1275 void* payload, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1276 const char* hashPatient, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1277 const char* hashStudy, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1278 const char* hashSeries, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1279 const char* hashInstance) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1280 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1281 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1282 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1283 try |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1284 { |
200 | 1285 backend->CreateInstance(*target, hashPatient, hashStudy, hashSeries, hashInstance); |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1286 return OrthancPluginErrorCode_Success; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1287 } |
200 | 1288 ORTHANC_PLUGINS_DATABASE_CATCH; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1289 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1290 #endif |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1291 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1292 |
78 | 1293 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1294 static OrthancPluginErrorCode SetResourcesContent( |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1295 void* payload, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1296 uint32_t countIdentifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1297 const OrthancPluginResourcesContentTags* identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1298 uint32_t countMainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1299 const OrthancPluginResourcesContentTags* mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1300 uint32_t countMetadata, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1301 const OrthancPluginResourcesContentMetadata* metadata) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1302 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1303 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1304 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1305 try |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1306 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1307 backend->SetResourcesContent(countIdentifierTags, identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1308 countMainDicomTags, mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1309 countMetadata, metadata); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1310 return OrthancPluginErrorCode_Success; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1311 } |
200 | 1312 ORTHANC_PLUGINS_DATABASE_CATCH; |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1313 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1314 #endif |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1315 |
0 | 1316 |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1317 // New primitive since Orthanc 1.5.2 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1318 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseContext* context, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1319 void* payload, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1320 int64_t resourceId, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1321 int32_t metadata) |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1322 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1323 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
204 | 1324 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1325 output->SetAllowedAnswers(Output::AllowedAnswers_None); | |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1326 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1327 try |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1328 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1329 std::list<std::string> values; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1330 backend->GetChildrenMetadata(values, resourceId, metadata); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1331 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1332 for (std::list<std::string>::const_iterator |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1333 it = values.begin(); it != values.end(); ++it) |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1334 { |
199 | 1335 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1336 output->GetDatabase(), |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1337 it->c_str()); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1338 } |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1339 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1340 return OrthancPluginErrorCode_Success; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1341 } |
200 | 1342 ORTHANC_PLUGINS_DATABASE_CATCH; |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1343 } |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1344 |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1345 |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1346 // New primitive since Orthanc 1.5.2 |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1347 static OrthancPluginErrorCode GetLastChangeIndex(int64_t* result, |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1348 void* payload) |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1349 { |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1350 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1351 |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1352 try |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1353 { |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1354 *result = backend->GetLastChangeIndex(); |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1355 return OrthancPluginErrorCode_Success; |
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1356 } |
200 | 1357 ORTHANC_PLUGINS_DATABASE_CATCH; |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1358 } |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1359 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1360 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1361 // New primitive since Orthanc 1.5.2 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1362 static OrthancPluginErrorCode TagMostRecentPatient(void* payload, |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1363 int64_t patientId) |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1364 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1365 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1366 |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1367 try |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1368 { |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1369 backend->TagMostRecentPatient(patientId); |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1370 return OrthancPluginErrorCode_Success; |
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1371 } |
200 | 1372 ORTHANC_PLUGINS_DATABASE_CATCH; |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1373 } |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1374 |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1375 |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1376 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1377 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1378 // New primitive since Orthanc 1.5.4 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1379 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseContext* context, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1380 void* payload, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1381 int64_t resourceId) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1382 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1383 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
204 | 1384 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1385 output->SetAllowedAnswers(Output::AllowedAnswers_Metadata); | |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1386 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1387 try |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1388 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1389 std::map<int32_t, std::string> result; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1390 backend->GetAllMetadata(result, resourceId); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1391 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1392 for (std::map<int32_t, std::string>::const_iterator |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1393 it = result.begin(); it != result.end(); ++it) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1394 { |
199 | 1395 OrthancPluginDatabaseAnswerMetadata(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1396 output->GetDatabase(), |
200 | 1397 resourceId, it->first, it->second.c_str()); |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1398 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1399 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1400 return OrthancPluginErrorCode_Success; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1401 } |
200 | 1402 ORTHANC_PLUGINS_DATABASE_CATCH; |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1403 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1404 # endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1405 #endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1406 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1407 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1408 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1409 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1410 // New primitive since Orthanc 1.5.4 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1411 static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseContext* context, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1412 uint8_t* isExisting, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1413 int64_t* id, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1414 OrthancPluginResourceType* type, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1415 void* payload, |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1416 const char* publicId) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1417 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1418 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
204 | 1419 std::unique_ptr<Output> output(dynamic_cast<Output*>(backend->CreateOutput())); |
1420 output->SetAllowedAnswers(Output::AllowedAnswers_String); | |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1421 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1422 try |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1423 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1424 std::string parent; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1425 if (backend->LookupResourceAndParent(*id, *type, parent, publicId)) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1426 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1427 *isExisting = 1; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1428 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1429 if (!parent.empty()) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1430 { |
199 | 1431 OrthancPluginDatabaseAnswerString(backend->GetContext(), |
201
42990b2dd51b
create IDatabaseBackendOutput only if needed
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
1432 output->GetDatabase(), |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1433 parent.c_str()); |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1434 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1435 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1436 else |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1437 { |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1438 *isExisting = 0; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1439 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1440 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1441 return OrthancPluginErrorCode_Success; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1442 } |
200 | 1443 ORTHANC_PLUGINS_DATABASE_CATCH; |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1444 } |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1445 # endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1446 #endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1447 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1448 |
0 | 1449 public: |
204 | 1450 class Factory : public IDatabaseBackendOutput::IFactory |
1451 { | |
1452 private: | |
1453 OrthancPluginContext* context_; | |
1454 OrthancPluginDatabaseContext* database_; | |
1455 | |
1456 public: | |
1457 Factory(OrthancPluginContext* context, | |
1458 OrthancPluginDatabaseContext* database) : | |
1459 context_(context), | |
1460 database_(database) | |
1461 { | |
1462 } | |
1463 | |
1464 virtual IDatabaseBackendOutput* CreateOutput() ORTHANC_OVERRIDE | |
1465 { | |
1466 return new Output(context_, database_); | |
1467 } | |
1468 }; | |
1469 | |
1470 | |
0 | 1471 /** |
1472 * Register a custom database back-end written in C++. | |
1473 * | |
1474 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1475 * @param backend Your custom database engine. | |
1476 **/ | |
1477 | |
1478 static void Register(OrthancPluginContext* context, | |
1479 IDatabaseBackend& backend) | |
1480 { | |
1481 OrthancPluginDatabaseBackend params; | |
1482 memset(¶ms, 0, sizeof(params)); | |
1483 | |
1484 OrthancPluginDatabaseExtensions extensions; | |
1485 memset(&extensions, 0, sizeof(extensions)); | |
1486 | |
1487 params.addAttachment = AddAttachment; | |
1488 params.attachChild = AttachChild; | |
1489 params.clearChanges = ClearChanges; | |
1490 params.clearExportedResources = ClearExportedResources; | |
1491 params.createResource = CreateResource; | |
1492 params.deleteAttachment = DeleteAttachment; | |
1493 params.deleteMetadata = DeleteMetadata; | |
1494 params.deleteResource = DeleteResource; | |
1495 params.getAllPublicIds = GetAllPublicIds; | |
1496 params.getChanges = GetChanges; | |
1497 params.getChildrenInternalId = GetChildrenInternalId; | |
1498 params.getChildrenPublicId = GetChildrenPublicId; | |
1499 params.getExportedResources = GetExportedResources; | |
1500 params.getLastChange = GetLastChange; | |
1501 params.getLastExportedResource = GetLastExportedResource; | |
1502 params.getMainDicomTags = GetMainDicomTags; | |
1503 params.getPublicId = GetPublicId; | |
1504 params.getResourceCount = GetResourceCount; | |
1505 params.getResourceType = GetResourceType; | |
1506 params.getTotalCompressedSize = GetTotalCompressedSize; | |
1507 params.getTotalUncompressedSize = GetTotalUncompressedSize; | |
1508 params.isExistingResource = IsExistingResource; | |
1509 params.isProtectedPatient = IsProtectedPatient; | |
1510 params.listAvailableMetadata = ListAvailableMetadata; | |
1511 params.listAvailableAttachments = ListAvailableAttachments; | |
1512 params.logChange = LogChange; | |
1513 params.logExportedResource = LogExportedResource; | |
1514 params.lookupAttachment = LookupAttachment; | |
1515 params.lookupGlobalProperty = LookupGlobalProperty; | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1516 params.lookupIdentifier = NULL; // Unused starting with Orthanc 0.9.5 (db v6) |
0 | 1517 params.lookupIdentifier2 = NULL; // Unused starting with Orthanc 0.9.5 (db v6) |
1518 params.lookupMetadata = LookupMetadata; | |
1519 params.lookupParent = LookupParent; | |
1520 params.lookupResource = LookupResource; | |
1521 params.selectPatientToRecycle = SelectPatientToRecycle; | |
1522 params.selectPatientToRecycle2 = SelectPatientToRecycle2; | |
1523 params.setGlobalProperty = SetGlobalProperty; | |
1524 params.setMainDicomTag = SetMainDicomTag; | |
1525 params.setIdentifierTag = SetIdentifierTag; | |
1526 params.setMetadata = SetMetadata; | |
1527 params.setProtectedPatient = SetProtectedPatient; | |
1528 params.startTransaction = StartTransaction; | |
1529 params.rollbackTransaction = RollbackTransaction; | |
1530 params.commitTransaction = CommitTransaction; | |
1531 params.open = Open; | |
1532 params.close = Close; | |
1533 | |
1534 extensions.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1535 extensions.getDatabaseVersion = GetDatabaseVersion; | |
1536 extensions.upgradeDatabase = UpgradeDatabase; | |
1537 extensions.clearMainDicomTags = ClearMainDicomTags; | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1538 extensions.getAllInternalIds = GetAllInternalIds; // New in Orthanc 0.9.5 (db v6) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1539 extensions.lookupIdentifier3 = LookupIdentifier3; // New in Orthanc 0.9.5 (db v6) |
0 | 1540 |
1541 bool performanceWarning = true; | |
1542 | |
1543 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | |
1544 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0) | |
1545 extensions.lookupIdentifierRange = LookupIdentifierRange; // New in Orthanc 1.4.0 | |
1546 # endif | |
1547 #endif | |
1548 | |
78 | 1549 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1550 // Optimizations brought by Orthanc 1.5.2 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1551 extensions.lookupResources = LookupResources; // Fast lookup |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1552 extensions.setResourcesContent = SetResourcesContent; // Fast setting tags/metadata |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1553 extensions.getChildrenMetadata = GetChildrenMetadata; |
85
1012fe77241c
new extension implemented for PostgreSQL and SQLite: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
78
diff
changeset
|
1554 extensions.getLastChangeIndex = GetLastChangeIndex; |
88
eb08ec14fb04
new extension implemented: TagMostRecentPatient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
1555 extensions.tagMostRecentPatient = TagMostRecentPatient; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1556 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1557 if (backend.HasCreateInstance()) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1558 { |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1559 extensions.createInstance = CreateInstance; // Fast creation of resources |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1560 } |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1561 #endif |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1562 |
117
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1563 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in 1.3.1 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1564 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 4) |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1565 // Optimizations brought by Orthanc 1.5.4 |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1566 extensions.lookupResourceAndParent = LookupResourceAndParent; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1567 extensions.getAllMetadata = GetAllMetadata; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1568 performanceWarning = false; |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1569 # endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1570 #endif |
ca0ecd412988
Implementation of new extensions: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
88
diff
changeset
|
1571 |
127
3424a54ca2ee
fix performance warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
1572 if (performanceWarning) |
0 | 1573 { |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1574 char info[1024]; |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1575 sprintf(info, |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1576 "Performance warning: The database index plugin was compiled " |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1577 "against an old version of the Orthanc SDK (%d.%d.%d): " |
129
534759b0cf14
use of macros to report performance warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
127
diff
changeset
|
1578 "Consider upgrading to version %d.%d.%d of the Orthanc SDK", |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1579 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1580 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
129
534759b0cf14
use of macros to report performance warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
127
diff
changeset
|
1581 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER, |
534759b0cf14
use of macros to report performance warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
127
diff
changeset
|
1582 ORTHANC_OPTIMAL_VERSION_MAJOR, |
534759b0cf14
use of macros to report performance warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
127
diff
changeset
|
1583 ORTHANC_OPTIMAL_VERSION_MINOR, |
534759b0cf14
use of macros to report performance warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
127
diff
changeset
|
1584 ORTHANC_OPTIMAL_VERSION_REVISION); |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1585 |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1586 OrthancPluginLogWarning(context, info); |
0 | 1587 } |
1588 | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1589 OrthancPluginDatabaseContext* database = |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1590 OrthancPluginRegisterDatabaseBackendV2(context, ¶ms, &extensions, &backend); |
0 | 1591 if (!context) |
1592 { | |
1593 throw std::runtime_error("Unable to register the database backend"); | |
1594 } | |
1595 | |
204 | 1596 backend.SetOutputFactory(new Factory(context, database)); |
0 | 1597 } |
1598 }; | |
1599 } |