Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexBackend.h @ 0:7cea966b6829
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Jul 2018 08:16:29 +0200 |
parents | |
children | d17b2631bb67 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7cea966b6829 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
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 #pragma once | |
23 | |
24 #include "../Common/DatabaseManager.h" | |
25 #include "OrthancCppDatabasePlugin.h" | |
26 | |
27 | |
28 namespace OrthancDatabases | |
29 { | |
30 class IndexBackend : public OrthancPlugins::IDatabaseBackend | |
31 { | |
32 private: | |
33 DatabaseManager manager_; | |
34 | |
35 protected: | |
36 DatabaseManager& GetManager() | |
37 { | |
38 return manager_; | |
39 } | |
40 | |
41 static int64_t ReadInteger64(const DatabaseManager::CachedStatement& statement, | |
42 size_t field); | |
43 | |
44 static int32_t ReadInteger32(const DatabaseManager::CachedStatement& statement, | |
45 size_t field); | |
46 | |
47 static std::string ReadString(const DatabaseManager::CachedStatement& statement, | |
48 size_t field); | |
49 | |
50 template <typename T> | |
51 static void ReadListOfIntegers(std::list<T>& target, | |
52 DatabaseManager::CachedStatement& statement, | |
53 const Dictionary& args); | |
54 | |
55 static void ReadListOfStrings(std::list<std::string>& target, | |
56 DatabaseManager::CachedStatement& statement, | |
57 const Dictionary& args); | |
58 | |
59 void ClearDeletedFiles(); | |
60 | |
61 void ClearDeletedResources(); | |
62 | |
63 void SignalDeletedFiles(); | |
64 | |
65 void SignalDeletedResources(); | |
66 | |
67 private: | |
68 void ReadChangesInternal(bool& done, | |
69 DatabaseManager::CachedStatement& statement, | |
70 const Dictionary& args, | |
71 uint32_t maxResults); | |
72 | |
73 void ReadExportedResourcesInternal(bool& done, | |
74 DatabaseManager::CachedStatement& statement, | |
75 const Dictionary& args, | |
76 uint32_t maxResults); | |
77 | |
78 public: | |
79 IndexBackend(IDatabaseFactory* factory); | |
80 | |
81 Dialect GetDialect() const | |
82 { | |
83 return manager_.GetDialect(); | |
84 } | |
85 | |
86 virtual void Open() | |
87 { | |
88 manager_.Open(); | |
89 } | |
90 | |
91 virtual void Close() | |
92 { | |
93 manager_.Close(); | |
94 } | |
95 | |
96 virtual void AddAttachment(int64_t id, | |
97 const OrthancPluginAttachment& attachment); | |
98 | |
99 virtual void AttachChild(int64_t parent, | |
100 int64_t child); | |
101 | |
102 virtual void ClearChanges(); | |
103 | |
104 virtual void ClearExportedResources(); | |
105 | |
106 virtual void DeleteAttachment(int64_t id, | |
107 int32_t attachment); | |
108 | |
109 virtual void DeleteMetadata(int64_t id, | |
110 int32_t metadataType); | |
111 | |
112 virtual void DeleteResource(int64_t id); | |
113 | |
114 virtual void GetAllInternalIds(std::list<int64_t>& target, | |
115 OrthancPluginResourceType resourceType); | |
116 | |
117 virtual void GetAllPublicIds(std::list<std::string>& target, | |
118 OrthancPluginResourceType resourceType); | |
119 | |
120 virtual void GetAllPublicIds(std::list<std::string>& target, | |
121 OrthancPluginResourceType resourceType, | |
122 uint64_t since, | |
123 uint64_t limit); | |
124 | |
125 virtual void GetChanges(bool& done /*out*/, | |
126 int64_t since, | |
127 uint32_t maxResults); | |
128 | |
129 virtual void GetChildrenInternalId(std::list<int64_t>& target /*out*/, | |
130 int64_t id); | |
131 | |
132 virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/, | |
133 int64_t id); | |
134 | |
135 virtual void GetExportedResources(bool& done /*out*/, | |
136 int64_t since, | |
137 uint32_t maxResults); | |
138 | |
139 virtual void GetLastChange(); | |
140 | |
141 virtual void GetLastExportedResource(); | |
142 | |
143 virtual void GetMainDicomTags(int64_t id); | |
144 | |
145 virtual std::string GetPublicId(int64_t resourceId); | |
146 | |
147 virtual uint64_t GetResourceCount(OrthancPluginResourceType resourceType); | |
148 | |
149 virtual OrthancPluginResourceType GetResourceType(int64_t resourceId); | |
150 | |
151 virtual uint64_t GetTotalCompressedSize(); | |
152 | |
153 virtual uint64_t GetTotalUncompressedSize(); | |
154 | |
155 virtual bool IsExistingResource(int64_t internalId); | |
156 | |
157 virtual bool IsProtectedPatient(int64_t internalId); | |
158 | |
159 virtual void ListAvailableMetadata(std::list<int32_t>& target /*out*/, | |
160 int64_t id); | |
161 | |
162 virtual void ListAvailableAttachments(std::list<int32_t>& target /*out*/, | |
163 int64_t id); | |
164 | |
165 virtual void LogChange(const OrthancPluginChange& change); | |
166 | |
167 virtual void LogExportedResource(const OrthancPluginExportedResource& resource); | |
168 | |
169 virtual bool LookupAttachment(int64_t id, | |
170 int32_t contentType); | |
171 | |
172 virtual bool LookupGlobalProperty(std::string& target /*out*/, | |
173 int32_t property); | |
174 | |
175 virtual void LookupIdentifier(std::list<int64_t>& target /*out*/, | |
176 OrthancPluginResourceType resourceType, | |
177 uint16_t group, | |
178 uint16_t element, | |
179 OrthancPluginIdentifierConstraint constraint, | |
180 const char* value); | |
181 | |
182 virtual void LookupIdentifierRange(std::list<int64_t>& target /*out*/, | |
183 OrthancPluginResourceType resourceType, | |
184 uint16_t group, | |
185 uint16_t element, | |
186 const char* start, | |
187 const char* end); | |
188 | |
189 virtual bool LookupMetadata(std::string& target /*out*/, | |
190 int64_t id, | |
191 int32_t metadataType); | |
192 | |
193 virtual bool LookupParent(int64_t& parentId /*out*/, | |
194 int64_t resourceId); | |
195 | |
196 virtual bool LookupResource(int64_t& id /*out*/, | |
197 OrthancPluginResourceType& type /*out*/, | |
198 const char* publicId); | |
199 | |
200 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/); | |
201 | |
202 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/, | |
203 int64_t patientIdToAvoid); | |
204 | |
205 virtual void SetGlobalProperty(int32_t property, | |
206 const char* value); | |
207 | |
208 virtual void SetMainDicomTag(int64_t id, | |
209 uint16_t group, | |
210 uint16_t element, | |
211 const char* value); | |
212 | |
213 virtual void SetIdentifierTag(int64_t id, | |
214 uint16_t group, | |
215 uint16_t element, | |
216 const char* value); | |
217 | |
218 virtual void SetMetadata(int64_t id, | |
219 int32_t metadataType, | |
220 const char* value); | |
221 | |
222 virtual void SetProtectedPatient(int64_t internalId, | |
223 bool isProtected); | |
224 | |
225 virtual void StartTransaction() | |
226 { | |
227 manager_.StartTransaction(); | |
228 } | |
229 | |
230 | |
231 virtual void RollbackTransaction() | |
232 { | |
233 manager_.RollbackTransaction(); | |
234 } | |
235 | |
236 | |
237 virtual void CommitTransaction() | |
238 { | |
239 manager_.CommitTransaction(); | |
240 } | |
241 | |
242 | |
243 virtual uint32_t GetDatabaseVersion(); | |
244 | |
245 virtual void UpgradeDatabase(uint32_t targetVersion, | |
246 OrthancPluginStorageArea* storageArea); | |
247 | |
248 virtual void ClearMainDicomTags(int64_t internalId); | |
249 | |
250 | |
251 // For unit testing only! | |
252 virtual uint64_t GetResourcesCount(); | |
253 | |
254 // For unit testing only! | |
255 virtual uint64_t GetUnprotectedPatientsCount(); | |
256 | |
257 // For unit testing only! | |
258 virtual bool GetParentPublicId(std::string& target, | |
259 int64_t id); | |
260 | |
261 // For unit tests only! | |
262 virtual void GetChildren(std::list<std::string>& childrenPublicIds, | |
263 int64_t id); | |
264 }; | |
265 } |