Mercurial > hg > orthanc
comparison OrthancServer/DatabaseWrapper.cpp @ 1239:92c6b3b57699
cleaning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Dec 2014 16:22:18 +0100 |
parents | 6c07108ff1e2 |
children | 62c35e4b67db |
comparison
equal
deleted
inserted
replaced
1238:6c07108ff1e2 | 1239:92c6b3b57699 |
---|---|
211 target = s.ColumnString(0); | 211 target = s.ColumnString(0); |
212 return true; | 212 return true; |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 std::string DatabaseWrapper::GetGlobalProperty(GlobalProperty property, | |
217 const std::string& defaultValue) | |
218 { | |
219 std::string s; | |
220 if (LookupGlobalProperty(s, property)) | |
221 { | |
222 return s; | |
223 } | |
224 else | |
225 { | |
226 return defaultValue; | |
227 } | |
228 } | |
229 | |
230 int64_t DatabaseWrapper::CreateResource(const std::string& publicId, | 216 int64_t DatabaseWrapper::CreateResource(const std::string& publicId, |
231 ResourceType type) | 217 ResourceType type) |
232 { | 218 { |
233 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)"); | 219 SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Resources VALUES(NULL, ?, ?, NULL)"); |
234 s.BindInt(0, type); | 220 s.BindInt(0, type); |
872 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE); | 858 EmbeddedResources::GetFileResource(query, EmbeddedResources::PREPARE_DATABASE); |
873 db_.Execute(query); | 859 db_.Execute(query); |
874 } | 860 } |
875 | 861 |
876 // Check the version of the database | 862 // Check the version of the database |
877 std::string version = GetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "Unknown"); | 863 std::string version; |
864 if (!LookupGlobalProperty(version, GlobalProperty_DatabaseSchemaVersion)) | |
865 { | |
866 version = "Unknown"; | |
867 } | |
868 | |
878 bool ok = false; | 869 bool ok = false; |
879 try | 870 try |
880 { | 871 { |
881 LOG(INFO) << "Version of the Orthanc database: " << version; | 872 LOG(INFO) << "Version of the Orthanc database: " << version; |
882 unsigned int v = boost::lexical_cast<unsigned int>(version); | 873 unsigned int v = boost::lexical_cast<unsigned int>(version); |