diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt index 48aac5f..e009383 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt @@ -8,6 +8,7 @@ import com.aamdigital.aambackendservice.reporting.report.core.ReportingStorage import com.aamdigital.aambackendservice.reporting.reportcalculation.core.CreateReportCalculationRequest import com.aamdigital.aambackendservice.reporting.reportcalculation.core.CreateReportCalculationResult import com.aamdigital.aambackendservice.reporting.reportcalculation.core.CreateReportCalculationUseCase +import com.aamdigital.aambackendservice.reporting.reportcalculation.dto.ReportCalculationData import com.aamdigital.aambackendservice.reporting.reportcalculation.dto.ReportCalculationDto import com.aamdigital.aambackendservice.reporting.storage.DefaultReportStorage import org.springframework.core.io.buffer.DataBuffer @@ -125,7 +126,7 @@ class ReportCalculationController( val prefix = """ { - "_id": "${calculationId}_data.json", + "id": "${calculationId}_data.json", "report": { "id": "${calculation.report.id}" }, @@ -168,6 +169,15 @@ class ReportCalculationController( startDate = it.calculationStarted, endDate = it.calculationCompleted, args = it.args, - attachments = it.attachments, + data = toReportCalculationData(it), ) + + private fun toReportCalculationData(it: ReportCalculation): ReportCalculationData? { + val attachment = it.attachments["data.json"] ?: return null + return ReportCalculationData( + contentType = attachment.contentType, + hash = attachment.digest, + length = attachment.length + ) + } } diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/dto/ControllerDtos.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/dto/ControllerDtos.kt index 442c650..f1aa028 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/dto/ControllerDtos.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/dto/ControllerDtos.kt @@ -1,6 +1,5 @@ package com.aamdigital.aambackendservice.reporting.reportcalculation.dto -import com.aamdigital.aambackendservice.couchdb.dto.AttachmentMetaData import com.aamdigital.aambackendservice.domain.DomainReference import com.aamdigital.aambackendservice.reporting.domain.ReportCalculationStatus @@ -14,7 +13,13 @@ data class ReportCalculationDto( var startDate: String? = null, var endDate: String? = null, var args: Map, - var attachments: Map = emptyMap(), + var data: ReportCalculationData?, +) + +data class ReportCalculationData( + val contentType: String, + val hash: String, + val length: Number, ) /** diff --git a/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/fetch-calculation-data.feature b/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/fetch-calculation-data.feature index 0a7878d..570cd74 100644 --- a/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/fetch-calculation-data.feature +++ b/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/fetch-calculation-data.feature @@ -10,7 +10,7 @@ Feature: the report calculation data endpoint persist to database When the client calls GET /v1/reporting/report-calculation/ReportCalculation:1/data Then the client receives an json object Then the client receives status code of 200 - Then the client receives value ReportCalculation:1_data.json for property _id + Then the client receives value ReportCalculation:1_data.json for property id # ReportCalculation not available Scenario: client makes call to GET /reporting/report-calculation/ReportCalculation:42/data and receives NotFound diff --git a/docs/api-specs/reporting-api-v1.yaml b/docs/api-specs/reporting-api-v1.yaml index 98ae81c..7597820 100644 --- a/docs/api-specs/reporting-api-v1.yaml +++ b/docs/api-specs/reporting-api-v1.yaml @@ -482,15 +482,32 @@ components: id: type: string format: uuid - start_date: + report: + type: object + properties: + id: + type: string + format: uuid + status: + type: string + description: Current status of the run + enum: + - PENDING + - RUNNING + - FINISHED_SUCCESS + - FINISHED_ERROR + startDate: type: string + description: The Date, the calculation starts processing the query example: date - end_date: + endDate: type: string + description: The Date, the calculation finished processing and the data is available example: date nullable: true - params: + args: type: object + description: Input arguments will be injected into the sql query properties: from: type: string @@ -502,14 +519,15 @@ components: description: optional end date filtering data included in the report. If no date is given here, all data (possibly filtered by the "from" date) is included. The field considered for date filtering are defined in each report's query specifically. format: date nullable: true - status: - type: string - description: Current status of the run - enum: - - PENDING - - RUNNING - - FINISHED_SUCCESS - - FINISHED_ERROR + data: + type: object + properties: + contentType: + type: string + hash: + type: string + length: + type: number ReportData: type: object