From 11f8ca5f88d996ab840a0a966c9045afb187a7cd Mon Sep 17 00:00:00 2001 From: SevKohler Date: Wed, 29 May 2024 15:22:33 +0200 Subject: [PATCH] added back together corrected compose files --- docker/docker-compose-ehrbase.yml | 16 ++++++++++-- docker/docker-compose-full.yml | 24 ++++++++++++++++-- docker/docker-compose-without-aft.yml | 25 +++++++++++++++++-- .../bih/aft/controller/QueryController.java | 3 --- .../org/bih/aft/service/CountVerificator.java | 4 +++ .../aft/service/FederationListService.java | 7 +++--- .../bih/aft/service/FederationService.java | 9 +++---- .../service/FederationListServiceTest.java | 1 - 8 files changed, 70 insertions(+), 19 deletions(-) diff --git a/docker/docker-compose-ehrbase.yml b/docker/docker-compose-ehrbase.yml index 6e69dca..09ff16a 100644 --- a/docker/docker-compose-ehrbase.yml +++ b/docker/docker-compose-ehrbase.yml @@ -9,7 +9,7 @@ services: networks: - ehrbase-net environment: - DB_URL: jdbc:postgresql://ehrdb:5433/ehrbase + DB_URL: jdbc:postgresql://ehrdb:5432/ehrbase DB_USER_ADMIN: ehrbase DB_PASS_ADMIN: ehrbase SECURITY_AUTHTYPE: BASIC @@ -20,7 +20,8 @@ services: DB_USER: ehrbase_restricted DB_PASS: ehrbase_restricted depends_on: - - ehrdb + ehrdb: + condition: service_healthy restart: on-failure ehrdb: @@ -32,10 +33,21 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + PGDATA: /var/lib/postgresql/data/pgdata EHRBASE_USER_ADMIN: ehrbase EHRBASE_PASSWORD_ADMIN: ehrbase EHRBASE_USER: ehrbase_restricted EHRBASE_PASSWORD: ehrbase_restricted + volumes: + - ehrdb-pgdata:/var/lib/postgresql/data/pgdata + healthcheck: + test: "pg_isready -h localhost -U $$POSTGRES_USER" + interval: 10s + timeout: 5s + retries: 70 networks: ehrbase-net: {} + +volumes: + ehrdb-pgdata: \ No newline at end of file diff --git a/docker/docker-compose-full.yml b/docker/docker-compose-full.yml index b5ad816..d7241c7 100644 --- a/docker/docker-compose-full.yml +++ b/docker/docker-compose-full.yml @@ -1,6 +1,5 @@ #docker-compose-full.yml services: - ehrbase: image: ehrbase/ehrbase:next ports: @@ -19,7 +18,8 @@ services: DB_USER: ehrbase_restricted DB_PASS: ehrbase_restricted depends_on: - - ehrdb + ehrdb: + condition: service_healthy restart: on-failure ehrdb: @@ -31,10 +31,18 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + PGDATA: /var/lib/postgresql/data/pgdata EHRBASE_USER_ADMIN: ehrbase EHRBASE_PASSWORD_ADMIN: ehrbase EHRBASE_USER: ehrbase_restricted EHRBASE_PASSWORD: ehrbase_restricted + volumes: + - ehrdb-pgdata:/var/lib/postgresql/data/pgdata + healthcheck: + test: "pg_isready -h localhost -U $$POSTGRES_USER" + interval: 10s + timeout: 5s + retries: 70 aft: image: aft:latest @@ -78,11 +86,23 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + PGDATA: /var/lib/postgresql/data/pgdata EHRBASE_USER_ADMIN: ehrbase EHRBASE_PASSWORD_ADMIN: ehrbase EHRBASE_USER: ehrbase_restricted EHRBASE_PASSWORD: ehrbase_restricted command: -p 5433 + volumes: + - ehrdb2-pgdata:/var/lib/postgresql/data/pgdata + healthcheck: + test: "pg_isready -h localhost -U $$POSTGRES_USER" + interval: 10s + timeout: 5s + retries: 70 networks: ehrbase-net: {} + +volumes: + ehrdb-pgdata: + ehrdb2-pgdata: \ No newline at end of file diff --git a/docker/docker-compose-without-aft.yml b/docker/docker-compose-without-aft.yml index 314186f..8b98228 100644 --- a/docker/docker-compose-without-aft.yml +++ b/docker/docker-compose-without-aft.yml @@ -1,6 +1,5 @@ #docker-compose-full.yml services: - ehrbase: image: ehrbase/ehrbase:next ports: @@ -19,8 +18,10 @@ services: DB_USER: ehrbase_restricted DB_PASS: ehrbase_restricted depends_on: - - ehrdb + ehrdb: + condition: service_healthy restart: on-failure + ehrdb: image: ehrbase/ehrbase-postgres:latest ports: @@ -30,10 +31,18 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + PGDATA: /var/lib/postgresql/data/pgdata EHRBASE_USER_ADMIN: ehrbase EHRBASE_PASSWORD_ADMIN: ehrbase EHRBASE_USER: ehrbase_restricted EHRBASE_PASSWORD: ehrbase_restricted + volumes: + - ehrdb-pgdata:/var/lib/postgresql/data/pgdata + healthcheck: + test: "pg_isready -h localhost -U $$POSTGRES_USER" + interval: 10s + timeout: 5s + retries: 70 ehrbase2: image: ehrbase/ehrbase:next @@ -65,11 +74,23 @@ services: environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + PGDATA: /var/lib/postgresql/data/pgdata EHRBASE_USER_ADMIN: ehrbase EHRBASE_PASSWORD_ADMIN: ehrbase EHRBASE_USER: ehrbase_restricted EHRBASE_PASSWORD: ehrbase_restricted command: -p 5433 + volumes: + - ehrdb2-pgdata:/var/lib/postgresql/data/pgdata + healthcheck: + test: "pg_isready -h localhost -U $$POSTGRES_USER" + interval: 10s + timeout: 5s + retries: 70 networks: ehrbase-net: {} + +volumes: + ehrdb-pgdata: + ehrdb2-pgdata: \ No newline at end of file diff --git a/src/main/java/org/bih/aft/controller/QueryController.java b/src/main/java/org/bih/aft/controller/QueryController.java index 5dda65b..fc6f92c 100644 --- a/src/main/java/org/bih/aft/controller/QueryController.java +++ b/src/main/java/org/bih/aft/controller/QueryController.java @@ -6,9 +6,6 @@ import org.bih.aft.exceptions.InvalidCountQuery; import org.bih.aft.controller.dao.AQLinput; import org.bih.aft.ports.QueryUseCase; -import org.bih.aft.service.FederationService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/org/bih/aft/service/CountVerificator.java b/src/main/java/org/bih/aft/service/CountVerificator.java index 1d3fcab..7eaf512 100644 --- a/src/main/java/org/bih/aft/service/CountVerificator.java +++ b/src/main/java/org/bih/aft/service/CountVerificator.java @@ -7,10 +7,14 @@ import org.ehrbase.openehr.sdk.aql.dto.operand.AggregateFunction; import org.ehrbase.openehr.sdk.aql.dto.select.SelectClause; import org.ehrbase.openehr.sdk.aql.dto.select.SelectExpression; +import org.springframework.stereotype.Service; import java.util.List; @Slf4j +@Service public class CountVerificator implements QueryVerificator { + + @Override public void verify(AQLinput aqlQuery) { // TODO: What return type here ? Response should be 400 in the end String query = aqlQuery.aql(); diff --git a/src/main/java/org/bih/aft/service/FederationListService.java b/src/main/java/org/bih/aft/service/FederationListService.java index 82a0217..51675a1 100644 --- a/src/main/java/org/bih/aft/service/FederationListService.java +++ b/src/main/java/org/bih/aft/service/FederationListService.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.util.List; @Service @@ -18,10 +19,8 @@ public class FederationListService implements LocationProvider { private FederationList loadFederationfile() { ObjectMapper mapper = new ObjectMapper(); - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - File file = new File(classloader.getResource(federationListPath).getFile()); - try { - federationList = mapper.readValue(file, FederationList.class); + try(InputStream inputStream = getClass().getClassLoader().getResourceAsStream(federationListPath)){ + federationList = mapper.readValue(inputStream, FederationList.class); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/src/main/java/org/bih/aft/service/FederationService.java b/src/main/java/org/bih/aft/service/FederationService.java index d6322a4..9549d30 100644 --- a/src/main/java/org/bih/aft/service/FederationService.java +++ b/src/main/java/org/bih/aft/service/FederationService.java @@ -25,14 +25,13 @@ public class FederationService implements QueryUseCase { @Value("${aft.location}") private String homeLocation; - OpenEhrClient openEhrClient; + private final OpenEhrClient openEhrClient; - QueryVerificator queryVerificator; + private final QueryVerificator queryVerificator; - LocationProvider federationListService; - - QueryService queryService; + private final LocationProvider federationListService; + private final QueryService queryService; @Override public List federate(AQLinput aqlQuery) throws InvalidCountQuery { diff --git a/src/test/java/org/bih/aft/service/FederationListServiceTest.java b/src/test/java/org/bih/aft/service/FederationListServiceTest.java index d96bb29..3aa5f46 100644 --- a/src/test/java/org/bih/aft/service/FederationListServiceTest.java +++ b/src/test/java/org/bih/aft/service/FederationListServiceTest.java @@ -16,7 +16,6 @@ void getFederationList() { List actual = service.locations(); Location location = new Location("Test2", "https://localhost:8091"); List expected = Lists.list(location); - assertEquals(expected, actual); } }