Moved csv header definition to nested function.
This commit is contained in:
parent
42ce7bd8df
commit
770e4546e8
@ -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())
|
||||
|
@ -97,14 +97,6 @@ data class Observation(
|
||||
@ManyToMany
|
||||
val persons: Set<Person>
|
||||
) {
|
||||
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)}," +
|
||||
|
Loading…
Reference in New Issue
Block a user