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