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