Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 1299:4ce47e8ed0d2
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 06 Feb 2015 15:13:05 +0100 |
parents | 910478b2d4e4 |
children | 919dfb2fb3fe |
comparison
equal
deleted
inserted
replaced
1298:cf9779324cbf | 1299:4ce47e8ed0d2 |
---|---|
219 { | 219 { |
220 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)"); | 220 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)"); |
221 s.BindInt(0, type); | 221 s.BindInt(0, type); |
222 s.BindString(1, publicId); | 222 s.BindString(1, publicId); |
223 s.Run(); | 223 s.Run(); |
224 int64_t id = db_.GetLastInsertRowId(); | 224 return db_.GetLastInsertRowId(); |
225 | |
226 ChangeType changeType; | |
227 switch (type) | |
228 { | |
229 case ResourceType_Patient: | |
230 changeType = ChangeType_NewPatient; | |
231 break; | |
232 | |
233 case ResourceType_Study: | |
234 changeType = ChangeType_NewStudy; | |
235 break; | |
236 | |
237 case ResourceType_Series: | |
238 changeType = ChangeType_NewSeries; | |
239 break; | |
240 | |
241 case ResourceType_Instance: | |
242 changeType = ChangeType_NewInstance; | |
243 break; | |
244 | |
245 default: | |
246 throw OrthancException(ErrorCode_InternalError); | |
247 } | |
248 | |
249 ServerIndexChange change(changeType, type, publicId); | |
250 LogChange(id, change); | |
251 return id; | |
252 } | 225 } |
253 | 226 |
254 bool DatabaseWrapper::LookupResource(int64_t& id, | 227 bool DatabaseWrapper::LookupResource(int64_t& id, |
255 ResourceType& type, | 228 ResourceType& type, |
256 const std::string& publicId) | 229 const std::string& publicId) |