diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt index 40ad8bd..e7ef81e 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -192,9 +192,17 @@ class Controller { @PostMapping("/observations/csv") fun getObservationsCsvDump(@Valid @RequestBody observationsRequest: ObservationsRequest): String? { + fun csvHeaderString(): String { + return "Ob ID,Observerfull,Observer,obDate,Title,Type,Department,Station,Station Focus,Scores-Monitoring,Scores-Control Procedural," + + "Scores-Control,Scores-Conservatism,Scores-Teamwork Comms,Scores-Teamwork Leadership,Scores-Teamwork Workload,\"Scores-Knowledge, Skills and Attitudes\"," + + "Strengths-Monitoring,Strengths-Control Procedural,Strengths-Control,Strengths-Conservatism,Strengths-Teamwork Comms," + + "Strengths-Teamwork Leadership,Strengths-Teamwork Workload,\"Strengths-Knowledge, Skills and Attitudes\"," + + "Develop-Monitoring,Develop-Control Procedural,Develop-Control,Develop-Conservatism,Develop-Teamwork Comms," + + "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\"" + } val data = getObservations(observationsRequest) if(data.isEmpty()) return null - val builder = StringBuilder(data[0].csvHeaderString()) + val builder = StringBuilder(csvHeaderString()) data.forEach { builder.append('\n') builder.append(it.toCsvFormat()) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt index 3ce80db..6580134 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt @@ -97,14 +97,6 @@ data class Observation( @ManyToMany val persons: Set ) { - fun csvHeaderString(): String { - return "Ob ID,Observerfull,Observer,obDate,Title,Type,Department,Station,Station Focus,Scores-Monitoring,Scores-Control Procedural," + - "Scores-Control,Scores-Conservatism,Scores-Teamwork Comms,Scores-Teamwork Leadership,Scores-Teamwork Workload,\"Scores-Knowledge, Skills and Attitudes\"," + - "Strengths-Monitoring,Strengths-Control Procedural,Strengths-Control,Strengths-Conservatism,Strengths-Teamwork Comms," + - "Strengths-Teamwork Leadership,Strengths-Teamwork Workload,\"Strengths-Knowledge, Skills and Attitudes\"," + - "Develop-Monitoring,Develop-Control Procedural,Develop-Control,Develop-Conservatism,Develop-Teamwork Comms," + - "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\"" - } fun toCsvFormat(): String { return ",,${tutors.elementAt(0).name},$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," + "${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," +