Skip to content

Commit

Permalink
Allow to skip connection check for certain sources
Browse files Browse the repository at this point in the history
Addresses #2359
  • Loading branch information
Gennadiy Anisimov authored and chrisknoll committed May 23, 2024
1 parent 6a43da5 commit ca11010
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/ohdsi/webapi/source/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public class Source extends CommonEntity<Integer> 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)
Expand Down Expand Up @@ -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) {

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/ohdsi/webapi/source/SourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ public <T> Map<T, Source> getSourcesMap(SourceMapKey<T> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE ${ohdsiSchema}.source
ADD COLUMN check_connection boolean not null DEFAULT true;

0 comments on commit ca11010

Please sign in to comment.