-
Notifications
You must be signed in to change notification settings - Fork 3
feat: support for SQL database connection settings #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4fbd15c
feat(agent): add settings for SQL db connection
RadovanTomik 39137fb
wip(agent): add database connection interface
RadovanTomik ee65601
wip(agent): refactor FHIR db connection names
RadovanTomik 6012ef3
wip(agent): refactor FHIR db connection names
RadovanTomik 4e9b9bb
wip(agent): refactor FHIR db connection names
RadovanTomik c154242
wip(agent): add datasource connection factory
RadovanTomik aed26ec
feat(agent): add support for SQL database settings
RadovanTomik ee328f5
refactor(agent): move data store impls to a separate subpackage
RadovanTomik 123fb06
refactor(agent): check for null values in settings update event
RadovanTomik 6060208
refactor(agent): fix validation of FhirUrl
RadovanTomik 59fc64c
chore(agent): code formatting
RadovanTomik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
agent/backend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/DataStoreFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package eu.bbmri_eric.quality.agent.dataquality; | ||
|
|
||
| /** Factory for selecting the active {@link DataStore} based on current settings. */ | ||
| public interface DataStoreFactory { | ||
| /** | ||
| * Resolves the data store that should be used based on current settings. | ||
| * | ||
| * @return the resolved {@link DataStore} | ||
| */ | ||
| DataStore resolveDataStore(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ackend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/domain/DataQualityCheck.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,5 +6,6 @@ public enum QualityCheckType { | |
| CQL, | ||
|
|
||
| /** Java-based built-in check implementation. */ | ||
| JAVA | ||
| JAVA, | ||
| SQL | ||
| } | ||
6 changes: 6 additions & 0 deletions
6
agent/backend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/dto/DBStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package eu.bbmri_eric.quality.agent.dataquality.dto; | ||
|
|
||
| public enum DBStatus { | ||
| UP, | ||
| DOWN | ||
| } |
33 changes: 33 additions & 0 deletions
33
.../backend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/dto/DatabaseHealthDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package eu.bbmri_eric.quality.agent.dataquality.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor | ||
| @Schema(name = "Database Health", description = "Health status information for the database") | ||
| public class DatabaseHealthDTO { | ||
| @Schema( | ||
| description = "Overall health status of the database", | ||
| example = "UP", | ||
| requiredMode = Schema.RequiredMode.REQUIRED) | ||
| public DBStatus status; | ||
|
|
||
| @Schema( | ||
| description = "Error message if the database is unhealthy", | ||
| example = "Connection refused", | ||
| requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
| public String error; | ||
|
|
||
| @Schema( | ||
| description = "Additional details about the health status", | ||
| example = "Database connection pool exhausted", | ||
| requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
| public String details; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...kend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/impl/FhirCqlQueryExecutor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package eu.bbmri_eric.quality.agent.dataquality.impl; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import eu.bbmri_eric.quality.agent.dataquality.FHIRServer; | ||
| import eu.bbmri_eric.quality.agent.dataquality.dto.ResultDTO; | ||
| import java.util.Base64; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import org.json.JSONObject; | ||
|
|
||
| public final class FhirCqlQueryExecutor { | ||
| private static final ObjectMapper mapper = new ObjectMapper(); | ||
|
|
||
| private FhirCqlQueryExecutor() {} | ||
|
|
||
| public static ResultDTO execute(FHIRServer fhirStore, String query) { | ||
| try { | ||
| String cqlData = Base64.getEncoder().encodeToString(query.getBytes()); | ||
| String libraryUri = java.util.UUID.randomUUID().toString().toLowerCase(); | ||
| String measureUri = java.util.UUID.randomUUID().toString().toLowerCase(); | ||
| JSONObject libraryResource = fhirStore.createLibrary(libraryUri, cqlData); | ||
| fhirStore.postResource("Library", libraryResource); | ||
| JSONObject measureResource = fhirStore.createMeasure(measureUri, libraryUri, "Patient"); | ||
| JSONObject measureResponse = fhirStore.postResource("Measure", measureResource); | ||
| String measureId = measureResponse.getString("id"); | ||
| JSONObject measureReport = fhirStore.evaluateMeasureList(measureId); | ||
| JsonNode mr = mapper.readTree(measureReport.toString()); | ||
|
|
||
| int count = mr.at("/group/0/population/0/count").asInt(); | ||
| Set<String> idSet = new HashSet<>(); | ||
| if (count != 0) { | ||
| String listRef = mr.at("/group/0/population/0/subjectResults/reference").asText(null); | ||
| if (listRef != null && listRef.startsWith("List/")) { | ||
| String listId = listRef.substring("List/".length()); | ||
|
|
||
| JSONObject listResource = fhirStore.getPatientList(listId); | ||
| JsonNode lr = mapper.readTree(listResource.toString()); | ||
|
|
||
| for (JsonNode entry : lr.withArray("entry")) { | ||
| String ref = entry.at("/item/reference").asText(null); | ||
| if (ref != null && ref.startsWith("Patient/")) { | ||
| idSet.add(ref.substring("Patient/".length())); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return new ResultDTO(count, "Patient", idSet); | ||
| } catch (Exception | NoSuchMethodError e) { | ||
|
RadovanTomik marked this conversation as resolved.
|
||
| return new ResultDTO(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
33 changes: 0 additions & 33 deletions
33
agent/backend/src/main/java/eu/bbmri_eric/quality/agent/dataquality/impl/FhirDataStore.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.