summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm/etl/processor
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-07-26 08:39:58 +0200
committerPaul-Christian Volkmer2023-07-26 08:39:58 +0200
commit26312c86205681723dd8a9c249e886c8655aa078 (patch)
treed8047466d1b3905e32a44bbc198e300808a0be1a /src/main/kotlin/dev/dnpm/etl/processor
parentcd20e0a17050c7096d3bf50dcf34d7bffd6cc1c6 (diff)
Add human readable data quality report
Diffstat (limited to 'src/main/kotlin/dev/dnpm/etl/processor')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt6
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/monitoring/ReportService.kt51
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt5
3 files changed, 61 insertions, 1 deletions
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 e4a97ee..5c3add2 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfiguration.kt
@@ -20,6 +20,7 @@
package dev.dnpm.etl.processor.config
import com.fasterxml.jackson.databind.ObjectMapper
+import dev.dnpm.etl.processor.monitoring.ReportService
import dev.dnpm.etl.processor.output.KafkaMtbFileSender
import dev.dnpm.etl.processor.output.MtbFileSender
import dev.dnpm.etl.processor.output.RestMtbFileSender
@@ -83,6 +84,11 @@ class AppConfiguration {
}
@Bean
+ fun reportService(objectMapper: ObjectMapper): ReportService {
+ return ReportService(objectMapper)
+ }
+
+ @Bean
fun statisticsUpdateProducer(): Sinks.Many<Any> {
return Sinks.many().multicast().directBestEffort()
}
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ReportService.kt b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ReportService.kt
new file mode 100644
index 0000000..6ee8ae9
--- /dev/null
+++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/ReportService.kt
@@ -0,0 +1,51 @@
+/*
+ * This file is part of ETL-Processor
+ *
+ * Copyright (c) 2023 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.monitoring
+
+import com.fasterxml.jackson.annotation.JsonValue
+import com.fasterxml.jackson.databind.JsonMappingException
+import com.fasterxml.jackson.databind.ObjectMapper
+
+class ReportService(
+ private val objectMapper: ObjectMapper
+) {
+
+ fun deserialize(dataQualityReport: String?): List<Issue> {
+ if (dataQualityReport.isNullOrBlank()) {
+ return listOf()
+ }
+ return try {
+ objectMapper.readValue(dataQualityReport, DataQualityReport::class.java).issues
+ } catch (e: JsonMappingException) {
+ e.printStackTrace()
+ listOf()
+ }
+ }
+
+
+ private data class DataQualityReport(val issues: List<Issue>)
+
+ data class Issue(val severity: Severity, val message: String)
+
+ enum class Severity(@JsonValue val value: String) {
+ ERROR("error"),
+ WARNING("warning"),
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
index c139bf7..51bf3fc 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
@@ -20,6 +20,7 @@
package dev.dnpm.etl.processor.web
import dev.dnpm.etl.processor.NotFoundException
+import dev.dnpm.etl.processor.monitoring.ReportService
import dev.dnpm.etl.processor.monitoring.RequestId
import dev.dnpm.etl.processor.monitoring.RequestRepository
import org.springframework.stereotype.Controller
@@ -31,7 +32,8 @@ import org.springframework.web.bind.annotation.RequestMapping
@Controller
@RequestMapping(path = ["/"])
class HomeController(
- private val requestRepository: RequestRepository
+ private val requestRepository: RequestRepository,
+ private val reportService: ReportService
) {
@GetMapping
@@ -46,6 +48,7 @@ class HomeController(
fun report(@PathVariable id: RequestId, model: Model): String {
val request = requestRepository.findByUuidEquals(id.toString()).orElse(null) ?: throw NotFoundException()
model.addAttribute("request", request)
+ model.addAttribute("issues", reportService.deserialize(request.report?.dataQualityReport))
return "report"
}