Mercurial > hg > orthanc
annotate OrthancServer/ServerIndex.h @ 376:2cef9c2d4148
separate path for SQLite index, manual loading of external dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 11:13:51 +0200 |
parents | fc856d175d18 |
children | 4d5f0857ec9c |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
0 | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * 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. | |
136 | 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. | |
0 | 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 <boost/thread.hpp> | |
220 | 36 #include <boost/noncopyable.hpp> |
0 | 37 #include "../Core/SQLite/Connection.h" |
38 #include "../Core/DicomFormat/DicomMap.h" | |
179 | 39 #include "../Core/DicomFormat/DicomInstanceHasher.h" |
183 | 40 #include "ServerEnumerations.h" |
0 | 41 |
186
f68c039b0571
preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
42 #include "DatabaseWrapper.h" |
f68c039b0571
preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
43 |
0 | 44 |
62 | 45 namespace Orthanc |
0 | 46 { |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
47 class ServerContext; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
48 |
0 | 49 namespace Internals |
50 { | |
202 | 51 class ServerIndexListener; |
0 | 52 } |
53 | |
220 | 54 class ServerIndex : public boost::noncopyable |
0 | 55 { |
56 private: | |
278
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
57 class Transaction; |
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
58 |
0 | 59 boost::mutex mutex_; |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
60 boost::thread flushThread_; |
0 | 61 |
202 | 62 std::auto_ptr<Internals::ServerIndexListener> listener_; |
63 std::auto_ptr<DatabaseWrapper> db_; | |
180
626777d01dc4
use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
64 |
278
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
65 uint64_t currentStorageSize_; |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
66 uint64_t maximumStorageSize_; |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
67 unsigned int maximumPatients_; |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
68 |
202 | 69 void MainDicomTagsToJson(Json::Value& result, |
70 int64_t resourceId); | |
198
663cc6c46d0a
before refactoring of ServerIndex::GetXXX
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
197
diff
changeset
|
71 |
199 | 72 SeriesStatus GetSeriesStatus(int id); |
73 | |
268
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
74 bool IsRecyclingNeeded(uint64_t instanceSize); |
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
75 |
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
76 void Recycle(uint64_t instanceSize, |
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
77 const std::string& newPatientId); |
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
78 |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
79 void StandaloneRecycling(); |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
80 |
0 | 81 public: |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
82 typedef std::list<FileInfo> Attachments; |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
83 |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
84 ServerIndex(ServerContext& context, |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
85 const std::string& dbPath); |
0 | 86 |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
87 ~ServerIndex(); |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
88 |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
89 uint64_t GetMaximumStorageSize() const |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
90 { |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
91 return maximumStorageSize_; |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
92 } |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
93 |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
94 uint64_t GetMaximumPatientCount() const |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
95 { |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
96 return maximumPatients_; |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
97 } |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
98 |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
99 // "size == 0" means no limit on the storage size |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
100 void SetMaximumStorageSize(uint64_t size); |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
101 |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
102 // "count == 0" means no limit on the number of patients |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
103 void SetMaximumPatientCount(unsigned int count); |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
104 |
187
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
186
diff
changeset
|
105 StoreStatus Store(const DicomMap& dicomSummary, |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
106 const Attachments& attachments, |
187
8e673a65564d
refactoring of storing new instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
186
diff
changeset
|
107 const std::string& remoteAet); |
0 | 108 |
238 | 109 void ComputeStatistics(Json::Value& target); |
0 | 110 |
212 | 111 bool LookupResource(Json::Value& result, |
112 const std::string& publicId, | |
113 ResourceType expectedType); | |
0 | 114 |
232
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
115 bool LookupAttachment(FileInfo& attachment, |
5368bbe813cf
refactoring of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
231
diff
changeset
|
116 const std::string& instanceUuid, |
233 | 117 FileContentType contentType); |
0 | 118 |
119 void GetAllUuids(Json::Value& target, | |
190 | 120 ResourceType resourceType); |
0 | 121 |
212 | 122 bool DeleteResource(Json::Value& target, |
123 const std::string& uuid, | |
124 ResourceType expectedType); | |
0 | 125 |
126 bool GetChanges(Json::Value& target, | |
127 int64_t since, | |
128 unsigned int maxResults); | |
231 | 129 |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
130 bool GetLastChange(Json::Value& target); |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
131 |
231 | 132 void LogExportedResource(const std::string& publicId, |
133 const std::string& remoteModality); | |
134 | |
135 bool GetExportedResources(Json::Value& target, | |
136 int64_t since, | |
137 unsigned int maxResults); | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
138 |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
139 bool GetLastExportedResource(Json::Value& target); |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
140 |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
141 bool IsProtectedPatient(const std::string& publicId); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
142 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
143 void SetProtectedPatient(const std::string& publicId, |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
144 bool isProtected); |
304 | 145 |
146 void GetChildInstances(std::list<std::string>& result, | |
147 const std::string& publicId); | |
148 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
149 void SetMetadata(const std::string& publicId, |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
150 MetadataType type, |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
151 const std::string& value); |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
152 |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
153 bool LookupMetadata(std::string& target, |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
154 const std::string& publicId, |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
155 MetadataType type); |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
156 |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
157 bool LookupParent(std::string& target, |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
158 const std::string& publicId); |
310 | 159 |
160 uint64_t IncrementGlobalSequence(GlobalProperty sequence); | |
315 | 161 |
162 void LogChange(ChangeType changeType, | |
163 const std::string& publicId); | |
0 | 164 }; |
165 } |