From 5fcc24f915f0e91106b5890e81854720e9ead1a4 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Mon, 29 Apr 2024 10:11:25 +0200 Subject: refactor: add additional constructors --- .../dev/dnpm/etl/processor/monitoring/Request.kt | 23 ++++++++++++++++++++- .../etl/processor/services/RequestProcessor.kt | 24 +++++++++++----------- 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'src/main') diff --git a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt index 976c333..79a3a5b 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt @@ -43,7 +43,28 @@ data class Request( var status: RequestStatus, var processedAt: Instant = Instant.now(), @Embedded.Nullable var report: Report? = null -) +) { + constructor( + uuid: String, + patientId: String, + pid: String, + fingerprint: String, + type: RequestType, + status: RequestStatus + ) : + this(null, uuid, patientId, pid, fingerprint, type, status, Instant.now()) + + constructor( + uuid: String, + patientId: String, + pid: String, + fingerprint: String, + type: RequestType, + status: RequestStatus, + processedAt: Instant + ) : + this(null, uuid, patientId, pid, fingerprint, type, status, processedAt) +} @JvmRecord data class Report( diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt index bdf07cb..939af16 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt @@ -62,12 +62,12 @@ class RequestProcessor( requestService.save( Request( - uuid = requestId, - patientId = request.mtbFile.patient.id, - pid = pid, - fingerprint = fingerprint(request.mtbFile), - status = RequestStatus.UNKNOWN, - type = RequestType.MTB_FILE + requestId, + request.mtbFile.patient.id, + pid, + fingerprint(request.mtbFile), + RequestType.MTB_FILE, + RequestStatus.UNKNOWN ) ) @@ -117,12 +117,12 @@ class RequestProcessor( requestService.save( Request( - uuid = requestId, - patientId = patientPseudonym, - pid = patientId, - fingerprint = fingerprint(patientPseudonym), - status = RequestStatus.UNKNOWN, - type = RequestType.DELETE + requestId, + patientPseudonym, + patientId, + fingerprint(patientPseudonym), + RequestType.DELETE, + RequestStatus.UNKNOWN ) ) -- cgit v1.2.3