Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapperBase.h @ 1670:16955f8fec4d db-changes
refactoring: DatabaseWrapperBase
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 01 Oct 2015 14:03:07 +0200 |
parents | |
children | 2f2e2ec17bc4 |
comparison
equal
deleted
inserted
replaced
1669:a412ad57f0f9 | 1670:16955f8fec4d |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
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 | |
35 #include "../Core/DicomFormat/DicomMap.h" | |
36 #include "../Core/DicomFormat/DicomTag.h" | |
37 #include "../Core/Enumerations.h" | |
38 #include "../Core/FileStorage/FileInfo.h" | |
39 #include "../Core/SQLite/Connection.h" | |
40 #include "../OrthancServer/ServerIndexChange.h" | |
41 #include "../OrthancServer/ExportedResource.h" | |
42 #include "ServerEnumerations.h" | |
43 | |
44 #include <list> | |
45 | |
46 | |
47 namespace Orthanc | |
48 { | |
49 class DatabaseWrapperBase | |
50 { | |
51 private: | |
52 SQLite::Connection& db_; | |
53 | |
54 void GetChangesInternal(std::list<ServerIndexChange>& target, | |
55 bool& done, | |
56 SQLite::Statement& s, | |
57 uint32_t maxResults); | |
58 | |
59 void GetExportedResourcesInternal(std::list<ExportedResource>& target, | |
60 bool& done, | |
61 SQLite::Statement& s, | |
62 uint32_t maxResults); | |
63 | |
64 public: | |
65 DatabaseWrapperBase(SQLite::Connection& db) : db_(db) | |
66 { | |
67 } | |
68 | |
69 void SetGlobalProperty(GlobalProperty property, | |
70 const std::string& value); | |
71 | |
72 bool LookupGlobalProperty(std::string& target, | |
73 GlobalProperty property); | |
74 | |
75 int64_t CreateResource(const std::string& publicId, | |
76 ResourceType type); | |
77 | |
78 bool LookupResource(int64_t& id, | |
79 ResourceType& type, | |
80 const std::string& publicId); | |
81 | |
82 bool LookupParent(int64_t& parentId, | |
83 int64_t resourceId); | |
84 | |
85 std::string GetPublicId(int64_t resourceId); | |
86 | |
87 ResourceType GetResourceType(int64_t resourceId); | |
88 | |
89 void AttachChild(int64_t parent, | |
90 int64_t child); | |
91 | |
92 void SetMetadata(int64_t id, | |
93 MetadataType type, | |
94 const std::string& value); | |
95 | |
96 void DeleteMetadata(int64_t id, | |
97 MetadataType type); | |
98 | |
99 bool LookupMetadata(std::string& target, | |
100 int64_t id, | |
101 MetadataType type); | |
102 | |
103 void ListAvailableMetadata(std::list<MetadataType>& target, | |
104 int64_t id); | |
105 | |
106 void AddAttachment(int64_t id, | |
107 const FileInfo& attachment); | |
108 | |
109 void DeleteAttachment(int64_t id, | |
110 FileContentType attachment); | |
111 | |
112 void ListAvailableAttachments(std::list<FileContentType>& target, | |
113 int64_t id); | |
114 | |
115 bool LookupAttachment(FileInfo& attachment, | |
116 int64_t id, | |
117 FileContentType contentType); | |
118 | |
119 | |
120 void ClearMainDicomTags(int64_t id); | |
121 | |
122 | |
123 void SetMainDicomTag(int64_t id, | |
124 const DicomTag& tag, | |
125 const std::string& value); | |
126 | |
127 void GetMainDicomTags(DicomMap& map, | |
128 int64_t id); | |
129 | |
130 void GetChildrenPublicId(std::list<std::string>& target, | |
131 int64_t id); | |
132 | |
133 void GetChildrenInternalId(std::list<int64_t>& target, | |
134 int64_t id); | |
135 | |
136 void LogChange(int64_t internalId, | |
137 const ServerIndexChange& change); | |
138 | |
139 void GetChanges(std::list<ServerIndexChange>& target, | |
140 bool& done, | |
141 int64_t since, | |
142 uint32_t maxResults); | |
143 | |
144 void GetLastChange(std::list<ServerIndexChange>& target); | |
145 | |
146 | |
147 void LogExportedResource(const ExportedResource& resource); | |
148 | |
149 void GetExportedResources(std::list<ExportedResource>& target, | |
150 bool& done, | |
151 int64_t since, | |
152 uint32_t maxResults); | |
153 | |
154 void GetLastExportedResource(std::list<ExportedResource>& target); | |
155 | |
156 uint64_t GetTotalCompressedSize(); | |
157 | |
158 uint64_t GetTotalUncompressedSize(); | |
159 | |
160 void GetAllPublicIds(std::list<std::string>& target, | |
161 ResourceType resourceType); | |
162 | |
163 void GetAllPublicIds(std::list<std::string>& target, | |
164 ResourceType resourceType, | |
165 size_t since, | |
166 size_t limit); | |
167 | |
168 uint64_t GetResourceCount(ResourceType resourceType); | |
169 | |
170 bool SelectPatientToRecycle(int64_t& internalId); | |
171 | |
172 bool SelectPatientToRecycle(int64_t& internalId, | |
173 int64_t patientIdToAvoid); | |
174 | |
175 bool IsProtectedPatient(int64_t internalId); | |
176 | |
177 void SetProtectedPatient(int64_t internalId, | |
178 bool isProtected); | |
179 | |
180 bool IsExistingResource(int64_t internalId); | |
181 | |
182 | |
183 void LookupIdentifier(std::list<int64_t>& target, | |
184 const DicomTag& tag, | |
185 const std::string& value); | |
186 | |
187 void LookupIdentifier(std::list<int64_t>& target, | |
188 const std::string& value); | |
189 }; | |
190 } | |
191 |