Improved Javadoc

This commit is contained in:
neviyn 2019-07-23 09:27:30 +01:00
parent e70567d1a8
commit 93b0f68721
3 changed files with 36 additions and 0 deletions

View File

@ -1,5 +1,8 @@
package uk.co.neviyn.observationdatabase package uk.co.neviyn.observationdatabase
/**
* Header line for a CSV file in the format of the standard observation database
*/
fun csvHeaderString(): String { fun csvHeaderString(): String {
return "Ob ID,Observerfull,Observer,obDate,Title,Type,Department,Station,Station Focus,Scores-Monitoring,Scores-Control Procedural," + 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\"," + "Scores-Control,Scores-Conservatism,Scores-Teamwork Comms,Scores-Teamwork Leadership,Scores-Teamwork Workload,\"Scores-Knowledge, Skills and Attitudes\"," +
@ -9,6 +12,9 @@ fun csvHeaderString(): String {
"Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\"" "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\""
} }
/**
* Given the observations in [data], output a string that aligns the data with the format described in csvHeaderString()
*/
fun observationsToCSV(data: List<Observation>): String { fun observationsToCSV(data: List<Observation>): String {
val builder = StringBuilder(csvHeaderString()) val builder = StringBuilder(csvHeaderString())
data.forEach { data.forEach {

View File

@ -17,6 +17,9 @@ class Email {
private val logger: Logger = LoggerFactory.getLogger(javaClass)!! private val logger: Logger = LoggerFactory.getLogger(javaClass)!!
/**
* Send observation data to the configured email address
*/
fun sendObservationData(observations: List<Observation>) { fun sendObservationData(observations: List<Observation>) {
if (observations.isEmpty()) { if (observations.isEmpty()) {
logger.error("Cannot send observations email containing no observations!") logger.error("Cannot send observations email containing no observations!")

View File

@ -17,6 +17,9 @@ object GroupSessionManager {
var scenarioTitles: List<String>? = null var scenarioTitles: List<String>? = null
var observations: MutableMap<String, GroupObservation> = mutableMapOf() var observations: MutableMap<String, GroupObservation> = mutableMapOf()
/**
* Start a new group session
*/
fun startNewSession(site: Site, tutors: Set<Tutor>, trainingType: TrainingType, scenarioTitles: List<String>): Int { fun startNewSession(site: Site, tutors: Set<Tutor>, trainingType: TrainingType, scenarioTitles: List<String>): Int {
logger.info("Starting new Group Session") logger.info("Starting new Group Session")
logger.debug("Previous ID was $sessionId") logger.debug("Previous ID was $sessionId")
@ -34,6 +37,9 @@ object GroupSessionManager {
return sessionId return sessionId
} }
/**
* Invalidate the current session
*/
fun invalidate() { fun invalidate() {
this.site = null this.site = null
this.tutors = null this.tutors = null
@ -42,14 +48,23 @@ object GroupSessionManager {
this.observations = mutableMapOf() this.observations = mutableMapOf()
} }
/**
* Check if the current session has [sessionId] and is valid
*/
fun isValid(sessionId: Int): Boolean { fun isValid(sessionId: Int): Boolean {
return isValid() && sessionId == this.sessionId return isValid() && sessionId == this.sessionId
} }
/**
* Check if the current session is valid
*/
fun isValid(): Boolean { fun isValid(): Boolean {
return site != null && tutors != null && trainingType != null && scenarioTitles != null return site != null && tutors != null && trainingType != null && scenarioTitles != null
} }
/**
* Return the data contained in the current session in the scenario format
*/
fun asScenarioView(): MutableMap<String, MutableList<Scenario>> { fun asScenarioView(): MutableMap<String, MutableList<Scenario>> {
val output: MutableMap<String, MutableList<Scenario>> = mutableMapOf() val output: MutableMap<String, MutableList<Scenario>> = mutableMapOf()
scenarioTitles?.forEach { title -> scenarioTitles?.forEach { title ->
@ -63,6 +78,9 @@ object GroupSessionManager {
return output return output
} }
/**
* Check whether the data currently submitted for a session is all valid
*/
fun dataComplete(): Boolean { fun dataComplete(): Boolean {
if (observations.isEmpty()) { if (observations.isEmpty()) {
logger.warn("Observations is currently empty") logger.warn("Observations is currently empty")
@ -77,11 +95,20 @@ object GroupSessionManager {
return true return true
} }
/**
* Update the stored data for the individual submitting the [input] data
*/
fun updateObservationData(input: GroupObservation) { fun updateObservationData(input: GroupObservation) {
observations[input.person] = input observations[input.person] = input
} }
/**
* Check whether [name] exists as a participant in this session
*/
fun participantExistsInSession(name: String): Boolean = observations.containsKey(name) fun participantExistsInSession(name: String): Boolean = observations.containsKey(name)
/**
* Get the observation data stored in this session for [name]
*/
fun getObservationDataForParticipant(name: String): GroupObservation? = observations[name] fun getObservationDataForParticipant(name: String): GroupObservation? = observations[name]
} }