summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dev')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt6
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt6
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSender.kt19
3 files changed, 21 insertions, 10 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
index 1575c39..0f257e8 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
@@ -45,7 +45,11 @@ data class PseudonymizeConfigProperties(
@ConfigurationProperties(GPasConfigProperties.NAME)
data class GPasConfigProperties(
val uri: String?,
- val target: String = "etl-processor"
+ val target: String = "etl-processor",
+ val username: String?,
+ val password: String?,
+ val sslCaLocation: String?,
+
) {
companion object {
const val NAME = "app.pseudonymize.gpas"
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt
index 5c3add2..c677f2b 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt
@@ -28,16 +28,12 @@ import dev.dnpm.etl.processor.pseudonym.AnonymizingGenerator
import dev.dnpm.etl.processor.pseudonym.Generator
import dev.dnpm.etl.processor.pseudonym.GpasPseudonymGenerator
import dev.dnpm.etl.processor.pseudonym.PseudonymizeService
-import org.reactivestreams.Publisher
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.kafka.core.KafkaTemplate
-import reactor.core.publisher.Flux
import reactor.core.publisher.Sinks
-import java.net.URI
-import java.time.Duration
@Configuration
@EnableConfigurationProperties(
@@ -54,7 +50,7 @@ class AppConfiguration {
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "GPAS")
@Bean
fun gpasPseudonymGenerator(configProperties: GPasConfigProperties): Generator {
- return GpasPseudonymGenerator(URI.create(configProperties.uri!!), configProperties.target)
+ return GpasPseudonymGenerator(configProperties)
}
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "BUILDIN", matchIfMissing = true)
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSender.kt b/src/main/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSender.kt
index 374c0af..9867deb 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSender.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/output/KafkaMtbFileSender.kt
@@ -33,11 +33,22 @@ class KafkaMtbFileSender(
override fun send(mtbFile: MtbFile): MtbFileSender.Response {
return try {
- kafkaTemplate.sendDefault(objectMapper.writeValueAsString(mtbFile))
- logger.debug("Sent file via KafkaMtbFileSender")
- MtbFileSender.Response(MtbFileSender.ResponseStatus.UNKNOWN)
+ val result = kafkaTemplate.sendDefault(
+ String.format(
+ "{\"pid\": \"%s\", \"eid\": \"%s\"}",
+ mtbFile.patient.id,
+ mtbFile.episode.id
+ ), objectMapper.writeValueAsString(mtbFile)
+ )
+ if (result.get() != null) {
+ logger.debug("Sent file via KafkaMtbFileSender")
+ MtbFileSender.Response(MtbFileSender.ResponseStatus.SUCCESS)
+ } else {
+ MtbFileSender.Response(MtbFileSender.ResponseStatus.ERROR)
+ }
+
} catch (e: Exception) {
- logger.error("An error occured sending to kafka", e)
+ logger.error("An error occurred sending to kafka", e)
MtbFileSender.Response(MtbFileSender.ResponseStatus.UNKNOWN)
}
}