Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.h @ 1364:111e23bb4904 query-retrieve
integration mainline->query-retrieve
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 21 May 2015 16:58:30 +0200 |
parents | 67e6400fca03 3dd494f201a1 |
children | 0ac74fa21db8 |
comparison
equal
deleted
inserted
replaced
953:f894be6e7cc1 | 1364:111e23bb4904 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, | 3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
4 * Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * | 5 * |
6 * This program is free software: you can redistribute it and/or | 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 | 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 | 8 * published by the Free Software Foundation, either version 3 of the |
9 * License, or (at your option) any later version. | 9 * License, or (at your option) any later version. |
38 #include "../Core/SQLite/Connection.h" | 38 #include "../Core/SQLite/Connection.h" |
39 #include "../Core/DicomFormat/DicomMap.h" | 39 #include "../Core/DicomFormat/DicomMap.h" |
40 #include "../Core/DicomFormat/DicomInstanceHasher.h" | 40 #include "../Core/DicomFormat/DicomInstanceHasher.h" |
41 #include "ServerEnumerations.h" | 41 #include "ServerEnumerations.h" |
42 | 42 |
43 #include "DatabaseWrapper.h" | 43 #include "IDatabaseWrapper.h" |
44 | 44 |
45 | 45 |
46 namespace Orthanc | 46 namespace Orthanc |
47 { | 47 { |
48 class ServerContext; | 48 class ServerContext; |
52 class ServerIndexListener; | 52 class ServerIndexListener; |
53 } | 53 } |
54 | 54 |
55 class ServerIndex : public boost::noncopyable | 55 class ServerIndex : public boost::noncopyable |
56 { | 56 { |
57 public: | |
58 typedef std::list<FileInfo> Attachments; | |
59 typedef std::map< std::pair<ResourceType, MetadataType>, std::string> MetadataMap; | |
60 | |
57 private: | 61 private: |
58 class Transaction; | 62 class Transaction; |
59 struct UnstableResourcePayload; | 63 class UnstableResourcePayload; |
60 | 64 |
61 bool done_; | 65 bool done_; |
62 boost::mutex mutex_; | 66 boost::mutex mutex_; |
63 boost::thread flushThread_; | 67 boost::thread flushThread_; |
64 boost::thread unstableResourcesMonitorThread_; | 68 boost::thread unstableResourcesMonitorThread_; |
65 | 69 |
66 std::auto_ptr<Internals::ServerIndexListener> listener_; | 70 std::auto_ptr<Internals::ServerIndexListener> listener_; |
67 std::auto_ptr<DatabaseWrapper> db_; | 71 IDatabaseWrapper& db_; |
68 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_; | 72 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_; |
69 | 73 |
70 uint64_t currentStorageSize_; | 74 uint64_t currentStorageSize_; |
71 uint64_t maximumStorageSize_; | 75 uint64_t maximumStorageSize_; |
72 unsigned int maximumPatients_; | 76 unsigned int maximumPatients_; |
86 const std::string& newPatientId); | 90 const std::string& newPatientId); |
87 | 91 |
88 void StandaloneRecycling(); | 92 void StandaloneRecycling(); |
89 | 93 |
90 void MarkAsUnstable(int64_t id, | 94 void MarkAsUnstable(int64_t id, |
91 Orthanc::ResourceType type); | 95 Orthanc::ResourceType type, |
96 const std::string& publicId); | |
92 | 97 |
93 void GetStatisticsInternal(/* out */ uint64_t& compressedSize, | 98 void GetStatisticsInternal(/* out */ uint64_t& compressedSize, |
94 /* out */ uint64_t& uncompressedSize, | 99 /* out */ uint64_t& uncompressedSize, |
95 /* out */ unsigned int& countStudies, | 100 /* out */ unsigned int& countStudies, |
96 /* out */ unsigned int& countSeries, | 101 /* out */ unsigned int& countSeries, |
97 /* out */ unsigned int& countInstances, | 102 /* out */ unsigned int& countInstances, |
98 /* in */ int64_t id, | 103 /* in */ int64_t id, |
99 /* in */ ResourceType type); | 104 /* in */ ResourceType type); |
100 | 105 |
106 bool GetMetadataAsInteger(int64_t& result, | |
107 int64_t id, | |
108 MetadataType type); | |
109 | |
110 void LogChange(int64_t internalId, | |
111 ChangeType changeType, | |
112 ResourceType resourceType, | |
113 const std::string& publicId); | |
114 | |
115 uint64_t IncrementGlobalSequenceInternal(GlobalProperty property); | |
116 | |
117 void SetMainDicomTags(int64_t resource, | |
118 const DicomMap& tags); | |
119 | |
120 int64_t CreateResource(const std::string& publicId, | |
121 ResourceType type); | |
122 | |
101 public: | 123 public: |
102 typedef std::list<FileInfo> Attachments; | |
103 | |
104 ServerIndex(ServerContext& context, | 124 ServerIndex(ServerContext& context, |
105 const std::string& dbPath); | 125 IDatabaseWrapper& database); |
106 | 126 |
107 ~ServerIndex(); | 127 ~ServerIndex(); |
108 | 128 |
109 uint64_t GetMaximumStorageSize() const | 129 uint64_t GetMaximumStorageSize() const |
110 { | 130 { |
120 void SetMaximumStorageSize(uint64_t size); | 140 void SetMaximumStorageSize(uint64_t size); |
121 | 141 |
122 // "count == 0" means no limit on the number of patients | 142 // "count == 0" means no limit on the number of patients |
123 void SetMaximumPatientCount(unsigned int count); | 143 void SetMaximumPatientCount(unsigned int count); |
124 | 144 |
125 StoreStatus Store(const DicomMap& dicomSummary, | 145 StoreStatus Store(std::map<MetadataType, std::string>& instanceMetadata, |
146 const DicomMap& dicomSummary, | |
126 const Attachments& attachments, | 147 const Attachments& attachments, |
127 const std::string& remoteAet); | 148 const std::string& remoteAet, |
149 const MetadataMap& metadata); | |
128 | 150 |
129 void ComputeStatistics(Json::Value& target); | 151 void ComputeStatistics(Json::Value& target); |
130 | 152 |
131 bool LookupResource(Json::Value& result, | 153 bool LookupResource(Json::Value& result, |
132 const std::string& publicId, | 154 const std::string& publicId, |
134 | 156 |
135 bool LookupAttachment(FileInfo& attachment, | 157 bool LookupAttachment(FileInfo& attachment, |
136 const std::string& instanceUuid, | 158 const std::string& instanceUuid, |
137 FileContentType contentType); | 159 FileContentType contentType); |
138 | 160 |
139 void GetAllUuids(Json::Value& target, | 161 void GetAllUuids(std::list<std::string>& target, |
140 ResourceType resourceType); | 162 ResourceType resourceType); |
141 | 163 |
142 bool DeleteResource(Json::Value& target, | 164 bool DeleteResource(Json::Value& target /* out */, |
143 const std::string& uuid, | 165 const std::string& uuid, |
144 ResourceType expectedType); | 166 ResourceType expectedType); |
145 | 167 |
146 bool GetChanges(Json::Value& target, | 168 void GetChanges(Json::Value& target, |
147 int64_t since, | 169 int64_t since, |
148 unsigned int maxResults); | 170 unsigned int maxResults); |
149 | 171 |
150 bool GetLastChange(Json::Value& target); | 172 void GetLastChange(Json::Value& target); |
151 | 173 |
152 void LogExportedResource(const std::string& publicId, | 174 void LogExportedResource(const std::string& publicId, |
153 const std::string& remoteModality); | 175 const std::string& remoteModality); |
154 | 176 |
155 bool GetExportedResources(Json::Value& target, | 177 void GetExportedResources(Json::Value& target, |
156 int64_t since, | 178 int64_t since, |
157 unsigned int maxResults); | 179 unsigned int maxResults); |
158 | 180 |
159 bool GetLastExportedResource(Json::Value& target); | 181 void GetLastExportedResource(Json::Value& target); |
160 | 182 |
161 bool IsProtectedPatient(const std::string& publicId); | 183 bool IsProtectedPatient(const std::string& publicId); |
162 | 184 |
163 void SetProtectedPatient(const std::string& publicId, | 185 void SetProtectedPatient(const std::string& publicId, |
164 bool isProtected); | 186 bool isProtected); |
180 const std::string& publicId, | 202 const std::string& publicId, |
181 MetadataType type); | 203 MetadataType type); |
182 | 204 |
183 void ListAvailableMetadata(std::list<MetadataType>& target, | 205 void ListAvailableMetadata(std::list<MetadataType>& target, |
184 const std::string& publicId); | 206 const std::string& publicId); |
207 | |
208 bool GetMetadata(Json::Value& target, | |
209 const std::string& publicId); | |
185 | 210 |
186 void ListAvailableAttachments(std::list<FileContentType>& target, | 211 void ListAvailableAttachments(std::list<FileContentType>& target, |
187 const std::string& publicId, | 212 const std::string& publicId, |
188 ResourceType expectedType); | 213 ResourceType expectedType); |
189 | 214 |
207 /* out */ unsigned int& countStudies, | 232 /* out */ unsigned int& countStudies, |
208 /* out */ unsigned int& countSeries, | 233 /* out */ unsigned int& countSeries, |
209 /* out */ unsigned int& countInstances, | 234 /* out */ unsigned int& countInstances, |
210 const std::string& publicId); | 235 const std::string& publicId); |
211 | 236 |
212 void LookupTagValue(std::list<std::string>& result, | 237 void LookupIdentifier(std::list<std::string>& result, |
213 DicomTag tag, | 238 const DicomTag& tag, |
214 const std::string& value, | 239 const std::string& value, |
215 ResourceType type); | 240 ResourceType type); |
216 | 241 |
217 void LookupTagValue(std::list<std::string>& result, | 242 void LookupIdentifier(std::list<std::string>& result, |
218 DicomTag tag, | 243 const DicomTag& tag, |
219 const std::string& value); | 244 const std::string& value); |
220 | 245 |
221 void LookupTagValue(std::list<std::string>& result, | 246 void LookupIdentifier(std::list< std::pair<ResourceType, std::string> >& result, |
222 const std::string& value); | 247 const std::string& value); |
223 | 248 |
224 StoreStatus AddAttachment(const FileInfo& attachment, | 249 StoreStatus AddAttachment(const FileInfo& attachment, |
225 const std::string& publicId); | 250 const std::string& publicId); |
226 | 251 |
227 void DeleteAttachment(const std::string& publicId, | 252 void DeleteAttachment(const std::string& publicId, |
228 FileContentType type); | 253 FileContentType type); |
254 | |
255 void SetGlobalProperty(GlobalProperty property, | |
256 const std::string& value); | |
257 | |
258 std::string GetGlobalProperty(GlobalProperty property, | |
259 const std::string& defaultValue); | |
260 | |
261 bool GetMainDicomTags(DicomMap& result, | |
262 const std::string& publicId, | |
263 ResourceType expectedType); | |
229 }; | 264 }; |
230 } | 265 } |