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