Mercurial > hg > orthanc
annotate OrthancServer/IDatabaseWrapper.h @ 3087:df1b17be20f6 db-changes
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jan 2019 17:22:47 +0100 |
parents | 683d572424b6 |
children | fb8ee0786b1e |
rev | line source |
---|---|
1247 | 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 |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
1247 | 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 | |
36 #include "../Core/DicomFormat/DicomMap.h" | |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
37 #include "../Core/FileStorage/FileInfo.h" |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
38 #include "../Core/FileStorage/IStorageArea.h" |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
39 #include "../Core/SQLite/ITransaction.h" |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
40 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
41 #include "ExportedResource.h" |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
42 #include "IDatabaseListener.h" |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
43 #include "Search/DatabaseConstraint.h" |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
44 #include "Search/DatabaseLookup.h" |
1247 | 45 |
46 #include <list> | |
47 #include <boost/noncopyable.hpp> | |
48 | |
49 namespace Orthanc | |
50 { | |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3082
diff
changeset
|
51 class ResourcesContent; |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3082
diff
changeset
|
52 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3082
diff
changeset
|
53 |
1247 | 54 class IDatabaseWrapper : public boost::noncopyable |
55 { | |
56 public: | |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
57 class ITransaction : public boost::noncopyable |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
58 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
59 public: |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
60 virtual ~ITransaction() |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
61 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
62 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
63 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
64 virtual void Begin() = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
65 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
66 virtual void Rollback() = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
67 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
68 virtual void Commit(int64_t fileSizeDelta) = 0; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
69 }; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
70 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
71 |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
72 struct CreateInstanceResult |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
73 { |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
74 bool isNewPatient_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
75 bool isNewStudy_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
76 bool isNewSeries_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
77 int64_t patientId_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
78 int64_t studyId_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
79 int64_t seriesId_; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
80 }; |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
81 |
1247 | 82 virtual ~IDatabaseWrapper() |
83 { | |
84 } | |
85 | |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
86 virtual void Open() = 0; |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
87 |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
88 virtual void Close() = 0; |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
89 |
1247 | 90 virtual void AddAttachment(int64_t id, |
91 const FileInfo& attachment) = 0; | |
92 | |
1286 | 93 virtual void ClearChanges() = 0; |
94 | |
95 virtual void ClearExportedResources() = 0; | |
1247 | 96 |
97 virtual void DeleteAttachment(int64_t id, | |
98 FileContentType attachment) = 0; | |
99 | |
100 virtual void DeleteMetadata(int64_t id, | |
101 MetadataType type) = 0; | |
102 | |
103 virtual void DeleteResource(int64_t id) = 0; | |
104 | |
105 virtual void FlushToDisk() = 0; | |
106 | |
1306
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
107 virtual bool HasFlushToDisk() const = 0; |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1302
diff
changeset
|
108 |
1301 | 109 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
1247 | 110 int64_t id) = 0; |
111 | |
112 virtual void GetAllPublicIds(std::list<std::string>& target, | |
113 ResourceType resourceType) = 0; | |
114 | |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
115 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
|
116 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
|
117 size_t since, |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
118 size_t limit) = 0; |
1247 | 119 |
120 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, | |
121 bool& done /*out*/, | |
122 int64_t since, | |
1302 | 123 uint32_t maxResults) = 0; |
1247 | 124 |
1301 | 125 virtual void GetChildrenInternalId(std::list<int64_t>& target, |
1247 | 126 int64_t id) = 0; |
127 | |
1301 | 128 virtual void GetChildrenPublicId(std::list<std::string>& target, |
1247 | 129 int64_t id) = 0; |
130 | |
131 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, | |
132 bool& done /*out*/, | |
133 int64_t since, | |
1302 | 134 uint32_t maxResults) = 0; |
1247 | 135 |
136 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) = 0; | |
137 | |
138 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) = 0; | |
139 | |
140 virtual void GetMainDicomTags(DicomMap& map, | |
141 int64_t id) = 0; | |
142 | |
143 virtual std::string GetPublicId(int64_t resourceId) = 0; | |
144 | |
145 virtual uint64_t GetResourceCount(ResourceType resourceType) = 0; | |
146 | |
147 virtual ResourceType GetResourceType(int64_t resourceId) = 0; | |
148 | |
149 virtual uint64_t GetTotalCompressedSize() = 0; | |
150 | |
151 virtual uint64_t GetTotalUncompressedSize() = 0; | |
152 | |
153 virtual bool IsExistingResource(int64_t internalId) = 0; | |
154 | |
155 virtual bool IsProtectedPatient(int64_t internalId) = 0; | |
156 | |
157 virtual void ListAvailableMetadata(std::list<MetadataType>& target, | |
158 int64_t id) = 0; | |
159 | |
1301 | 160 virtual void ListAvailableAttachments(std::list<FileContentType>& target, |
1247 | 161 int64_t id) = 0; |
162 | |
163 virtual void LogChange(int64_t internalId, | |
164 const ServerIndexChange& change) = 0; | |
165 | |
166 virtual void LogExportedResource(const ExportedResource& resource) = 0; | |
167 | |
168 virtual bool LookupAttachment(FileInfo& attachment, | |
169 int64_t id, | |
170 FileContentType contentType) = 0; | |
171 | |
172 virtual bool LookupGlobalProperty(std::string& target, | |
173 GlobalProperty property) = 0; | |
174 | |
175 virtual bool LookupMetadata(std::string& target, | |
176 int64_t id, | |
177 MetadataType type) = 0; | |
178 | |
179 virtual bool LookupParent(int64_t& parentId, | |
180 int64_t resourceId) = 0; | |
181 | |
1294 | 182 virtual bool LookupResource(int64_t& id, |
183 ResourceType& type, | |
184 const std::string& publicId) = 0; | |
1247 | 185 |
186 virtual bool SelectPatientToRecycle(int64_t& internalId) = 0; | |
187 | |
188 virtual bool SelectPatientToRecycle(int64_t& internalId, | |
189 int64_t patientIdToAvoid) = 0; | |
190 | |
191 virtual void SetGlobalProperty(GlobalProperty property, | |
192 const std::string& value) = 0; | |
193 | |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
194 virtual void ClearMainDicomTags(int64_t id) = 0; |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1615
diff
changeset
|
195 |
1247 | 196 virtual void SetMetadata(int64_t id, |
197 MetadataType type, | |
198 const std::string& value) = 0; | |
199 | |
200 virtual void SetProtectedPatient(int64_t internalId, | |
201 bool isProtected) = 0; | |
202 | |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2697
diff
changeset
|
203 virtual ITransaction* StartTransaction() = 0; |
1247 | 204 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1306
diff
changeset
|
205 virtual void SetListener(IDatabaseListener& listener) = 0; |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
206 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
207 virtual unsigned int GetDatabaseVersion() = 0; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
208 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
209 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
|
210 IStorageArea& storageArea) = 0; |
3020
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
211 |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
212 |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
213 /** |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
214 * Primitives introduced in Orthanc 1.5.2 |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
215 **/ |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
216 |
3020
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
217 virtual bool IsDiskSizeAbove(uint64_t threshold) = 0; |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
218 |
3075
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
219 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
220 std::list<std::string>* instancesId, // Can be NULL if not needed |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
221 const std::vector<DatabaseConstraint>& lookup, |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
222 ResourceType queryLevel, |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
223 size_t limit) = 0; |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
224 |
3082
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
225 // Returns "true" iff. the instance already exists. If "false" is |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
226 // returned, the content of "result" is undefined, but |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
227 // "instanceId" must be properly set. |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
228 virtual bool CreateInstance(CreateInstanceResult& result, /* out */ |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
229 int64_t& instanceId, /* out */ |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
230 const std::string& patient, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
231 const std::string& study, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
232 const std::string& series, |
3082
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
233 const std::string& instance) = 0; |
3083
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3082
diff
changeset
|
234 |
683d572424b6
IDatabaseWrapper::SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3082
diff
changeset
|
235 virtual void SetResourcesContent(const ResourcesContent& content) = 0; |
1247 | 236 }; |
237 } |