From ca11010503c444b642114924bb38d9c3028379f4 Mon Sep 17 00:00:00 2001 From: Gennadiy Anisimov Date: Thu, 23 May 2024 19:32:59 +0300 Subject: [PATCH] Allow to skip connection check for certain sources Addresses #2359 --- src/main/java/org/ohdsi/webapi/source/Source.java | 12 ++++++++++++ .../java/org/ohdsi/webapi/source/SourceService.java | 6 ++++-- ...20240523164700__skip_connection_check_setting.sql | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/db/migration/postgresql/V2.15.0.20240523164700__skip_connection_check_setting.sql diff --git a/src/main/java/org/ohdsi/webapi/source/Source.java b/src/main/java/org/ohdsi/webapi/source/Source.java index bbff30fd9d..c6f7820285 100644 --- a/src/main/java/org/ohdsi/webapi/source/Source.java +++ b/src/main/java/org/ohdsi/webapi/source/Source.java @@ -113,6 +113,10 @@ public class Source extends CommonEntity implements Serializable { @Column(name = "is_cache_enabled") private boolean isCacheEnabled; + @Column(name = "check_connection") + private boolean checkConnection; + + public String getTableQualifier(DaimonType daimonType) { String result = getTableQualifierOrNull(daimonType); if (result == null) @@ -251,6 +255,14 @@ public void setIsCacheEnabled(boolean isCacheEnabled) { this.isCacheEnabled = isCacheEnabled; } + public boolean isCheckConnection() { + return checkConnection; + } + + public void setCheckConnection(boolean checkConnection) { + this.checkConnection = checkConnection; + } + @Override public boolean equals(Object o) { diff --git a/src/main/java/org/ohdsi/webapi/source/SourceService.java b/src/main/java/org/ohdsi/webapi/source/SourceService.java index f2dca56b41..65551781a2 100644 --- a/src/main/java/org/ohdsi/webapi/source/SourceService.java +++ b/src/main/java/org/ohdsi/webapi/source/SourceService.java @@ -104,8 +104,10 @@ public Map getSourcesMap(SourceMapKey mapKey) { public void checkConnection(Source source) { - final JdbcTemplate jdbcTemplate = getSourceJdbcTemplate(source); - jdbcTemplate.execute(SqlTranslate.translateSql("select 1;", source.getSourceDialect()).replaceAll(";$", "")); + if (source.isCheckConnection()) { + final JdbcTemplate jdbcTemplate = getSourceJdbcTemplate(source); + jdbcTemplate.execute(SqlTranslate.translateSql("select 1;", source.getSourceDialect()).replaceAll(";$", "")); + } } public Source getPrioritySourceForDaimon(SourceDaimon.DaimonType daimonType) { diff --git a/src/main/resources/db/migration/postgresql/V2.15.0.20240523164700__skip_connection_check_setting.sql b/src/main/resources/db/migration/postgresql/V2.15.0.20240523164700__skip_connection_check_setting.sql new file mode 100644 index 0000000000..b1f361b4c2 --- /dev/null +++ b/src/main/resources/db/migration/postgresql/V2.15.0.20240523164700__skip_connection_check_setting.sql @@ -0,0 +1,2 @@ +ALTER TABLE ${ohdsiSchema}.source + ADD COLUMN check_connection boolean not null DEFAULT true; \ No newline at end of file