comparison Plugins/Samples/ModalityWorklists/Plugin.cpp @ 1808:9c2ffc4e938b worklists

configuration of the sample modality worklists plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 23 Nov 2015 16:58:55 +0100
parents 138664eb59de
children 796d0b087fb8
comparison
equal deleted inserted replaced
1807:91216c42c6e5 1808:9c2ffc4e938b
167 extern "C" 167 extern "C"
168 { 168 {
169 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) 169 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c)
170 { 170 {
171 context_ = c; 171 context_ = c;
172 OrthancPluginLogWarning(context_, "Storage plugin is initializing"); 172 OrthancPluginLogWarning(context_, "Sample worklist plugin is initializing");
173 OrthancPluginSetDescription(context_, "Serve DICOM modality worklists from a folder with Orthanc.");
173 174
174 /* Check the version of the Orthanc core */ 175 /* Check the version of the Orthanc core */
175 if (OrthancPluginCheckVersion(c) == 0) 176 if (OrthancPluginCheckVersion(c) == 0)
176 { 177 {
177 char info[1024]; 178 char info[1024];
185 } 186 }
186 187
187 Json::Value configuration; 188 Json::Value configuration;
188 if (!ConvertToJson(configuration, OrthancPluginGetConfiguration(context_))) 189 if (!ConvertToJson(configuration, OrthancPluginGetConfiguration(context_)))
189 { 190 {
190 OrthancPluginLogError(context_, "Cannot access the configuration"); 191 OrthancPluginLogError(context_, "Cannot access the configuration of the worklist server");
191 return -1; 192 return -1;
192 } 193 }
193 194
194 if (configuration.isMember("WorklistsFolder")) 195 bool enabled = false;
195 { 196
196 if (configuration["WorklistsFolder"].type() != Json::stringValue) 197 if (configuration.isMember("Worklists"))
198 {
199 const Json::Value& config = configuration["Worklists"];
200 if (!config.isMember("Enable") ||
201 config["Enable"].type() != Json::booleanValue)
197 { 202 {
198 OrthancPluginLogError(context_, "The configuration option \"WorklistsFolder\" must be a string"); 203 OrthancPluginLogError(context_, "The configuration option \"Worklists.Enable\" must contain a Boolean");
199 return -1; 204 return -1;
200 } 205 }
201 206 else
202 folder_ = configuration["WorklistsFolder"].asString(); 207 {
208 enabled = config["Enable"].asBool();
209 if (enabled)
210 {
211 if (!config.isMember("Database") ||
212 config["Database"].type() != Json::stringValue)
213 {
214 OrthancPluginLogError(context_, "The configuration option \"Worklists.Database\" must contain a path");
215 return -1;
216 }
217
218 folder_ = config["Database"].asString();
219 }
220 else
221 {
222 OrthancPluginLogWarning(context_, "Worklists server is disabled by the configuration file");
223 }
224 }
203 } 225 }
204 else 226 else
205 { 227 {
206 folder_ = DEFAULT_WORKLISTS_FOLDER; 228 OrthancPluginLogWarning(context_, "Worklists server is disabled, no suitable configuration section was provided");
207 } 229 }
208 230
209 std::string message = "The database of worklists will be read from folder: " + folder_; 231 if (enabled)
210 OrthancPluginLogWarning(context_, message.c_str()); 232 {
211 233 std::string message = "The database of worklists will be read from folder: " + folder_;
212 OrthancPluginRegisterWorklistCallback(context_, Callback); 234 OrthancPluginLogWarning(context_, message.c_str());
235
236 OrthancPluginRegisterWorklistCallback(context_, Callback);
237 }
213 238
214 return 0; 239 return 0;
215 } 240 }
216 241
217 242
221 } 246 }
222 247
223 248
224 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() 249 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
225 { 250 {
226 return "sample-worklists"; 251 return "worklists";
227 } 252 }
228 253
229 254
230 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() 255 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
231 { 256 {
232 return SAMPLE_MODALITY_WORKLISTS_VERSION; 257 return MODALITY_WORKLISTS_VERSION;
233 } 258 }
234 } 259 }