Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexBackend.cpp @ 553:7f45f23b10d0 find-refactoring
integration mainline->find-refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Sep 2024 15:27:52 +0200 |
parents | 12f1c5265081 987460ae14c9 |
children | 1a74fc1bea2d |
comparison
equal
deleted
inserted
replaced
550:9ed9a91bde33 | 553:7f45f23b10d0 |
---|---|
2125 ReadListOfStrings(childrenPublicIds, statement, args); | 2125 ReadListOfStrings(childrenPublicIds, statement, args); |
2126 } | 2126 } |
2127 | 2127 |
2128 | 2128 |
2129 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | 2129 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
2130 class IndexBackend::LookupFormatter : public Orthanc::ISqlLookupFormatter | 2130 class IndexBackend::LookupFormatter : public ISqlLookupFormatter |
2131 { | 2131 { |
2132 private: | 2132 private: |
2133 Dialect dialect_; | 2133 Dialect dialect_; |
2134 size_t count_; | 2134 size_t count_; |
2135 Dictionary dictionary_; | 2135 Dictionary dictionary_; |
2156 return "${" + key + "}"; | 2156 return "${" + key + "}"; |
2157 } | 2157 } |
2158 | 2158 |
2159 virtual std::string FormatResourceType(Orthanc::ResourceType level) | 2159 virtual std::string FormatResourceType(Orthanc::ResourceType level) |
2160 { | 2160 { |
2161 return boost::lexical_cast<std::string>(Orthanc::Plugins::Convert(level)); | 2161 return boost::lexical_cast<std::string>(Plugins::Convert(level)); |
2162 } | 2162 } |
2163 | 2163 |
2164 virtual std::string FormatWildcardEscape() | 2164 virtual std::string FormatWildcardEscape() |
2165 { | 2165 { |
2166 switch (dialect_) | 2166 switch (dialect_) |
2242 | 2242 |
2243 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | 2243 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
2244 // New primitive since Orthanc 1.5.2 | 2244 // New primitive since Orthanc 1.5.2 |
2245 void IndexBackend::LookupResources(IDatabaseBackendOutput& output, | 2245 void IndexBackend::LookupResources(IDatabaseBackendOutput& output, |
2246 DatabaseManager& manager, | 2246 DatabaseManager& manager, |
2247 const Orthanc::DatabaseConstraints& lookup, | 2247 const DatabaseConstraints& lookup, |
2248 OrthancPluginResourceType queryLevel_, | 2248 OrthancPluginResourceType queryLevel_, |
2249 const std::set<std::string>& labels, | 2249 const std::set<std::string>& labels, |
2250 Orthanc::LabelsConstraint labelsConstraint, | 2250 LabelsConstraint labelsConstraint, |
2251 uint32_t limit, | 2251 uint32_t limit, |
2252 bool requestSomeInstance) | 2252 bool requestSomeInstance) |
2253 { | 2253 { |
2254 LookupFormatter formatter(manager.GetDialect()); | 2254 LookupFormatter formatter(manager.GetDialect()); |
2255 Orthanc::ResourceType queryLevel = Orthanc::Plugins::Convert(queryLevel_); | 2255 Orthanc::ResourceType queryLevel = Plugins::Convert(queryLevel_); |
2256 Orthanc::ResourceType lowerLevel, upperLevel; | 2256 Orthanc::ResourceType lowerLevel, upperLevel; |
2257 Orthanc::ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); | 2257 ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup); |
2258 | 2258 |
2259 std::string sql; | 2259 std::string sql; |
2260 bool enableNewStudyCode = true; | 2260 bool enableNewStudyCode = true; |
2261 | 2261 |
2262 if (enableNewStudyCode && lowerLevel == queryLevel && upperLevel == queryLevel) | 2262 if (enableNewStudyCode && lowerLevel == queryLevel && upperLevel == queryLevel) |
2263 { | 2263 { |
2264 Orthanc::ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); | 2264 ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); |
2265 | 2265 |
2266 if (requestSomeInstance) | 2266 if (requestSomeInstance) |
2267 { | 2267 { |
2268 // Composite query to find some instance if requested | 2268 // Composite query to find some instance if requested |
2269 switch (queryLevel) | 2269 switch (queryLevel) |
2308 } | 2308 } |
2309 } | 2309 } |
2310 } | 2310 } |
2311 else | 2311 else |
2312 { | 2312 { |
2313 Orthanc::ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); | 2313 ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit); |
2314 | 2314 |
2315 if (requestSomeInstance) | 2315 if (requestSomeInstance) |
2316 { | 2316 { |
2317 // Composite query to find some instance if requested | 2317 // Composite query to find some instance if requested |
2318 switch (queryLevel) | 2318 switch (queryLevel) |
2943 | 2943 |
2944 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | 2944 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
2945 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) | 2945 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) |
2946 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 12, 0) == 1) | 2946 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 12, 0) == 1) |
2947 { | 2947 { |
2948 OrthancDatabases::DatabaseBackendAdapterV4::Register(backend, countConnections, maxDatabaseRetries); | 2948 DatabaseBackendAdapterV4::Register(backend, countConnections, maxDatabaseRetries); |
2949 return; | 2949 return; |
2950 } | 2950 } |
2951 # endif | 2951 # endif |
2952 #endif | 2952 #endif |
2953 | 2953 |
2954 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | 2954 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
2955 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) | 2955 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) |
2956 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1) | 2956 if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1) |
2957 { | 2957 { |
2958 OrthancDatabases::DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries); | 2958 DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries); |
2959 return; | 2959 return; |
2960 } | 2960 } |
2961 # endif | 2961 # endif |
2962 #endif | 2962 #endif |
2963 | 2963 |
2964 LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers"; | 2964 LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers"; |
2965 OrthancDatabases::DatabaseBackendAdapterV2::Register(backend); | 2965 DatabaseBackendAdapterV2::Register(backend); |
2966 } | 2966 } |
2967 | 2967 |
2968 | 2968 |
2969 bool IndexBackend::LookupGlobalIntegerProperty(int& target, | 2969 bool IndexBackend::LookupGlobalIntegerProperty(int& target, |
2970 DatabaseManager& manager, | 2970 DatabaseManager& manager, |
3003 } | 3003 } |
3004 | 3004 |
3005 | 3005 |
3006 void IndexBackend::Finalize() | 3006 void IndexBackend::Finalize() |
3007 { | 3007 { |
3008 OrthancDatabases::DatabaseBackendAdapterV2::Finalize(); | 3008 DatabaseBackendAdapterV2::Finalize(); |
3009 | 3009 |
3010 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | 3010 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
3011 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) | 3011 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2) |
3012 OrthancDatabases::DatabaseBackendAdapterV3::Finalize(); | 3012 DatabaseBackendAdapterV3::Finalize(); |
3013 # endif | 3013 # endif |
3014 #endif | 3014 #endif |
3015 | 3015 |
3016 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | 3016 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
3017 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) | 3017 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) |
3018 OrthancDatabases::DatabaseBackendAdapterV4::Finalize(); | 3018 DatabaseBackendAdapterV4::Finalize(); |
3019 # endif | 3019 # endif |
3020 #endif | 3020 #endif |
3021 } | 3021 } |
3022 | 3022 |
3023 | 3023 |