Mercurial > hg > orthanc
annotate OrthancServer/DatabaseWrapper.h @ 2567:3caca43371f5 jobs
archival of BagOfTasksProcessor, Mutex, and ReaderWriterLock
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 May 2018 14:26:31 +0200 |
parents | 878b59270859 |
children | e583478e0c6c |
rev | line source |
---|---|
183 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1286
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
183 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
1247 | 36 #include "IDatabaseWrapper.h" |
37 | |
183 | 38 #include "../Core/SQLite/Connection.h" |
187
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
39 #include "../Core/SQLite/Transaction.h" |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
40 #include "DatabaseWrapperBase.h" |
1242 | 41 |
183 | 42 namespace Orthanc |
43 { | |
44 namespace Internals | |
45 { | |
46 class SignalRemainingAncestor; | |
47 } | |
48 | |
49 /** | |
50 * This class manages an instance of the Orthanc SQLite database. It | |
51 * translates low-level requests into SQL statements. Mutual | |
52 * exclusion MUST be implemented at a higher level. | |
53 **/ | |
1247 | 54 class DatabaseWrapper : public IDatabaseWrapper |
183 | 55 { |
56 private: | |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
57 IDatabaseListener* listener_; |
183 | 58 SQLite::Connection db_; |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
59 DatabaseWrapperBase base_; |
183 | 60 Internals::SignalRemainingAncestor* signalRemainingAncestor_; |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
61 unsigned int version_; |
183 | 62 |
1286 | 63 void ClearTable(const std::string& tableName); |
64 | |
183 | 65 public: |
1247 | 66 DatabaseWrapper(const std::string& path); |
67 | |
68 DatabaseWrapper(); | |
69 | |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
70 virtual void Open(); |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
71 |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
72 virtual void Close() |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
73 { |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
74 db_.Close(); |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
75 } |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1671
diff
changeset
|
76 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
77 virtual void SetListener(IDatabaseListener& listener); |
183 | 78 |
1247 | 79 virtual void SetGlobalProperty(GlobalProperty property, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
80 const std::string& value) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
81 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
82 base_.SetGlobalProperty(property, value); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
83 } |
183 | 84 |
1247 | 85 virtual bool LookupGlobalProperty(std::string& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
86 GlobalProperty property) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
87 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
88 return base_.LookupGlobalProperty(target, property); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
89 } |
1247 | 90 |
91 virtual int64_t CreateResource(const std::string& publicId, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
92 ResourceType type) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
93 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
94 return base_.CreateResource(publicId, type); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
95 } |
183 | 96 |
1294 | 97 virtual bool LookupResource(int64_t& id, |
98 ResourceType& type, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
99 const std::string& publicId) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
100 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
101 return base_.LookupResource(id, type, publicId); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
102 } |
183 | 103 |
1247 | 104 virtual bool LookupParent(int64_t& parentId, |
1671
2f2e2ec17bc4
sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1670
diff
changeset
|
105 int64_t resourceId); |
198
663cc6c46d0a
before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
197
diff
changeset
|
106 |
1671
2f2e2ec17bc4
sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1670
diff
changeset
|
107 virtual std::string GetPublicId(int64_t resourceId); |
1247 | 108 |
1671
2f2e2ec17bc4
sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1670
diff
changeset
|
109 virtual ResourceType GetResourceType(int64_t resourceId); |
198
663cc6c46d0a
before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
197
diff
changeset
|
110 |
1247 | 111 virtual void AttachChild(int64_t parent, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
112 int64_t child) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
113 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
114 base_.AttachChild(parent, child); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
115 } |
304 | 116 |
1247 | 117 virtual void DeleteResource(int64_t id); |
183 | 118 |
1247 | 119 virtual void SetMetadata(int64_t id, |
120 MetadataType type, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
121 const std::string& value) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
122 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
123 base_.SetMetadata(id, type, value); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
124 } |
1247 | 125 |
126 virtual void DeleteMetadata(int64_t id, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
127 MetadataType type) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
128 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
129 base_.DeleteMetadata(id, type); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
130 } |
183 | 131 |
1247 | 132 virtual bool LookupMetadata(std::string& target, |
133 int64_t id, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
134 MetadataType type) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
135 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
136 return base_.LookupMetadata(target, id, type); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
137 } |
183 | 138 |
1247 | 139 virtual void ListAvailableMetadata(std::list<MetadataType>& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
140 int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
141 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
142 base_.ListAvailableMetadata(target, id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
143 } |
438 | 144 |
1247 | 145 virtual void AddAttachment(int64_t id, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
146 const FileInfo& attachment) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
147 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
148 base_.AddAttachment(id, attachment); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
149 } |
183 | 150 |
1247 | 151 virtual void DeleteAttachment(int64_t id, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
152 FileContentType attachment) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
153 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
154 base_.DeleteAttachment(id, attachment); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
155 } |
1247 | 156 |
1301 | 157 virtual void ListAvailableAttachments(std::list<FileContentType>& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
158 int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
159 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
160 return base_.ListAvailableAttachments(target, id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
161 } |
436
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
162 |
1247 | 163 virtual bool LookupAttachment(FileInfo& attachment, |
164 int64_t id, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
165 FileContentType contentType) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
166 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
167 return base_.LookupAttachment(attachment, id, contentType); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
168 } |
183 | 169 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
170 virtual void ClearMainDicomTags(int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
171 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
172 base_.ClearMainDicomTags(id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
173 } |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1664
diff
changeset
|
174 |
1286 | 175 virtual void SetMainDicomTag(int64_t id, |
176 const DicomTag& tag, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
177 const std::string& value) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
178 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
179 base_.SetMainDicomTag(id, tag, value); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
180 } |
699
2929e17f8447
add attachments to resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
181 |
1713 | 182 virtual void SetIdentifierTag(int64_t id, |
183 const DicomTag& tag, | |
184 const std::string& value) | |
185 { | |
186 base_.SetIdentifierTag(id, tag, value); | |
187 } | |
188 | |
1247 | 189 virtual void GetMainDicomTags(DicomMap& map, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
190 int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
191 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
192 base_.GetMainDicomTags(map, id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
193 } |
440
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
194 |
1301 | 195 virtual void GetChildrenPublicId(std::list<std::string>& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
196 int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
197 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
198 base_.GetChildrenPublicId(target, id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
199 } |
200
9c58b2b03cf0
refactoring of read operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
199
diff
changeset
|
200 |
1301 | 201 virtual void GetChildrenInternalId(std::list<int64_t>& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
202 int64_t id) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
203 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
204 base_.GetChildrenInternalId(target, id); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
205 } |
183 | 206 |
1247 | 207 virtual void LogChange(int64_t internalId, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
208 const ServerIndexChange& change) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
209 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
210 base_.LogChange(internalId, change); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
211 } |
183 | 212 |
1247 | 213 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, |
214 bool& done /*out*/, | |
215 int64_t since, | |
1671
2f2e2ec17bc4
sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1670
diff
changeset
|
216 uint32_t maxResults); |
183 | 217 |
1671
2f2e2ec17bc4
sample database plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1670
diff
changeset
|
218 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/); |
204 | 219 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
220 virtual void LogExportedResource(const ExportedResource& resource) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
221 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
222 base_.LogExportedResource(resource); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
223 } |
183 | 224 |
1247 | 225 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, |
226 bool& done /*out*/, | |
227 int64_t since, | |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
228 uint32_t maxResults) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
229 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
230 base_.GetExportedResources(target, done, since, maxResults); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
231 } |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
232 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
233 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
234 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
235 base_.GetLastExportedResource(target); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
236 } |
183 | 237 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
238 virtual uint64_t GetTotalCompressedSize() |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
239 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
240 return base_.GetTotalCompressedSize(); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
241 } |
1247 | 242 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
243 virtual uint64_t GetTotalUncompressedSize() |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
244 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
245 return base_.GetTotalUncompressedSize(); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
246 } |
238 | 247 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
248 virtual uint64_t GetResourceCount(ResourceType resourceType) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
249 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
250 return base_.GetResourceCount(resourceType); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
251 } |
190 | 252 |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
253 virtual void GetAllInternalIds(std::list<int64_t>& target, |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
254 ResourceType resourceType) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
255 { |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
256 base_.GetAllInternalIds(target, resourceType); |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
257 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
258 |
1247 | 259 virtual void GetAllPublicIds(std::list<std::string>& target, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
260 ResourceType resourceType) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
261 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
262 base_.GetAllPublicIds(target, resourceType); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
263 } |
262
2354560daf2f
primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
264 |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
265 virtual void GetAllPublicIds(std::list<std::string>& target, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
266 ResourceType resourceType, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
267 size_t since, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
268 size_t limit) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
269 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
270 base_.GetAllPublicIds(target, resourceType, since, limit); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
271 } |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
272 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
273 virtual bool SelectPatientToRecycle(int64_t& internalId) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
274 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
275 return base_.SelectPatientToRecycle(internalId); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
276 } |
262
2354560daf2f
primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
277 |
1247 | 278 virtual bool SelectPatientToRecycle(int64_t& internalId, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
279 int64_t patientIdToAvoid) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
280 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
281 return base_.SelectPatientToRecycle(internalId, patientIdToAvoid); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
282 } |
1247 | 283 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
284 virtual bool IsProtectedPatient(int64_t internalId) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
285 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
286 return base_.IsProtectedPatient(internalId); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
287 } |
262
2354560daf2f
primitives for recycling patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
288 |
1247 | 289 virtual void SetProtectedPatient(int64_t internalId, |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
290 bool isProtected) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
291 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
292 base_.SetProtectedPatient(internalId, isProtected); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
293 } |
183 | 294 |
1247 | 295 virtual SQLite::ITransaction* StartTransaction() |
187
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
296 { |
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
297 return new SQLite::Transaction(db_); |
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
298 } |
202 | 299 |
1247 | 300 virtual void FlushToDisk() |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
301 { |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
302 db_.FlushToDisk(); |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
303 } |
310 | 304 |
1306
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
305 virtual bool HasFlushToDisk() const |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
306 { |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
307 return true; |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
308 } |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
309 |
1286 | 310 virtual void ClearChanges() |
311 { | |
312 ClearTable("Changes"); | |
313 } | |
314 | |
315 virtual void ClearExportedResources() | |
316 { | |
317 ClearTable("ExportedResources"); | |
318 } | |
513 | 319 |
1670
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
320 virtual bool IsExistingResource(int64_t internalId) |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
321 { |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
322 return base_.IsExistingResource(internalId); |
16955f8fec4d
refactoring: DatabaseWrapperBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
323 } |
521 | 324 |
1746 | 325 virtual void LookupIdentifier(std::list<int64_t>& result, |
326 ResourceType level, | |
327 const DicomTag& tag, | |
328 IdentifierConstraintType type, | |
329 const std::string& value) | |
1725 | 330 { |
1746 | 331 base_.LookupIdentifier(result, level, tag, type, value); |
1729 | 332 } |
333 | |
1301 | 334 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
1247 | 335 int64_t id); |
1241 | 336 |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
337 virtual unsigned int GetDatabaseVersion() |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
338 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
339 return version_; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
340 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
341 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
342 virtual void Upgrade(unsigned int targetVersion, |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
343 IStorageArea& storageArea); |
1241 | 344 |
345 | |
346 | |
347 /** | |
348 * The methods declared below are for unit testing only! | |
349 **/ | |
350 | |
1247 | 351 const char* GetErrorMessage() const |
352 { | |
353 return db_.GetErrorMessage(); | |
354 } | |
355 | |
1286 | 356 void GetChildren(std::list<std::string>& childrenPublicIds, |
357 int64_t id); | |
1241 | 358 |
1286 | 359 int64_t GetTableRecordCount(const std::string& table); |
1241 | 360 |
1301 | 361 bool GetParentPublicId(std::string& target, |
1286 | 362 int64_t id); |
1241 | 363 |
183 | 364 }; |
365 } |