From 12e446655c31fb2dc6f5d2e4308809086631adec Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Thu, 6 Jun 2024 13:53:40 +0200 Subject: [PATCH] fix: prevent JsonParsing errors in ReportDoc data class --- .../reporting/report/dto/ControllerDtos.kt | 4 ++-- .../reporting/storage/DefaultReportingStorage.kt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/report/dto/ControllerDtos.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/report/dto/ControllerDtos.kt index 9910e92..13f3582 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/report/dto/ControllerDtos.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/report/dto/ControllerDtos.kt @@ -20,8 +20,8 @@ data class ReportDoc( @JsonProperty("_rev") val rev: String, val title: String, - val mode: String, - val aggregationDefinition: String, + val mode: String = "unknown", + val aggregationDefinition: String?, val created: EditAtBy?, val updated: EditAtBy?, ) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/storage/DefaultReportingStorage.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/storage/DefaultReportingStorage.kt index 644da36..2b63235 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/storage/DefaultReportingStorage.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/storage/DefaultReportingStorage.kt @@ -50,9 +50,9 @@ class DefaultReportingStorage( id = it.id, name = it.doc.title, mode = it.doc.mode, - query = it.doc.aggregationDefinition, + query = it.doc.aggregationDefinition ?: "", schema = ReportSchema( - fields = reportSchemaGenerator.getTableNamesByQuery(it.doc.aggregationDefinition) + fields = reportSchemaGenerator.getTableNamesByQuery(it.doc.aggregationDefinition ?: "") ) ) } @@ -68,10 +68,10 @@ class DefaultReportingStorage( Report( id = reportDoc.id, name = reportDoc.title, - query = reportDoc.aggregationDefinition, + query = reportDoc.aggregationDefinition ?: "", mode = reportDoc.mode, schema = ReportSchema( - fields = reportSchemaGenerator.getTableNamesByQuery(reportDoc.aggregationDefinition) + fields = reportSchemaGenerator.getTableNamesByQuery(reportDoc.aggregationDefinition ?: "") ) ) )