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 @@ -82,6 +83,11 @@ class AppConfiguration { return KafkaMtbFileSender(kafkaTemplate, objectMapper) } + @Bean + fun reportService(objectMapper: ObjectMapper): ReportService { + return ReportService(objectMapper) + } + @Bean fun statisticsUpdateProducer(): Sinks.Many { 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 . + */ + +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 { + 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) + + 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" } diff --git a/src/main/resources/templates/report.html b/src/main/resources/templates/report.html index 5a08e44..d9087bf 100644 --- a/src/main/resources/templates/report.html +++ b/src/main/resources/templates/report.html @@ -35,7 +35,22 @@

-
+ + + + + + + + + + + + + + + +
SchweregradBeschreibung
[[ ${issue.severity} ]][[ ${issue.severity} ]][[ ${issue.message} ]]