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")
|
@PostMapping("/observations/csv")
|
||||||
fun getObservationsCsvDump(@Valid @RequestBody observationsRequest: ObservationsRequest): String? {
|
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)
|
val data = getObservations(observationsRequest)
|
||||||
if(data.isEmpty()) return null
|
if(data.isEmpty()) return null
|
||||||
val builder = StringBuilder(data[0].csvHeaderString())
|
val builder = StringBuilder(csvHeaderString())
|
||||||
data.forEach {
|
data.forEach {
|
||||||
builder.append('\n')
|
builder.append('\n')
|
||||||
builder.append(it.toCsvFormat())
|
builder.append(it.toCsvFormat())
|
||||||
|
@ -97,14 +97,6 @@ data class Observation(
|
|||||||
@ManyToMany
|
@ManyToMany
|
||||||
val persons: Set<Person>
|
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 {
|
fun toCsvFormat(): String {
|
||||||
return ",,${tutors.elementAt(0).name},$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," +
|
return ",,${tutors.elementAt(0).name},$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," +
|
||||||
"${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," +
|
"${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," +
|
||||||
|
Loading…
Reference in New Issue
Block a user