From f1ba1036262e1b07bdc15b71ede0668da0b83d83 Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Wed, 17 Jul 2024 14:58:04 +0200 Subject: [PATCH 01/10] work on docker compose file --- ...TaskStartDataSendWithAbsoluteReference.xml | 14 +++++----- ...skStartDataSendWithIdentifierReference.xml | 16 ++++++------ .../fhir/Task/TaskStartDataTrigger.xml | 8 +++--- .../fhir/Task/TaskStopDataTrigger.xml | 4 +-- .../README.md | 26 +++++++++---------- .../docker-compose.yml | 20 ++++++++------ 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithAbsoluteReference.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithAbsoluteReference.xml index 325c15e3..16121807 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithAbsoluteReference.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithAbsoluteReference.xml @@ -1,8 +1,8 @@ - + - + @@ -44,8 +44,8 @@ - @@ -56,8 +56,8 @@ - - \ No newline at end of file + diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml index 6f57fd86..bb743b56 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml @@ -1,8 +1,8 @@ - + - + @@ -32,7 +32,7 @@ @@ -49,8 +49,8 @@ - @@ -61,8 +61,8 @@ - - \ No newline at end of file + diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataTrigger.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataTrigger.xml index 9255df41..8cf13dc7 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataTrigger.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataTrigger.xml @@ -1,8 +1,8 @@ - + - + @@ -31,7 +31,7 @@ - - \ No newline at end of file + diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStopDataTrigger.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStopDataTrigger.xml index a2311792..8dce74be 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStopDataTrigger.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStopDataTrigger.xml @@ -1,8 +1,8 @@ - + - + diff --git a/codex-processes-ap1-docker-test-setup/README.md b/codex-processes-ap1-docker-test-setup/README.md index 2b177e28..b54dc196 100644 --- a/codex-processes-ap1-docker-test-setup/README.md +++ b/codex-processes-ap1-docker-test-setup/README.md @@ -9,53 +9,53 @@ mvn clean package Add entries to your hosts file ``` 127.0.0.1 dic -127.0.0.1 gth +127.0.0.1 dts 127.0.0.1 crr ``` -*Start docker-compose commands from sub-folder:* `codex-processes-ap1/codex-processes-ap1-docker-test-setup` +*Start docker compose commands from sub-folder:* `codex-processes-ap1/codex-processes-ap1-docker-test-setup` Console 1: Start DIC HAPI FHIR Server or DIC blaze FHIR Server ```sh -docker-compose up dic-fhir-store-hapi -docker-compose up dic-fhir-store-blaze +docker compose up dic-fhir-store-hapi +docker compose up dic-fhir-store-blaze ``` Access at http://localhost:8080/fhir/ Console 2: Start CRR fhir-bridge server ```sh -docker-compose up crr-fhir-bridge +docker compose up crr-fhir-bridge ``` Access at http://localhost:8888/fhir-bridge/fhir/ Console 3: Start DIC DSF FHIR Server and wait till started ```sh -docker-compose up -d dic-fhir && docker-compose logs -f dic-fhir +docker compose up -d dic-fhir && docker compose logs -f dic-fhir ``` Console 3: Disconnect from log output (Ctrl-C) if server started Console 3: Start DIC DSF BPE Server ```sh -docker-compose up -d dic-bpe && docker-compose logs -f dic-fhir dic-bpe +docker compose up -d dic-bpe && docker compose logs -f dic-fhir dic-bpe ```` Console 4: Start GTH DSF FHIR Server and wait till started ```sh -docker-compose up -d gth-fhir && docker-compose logs -f gth-fhir +docker compose up -d dts-fhir && docker compose logs -f dts-fhir ``` Console 4: Disconnect from log output (Ctrl-C) if server started Console 4: Start GTH DSF BPE Server ```sh -docker-compose up -d gth-bpe && docker-compose logs -f gth-fhir gth-bpe +docker compose up -d dts-bpe && docker compose logs -f dts-fhir dts-bpe ```` Console 5: Start CRR DSF FHIR Server and wait till started ```sh -docker-compose up -d crr-fhir && docker-compose logs -f crr-fhir +docker compose up -d crr-fhir && docker compose logs -f crr-fhir ``` Console 5: Dicconnect from log output (Ctrl-C) if server started Console 5: Start CRR DSF BPE Server ```sh -docker-compose up -d crr-bpe && docker-compose logs -f crr-fhir crr-bpe +docker compose up -d crr-bpe && docker compose logs -f crr-fhir crr-bpe ```` @@ -62,7 +62,7 @@ - @@ -73,8 +73,8 @@ - @@ -85,4 +85,13 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml index bb743b56..5cb42c7a 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml @@ -86,4 +86,13 @@ --> + + + + + + + + + diff --git a/codex-processes-ap1-docker-test-setup/docker-compose.yml b/codex-processes-ap1-docker-test-setup/docker-compose.yml index 13d33aed..c086173e 100644 --- a/codex-processes-ap1-docker-test-setup/docker-compose.yml +++ b/codex-processes-ap1-docker-test-setup/docker-compose.yml @@ -472,7 +472,7 @@ services: DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CRR_PRIVATE_KEY: /run/secrets/crr_private_key.pem DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATA_BASE_URL: http://crr-fhir-store-hapi:8080/fhir DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATALOGGINGENABLED: 'true' - DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CLIENT_MAP: 'num=http://crr-fhir-store-hapi:8080/fhir, restPrincipe=http://crr-fhir-store-hapi-2:8080/fhir' + DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CLIENT_MAP: 'numNum=http://crr-fhir-store-hapi:8080/fhir, restPrincipe=http://crr-fhir-store-hapi-2:8080/fhir' networks: crr-bpe-frontend: crr-bpe-backend: From 744de2aadb73fa05363fcadd6ea32b9f193519da Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Wed, 31 Jul 2024 11:57:33 +0200 Subject: [PATCH 05/10] client config as map, with test property file --- .../DataTransferProcessPluginDefinition.java | 11 +-- .../message/StartReceiveProcess.java | 2 - .../message/StartTranslateProcess.java | 2 - .../service/receive/InsertDataIntoCodex.java | 5 +- .../spring/config/RdpCrrConfig.java | 96 +++++++++++++++++++ .../spring/config/ReceiveConfig.java | 65 +------------ .../bpe/process/rdp-application.properties | 13 +++ .../docker-compose.yml | 1 - 8 files changed, 118 insertions(+), 77 deletions(-) create mode 100644 codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java create mode 100644 codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java index 85965d8c..6f8be42d 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java @@ -5,14 +5,7 @@ import java.util.List; import java.util.Map; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ProcessPluginDeploymentConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ReceiveConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.SendConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.TransferDataConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.TransferDataSerializerConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.TranslateConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.TriggerConfig; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ValidationConfig; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.*; import dev.dsf.bpe.v1.ProcessPluginDefinition; public class DataTransferProcessPluginDefinition implements ProcessPluginDefinition @@ -48,7 +41,7 @@ public List getProcessModels() public List> getSpringConfigurations() { return List.of(TransferDataConfig.class, TransferDataSerializerConfig.class, ValidationConfig.class, - TriggerConfig.class, SendConfig.class, TranslateConfig.class, ReceiveConfig.class, + TriggerConfig.class, SendConfig.class, TranslateConfig.class, ReceiveConfig.class, RdpCrrConfig.class, ProcessPluginDeploymentConfig.class); } diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java index 9f1fe751..87ff1130 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java @@ -56,8 +56,6 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw .get(); String endpointAddress = endpoint.getAddress(); - logger.info("HIER =====> {}", asString(variables.getStartTask())); - Target target = variables.createTarget(crrIdentifierValue, endpointIdentifierValue, endpointAddress); variables.setTarget(target); diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java index 1ba1b574..22068bf9 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java @@ -57,8 +57,6 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw .get(); String endpointAddress = endpoint.getAddress(); - logger.info("HIER =====> {}", asString(variables.getStartTask())); - Target target = variables.createTarget(dtsIdentifierValue, endpointIdentifierValue, endpointAddress); variables.setTarget(target); diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java index c2eda71b..d2dd3f08 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java @@ -18,6 +18,7 @@ import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.ValidationException; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.ContinueStatus; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.RdpCrrConfig; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; import dev.dsf.bpe.v1.variables.Variables; @@ -29,10 +30,10 @@ public class InsertDataIntoCodex extends AbstractServiceDelegate private final DataStoreClientFactory dataClientFactory; private final DataLogger dataLogger; private final FhirContext fhirContext; - private final Map clientMap; + private final Map clientMap; public InsertDataIntoCodex(ProcessPluginApi api, DataStoreClientFactory dataClientFactory, DataLogger dataLogger, - FhirContext fhirContext, Map clientConfig) + FhirContext fhirContext, Map clientConfig) { super(api); diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java new file mode 100644 index 00000000..1678c91a --- /dev/null +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java @@ -0,0 +1,96 @@ +package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.annotation.PostConstruct; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import java.util.Collections; +import java.util.Map; + +@Configuration +@PropertySource(ignoreResourceNotFound = true, value = "file:process/rdp-application.properties") +public class RdpCrrConfig +{ + private static final Logger logger = LoggerFactory.getLogger(RdpCrrConfig.class); + public static final String INVALID_CONFIG_MESSAGE = "Invalid Client Config map"; + public static final String VALID_CONFIG_MESSAGE = "Client Config found: {}"; + + @Autowired + private ObjectMapper objectMapper; + + @Value("${rpdClient:#{null}}") + private String rdpClientMapProperty; + private Map rdpClientConfigValues; + + @PostConstruct + private void convertClientMap() + { + if (rdpClientMapProperty == null || rdpClientMapProperty.isEmpty()) + { + return; + } + + try + { + rdpClientConfigValues = objectMapper.readValue(rdpClientMapProperty, new TypeReference<>() + { + }); + + logger.info(VALID_CONFIG_MESSAGE, rdpClientConfigValues.keySet()); + } + catch (JsonProcessingException e) + { + logger.error(INVALID_CONFIG_MESSAGE); + rdpClientConfigValues = Collections.emptyMap(); + throw new RuntimeException(INVALID_CONFIG_MESSAGE, e); + } + } + + @Bean + public Map getRdpClientMap() + { + return rdpClientConfigValues; + } + + public static class RdpClientConfigValues + { + private String baseUrl; + private String username; + private String password; + private String bearerToken; + + public String getBaseUrl() + { + return baseUrl; + } + + public String getUsername() + { + return username; + } + + public String getPassword() + { + return password; + } + + public String getBearerToken() + { + return bearerToken; + } + + @Override + public String toString() + { + return "RdpClientConfigValues{" + "baseUrl='" + baseUrl + '\'' + ", Username='" + username + '\'' + '}'; + } + } +} diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java index b43916ee..9e211507 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java @@ -1,13 +1,6 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,27 +9,12 @@ import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.message.ContinueTranslateProcess; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.message.ContinueTranslateProcessWithError; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.message.ContinueTranslateProcessWithValidationError; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.DecryptData; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.DeleteValidationErrorForDts; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.DownloadDataFromDts; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.EncryptValidationError; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.InsertDataIntoCodex; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.LogError; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.LogSuccess; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.LogValidationError; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.StoreValidationErrorForDts; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.*; import dev.dsf.bpe.v1.ProcessPluginApi; -import dev.dsf.bpe.v1.documentation.ProcessDocumentation; -import jakarta.annotation.PostConstruct; @Configuration public class ReceiveConfig { - private static final Logger logger = LoggerFactory.getLogger(ReceiveConfig.class); - public static final String INVALID_CONFIG_MESSAGE = "Invalid Client Config, incorrect key value pair, key = '{}'"; - public static final String VALID_CONFIG_MESSAGE = "Client Config found: {}"; - public static final String CLIENT_SEPARATOR = ","; - public static final String KEY_VALUE_SEPARATOR = "="; @Autowired private ProcessPluginApi api; @@ -44,36 +22,8 @@ public class ReceiveConfig @Autowired private TransferDataConfig transferDataConfig; - @ProcessDocumentation(description = "A Test Value", processNames = "wwwnetzwerk-universitaetsmedizinde_receive") - @Value("${de.netzwerk.universitaetsmedizin.rdp.client.map:#{null}}") - private String clientConfig; - - private Map clientConfigMap; - - @PostConstruct - private void convertConfigValues() - { - if (clientConfig == null) - { - clientConfigMap = Collections.emptyMap(); - return; - } - - clientConfigMap = new HashMap<>(); - String[] configList = clientConfig.split(CLIENT_SEPARATOR); - for (String config : configList) - { - String[] configEntrySet = config.split(KEY_VALUE_SEPARATOR); - if (configEntrySet.length % 2 != 0) - { - logger.warn(INVALID_CONFIG_MESSAGE, configEntrySet[0]); - continue; - } - clientConfigMap.put(configEntrySet[0].trim(), configEntrySet[1].trim()); - } - logger.info(VALID_CONFIG_MESSAGE, clientConfigMap.keySet()); - logger.debug(VALID_CONFIG_MESSAGE, clientConfigMap); - } + @Autowired + private RdpCrrConfig rdpCrrConfig; @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @@ -94,7 +44,7 @@ public DecryptData decryptData() public InsertDataIntoCodex insertDataIntoCodex() { return new InsertDataIntoCodex(api, transferDataConfig.dataStoreClientFactory(), - transferDataConfig.dataLogger(), api.getFhirContext(), getClientConfigMap()); + transferDataConfig.dataLogger(), api.getFhirContext(), rdpCrrConfig.getRdpClientMap()); } @Bean @@ -162,11 +112,4 @@ public LogError logError() { return new LogError(api, transferDataConfig.errorOutputParameterGenerator(), transferDataConfig.errorLogger()); } - - @Bean - @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) - public Map getClientConfigMap() - { - return clientConfigMap; - } } diff --git a/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties new file mode 100644 index 00000000..7428e780 --- /dev/null +++ b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties @@ -0,0 +1,13 @@ +rpdClient={\ + "numNum": {\ + "baseUrl": "http://crr-fhir-store-hapi:8080/fhir",\ + "username": "NumUser",\ + "password": "Password1",\ + "bearerToken": "asdvjnasdoivjn"\ + },\ + "restPrincipe": {\ + "baseUrl": "http://crr-fhir-store-hapi-2:8080/fhir",\ + "username": "",\ + "bearerToken": "684641843141384"\ + }\ +} diff --git a/codex-processes-ap1-docker-test-setup/docker-compose.yml b/codex-processes-ap1-docker-test-setup/docker-compose.yml index c086173e..33c0265c 100644 --- a/codex-processes-ap1-docker-test-setup/docker-compose.yml +++ b/codex-processes-ap1-docker-test-setup/docker-compose.yml @@ -472,7 +472,6 @@ services: DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CRR_PRIVATE_KEY: /run/secrets/crr_private_key.pem DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATA_BASE_URL: http://crr-fhir-store-hapi:8080/fhir DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATALOGGINGENABLED: 'true' - DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CLIENT_MAP: 'numNum=http://crr-fhir-store-hapi:8080/fhir, restPrincipe=http://crr-fhir-store-hapi-2:8080/fhir' networks: crr-bpe-frontend: crr-bpe-backend: From 92a20d3e45249c2041c560694516977a869029cc Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Wed, 31 Jul 2024 13:23:45 +0200 Subject: [PATCH 06/10] receive: multiple client first try --- .../client/DataStoreClientFactory.java | 71 +++++++++++-------- .../service/receive/InsertDataIntoCodex.java | 39 ++++++---- .../spring/config/RdpCrrConfig.java | 30 ++++++-- .../spring/config/ReceiveConfig.java | 5 +- .../spring/config/TransferDataConfig.java | 7 +- .../docker-compose.yml | 10 +++ 6 files changed, 109 insertions(+), 53 deletions(-) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java index a2ebd6cb..8ee8435d 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java @@ -9,6 +9,7 @@ import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.util.Map; import java.util.UUID; import org.bouncycastle.pkcs.PKCSException; @@ -20,6 +21,7 @@ import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.DataStoreFhirClient; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.DataStoreFhirClientStub; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.RdpCrrConfig; import de.rwh.utils.crypto.CertificateHelper; import de.rwh.utils.crypto.io.CertificateReader; import de.rwh.utils.crypto.io.PemIo; @@ -27,6 +29,7 @@ public class DataStoreClientFactory { private static final Logger logger = LoggerFactory.getLogger(DataStoreClientFactory.class); + private static final String DEFAULT_DATA_STORE = "default"; private static final class DataStoreClientStub implements DataStoreClient { @@ -91,10 +94,7 @@ public boolean shouldUseChainedParameterNotLogicalReference() private final int socketTimeout; private final int connectionRequestTimeout; - private final String dataStoreServerBase; - private final String dataStoreServerBasicAuthUsername; - private final String dataStoreServerBasicAuthPassword; - private final String dataStoreServerBearerToken; + private final Map clientConfigMap; private final String proxyUrl; private final String proxyUsername; @@ -112,10 +112,11 @@ public boolean shouldUseChainedParameterNotLogicalReference() public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath, char[] privateKeyPassword, int connectTimeout, int socketTimeout, int connectionRequestTimeout, String dataStoreServerBase, String dataStoreServerBasicAuthUsername, - String dataStoreServerBasicAuthPassword, String dataStoreServerBearerToken, String proxyUrl, - String proxyUsername, String proxyPassword, boolean hapiClientVerbose, FhirContext fhirContext, - Path searchBundleOverride, Class dataStoreFhirClientClass, - boolean useChainedParameterNotLogicalReference, DataLogger dataLogger) + String dataStoreServerBasicAuthPassword, String dataStoreServerBearerToken, + Map clientConfigMap, String proxyUrl, String proxyUsername, + String proxyPassword, boolean hapiClientVerbose, FhirContext fhirContext, Path searchBundleOverride, + Class dataStoreFhirClientClass, boolean useChainedParameterNotLogicalReference, + DataLogger dataLogger) { this.trustStorePath = trustStorePath; this.certificatePath = certificatePath; @@ -126,10 +127,9 @@ public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path pr this.socketTimeout = socketTimeout; this.connectionRequestTimeout = connectionRequestTimeout; - this.dataStoreServerBase = dataStoreServerBase; - this.dataStoreServerBasicAuthUsername = dataStoreServerBasicAuthUsername; - this.dataStoreServerBasicAuthPassword = dataStoreServerBasicAuthPassword; - this.dataStoreServerBearerToken = dataStoreServerBearerToken; + this.clientConfigMap = clientConfigMap; + this.clientConfigMap.put(DEFAULT_DATA_STORE, new RdpCrrConfig.RdpClientConfigValues(dataStoreServerBase, + dataStoreServerBasicAuthUsername, dataStoreServerBasicAuthPassword, dataStoreServerBearerToken)); this.proxyUrl = proxyUrl; this.proxyUsername = proxyUsername; @@ -146,21 +146,25 @@ public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path pr public String getServerBase() { - return dataStoreServerBase; + return clientConfigMap.get(DEFAULT_DATA_STORE).getBaseUrl(); } public void testConnection() { try { - logger.info( - "Testing connection to Data Store FHIR server with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, privateKeyPassword: {}," - + " basicAuthUsername: {}, basicAuthPassword: {}, bearerToken: {}, serverBase: {}, proxy: values from 'DEV_DSF_PROXY'... config}", - trustStorePath, certificatePath, privateKeyPath, privateKeyPassword != null ? "***" : "null", - dataStoreServerBasicAuthUsername, dataStoreServerBasicAuthPassword != null ? "***" : "null", - dataStoreServerBearerToken != null ? "***" : "null", dataStoreServerBase); + for (String client : clientConfigMap.keySet()) + { + final RdpCrrConfig.RdpClientConfigValues value = clientConfigMap.get(client); + logger.info( + "Testing connection to Data Store FHIR server with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, privateKeyPassword: {}," + + " basicAuthUsername: {}, basicAuthPassword: {}, bearerToken: {}, serverBase: {}, proxy: values from 'DEV_DSF_PROXY'... config}", + trustStorePath, certificatePath, privateKeyPath, privateKeyPassword != null ? "***" : "null", + value.getUsername(), value.getPassword() != null ? "***" : "null", + value.getBearerToken() != null ? "***" : "null", value.getBaseUrl()); - getDataStoreClient().testConnection(); + getDataStoreClient(client).testConnection(); + } } catch (Exception e) { @@ -170,18 +174,28 @@ public void testConnection() public DataStoreClient getDataStoreClient() { - if (configured()) - return createDataStoreClient(); + return getDataStoreClient(DEFAULT_DATA_STORE); + } + + public DataStoreClient getDataStoreClient(String client) + { + if (configured(client)) + return createDataStoreClient(client); else return new DataStoreClientStub(fhirContext, dataLogger); } - private boolean configured() + private boolean configured(String client) { - return dataStoreServerBase != null && !dataStoreServerBase.isBlank(); + return clientConfigMap.get(client).getBaseUrl() != null && !clientConfigMap.get(client).getBaseUrl().isBlank(); } protected DataStoreClient createDataStoreClient() + { + return createDataStoreClient(DEFAULT_DATA_STORE); + } + + protected DataStoreClient createDataStoreClient(String client) { KeyStore trustStore = null; char[] keyStorePassword = null; @@ -200,11 +214,12 @@ protected DataStoreClient createDataStoreClient() keyStore = readKeyStore(certificatePath, privateKeyPath, privateKeyPassword, keyStorePassword); } + final RdpCrrConfig.RdpClientConfigValues value = clientConfigMap.get(client); + return new DataStoreClientImpl(trustStore, keyStore, keyStorePassword, connectTimeout, socketTimeout, - connectionRequestTimeout, dataStoreServerBasicAuthUsername, dataStoreServerBasicAuthPassword, - dataStoreServerBearerToken, dataStoreServerBase, proxyUrl, proxyUsername, proxyPassword, - hapiClientVerbose, fhirContext, searchBundleOverride, dataStoreFhirClientClass, - useChainedParameterNotLogicalReference, dataLogger); + connectionRequestTimeout, value.getUsername(), value.getPassword(), value.getBearerToken(), + value.getBaseUrl(), proxyUrl, proxyUsername, proxyPassword, hapiClientVerbose, fhirContext, + searchBundleOverride, dataStoreFhirClientClass, useChainedParameterNotLogicalReference, dataLogger); } private KeyStore readTrustStore(Path trustPath) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java index d2dd3f08..3caa5ea3 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java @@ -1,15 +1,15 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive; -import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_BUNDLE; -import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_CONTINUE_STATUS; -import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_INSERT_INTO_CRR_FHIR_REPOSITORY_FAILED; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; -import java.util.*; +import java.util.Map; +import java.util.Objects; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Resource; +import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,7 +18,6 @@ import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.ValidationException; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.ContinueStatus; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.RdpCrrConfig; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; import dev.dsf.bpe.v1.variables.Variables; @@ -30,17 +29,15 @@ public class InsertDataIntoCodex extends AbstractServiceDelegate private final DataStoreClientFactory dataClientFactory; private final DataLogger dataLogger; private final FhirContext fhirContext; - private final Map clientMap; public InsertDataIntoCodex(ProcessPluginApi api, DataStoreClientFactory dataClientFactory, DataLogger dataLogger, - FhirContext fhirContext, Map clientConfig) + FhirContext fhirContext) { super(api); this.dataClientFactory = dataClientFactory; this.dataLogger = dataLogger; this.fhirContext = fhirContext; - this.clientMap = clientConfig; } @Override @@ -61,12 +58,17 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw { try { - logger.info("Executing bundle against FHIR store ... {}", asString(variables.getStartTask())); - logger.info("Client filter Map {}", clientMap); - logger.info("Client filter keySet {}", clientMap.keySet()); + + String studyId = getStudyId(variables.getStartTask()); + if (studyId.isEmpty()) + { + logger.error("Unable to receive, studyId is empty"); + throw new RuntimeException("study-Id is empty"); + } + logger.info("Executing bundle against FHIR store ... {}", studyId); dataLogger.logData("Received bundle", bundle); - dataClientFactory.getDataStoreClient().getFhirClient().storeBundle(bundle); + dataClientFactory.getDataStoreClient(studyId).getFhirClient().storeBundle(bundle); execution.setVariable(BPMN_EXECUTION_VARIABLE_CONTINUE_STATUS, ContinueStatus.SUCCESS); } @@ -89,4 +91,17 @@ private String asString(Resource resource) { return fhirContext.newJsonParser().encodeResourceToString(resource); } + + private String getStudyId(Task task) + { + for (Task.ParameterComponent input : task.getInput()) + { + if (input.getType().getCodingFirstRep().getCode().equals("study-id")) + { + return input.getValue().toString(); + } + } + + return ""; + } } diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java index 1678c91a..b4a3d43c 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java @@ -1,9 +1,9 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.annotation.PostConstruct; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -12,8 +12,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import java.util.Collections; -import java.util.Map; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import jakarta.annotation.PostConstruct; @Configuration @PropertySource(ignoreResourceNotFound = true, value = "file:process/rdp-application.properties") @@ -35,6 +38,7 @@ private void convertClientMap() { if (rdpClientMapProperty == null || rdpClientMapProperty.isEmpty()) { + rdpClientConfigValues = new HashMap<>(); return; } @@ -49,7 +53,7 @@ private void convertClientMap() catch (JsonProcessingException e) { logger.error(INVALID_CONFIG_MESSAGE); - rdpClientConfigValues = Collections.emptyMap(); + rdpClientConfigValues = new HashMap<>(); throw new RuntimeException(INVALID_CONFIG_MESSAGE, e); } } @@ -67,6 +71,18 @@ public static class RdpClientConfigValues private String password; private String bearerToken; + public RdpClientConfigValues() + { + } + + public RdpClientConfigValues(String baseUrl, String username, String password, String bearerToken) + { + this.baseUrl = baseUrl; + this.username = username; + this.password = password; + this.bearerToken = bearerToken; + } + public String getBaseUrl() { return baseUrl; diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java index 9e211507..6a33db48 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java @@ -22,9 +22,6 @@ public class ReceiveConfig @Autowired private TransferDataConfig transferDataConfig; - @Autowired - private RdpCrrConfig rdpCrrConfig; - @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public DownloadDataFromDts downloadDataFromDts() @@ -44,7 +41,7 @@ public DecryptData decryptData() public InsertDataIntoCodex insertDataIntoCodex() { return new InsertDataIntoCodex(api, transferDataConfig.dataStoreClientFactory(), - transferDataConfig.dataLogger(), api.getFhirContext(), rdpCrrConfig.getRdpClientMap()); + transferDataConfig.dataLogger(), api.getFhirContext()); } @Bean diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java index 6d6266e3..1a994e30 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java @@ -29,6 +29,9 @@ public class TransferDataConfig @Autowired private ProcessPluginApi api; + @Autowired + private RdpCrrConfig rdpCrrConfig; + @ProcessDocumentation(description = "PEM encoded file with trusted certificates to validate the server-certificate of the data FHIR server", processNames = { "wwwnetzwerk-universitaetsmedizinde_dataSend", "wwwnetzwerk-universitaetsmedizinde_dataReceive" }, recommendation = "Use docker secret file to configure", example = "/run/secrets/data_fhir_server_ca.pem") @@ -318,8 +321,8 @@ public DataStoreClientFactory dataStoreClientFactory() return new DataStoreClientFactory(trustStorePath, certificatePath, privateKeyPath, fhirStorePrivateKeyPassword, fhirStoreConnectTimeout, fhirStoreSocketTimeout, fhirStoreConnectionRequestTimeout, fhirStoreBaseUrl, fhirStoreUsername, fhirStorePassword, - fhirStoreBearerToken, proxyUrl, proxyUsername, proxyPassword, fhirStoreHapiClientVerbose, - api.getFhirContext(), searchBundleOverride, + fhirStoreBearerToken, rdpCrrConfig.getRdpClientMap(), proxyUrl, proxyUsername, proxyPassword, + fhirStoreHapiClientVerbose, api.getFhirContext(), searchBundleOverride, (Class) Class.forName(fhirStoreClientClass), fhirStoreUseChainedParameterNotLogicalReference, dataLogger()); } diff --git a/codex-processes-ap1-docker-test-setup/docker-compose.yml b/codex-processes-ap1-docker-test-setup/docker-compose.yml index 33c0265c..56fb08f7 100644 --- a/codex-processes-ap1-docker-test-setup/docker-compose.yml +++ b/codex-processes-ap1-docker-test-setup/docker-compose.yml @@ -541,6 +541,16 @@ services: hapi.fhir.allowed_bundle_types: COLLECTION,DOCUMENT,MESSAGE,TRANSACTION networks: - crr-bpe-backend + crr-fhir-store-hapi-2: + build: ./crr/hapi + restart: "no" + ports: + - 127.0.0.1:8890:8080 + environment: + TZ: Europe/Berlin + hapi.fhir.allowed_bundle_types: COLLECTION,DOCUMENT,MESSAGE,TRANSACTION + networks: + - crr-bpe-backend secrets: From 2f57b43e6752cfa8a65d97645a94f120a3c33d2d Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Thu, 1 Aug 2024 10:13:02 +0200 Subject: [PATCH 07/10] cleanup and renaming --- .../DataTransferProcessPluginDefinition.java | 4 +- .../client/DataStoreClientFactory.java | 44 ++++++++++--------- .../message/StartReceiveProcess.java | 10 +---- .../message/StartTranslateProcess.java | 10 +---- .../service/receive/InsertDataIntoCodex.java | 31 +++++-------- .../spring/config/ReceiveConfig.java | 5 +-- ...onfig.java => ReceiveDataStoreConfig.java} | 29 ++++++------ .../spring/config/SendConfig.java | 2 +- .../spring/config/TransferDataConfig.java | 8 ++-- .../spring/config/TranslateConfig.java | 2 +- .../bpe/process/rdp-application.properties | 2 +- .../docker-compose.yml | 1 - 12 files changed, 60 insertions(+), 88 deletions(-) rename codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/{RdpCrrConfig.java => ReceiveDataStoreConfig.java} (69%) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java index 6f8be42d..f6b76bfa 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/DataTransferProcessPluginDefinition.java @@ -41,8 +41,8 @@ public List getProcessModels() public List> getSpringConfigurations() { return List.of(TransferDataConfig.class, TransferDataSerializerConfig.class, ValidationConfig.class, - TriggerConfig.class, SendConfig.class, TranslateConfig.class, ReceiveConfig.class, RdpCrrConfig.class, - ProcessPluginDeploymentConfig.class); + TriggerConfig.class, SendConfig.class, TranslateConfig.class, ReceiveConfig.class, + ReceiveDataStoreConfig.class, ProcessPluginDeploymentConfig.class); } @Override diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java index 8ee8435d..5dfdb2ad 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/DataStoreClientFactory.java @@ -21,7 +21,7 @@ import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.DataStoreFhirClient; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.DataStoreFhirClientStub; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.RdpCrrConfig; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ReceiveDataStoreConfig; import de.rwh.utils.crypto.CertificateHelper; import de.rwh.utils.crypto.io.CertificateReader; import de.rwh.utils.crypto.io.PemIo; @@ -94,7 +94,7 @@ public boolean shouldUseChainedParameterNotLogicalReference() private final int socketTimeout; private final int connectionRequestTimeout; - private final Map clientConfigMap; + private final Map dataStoreConnectionMap; private final String proxyUrl; private final String proxyUsername; @@ -113,10 +113,10 @@ public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path pr char[] privateKeyPassword, int connectTimeout, int socketTimeout, int connectionRequestTimeout, String dataStoreServerBase, String dataStoreServerBasicAuthUsername, String dataStoreServerBasicAuthPassword, String dataStoreServerBearerToken, - Map clientConfigMap, String proxyUrl, String proxyUsername, - String proxyPassword, boolean hapiClientVerbose, FhirContext fhirContext, Path searchBundleOverride, - Class dataStoreFhirClientClass, boolean useChainedParameterNotLogicalReference, - DataLogger dataLogger) + Map dataStoreConnectionMap, String proxyUrl, + String proxyUsername, String proxyPassword, boolean hapiClientVerbose, FhirContext fhirContext, + Path searchBundleOverride, Class dataStoreFhirClientClass, + boolean useChainedParameterNotLogicalReference, DataLogger dataLogger) { this.trustStorePath = trustStorePath; this.certificatePath = certificatePath; @@ -127,9 +127,11 @@ public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path pr this.socketTimeout = socketTimeout; this.connectionRequestTimeout = connectionRequestTimeout; - this.clientConfigMap = clientConfigMap; - this.clientConfigMap.put(DEFAULT_DATA_STORE, new RdpCrrConfig.RdpClientConfigValues(dataStoreServerBase, - dataStoreServerBasicAuthUsername, dataStoreServerBasicAuthPassword, dataStoreServerBearerToken)); + this.dataStoreConnectionMap = dataStoreConnectionMap; + this.dataStoreConnectionMap.put(DEFAULT_DATA_STORE, + new ReceiveDataStoreConfig.DataStoreConnectionValues(dataStoreServerBase, + dataStoreServerBasicAuthUsername, dataStoreServerBasicAuthPassword, + dataStoreServerBearerToken)); this.proxyUrl = proxyUrl; this.proxyUsername = proxyUsername; @@ -146,22 +148,22 @@ public DataStoreClientFactory(Path trustStorePath, Path certificatePath, Path pr public String getServerBase() { - return clientConfigMap.get(DEFAULT_DATA_STORE).getBaseUrl(); + return dataStoreConnectionMap.get(DEFAULT_DATA_STORE).getBaseUrl(); } public void testConnection() { try { - for (String client : clientConfigMap.keySet()) + for (String client : dataStoreConnectionMap.keySet()) { - final RdpCrrConfig.RdpClientConfigValues value = clientConfigMap.get(client); + final ReceiveDataStoreConfig.DataStoreConnectionValues value = dataStoreConnectionMap.get(client); logger.info( "Testing connection to Data Store FHIR server with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, privateKeyPassword: {}," + " basicAuthUsername: {}, basicAuthPassword: {}, bearerToken: {}, serverBase: {}, proxy: values from 'DEV_DSF_PROXY'... config}", trustStorePath, certificatePath, privateKeyPath, privateKeyPassword != null ? "***" : "null", - value.getUsername(), value.getPassword() != null ? "***" : "null", - value.getBearerToken() != null ? "***" : "null", value.getBaseUrl()); + value.getBaseUrl(), value.getPassword() != null ? "***" : "null", + value.getBearerToken() != null ? "***" : "null", value.getUsername()); getDataStoreClient(client).testConnection(); } @@ -187,7 +189,8 @@ public DataStoreClient getDataStoreClient(String client) private boolean configured(String client) { - return clientConfigMap.get(client).getBaseUrl() != null && !clientConfigMap.get(client).getBaseUrl().isBlank(); + return dataStoreConnectionMap.get(client).getBaseUrl() != null + && !dataStoreConnectionMap.get(client).getBaseUrl().isBlank(); } protected DataStoreClient createDataStoreClient() @@ -195,7 +198,7 @@ protected DataStoreClient createDataStoreClient() return createDataStoreClient(DEFAULT_DATA_STORE); } - protected DataStoreClient createDataStoreClient(String client) + protected DataStoreClient createDataStoreClient(String dataStore) { KeyStore trustStore = null; char[] keyStorePassword = null; @@ -214,12 +217,13 @@ protected DataStoreClient createDataStoreClient(String client) keyStore = readKeyStore(certificatePath, privateKeyPath, privateKeyPassword, keyStorePassword); } - final RdpCrrConfig.RdpClientConfigValues value = clientConfigMap.get(client); + final ReceiveDataStoreConfig.DataStoreConnectionValues dataStoreConfig = dataStoreConnectionMap.get(dataStore); return new DataStoreClientImpl(trustStore, keyStore, keyStorePassword, connectTimeout, socketTimeout, - connectionRequestTimeout, value.getUsername(), value.getPassword(), value.getBearerToken(), - value.getBaseUrl(), proxyUrl, proxyUsername, proxyPassword, hapiClientVerbose, fhirContext, - searchBundleOverride, dataStoreFhirClientClass, useChainedParameterNotLogicalReference, dataLogger); + connectionRequestTimeout, dataStoreConfig.getUsername(), dataStoreConfig.getPassword(), + dataStoreConfig.getBearerToken(), dataStoreConfig.getBaseUrl(), proxyUrl, proxyUsername, proxyPassword, + hapiClientVerbose, fhirContext, searchBundleOverride, dataStoreFhirClientClass, + useChainedParameterNotLogicalReference, dataLogger); } private KeyStore readTrustStore(Path trustPath) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java index 87ff1130..553bff2a 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java @@ -29,14 +29,11 @@ public class StartReceiveProcess extends AbstractTaskMessageSend private final String crrIdentifierValue; - private final FhirContext fhirContext; - - public StartReceiveProcess(ProcessPluginApi api, String crrIdentifierValue, FhirContext fhirContext) + public StartReceiveProcess(ProcessPluginApi api, String crrIdentifierValue) { super(api); this.crrIdentifierValue = crrIdentifierValue; - this.fhirContext = fhirContext; } @Override @@ -62,11 +59,6 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw super.doExecute(execution, variables); } - private String asString(Resource resource) - { - return fhirContext.newJsonParser().encodeResourceToString(resource); - } - @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java index 22068bf9..0e0d41a3 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java @@ -30,14 +30,11 @@ public class StartTranslateProcess extends AbstractTaskMessageSend private final String dtsIdentifierValue; - private final FhirContext fhirContext; - - public StartTranslateProcess(ProcessPluginApi api, String dtsIdentifierValue, FhirContext fhirContext) + public StartTranslateProcess(ProcessPluginApi api, String dtsIdentifierValue) { super(api); this.dtsIdentifierValue = dtsIdentifierValue; - this.fhirContext = fhirContext; } @Override @@ -63,11 +60,6 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw super.doExecute(execution, variables); } - private String asString(Resource resource) - { - return fhirContext.newJsonParser().encodeResourceToString(resource); - } - @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java index 3caa5ea3..e4d5d081 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java @@ -2,18 +2,15 @@ import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; -import java.util.Map; import java.util.Objects; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.Task; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import ca.uhn.fhir.context.FhirContext; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.DataStoreClientFactory; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.ValidationException; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; @@ -28,16 +25,13 @@ public class InsertDataIntoCodex extends AbstractServiceDelegate private final DataStoreClientFactory dataClientFactory; private final DataLogger dataLogger; - private final FhirContext fhirContext; - public InsertDataIntoCodex(ProcessPluginApi api, DataStoreClientFactory dataClientFactory, DataLogger dataLogger, - FhirContext fhirContext) + public InsertDataIntoCodex(ProcessPluginApi api, DataStoreClientFactory dataClientFactory, DataLogger dataLogger) { super(api); this.dataClientFactory = dataClientFactory; this.dataLogger = dataLogger; - this.fhirContext = fhirContext; } @Override @@ -54,18 +48,18 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw { Bundle bundle = variables.getResource(BPMN_EXECUTION_VARIABLE_BUNDLE); + String studyId = getStudyId(variables.getStartTask()); + if (studyId == null || studyId.isEmpty()) + { + logger.error("Unable to receive, {} is empty", CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); + throw new RuntimeException(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID + " is empty"); + } + try { try { - - String studyId = getStudyId(variables.getStartTask()); - if (studyId.isEmpty()) - { - logger.error("Unable to receive, studyId is empty"); - throw new RuntimeException("study-Id is empty"); - } - logger.info("Executing bundle against FHIR store ... {}", studyId); + logger.info("Executing bundle against FHIR store '{}'", studyId); dataLogger.logData("Received bundle", bundle); dataClientFactory.getDataStoreClient(studyId).getFhirClient().storeBundle(bundle); @@ -87,16 +81,11 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw } } - private String asString(Resource resource) - { - return fhirContext.newJsonParser().encodeResourceToString(resource); - } - private String getStudyId(Task task) { for (Task.ParameterComponent input : task.getInput()) { - if (input.getType().getCodingFirstRep().getCode().equals("study-id")) + if (input.getType().getCodingFirstRep().getCode().equals(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)) { return input.getValue().toString(); } diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java index 6a33db48..af3b508e 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveConfig.java @@ -15,7 +15,6 @@ @Configuration public class ReceiveConfig { - @Autowired private ProcessPluginApi api; @@ -37,11 +36,11 @@ public DecryptData decryptData() } @Bean - @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public InsertDataIntoCodex insertDataIntoCodex() { return new InsertDataIntoCodex(api, transferDataConfig.dataStoreClientFactory(), - transferDataConfig.dataLogger(), api.getFhirContext()); + transferDataConfig.dataLogger()); } @Bean diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java similarity index 69% rename from codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java rename to codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java index b4a3d43c..0c32892c 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/RdpCrrConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java @@ -1,6 +1,5 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -20,62 +19,60 @@ @Configuration @PropertySource(ignoreResourceNotFound = true, value = "file:process/rdp-application.properties") -public class RdpCrrConfig +public class ReceiveDataStoreConfig { - private static final Logger logger = LoggerFactory.getLogger(RdpCrrConfig.class); + private static final Logger logger = LoggerFactory.getLogger(ReceiveDataStoreConfig.class); public static final String INVALID_CONFIG_MESSAGE = "Invalid Client Config map"; public static final String VALID_CONFIG_MESSAGE = "Client Config found: {}"; @Autowired private ObjectMapper objectMapper; - @Value("${rpdClient:#{null}}") - private String rdpClientMapProperty; - private Map rdpClientConfigValues; + @Value("${dataStores:#{null}}") + private String dataStoresProperty; + private Map dataStoreConnectionConfigs = new HashMap<>();; @PostConstruct private void convertClientMap() { - if (rdpClientMapProperty == null || rdpClientMapProperty.isEmpty()) + if (dataStoresProperty == null || dataStoresProperty.isEmpty()) { - rdpClientConfigValues = new HashMap<>(); return; } try { - rdpClientConfigValues = objectMapper.readValue(rdpClientMapProperty, new TypeReference<>() + dataStoreConnectionConfigs = objectMapper.readValue(dataStoresProperty, new TypeReference<>() { }); - logger.info(VALID_CONFIG_MESSAGE, rdpClientConfigValues.keySet()); + logger.info(VALID_CONFIG_MESSAGE, dataStoreConnectionConfigs.keySet()); } catch (JsonProcessingException e) { logger.error(INVALID_CONFIG_MESSAGE); - rdpClientConfigValues = new HashMap<>(); throw new RuntimeException(INVALID_CONFIG_MESSAGE, e); } } @Bean - public Map getRdpClientMap() + public Map getDataStoreConnectionConfigs() { - return rdpClientConfigValues; + return dataStoreConnectionConfigs; } - public static class RdpClientConfigValues + public static class DataStoreConnectionValues { private String baseUrl; private String username; private String password; private String bearerToken; - public RdpClientConfigValues() + public DataStoreConnectionValues() { } - public RdpClientConfigValues(String baseUrl, String username, String password, String bearerToken) + public DataStoreConnectionValues(String baseUrl, String username, String password, String bearerToken) { this.baseUrl = baseUrl; this.username = username; diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/SendConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/SendConfig.java index 10c07059..58daee36 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/SendConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/SendConfig.java @@ -132,7 +132,7 @@ public StoreDataForDts storeDataForDts() @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public StartTranslateProcess startTranslateProcess() { - return new StartTranslateProcess(api, transferDataConfig.dtsIdentifierValue(), api.getFhirContext()); + return new StartTranslateProcess(api, transferDataConfig.dtsIdentifierValue()); } @Bean(name = "Send-setTimeoutError") // prefix to force distinct bean names diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java index 1a994e30..7e014613 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java @@ -30,7 +30,7 @@ public class TransferDataConfig private ProcessPluginApi api; @Autowired - private RdpCrrConfig rdpCrrConfig; + private ReceiveDataStoreConfig receiveDataStoreConfig; @ProcessDocumentation(description = "PEM encoded file with trusted certificates to validate the server-certificate of the data FHIR server", processNames = { "wwwnetzwerk-universitaetsmedizinde_dataSend", @@ -321,9 +321,9 @@ public DataStoreClientFactory dataStoreClientFactory() return new DataStoreClientFactory(trustStorePath, certificatePath, privateKeyPath, fhirStorePrivateKeyPassword, fhirStoreConnectTimeout, fhirStoreSocketTimeout, fhirStoreConnectionRequestTimeout, fhirStoreBaseUrl, fhirStoreUsername, fhirStorePassword, - fhirStoreBearerToken, rdpCrrConfig.getRdpClientMap(), proxyUrl, proxyUsername, proxyPassword, - fhirStoreHapiClientVerbose, api.getFhirContext(), searchBundleOverride, - (Class) Class.forName(fhirStoreClientClass), + fhirStoreBearerToken, receiveDataStoreConfig.getDataStoreConnectionConfigs(), proxyUrl, + proxyUsername, proxyPassword, fhirStoreHapiClientVerbose, api.getFhirContext(), + searchBundleOverride, (Class) Class.forName(fhirStoreClientClass), fhirStoreUseChainedParameterNotLogicalReference, dataLogger()); } catch (ClassNotFoundException e) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TranslateConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TranslateConfig.java index 25cfb978..4b6eeac1 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TranslateConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TranslateConfig.java @@ -59,7 +59,7 @@ public StoreDataForCrr storeDataForCodex() @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public StartReceiveProcess startReceiveProcess() { - return new StartReceiveProcess(api, transferDataConfig.crrIdentifierValue(), api.getFhirContext()); + return new StartReceiveProcess(api, transferDataConfig.crrIdentifierValue()); } @Bean(name = "Translate-setTimeoutError") // prefix to force distinct bean names diff --git a/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties index 7428e780..d7dff08a 100644 --- a/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties +++ b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties @@ -1,4 +1,4 @@ -rpdClient={\ +dataStores={\ "numNum": {\ "baseUrl": "http://crr-fhir-store-hapi:8080/fhir",\ "username": "NumUser",\ diff --git a/codex-processes-ap1-docker-test-setup/docker-compose.yml b/codex-processes-ap1-docker-test-setup/docker-compose.yml index 56fb08f7..e0b0b413 100644 --- a/codex-processes-ap1-docker-test-setup/docker-compose.yml +++ b/codex-processes-ap1-docker-test-setup/docker-compose.yml @@ -470,7 +470,6 @@ services: DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DTS_IDENTIFIER_VALUE: Test_DTS DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CRR_IDENTIFIER_VALUE: Test_CRR DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_CRR_PRIVATE_KEY: /run/secrets/crr_private_key.pem - DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATA_BASE_URL: http://crr-fhir-store-hapi:8080/fhir DE_NETZWERK_UNIVERSITAETSMEDIZIN_RDP_DATALOGGINGENABLED: 'true' networks: crr-bpe-frontend: From aa3ebe21cb54ba0a2338e692d77cb1e02b6c7a13 Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Mon, 5 Aug 2024 14:15:04 +0200 Subject: [PATCH 08/10] add tests and cleanups --- codex-process-data-transfer/pom.xml | 15 ++- .../service/receive/InsertDataIntoCodex.java | 17 ++-- .../spring/config/ReceiveDataStoreConfig.java | 13 +-- .../receive/InsertDataIntoCodexTest.java | 95 +++++++++++++++++++ .../config/ReceiveDataStoreConfigTest.java | 80 ++++++++++++++++ .../invalid-application.properties | 3 + .../valid-application.properties | 8 ++ .../bpe/process/rdp-application.properties | 11 +-- pom.xml | 18 ++-- 9 files changed, 229 insertions(+), 31 deletions(-) create mode 100644 codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodexTest.java create mode 100644 codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfigTest.java create mode 100644 codex-process-data-transfer/src/test/resources/applicationProperties/invalid-application.properties create mode 100644 codex-process-data-transfer/src/test/resources/applicationProperties/valid-application.properties diff --git a/codex-process-data-transfer/pom.xml b/codex-process-data-transfer/pom.xml index 364a6523..efd17551 100644 --- a/codex-process-data-transfer/pom.xml +++ b/codex-process-data-transfer/pom.xml @@ -65,6 +65,17 @@ mockito-core test + + org.mockito + mockito-junit-jupiter + test + + + org.springframework + spring-test + 6.0.11 + test + org.apache.logging.log4j log4j-slf4j2-impl @@ -102,7 +113,7 @@ false - + @@ -263,4 +274,4 @@ - \ No newline at end of file + diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java index e4d5d081..a049b26a 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java @@ -3,6 +3,7 @@ import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; import java.util.Objects; +import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -11,12 +12,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.DataStoreClientFactory; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.ValidationException; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.ContinueStatus; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractServiceDelegate; +import dev.dsf.bpe.v1.service.TaskHelper; import dev.dsf.bpe.v1.variables.Variables; public class InsertDataIntoCodex extends AbstractServiceDelegate @@ -52,7 +55,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw if (studyId == null || studyId.isEmpty()) { logger.error("Unable to receive, {} is empty", CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); - throw new RuntimeException(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID + " is empty"); + throw new IllegalArgumentException(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID + " is empty"); } try @@ -83,14 +86,10 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw private String getStudyId(Task task) { - for (Task.ParameterComponent input : task.getInput()) - { - if (input.getType().getCodingFirstRep().getCode().equals(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)) - { - return input.getValue().toString(); - } - } + TaskHelper taskHelper = this.api.getTaskHelper(); + Optional studyId = taskHelper.getFirstInputParameterStringValue(task, + CODESYSTEM_NUM_CODEX_DATA_TRANSFER, CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); - return ""; + return studyId.orElse(""); } } diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java index 0c32892c..25cf555d 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfig.java @@ -30,10 +30,10 @@ public class ReceiveDataStoreConfig @Value("${dataStores:#{null}}") private String dataStoresProperty; - private Map dataStoreConnectionConfigs = new HashMap<>();; + private Map dataStoreConnectionConfigs = new HashMap<>(); @PostConstruct - private void convertClientMap() + protected void convertClientMap() { if (dataStoresProperty == null || dataStoresProperty.isEmpty()) { @@ -42,16 +42,17 @@ private void convertClientMap() try { - dataStoreConnectionConfigs = objectMapper.readValue(dataStoresProperty, new TypeReference<>() - { - }); + dataStoreConnectionConfigs = objectMapper.readValue(dataStoresProperty, + new TypeReference>() + { + }); logger.info(VALID_CONFIG_MESSAGE, dataStoreConnectionConfigs.keySet()); } catch (JsonProcessingException e) { logger.error(INVALID_CONFIG_MESSAGE); - throw new RuntimeException(INVALID_CONFIG_MESSAGE, e); + throw new IllegalArgumentException(INVALID_CONFIG_MESSAGE, e); } } diff --git a/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodexTest.java b/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodexTest.java new file mode 100644 index 00000000..1c4ab7a2 --- /dev/null +++ b/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodexTest.java @@ -0,0 +1,95 @@ +package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive; + +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.*; + +import java.util.Optional; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.hl7.fhir.r4.model.*; +import org.junit.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; + +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.DataStoreClient; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.DataStoreClientFactory; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.DataStoreFhirClient; +import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; +import dev.dsf.bpe.v1.ProcessPluginApi; +import dev.dsf.bpe.v1.service.TaskHelper; +import dev.dsf.bpe.v1.variables.Variables; + +@ExtendWith(MockitoExtension.class) +@RunWith(MockitoJUnitRunner.class) +public class InsertDataIntoCodexTest +{ + + @Test + public void testDoExecuteWithStudyId() throws Exception + { + ProcessPluginApi api = mock(ProcessPluginApi.class); + DataStoreClientFactory dataStoreClientFactory = mock(DataStoreClientFactory.class); + DataLogger dataLogger = mock(DataLogger.class); + InsertDataIntoCodex insertDataIntoCodex = new InsertDataIntoCodex(api, dataStoreClientFactory, dataLogger); + + Variables variables = mock(Variables.class); + DelegateExecution execution = mock(DelegateExecution.class); + Bundle bundle = new Bundle(); + when(api.getVariables(execution)).thenReturn(variables); + when(variables.getResource(BPMN_EXECUTION_VARIABLE_BUNDLE)).thenReturn(bundle); + + Task task = createTask(); + when(variables.getStartTask()).thenReturn(task); + TaskHelper taskHelper = mock(TaskHelper.class); + when(api.getTaskHelper()).thenReturn(taskHelper); + + when(taskHelper.getFirstInputParameterStringValue(task, CODESYSTEM_NUM_CODEX_DATA_TRANSFER, + CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)).thenReturn(Optional.of("dataStore")); + + DataStoreClient dataStoreClient = mock(DataStoreClient.class); + DataStoreFhirClient fhirClient = mock(DataStoreFhirClient.class); + when(dataStoreClientFactory.getDataStoreClient("dataStore")).thenReturn(dataStoreClient); + when(dataStoreClient.getFhirClient()).thenReturn(fhirClient); + + insertDataIntoCodex.execute(execution); + + verify(dataStoreClientFactory, times(1)).getDataStoreClient("dataStore"); + } + + @Test + public void testDoExecuteWithoutStudyId() throws Exception + { + ProcessPluginApi api = mock(ProcessPluginApi.class); + DataStoreClientFactory dataStoreClientFactory = mock(DataStoreClientFactory.class); + DataLogger dataLogger = mock(DataLogger.class); + InsertDataIntoCodex insertDataIntoCodex = new InsertDataIntoCodex(api, dataStoreClientFactory, dataLogger); + + Variables variables = mock(Variables.class); + DelegateExecution execution = mock(DelegateExecution.class); + Bundle bundle = new Bundle(); + when(variables.getResource(BPMN_EXECUTION_VARIABLE_BUNDLE)).thenReturn(bundle); + + Task task = createTask(); + when(variables.getStartTask()).thenReturn(task); + TaskHelper taskHelper = mock(TaskHelper.class); + when(api.getTaskHelper()).thenReturn(taskHelper); + + when(taskHelper.getFirstInputParameterStringValue(task, CODESYSTEM_NUM_CODEX_DATA_TRANSFER, + CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)).thenReturn(Optional.of("")); + + assertThrows(IllegalArgumentException.class, () -> insertDataIntoCodex.doExecute(execution, variables)); + verify(dataStoreClientFactory, never()); + } + + private Task createTask() + { + Task task = new Task(); + Coding code = new Coding(); + code.setSystem(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); + task.addInput(new Task.ParameterComponent(new CodeableConcept(code), new StringType("study_id"))); + return task; + } +} diff --git a/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfigTest.java b/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfigTest.java new file mode 100644 index 00000000..ec659502 --- /dev/null +++ b/codex-process-data-transfer/src/test/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/ReceiveDataStoreConfigTest.java @@ -0,0 +1,80 @@ +package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config; + +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import java.util.Properties; + +import org.junit.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; + +import junit.framework.TestCase; + +@ExtendWith(MockitoExtension.class) +@RunWith(MockitoJUnitRunner.class) +public class ReceiveDataStoreConfigTest extends TestCase +{ + + public static final String VALID_PROPERTIES = "applicationProperties/valid-application.properties"; + public static final String INVALID_PROPERTIES = "applicationProperties/invalid-application.properties"; + + @InjectMocks + private ReceiveDataStoreConfig receiveDataStoreConfig; + + @Spy + private ObjectMapper objectMapper = JsonMapper.builder().serializationInclusion(JsonInclude.Include.NON_NULL) + .serializationInclusion(JsonInclude.Include.NON_EMPTY).disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS).disable(MapperFeature.AUTO_DETECT_SETTERS).build(); + + @Test + public void testConvertClientMapValidMap() throws IOException + { + String fileContent = readPropertyFile(VALID_PROPERTIES); + + receiveDataStoreConfig.convertClientMap(); + verify(objectMapper, times(1)).readValue(eq(fileContent), any(TypeReference.class)); + } + + @Test(expected = IllegalArgumentException.class) + public void testConvertClientMapInvalidMap() throws IOException + { + String fileContent = readPropertyFile(INVALID_PROPERTIES); + + receiveDataStoreConfig.convertClientMap(); + verify(objectMapper, times(1)).readValue(eq(fileContent), any(TypeReference.class)); + } + + @Test + public void testConvertClientMapWithoutMap() throws IOException + { + receiveDataStoreConfig.convertClientMap(); + verify(objectMapper, never()).readValue(anyString(), any(TypeReference.class)); + } + + private String readPropertyFile(String resourcePath) throws IOException + { + Properties props = new Properties(); + + ClassLoader classLoader = this.getClass().getClassLoader(); + InputStream propsStream = Objects.requireNonNull(classLoader.getResourceAsStream(resourcePath)); + props.load(propsStream); + propsStream.close(); + String dataStores = (String) props.get("dataStores"); + ReflectionTestUtils.setField(receiveDataStoreConfig, "dataStoresProperty", dataStores); + return dataStores; + } +} diff --git a/codex-process-data-transfer/src/test/resources/applicationProperties/invalid-application.properties b/codex-process-data-transfer/src/test/resources/applicationProperties/invalid-application.properties new file mode 100644 index 00000000..049b6ca1 --- /dev/null +++ b/codex-process-data-transfer/src/test/resources/applicationProperties/invalid-application.properties @@ -0,0 +1,3 @@ +dataStores={\ + "invalid"\ +} diff --git a/codex-process-data-transfer/src/test/resources/applicationProperties/valid-application.properties b/codex-process-data-transfer/src/test/resources/applicationProperties/valid-application.properties new file mode 100644 index 00000000..7980cec2 --- /dev/null +++ b/codex-process-data-transfer/src/test/resources/applicationProperties/valid-application.properties @@ -0,0 +1,8 @@ +dataStores={\ + "validDataStore": {\ + "baseUrl": "http://fhir-store:8080/fhir",\ + "username": "user",\ + "password": "strongPassword1",\ + "bearerToken": "valid123"\ + }\ +} diff --git a/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties index d7dff08a..ea845ec0 100644 --- a/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties +++ b/codex-processes-ap1-docker-test-setup/crr/bpe/process/rdp-application.properties @@ -1,13 +1,8 @@ dataStores={\ - "numNum": {\ - "baseUrl": "http://crr-fhir-store-hapi:8080/fhir",\ - "username": "NumUser",\ - "password": "Password1",\ - "bearerToken": "asdvjnasdoivjn"\ + "num": {\ + "baseUrl": "http://crr-fhir-store-hapi:8080/fhir"\ },\ "restPrincipe": {\ - "baseUrl": "http://crr-fhir-store-hapi-2:8080/fhir",\ - "username": "",\ - "bearerToken": "684641843141384"\ + "baseUrl": "http://crr-fhir-store-hapi-2:8080/fhir"\ }\ } diff --git a/pom.xml b/pom.xml index 82b7ca28..df8012bd 100644 --- a/pom.xml +++ b/pom.xml @@ -93,7 +93,7 @@ hapi-fhir-validation ${hapi.version} - + org.apache.commons @@ -131,7 +131,7 @@ crypto-utils 3.8.0 - + org.slf4j slf4j-api @@ -157,6 +157,12 @@ mockito-core 4.8.0 + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + org.apache.logging.log4j log4j-slf4j2-impl @@ -197,7 +203,7 @@ org.apache.maven.plugins - maven-shade-plugin + maven-shade-plugin 3.5.1 @@ -268,8 +274,8 @@ - github @@ -343,4 +349,4 @@ - \ No newline at end of file + From 24d84a2e340a9c0e7e264b9ef159e502161c2b90 Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Mon, 5 Aug 2024 14:22:12 +0200 Subject: [PATCH 09/10] revert assumption task with study ID --- .../message/StartReceiveProcess.java | 34 ++++++----------- .../message/StartTranslateProcess.java | 37 ++++++------------- .../fhir/CodeSystem/data-transfer.xml | 7 +--- .../task-start-data-receive.xml | 37 +------------------ .../task-start-data-send.xml | 36 +----------------- .../task-start-data-translate.xml | 37 +------------------ .../task-start-data-trigger.xml | 2 +- ...skStartDataSendWithIdentifierReference.xml | 5 ++- ...skStartDataSendWithIdentifierReference.xml | 5 ++- 9 files changed, 37 insertions(+), 163 deletions(-) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java index 553bff2a..48a9de19 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartReceiveProcess.java @@ -1,19 +1,26 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.message; -import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_BINARY_URL; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PSEUDONYM; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_CRR_NOT_REACHABLE; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DATA_REFERENCE; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_PSEUDONYM; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.NUM_PARENT_ORGANIZATION_IDENTIFIER; import java.util.Objects; -import java.util.Optional; import java.util.stream.Stream; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.Endpoint; +import org.hl7.fhir.r4.model.Identifier; +import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Task.ParameterComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import ca.uhn.fhir.context.FhirContext; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend; @@ -62,7 +69,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return Stream.of(pseudonymParameter(execution), dataReferenceParameter(execution), studyIdParameter(variables)); + return Stream.of(pseudonymParameter(execution), dataReferenceParameter(execution)); } @Override @@ -105,23 +112,6 @@ private ParameterComponent dataReferenceParameter(DelegateExecution execution) return param; } - private ParameterComponent studyIdParameter(Variables variables) - { - Optional tutorialInput = this.api.getTaskHelper().getFirstInputParameterStringValue( - variables.getStartTask(), ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); - - - return tutorialInput - .map(value -> api.getTaskHelper().createInput(new StringType(value), - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)) - .orElse(api.getTaskHelper().createInput(new StringType("num"), - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)); - } - - @Override protected void handleSendTaskError(DelegateExecution execution, Variables variables, Exception exception, String errorMessage) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java index 0e0d41a3..10e31cdd 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/message/StartTranslateProcess.java @@ -1,21 +1,25 @@ package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.message; -import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.*; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_BINARY_URL; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.BPMN_EXECUTION_VARIABLE_PATIENT_REFERENCE; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_DTS_NOT_REACHABLE; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_DATA_REFERENCE; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_PSEUDONYM; +import static de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer.NUM_PARENT_ORGANIZATION_IDENTIFIER; import java.util.Objects; -import java.util.Optional; import java.util.stream.Stream; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.hl7.fhir.r4.model.*; +import org.hl7.fhir.r4.model.Coding; +import org.hl7.fhir.r4.model.Endpoint; +import org.hl7.fhir.r4.model.Identifier; +import org.hl7.fhir.r4.model.Reference; import org.hl7.fhir.r4.model.Task.ParameterComponent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import ca.uhn.fhir.context.FhirContext; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.receive.InsertDataIntoCodex; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.variables.PatientReference; import dev.dsf.bpe.v1.ProcessPluginApi; import dev.dsf.bpe.v1.activity.AbstractTaskMessageSend; @@ -25,7 +29,6 @@ public class StartTranslateProcess extends AbstractTaskMessageSend { - private static final Logger logger = LoggerFactory.getLogger(StartTranslateProcess.class); private static final Coding DTS_ROLE = new Coding("http://dsf.dev/fhir/CodeSystem/organization-role", "DTS", null); private final String dtsIdentifierValue; @@ -63,7 +66,7 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw @Override protected Stream getAdditionalInputParameters(DelegateExecution execution, Variables variables) { - return Stream.of(pseudonymParameter(execution), dataReferenceParameter(execution), studyIdParameter(variables)); + return Stream.of(pseudonymParameter(execution), dataReferenceParameter(execution)); } private ParameterComponent pseudonymParameter(DelegateExecution execution) @@ -94,22 +97,6 @@ private ParameterComponent dataReferenceParameter(DelegateExecution execution) return param; } - private ParameterComponent studyIdParameter(Variables variables) - { - Optional tutorialInput = this.api.getTaskHelper().getFirstInputParameterStringValue( - variables.getStartTask(), ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID); - - - return tutorialInput - .map(value -> api.getTaskHelper().createInput(new StringType(value), - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)) - .orElse(api.getTaskHelper().createInput(new StringType("num"), - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER, - ConstantsDataTransfer.CODESYSTEM_NUM_CODEX_DATA_TRANSFER_VALUE_STUDY_ID)); - } - @Override protected void handleSendTaskError(DelegateExecution execution, Variables variables, Exception exception, String errorMessage) diff --git a/codex-process-data-transfer/src/main/resources/fhir/CodeSystem/data-transfer.xml b/codex-process-data-transfer/src/main/resources/fhir/CodeSystem/data-transfer.xml index be9d8dcb..60a52ecb 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/CodeSystem/data-transfer.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/CodeSystem/data-transfer.xml @@ -51,11 +51,6 @@ - - - - - @@ -71,4 +66,4 @@ - + \ No newline at end of file diff --git a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-receive.xml b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-receive.xml index 37dd2572..fb540ba7 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-receive.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-receive.xml @@ -28,7 +28,7 @@ - + @@ -134,39 +134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -193,4 +160,4 @@ - + \ No newline at end of file diff --git a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-send.xml b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-send.xml index 41e94db4..a998514d 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-send.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-send.xml @@ -178,40 +178,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -340,4 +306,4 @@ - + \ No newline at end of file diff --git a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-translate.xml b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-translate.xml index 5cdf9602..2065d8f2 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-translate.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-translate.xml @@ -28,7 +28,7 @@ - + @@ -134,39 +134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -227,4 +194,4 @@ - + \ No newline at end of file diff --git a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-trigger.xml b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-trigger.xml index 7b8d2288..ed77026e 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-trigger.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/StructureDefinition/task-start-data-trigger.xml @@ -112,4 +112,4 @@ - + \ No newline at end of file diff --git a/codex-process-data-transfer/src/main/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml b/codex-process-data-transfer/src/main/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml index a9035487..40d12aa0 100644 --- a/codex-process-data-transfer/src/main/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml +++ b/codex-process-data-transfer/src/main/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml @@ -85,6 +85,7 @@ + diff --git a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml index 5cb42c7a..0cde2d33 100644 --- a/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml +++ b/codex-process-data-transfer/src/test/resources/fhir/Task/TaskStartDataSendWithIdentifierReference.xml @@ -86,6 +86,7 @@ --> + From 39d54a4257f92de0c48d6e118c4ab6a652bd4700 Mon Sep 17 00:00:00 2001 From: Marcus Fabarius Date: Wed, 7 Aug 2024 10:46:02 +0200 Subject: [PATCH 10/10] update error log massage, add target store key --- .../data_transfer/service/receive/InsertDataIntoCodex.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java index a049b26a..a86d6e52 100644 --- a/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java +++ b/codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/service/receive/InsertDataIntoCodex.java @@ -12,7 +12,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.ConstantsDataTransfer; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.DataStoreClientFactory; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.client.fhir.ValidationException; import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger; @@ -78,9 +77,9 @@ protected void doExecute(DelegateExecution execution, Variables variables) throw } catch (Exception e) { - logger.warn("Unable to insert data into CRR: {} - {}", e.getClass().getName(), e.getMessage()); + logger.warn("Unable to insert data into '{}': {} - {}", studyId, e.getClass().getName(), e.getMessage()); throw new BpmnError(CODESYSTEM_NUM_CODEX_DATA_TRANSFER_ERROR_VALUE_INSERT_INTO_CRR_FHIR_REPOSITORY_FAILED, - "Unable to insert data into CRR"); + "Unable to insert data into '" + studyId + "'"); } }