1
0
mirror of https://github.com/pcvolkmer/etl-processor.git synced 2025-07-04 07:22:55 +00:00

refactor: use different sender classes for bwHC and DIP

This commit is contained in:
2025-03-08 11:18:47 +01:00
parent 262c54f2e5
commit 91e2cf5ef1
6 changed files with 362 additions and 24 deletions

View File

@ -1,7 +1,7 @@
/*
* This file is part of ETL-Processor
*
* Copyright (c) 2024 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
* Copyright (c) 2025 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
@ -23,7 +23,8 @@ import dev.dnpm.etl.processor.monitoring.ConnectionCheckResult
import dev.dnpm.etl.processor.monitoring.ConnectionCheckService
import dev.dnpm.etl.processor.monitoring.RestConnectionCheckService
import dev.dnpm.etl.processor.output.MtbFileSender
import dev.dnpm.etl.processor.output.RestMtbFileSender
import dev.dnpm.etl.processor.output.RestBwhcMtbFileSender
import dev.dnpm.etl.processor.output.RestDipMtbFileSender
import org.slf4j.LoggerFactory
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
@ -54,8 +55,13 @@ class AppRestConfiguration {
restTargetProperties: RestTargetProperties,
retryTemplate: RetryTemplate
): MtbFileSender {
logger.info("Selected 'RestMtbFileSender'")
return RestMtbFileSender(restTemplate, restTargetProperties, retryTemplate)
if (restTargetProperties.isBwhc) {
logger.info("Selected 'RestBwhcMtbFileSender'")
return RestBwhcMtbFileSender(restTemplate, restTargetProperties, retryTemplate)
}
logger.info("Selected 'RestDipMtbFileSender'")
return RestDipMtbFileSender(restTemplate, restTargetProperties, retryTemplate)
}
@Bean

View File

@ -0,0 +1,41 @@
/*
* This file is part of ETL-Processor
*
* Copyright (c) 2025 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package dev.dnpm.etl.processor.output
import dev.dnpm.etl.processor.PatientPseudonym
import dev.dnpm.etl.processor.config.RestTargetProperties
import org.springframework.retry.support.RetryTemplate
import org.springframework.web.client.RestTemplate
class RestBwhcMtbFileSender(
private val restTemplate: RestTemplate,
private val restTargetProperties: RestTargetProperties,
private val retryTemplate: RetryTemplate
) : RestMtbFileSender(restTemplate, restTargetProperties, retryTemplate) {
override fun sendUrl(): String {
return "${restTargetProperties.uri}/MTBFile"
}
override fun deleteUrl(patientId: PatientPseudonym): String {
return "${restTargetProperties.uri}/Patient/${patientId.value}"
}
}

View File

@ -0,0 +1,41 @@
/*
* This file is part of ETL-Processor
*
* Copyright (c) 2025 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package dev.dnpm.etl.processor.output
import dev.dnpm.etl.processor.PatientPseudonym
import dev.dnpm.etl.processor.config.RestTargetProperties
import org.springframework.retry.support.RetryTemplate
import org.springframework.web.client.RestTemplate
class RestDipMtbFileSender(
private val restTemplate: RestTemplate,
private val restTargetProperties: RestTargetProperties,
private val retryTemplate: RetryTemplate
) : RestMtbFileSender(restTemplate, restTargetProperties, retryTemplate) {
override fun sendUrl(): String {
return "${restTargetProperties.uri}/patient-record"
}
override fun deleteUrl(patientId: PatientPseudonym): String {
return "${restTargetProperties.uri}/patient/${patientId.value}"
}
}

View File

@ -30,7 +30,7 @@ import org.springframework.retry.support.RetryTemplate
import org.springframework.web.client.RestClientException
import org.springframework.web.client.RestTemplate
class RestMtbFileSender(
abstract class RestMtbFileSender(
private val restTemplate: RestTemplate,
private val restTargetProperties: RestTargetProperties,
private val retryTemplate: RetryTemplate
@ -38,21 +38,9 @@ class RestMtbFileSender(
private val logger = LoggerFactory.getLogger(RestMtbFileSender::class.java)
fun sendUrl(): String {
return if(restTargetProperties.isBwhc) {
"${restTargetProperties.uri}/MTBFile"
} else {
"${restTargetProperties.uri}/patient-record"
}
}
abstract fun sendUrl(): String
fun deleteUrl(patientId: PatientPseudonym): String {
return if(restTargetProperties.isBwhc) {
"${restTargetProperties.uri}/Patient/${patientId.value}"
} else {
"${restTargetProperties.uri}/patient/${patientId.value}"
}
}
abstract fun deleteUrl(patientId: PatientPseudonym): String
override fun send(request: MtbFileSender.MtbFileRequest): MtbFileSender.Response {
try {