Mercurial > hg > orthanc-databases
comparison Odbc/Plugins/IndexPlugin.cpp @ 569:f18e46d7dbf8 attach-custom-data
merged find-refactoring -> attach-custom-data
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 24 Sep 2024 15:04:21 +0200 |
parents | 54d518dcd74a |
children |
comparison
equal
deleted
inserted
replaced
368:82f73188b58d | 569:f18e46d7dbf8 |
---|---|
1 /** | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4 * Department, University Hospital of Liege, Belgium | 4 * Department, University Hospital of Liege, Belgium |
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium | 5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
6 * | 8 * |
7 * This program is free software: you can redistribute it and/or | 9 * This program is free software: you can redistribute it and/or |
8 * modify it under the terms of the GNU Affero General Public License | 10 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | 11 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | 12 * the License, or (at your option) any later version. |
25 #include "../../Framework/Plugins/PluginInitialization.h" | 27 #include "../../Framework/Plugins/PluginInitialization.h" |
26 #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | 28 #include "../../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" |
27 | 29 |
28 #include <Logging.h> | 30 #include <Logging.h> |
29 | 31 |
32 #define ORTHANC_PLUGIN_NAME "odbc-index" | |
33 | |
30 | 34 |
31 #if defined(_WIN32) | 35 #if defined(_WIN32) |
32 # ifdef _MSC_VER | 36 # ifdef _MSC_VER |
33 # pragma message("Warning: Strings have not been tested on Windows (UTF-16 issues ahead)!") | 37 # pragma message("Warning: Strings have not been tested on Windows (UTF-16 issues ahead)!") |
34 # else | 38 # else |
39 # include <ltdl.h> | 43 # include <ltdl.h> |
40 # include <libltdl/lt_dlloader.h> | 44 # include <libltdl/lt_dlloader.h> |
41 #endif | 45 #endif |
42 | 46 |
43 | 47 |
48 #include <google/protobuf/any.h> | |
49 | |
50 | |
44 static const char* const KEY_ODBC = "Odbc"; | 51 static const char* const KEY_ODBC = "Odbc"; |
45 | 52 |
46 | 53 |
47 extern "C" | 54 extern "C" |
48 { | 55 { |
51 #endif | 58 #endif |
52 | 59 |
53 | 60 |
54 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) | 61 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* context) |
55 { | 62 { |
56 if (!OrthancDatabases::InitializePlugin(context, "ODBC", true)) | 63 GOOGLE_PROTOBUF_VERIFY_VERSION; |
64 | |
65 if (!OrthancDatabases::InitializePlugin(context, ORTHANC_PLUGIN_NAME, "ODBC", true)) | |
57 { | 66 { |
58 return -1; | 67 return -1; |
59 } | 68 } |
60 | 69 |
61 #if !defined(_WIN32) | 70 #if !defined(_WIN32) |
93 | 102 |
94 try | 103 try |
95 { | 104 { |
96 const std::string connectionString = odbc.GetStringValue("IndexConnectionString", ""); | 105 const std::string connectionString = odbc.GetStringValue("IndexConnectionString", ""); |
97 const unsigned int countConnections = odbc.GetUnsignedIntegerValue("IndexConnectionsCount", 1); | 106 const unsigned int countConnections = odbc.GetUnsignedIntegerValue("IndexConnectionsCount", 1); |
98 const unsigned int maxConnectionRetries = odbc.GetUnsignedIntegerValue("MaxConnectionRetries", 10); | 107 const unsigned int maxConnectionRetries = odbc.GetUnsignedIntegerValue("MaximumConnectionRetries", 10); |
99 const unsigned int connectionRetryInterval = odbc.GetUnsignedIntegerValue("ConnectionRetryInterval", 5); | 108 const unsigned int connectionRetryInterval = odbc.GetUnsignedIntegerValue("ConnectionRetryInterval", 5); |
100 | 109 |
101 if (connectionString.empty()) | 110 if (connectionString.empty()) |
102 { | 111 { |
103 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | 112 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, |
127 | 136 |
128 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | 137 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
129 { | 138 { |
130 LOG(WARNING) << "ODBC index is finalizing"; | 139 LOG(WARNING) << "ODBC index is finalizing"; |
131 OrthancDatabases::IndexBackend::Finalize(); | 140 OrthancDatabases::IndexBackend::Finalize(); |
141 google::protobuf::ShutdownProtobufLibrary(); | |
132 } | 142 } |
133 | 143 |
134 | 144 |
135 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | 145 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
136 { | 146 { |
137 return "odbc-index"; | 147 return ORTHANC_PLUGIN_NAME; |
138 } | 148 } |
139 | 149 |
140 | 150 |
141 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | 151 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
142 { | 152 { |