comparison Framework/Plugins/GlobalProperties.cpp @ 221:73cc85f3d9c1

implementation of the "serverIdentifier" information for global properties
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Mar 2021 10:40:34 +0200
parents 3236894320d6
children
comparison
equal deleted inserted replaced
220:492aa3edf572 221:73cc85f3d9c1
32 namespace OrthancDatabases 32 namespace OrthancDatabases
33 { 33 {
34 bool LookupGlobalProperty(std::string& target, 34 bool LookupGlobalProperty(std::string& target,
35 IDatabase& db, 35 IDatabase& db,
36 ITransaction& transaction, 36 ITransaction& transaction,
37 const std::string& serverIdentifier,
37 Orthanc::GlobalProperty property) 38 Orthanc::GlobalProperty property)
38 { 39 {
39 Query query("SELECT value FROM GlobalProperties WHERE property=${property}", true); 40 Query query("SELECT value FROM GlobalProperties WHERE property=${property}", true);
40 query.SetType("property", ValueType_Integer64); 41 query.SetType("property", ValueType_Integer64);
41 42
71 } 72 }
72 73
73 74
74 bool LookupGlobalProperty(std::string& target /* out */, 75 bool LookupGlobalProperty(std::string& target /* out */,
75 DatabaseManager& manager, 76 DatabaseManager& manager,
77 const std::string& serverIdentifier,
76 Orthanc::GlobalProperty property) 78 Orthanc::GlobalProperty property)
77 { 79 {
78 DatabaseManager::CachedStatement statement( 80 DatabaseManager::CachedStatement statement(
79 STATEMENT_FROM_HERE, manager, 81 STATEMENT_FROM_HERE, manager,
80 "SELECT value FROM GlobalProperties WHERE property=${property}"); 82 "SELECT value FROM GlobalProperties WHERE property=${property}");
111 } 113 }
112 114
113 115
114 void SetGlobalProperty(IDatabase& db, 116 void SetGlobalProperty(IDatabase& db,
115 ITransaction& transaction, 117 ITransaction& transaction,
118 const std::string& serverIdentifier,
116 Orthanc::GlobalProperty property, 119 Orthanc::GlobalProperty property,
117 const std::string& utf8) 120 const std::string& utf8)
118 { 121 {
119 // This version of "SetGlobalProperty()" (with an explicit 122 // This version of "SetGlobalProperty()" (with an explicit
120 // transaction) is called internally by the plugin to set a global 123 // transaction) is called internally by the plugin to set a global
166 } 169 }
167 } 170 }
168 171
169 172
170 void SetGlobalProperty(DatabaseManager& manager, 173 void SetGlobalProperty(DatabaseManager& manager,
174 const std::string& serverIdentifier,
171 Orthanc::GlobalProperty property, 175 Orthanc::GlobalProperty property,
172 const std::string& utf8) 176 const std::string& utf8)
173 { 177 {
174 // This version of "SetGlobalProperty()" (without an explicit 178 // This version of "SetGlobalProperty()" (without an explicit
175 // transaction) is called by Orthanc during its execution. Orthanc 179 // transaction) is called by Orthanc during its execution. Orthanc
225 229
226 230
227 bool LookupGlobalIntegerProperty(int& target, 231 bool LookupGlobalIntegerProperty(int& target,
228 IDatabase& db, 232 IDatabase& db,
229 ITransaction& transaction, 233 ITransaction& transaction,
234 const std::string& serverIdentifier,
230 Orthanc::GlobalProperty property) 235 Orthanc::GlobalProperty property)
231 { 236 {
232 std::string value; 237 std::string value;
233 238
234 if (LookupGlobalProperty(value, db, transaction, property)) 239 if (LookupGlobalProperty(value, db, transaction, serverIdentifier, property))
235 { 240 {
236 try 241 try
237 { 242 {
238 target = boost::lexical_cast<int>(value); 243 target = boost::lexical_cast<int>(value);
239 return true; 244 return true;
251 } 256 }
252 257
253 258
254 void SetGlobalIntegerProperty(IDatabase& db, 259 void SetGlobalIntegerProperty(IDatabase& db,
255 ITransaction& transaction, 260 ITransaction& transaction,
261 const std::string& serverIdentifier,
256 Orthanc::GlobalProperty property, 262 Orthanc::GlobalProperty property,
257 int value) 263 int value)
258 { 264 {
259 SetGlobalProperty(db, transaction, property, boost::lexical_cast<std::string>(value)); 265 SetGlobalProperty(db, transaction, serverIdentifier, property, boost::lexical_cast<std::string>(value));
260 } 266 }
261 } 267 }