Changed some data types in Observation and Scenario data classes.
Had issues with data submission failing because the data entered was too long.
This commit is contained in:
parent
0600af16b4
commit
c4a7f4cc58
@ -1,6 +1,7 @@
|
|||||||
package uk.co.neviyn.observationdatabase
|
package uk.co.neviyn.observationdatabase
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
|
import org.hibernate.annotations.Type
|
||||||
import org.joda.time.LocalDate
|
import org.joda.time.LocalDate
|
||||||
import javax.persistence.CascadeType
|
import javax.persistence.CascadeType
|
||||||
import javax.persistence.Column
|
import javax.persistence.Column
|
||||||
@ -74,7 +75,7 @@ data class Observation(
|
|||||||
val date: LocalDate = LocalDate.now(),
|
val date: LocalDate = LocalDate.now(),
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
val type: TrainingType = TrainingType.INVALID,
|
val type: TrainingType = TrainingType.INVALID,
|
||||||
@Column(nullable = false)
|
@Column(nullable = false, length = 500)
|
||||||
val observed: String = "UNKNOWN",
|
val observed: String = "UNKNOWN",
|
||||||
val monitoring: Double? = null,
|
val monitoring: Double? = null,
|
||||||
val controlProcedural: Double? = null,
|
val controlProcedural: Double? = null,
|
||||||
@ -133,33 +134,57 @@ data class Scenario(
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
val id: Long = 0,
|
val id: Long = 0,
|
||||||
val title: String = "UNKNOWN",
|
val title: String = "UNKNOWN",
|
||||||
val monitoringRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val monitoringRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val monitoringStrengths: String = "",
|
val monitoringStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val monitoringImprovements: String = "",
|
val monitoringImprovements: String = "",
|
||||||
val controlProceduralRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val controlProceduralRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val controlProceduralStrengths: String = "",
|
val controlProceduralStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val controlProceduralImprovements: String = "",
|
val controlProceduralImprovements: String = "",
|
||||||
val controlRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val controlRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val controlStrengths: String = "",
|
val controlStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val controlImprovements: String = "",
|
val controlImprovements: String = "",
|
||||||
val conservatismRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val conservatismRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val conservatismStrengths: String = "",
|
val conservatismStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val conservatismImprovements: String = "",
|
val conservatismImprovements: String = "",
|
||||||
val teamworkCommunicationsRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val teamworkCommunicationsRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkCommunicationsStrengths: String = "",
|
val teamworkCommunicationsStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkCommunicationsImprovements: String = "",
|
val teamworkCommunicationsImprovements: String = "",
|
||||||
val teamworkLeadershipRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val teamworkLeadershipRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkLeadershipStrengths: String = "",
|
val teamworkLeadershipStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkLeadershipImprovements: String = "",
|
val teamworkLeadershipImprovements: String = "",
|
||||||
val teamworkWorkloadRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val teamworkWorkloadRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkWorkloadStrengths: String = "",
|
val teamworkWorkloadStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val teamworkWorkloadImprovements: String = "",
|
val teamworkWorkloadImprovements: String = "",
|
||||||
val knowledgeRating: Int = -1,
|
@Type(type = "byte")
|
||||||
|
val knowledgeRating: Byte = -1,
|
||||||
|
@Type(type = "text")
|
||||||
val knowledgeStrengths: String = "",
|
val knowledgeStrengths: String = "",
|
||||||
|
@Type(type = "text")
|
||||||
val knowledgeImprovements: String = ""
|
val knowledgeImprovements: String = ""
|
||||||
|
|
||||||
) {
|
) {
|
||||||
private fun ratingValid(rating: Int): Boolean {
|
private fun ratingValid(rating: Byte): Boolean {
|
||||||
return rating in 1..5
|
return rating in 1..5
|
||||||
}
|
}
|
||||||
fun ratingsAllValid(): Boolean {
|
fun ratingsAllValid(): Boolean {
|
||||||
|
@ -326,4 +326,18 @@ class RepositoryTest {
|
|||||||
assertEquals(1, result.size)
|
assertEquals(1, result.size)
|
||||||
assertEquals(justRight, result.first())
|
assertEquals(justRight, result.first())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testInsertEntryWithVeryLongText() {
|
||||||
|
val site = entityManager.persist(Site(name = "X"))
|
||||||
|
val tutor = entityManager.persist(Tutor(name = "Foo Bar", site = site))
|
||||||
|
val person = "Mr X"
|
||||||
|
val testString = "teststring".repeat(100)
|
||||||
|
val scenario = entityManager.persist(Scenario(0, "Something", 5, testString, "", 5, "", "", 5, "", "", 5, "", "", 5, "", "", 5, "", "", 5, "", "", 5, "", ""))
|
||||||
|
val scenarios = listOf(scenario)
|
||||||
|
val observation = Observation(0, site, LocalDate.now(), TrainingType.INITIAL, "An Observation", 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, scenarios, setOf(tutor), person)
|
||||||
|
val result = entityManager.persist(observation)
|
||||||
|
assertEquals(1, result.id)
|
||||||
|
assertEquals(testString, observation.scenarios.first().monitoringStrengths)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user