Removed unneeded entity fields, moved observation view to new format
This commit is contained in:
parent
cb58720c23
commit
d8b3c0040d
@ -20,7 +20,6 @@ data class NewObservation(
|
||||
val site: Long,
|
||||
val type: TrainingType,
|
||||
val observed: String,
|
||||
val whom: String,
|
||||
val scenarios: List<Scenario>,
|
||||
val tutors: List<Long>,
|
||||
val person: String
|
||||
|
@ -87,7 +87,6 @@ class Controller {
|
||||
date = LocalDate.now(),
|
||||
type = newObservation.type,
|
||||
observed = newObservation.scenarios.joinToString { it.title },
|
||||
whom = newObservation.whom,
|
||||
monitoring = newObservation.scenarios.map { it.monitoring.rating }.average(),
|
||||
conservatism = newObservation.scenarios.map { it.conservatism.rating }.average(),
|
||||
controlProcedural = newObservation.scenarios.map { it.controlProcedural.rating }.average(),
|
||||
@ -116,34 +115,19 @@ class Controller {
|
||||
fun getObservations(@Valid @RequestBody observationsRequest: ObservationsRequest): List<Observation> {
|
||||
if (observationsRequest.tutor != null) {
|
||||
return tutorRepository.findById(observationsRequest.tutor).map {
|
||||
when {
|
||||
(observationsRequest.whom == null || observationsRequest.whom.isEmpty()) -> observationRepository.findByTutorsAndDateBetweenOrderByDateAsc(tutor = it,
|
||||
observationRepository.findByTutorsAndDateBetweenOrderByDateAsc(tutor = it,
|
||||
startDate = observationsRequest.startDate,
|
||||
endDate = observationsRequest.endDate)
|
||||
else -> observationRepository.findByTutorsAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(tutor = it,
|
||||
whom = observationsRequest.whom,
|
||||
startDate = observationsRequest.startDate,
|
||||
endDate = observationsRequest.endDate)
|
||||
}
|
||||
}.orElse(listOf())
|
||||
} else if (observationsRequest.person != null && observationsRequest.person.isNotEmpty() && observationsRequest.site != null) {
|
||||
val person = personRepository.findFirstByNameLike(observationsRequest.person.toUpperCase()) ?: return listOf()
|
||||
val site = siteRepository.findById(observationsRequest.site).get()
|
||||
return if (observationsRequest.whom == null || observationsRequest.whom.isEmpty())
|
||||
observationRepository.findBySiteAndPersonAndDateBetweenOrderByDateAsc(site, person, observationsRequest.startDate, observationsRequest.endDate)
|
||||
else
|
||||
observationRepository.findBySiteAndWhomIgnoreCaseAndPersonAndDateBetweenOrderByDateAsc(site, observationsRequest.whom, person, observationsRequest.startDate, observationsRequest.endDate)
|
||||
return observationRepository.findBySiteAndPersonAndDateBetweenOrderByDateAsc(site, person, observationsRequest.startDate, observationsRequest.endDate)
|
||||
} else if (observationsRequest.site != null) {
|
||||
return siteRepository.findById(observationsRequest.site).map {
|
||||
when {
|
||||
(observationsRequest.whom == null || observationsRequest.whom.isEmpty()) -> observationRepository.findBySiteAndDateBetweenOrderByDateAsc(site = it,
|
||||
observationRepository.findBySiteAndDateBetweenOrderByDateAsc(site = it,
|
||||
startDate = observationsRequest.startDate,
|
||||
endDate = observationsRequest.endDate)
|
||||
else -> observationRepository.findBySiteAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(site = it,
|
||||
whom = observationsRequest.whom,
|
||||
startDate = observationsRequest.startDate,
|
||||
endDate = observationsRequest.endDate)
|
||||
}
|
||||
}.orElse(listOf())
|
||||
}
|
||||
return listOf()
|
||||
|
@ -3,8 +3,8 @@ package uk.co.neviyn.observationdatabase
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import org.joda.time.LocalDate
|
||||
import javax.persistence.CascadeType
|
||||
import javax.persistence.Column
|
||||
import javax.persistence.ElementCollection
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.FetchType
|
||||
import javax.persistence.GeneratedValue
|
||||
@ -76,8 +76,6 @@ data class Observation(
|
||||
@Column(nullable = false)
|
||||
val type: TrainingType,
|
||||
@Column(nullable = false)
|
||||
val whom: String,
|
||||
@Column(nullable = false)
|
||||
val observed: String,
|
||||
val monitoring: Double?,
|
||||
val controlProcedural: Double?,
|
||||
@ -87,7 +85,7 @@ data class Observation(
|
||||
val teamworkLeadership: Double?,
|
||||
val teamworkWorkload: Double?,
|
||||
val knowledge: Double?,
|
||||
@ElementCollection
|
||||
@OneToMany(cascade = [CascadeType.ALL])
|
||||
val scenarios: List<Scenario>,
|
||||
@ManyToMany(mappedBy = "observations")
|
||||
val tutors: Set<Tutor>,
|
||||
@ -132,21 +130,21 @@ data class Scenario(
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val id: Long = 0,
|
||||
val title: String,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val monitoring: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val controlProcedural: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val control: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val conservatism: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val teamworkCommunications: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val teamworkLeadership: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val teamworkWorkload: RatingComponent,
|
||||
@OneToOne
|
||||
@OneToOne(cascade = [CascadeType.ALL])
|
||||
val knowledge: RatingComponent
|
||||
|
||||
)
|
||||
|
@ -17,13 +17,7 @@ interface ObservationRepository : CrudRepository<Observation, Long> {
|
||||
|
||||
fun findByTutorsAndDateBetweenOrderByDateAsc(tutor: Tutor, startDate: LocalDate, endDate: LocalDate): List<Observation>
|
||||
|
||||
fun findBySiteAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(site: Site, whom: String, startDate: LocalDate, endDate: LocalDate): List<Observation>
|
||||
|
||||
fun findByTutorsAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(tutor: Tutor, whom: String, startDate: LocalDate, endDate: LocalDate): List<Observation>
|
||||
|
||||
fun findBySiteAndPersonAndDateBetweenOrderByDateAsc(site: Site, person: Person, startDate: LocalDate, endDate: LocalDate): List<Observation>
|
||||
|
||||
fun findBySiteAndWhomIgnoreCaseAndPersonAndDateBetweenOrderByDateAsc(site: Site, whom: String, person: Person, startDate: LocalDate, endDate: LocalDate): List<Observation>
|
||||
}
|
||||
|
||||
@Repository
|
||||
|
@ -112,11 +112,11 @@ class ControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithSite_TutorNull_NoWhom() {
|
||||
fun testGetObservations_WithSite_TutorNull() {
|
||||
val request = ObservationsRequest(1, null, "", "", LocalDate.now(), LocalDate.now())
|
||||
val site = Site(1, "Area 51")
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
|
||||
type = TrainingType.INITIAL, observed = "1", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, scenarios = listOf(), tutors = setOf(), person = Person(name = "noone"))
|
||||
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
||||
@ -128,28 +128,12 @@ class ControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithSite_TutorNull_WithWhom() {
|
||||
val request = ObservationsRequest(1, null, "Group A", "", LocalDate.now(), LocalDate.now())
|
||||
val site = Site(1, "Area 51")
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, scenarios = listOf(), tutors = setOf(), person = Person(name = "noone"))
|
||||
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
||||
doReturn(listOf(observation))
|
||||
.`when`(observationRepository).findBySiteAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(site, "Group A", LocalDate.now(), LocalDate.now())
|
||||
val result = controller.getObservations(request)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(observation, result[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithSite_WithTutor_NoWhom() {
|
||||
fun testGetObservations_WithSite_WithTutor() {
|
||||
val request = ObservationsRequest(null, 1, "", "", LocalDate.now(), LocalDate.now())
|
||||
val site = Site(1, "Area 51")
|
||||
val tutor = Tutor(1, "Mr Unknown", site)
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
|
||||
type = TrainingType.INITIAL, observed = "1", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, scenarios = listOf(), tutors = setOf(tutor), person = Person(name = "noone"))
|
||||
doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1)
|
||||
@ -160,23 +144,6 @@ class ControllerTest {
|
||||
assertEquals(observation, result[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithSite_WithTutor_WithWhom() {
|
||||
val request = ObservationsRequest(null, 1, "Group A", "", LocalDate.now(), LocalDate.now())
|
||||
val site = Site(1, "Area 51")
|
||||
val tutor = Tutor(1, "Mr Unknown", site)
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, scenarios = listOf(), tutors = setOf(tutor), person = Person(name = "noone"))
|
||||
doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1)
|
||||
doReturn(listOf(observation))
|
||||
.`when`(observationRepository).findByTutorsAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(tutor, "Group A", LocalDate.now(), LocalDate.now())
|
||||
val result = controller.getObservations(request)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(observation, result[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithPerson() {
|
||||
val request = ObservationsRequest(1, null, null, "Foo Bar", LocalDate.now(), LocalDate.now())
|
||||
@ -184,7 +151,7 @@ class ControllerTest {
|
||||
val tutor = Tutor(1, "Mr Unknown", site)
|
||||
val person = Person(1, "Foo Bar")
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
|
||||
type = TrainingType.INITIAL, observed = "1", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, scenarios = listOf(), tutors = setOf(tutor), person = person)
|
||||
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
||||
|
@ -31,15 +31,6 @@ class RepositoryTest {
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindBySiteAndWhomIgnoreCaseAndDateBetween_EmptyRepository() {
|
||||
val result = observationRepository.findBySiteAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(Site(
|
||||
id = 1,
|
||||
name = "x"
|
||||
), "none", LocalDate.now(), LocalDate.now())
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindByTutorsAndDateBetween_EmptyRepository() {
|
||||
val result = observationRepository.findByTutorsAndDateBetweenOrderByDateAsc(Tutor(
|
||||
@ -50,16 +41,6 @@ class RepositoryTest {
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindByTutorsAndWhomIgnoreCaseAndDateBetween_EmptyRepository() {
|
||||
val result = observationRepository.findByTutorsAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(Tutor(
|
||||
id = 1,
|
||||
name = "x",
|
||||
site = Site(1, "x")
|
||||
), "none", LocalDate.now(), LocalDate.now())
|
||||
assertTrue(result.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindBySiteAndDateBetween() {
|
||||
val correctSite = entityManager.persist(Site(name = "Correct"))
|
||||
@ -72,7 +53,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().minusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -90,7 +70,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().plusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -108,7 +87,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -126,7 +104,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -152,118 +129,6 @@ class RepositoryTest {
|
||||
assertEquals(justRight, result.first())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindBySiteAndWhomIgnoreCaseAndDateBetween() {
|
||||
val correctSite = entityManager.persist(Site(name = "Correct"))
|
||||
val incorrectSite = entityManager.persist(Site(name = "Incorrect"))
|
||||
val person = entityManager.persist(Person(name = "Foo Bar"))
|
||||
val tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
|
||||
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
|
||||
val tooEarly = Observation(
|
||||
site = correctSite,
|
||||
date = LocalDate.now().minusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(tutor),
|
||||
person = person
|
||||
)
|
||||
val tooLate = Observation(
|
||||
site = correctSite,
|
||||
date = LocalDate.now().plusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(tutor),
|
||||
person = person
|
||||
)
|
||||
val wrongSite = Observation(
|
||||
site = incorrectSite,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(tutor2),
|
||||
person = person
|
||||
)
|
||||
val justRight = Observation(
|
||||
site = correctSite,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(tutor),
|
||||
person = person
|
||||
)
|
||||
val wrongWhom = Observation(
|
||||
site = correctSite,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G2",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(tutor),
|
||||
person = person
|
||||
)
|
||||
entityManager.persist(tooEarly)
|
||||
entityManager.persist(tooLate)
|
||||
entityManager.persist(wrongSite)
|
||||
entityManager.persist(justRight)
|
||||
entityManager.persist(wrongWhom)
|
||||
val result = observationRepository.findBySiteAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(
|
||||
site = correctSite,
|
||||
startDate = LocalDate.now().minusDays(1),
|
||||
endDate = LocalDate.now().plusDays(1),
|
||||
whom = "G1"
|
||||
)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(justRight, result.first())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindByTutorsAndDateBetween() {
|
||||
val site = entityManager.persist(Site(name = "Correct"))
|
||||
@ -275,7 +140,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().minusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -293,7 +157,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().plusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -311,7 +174,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -329,7 +191,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -347,7 +208,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -380,143 +240,6 @@ class RepositoryTest {
|
||||
assertFalse(result.contains(wrongTutor))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindByTutorsAndWhomIgnoreCaseAndDateBetween() {
|
||||
val site = entityManager.persist(Site(name = "Correct"))
|
||||
val person = entityManager.persist(Person(name = "Foo Bar"))
|
||||
val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
|
||||
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
|
||||
val tooEarly = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now().minusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(correctTutor),
|
||||
person = person
|
||||
)
|
||||
val tooLate = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now().plusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(correctTutor),
|
||||
person = person
|
||||
)
|
||||
val wrongTutor = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(incorrectTutor),
|
||||
person = person
|
||||
)
|
||||
val justRight = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(correctTutor),
|
||||
person = person
|
||||
)
|
||||
val wrongGroup = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G2",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(correctTutor),
|
||||
person = person
|
||||
)
|
||||
val justRightMultipleTutors = Observation(
|
||||
site = site,
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
conservatism = 3.0,
|
||||
teamworkCommunications = 2.0,
|
||||
teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0,
|
||||
knowledge = 1.0,
|
||||
scenarios = listOf(),
|
||||
tutors = setOf(correctTutor, incorrectTutor),
|
||||
person = person
|
||||
)
|
||||
entityManager.persist(tooEarly)
|
||||
entityManager.persist(tooLate)
|
||||
entityManager.persist(wrongTutor)
|
||||
entityManager.persist(justRight)
|
||||
entityManager.persist(wrongGroup)
|
||||
entityManager.persist(justRightMultipleTutors)
|
||||
correctTutor.observations.addAll(listOf(tooEarly, tooLate, justRight, justRightMultipleTutors, wrongGroup))
|
||||
entityManager.persist(correctTutor)
|
||||
incorrectTutor.observations.addAll(listOf(wrongTutor, justRightMultipleTutors))
|
||||
entityManager.persist(incorrectTutor)
|
||||
val result = observationRepository.findByTutorsAndWhomIgnoreCaseAndDateBetweenOrderByDateAsc(
|
||||
tutor = correctTutor,
|
||||
startDate = LocalDate.now().minusDays(1),
|
||||
endDate = LocalDate.now().plusDays(1),
|
||||
whom = "G1"
|
||||
)
|
||||
assertEquals(2, result.size)
|
||||
assertTrue(result.contains(justRight))
|
||||
assertTrue(result.contains(justRightMultipleTutors))
|
||||
assertFalse(result.contains(wrongTutor))
|
||||
assertFalse(result.contains(wrongGroup))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFindBySiteAndPersonsAndDateBetween() {
|
||||
val person = entityManager.persist(Person(name = "Foo Bar"))
|
||||
@ -528,7 +251,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().minusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -546,7 +268,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now().plusDays(5),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -564,7 +285,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
@ -582,7 +302,6 @@ class RepositoryTest {
|
||||
date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL,
|
||||
observed = "1",
|
||||
whom = "G1",
|
||||
monitoring = 5.0,
|
||||
controlProcedural = 3.0,
|
||||
control = 4.0,
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<b-container fluid>
|
||||
<!-- <b-container v-if="description != null && type != null && whom != null && site != null && tutors != null" fluid style="padding-left: 130px;"> -->
|
||||
<!-- <b-container type != null && whom != null && site != null && tutors != null" fluid style="padding-left: 130px;"> -->
|
||||
<b-container fluid style="padding-left: 130px;">
|
||||
<h3>
|
||||
<v-icon name="tag" scale="1.5"/>
|
||||
@ -324,7 +324,7 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(["description", "type", "whom", "site", "tutors"])
|
||||
...mapState(["type", "whom", "site", "tutors"])
|
||||
},
|
||||
methods: {
|
||||
addAnotherObservation: function() {
|
||||
@ -468,8 +468,9 @@ export default {
|
||||
{
|
||||
site: this.site,
|
||||
tutors: this.tutors,
|
||||
whom: this.whom,
|
||||
person: this.whom,
|
||||
type: this.type,
|
||||
observed: this.scenarios.map(x => x.title).join(', '),
|
||||
scenarios: JSON.parse(JSON.stringify(this.scenarios))
|
||||
},
|
||||
axiosConfig
|
||||
|
@ -112,7 +112,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(["site", "description", "type", "tutors", "whom"])
|
||||
...mapState(["site", "type", "tutors", "whom"])
|
||||
},
|
||||
watch: {
|
||||
site: function() {
|
||||
@ -130,7 +130,6 @@ export default {
|
||||
methods: {
|
||||
...mapMutations([
|
||||
"setSite",
|
||||
"setDescription",
|
||||
"setType",
|
||||
"setTutors",
|
||||
"setWhom",
|
||||
|
@ -5,25 +5,22 @@
|
||||
<h3 class="modal-title w-100">{{ errorStatus }}</h3>
|
||||
</div>
|
||||
<div class="d-block">
|
||||
<br/>
|
||||
<br>
|
||||
<span style="font-size:20px;" v-html="errorMessage"/>
|
||||
<button class="btn btn-warning" @click="$refs.errorModal.hide()">
|
||||
<v-icon name="exclamation-circle"/>
|
||||
Dismiss
|
||||
<v-icon name="exclamation-circle"/>Dismiss
|
||||
</button>
|
||||
</div>
|
||||
</b-modal>
|
||||
<b-row>
|
||||
<b-col>
|
||||
<b-form-group label="Site">
|
||||
<b-form-select class="text-center" v-model="siteSelection"
|
||||
:options="siteOptions"/>
|
||||
<b-form-select class="text-center" v-model="siteSelection" :options="siteOptions"/>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
<b-col>
|
||||
<b-form-group label="Tutor">
|
||||
<b-form-select class="text-center" v-model="tutorSelection"
|
||||
:options="tutorOptions"/>
|
||||
<b-form-select class="text-center" v-model="tutorSelection" :options="tutorOptions"/>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
<b-col>
|
||||
@ -38,14 +35,22 @@
|
||||
</b-col>
|
||||
<b-col>
|
||||
<b-form-group label="From">
|
||||
<date-picker v-model="startDate" @dp-change="changeStartDate" value="startDate"
|
||||
:config="dateOptions"/>
|
||||
<date-picker
|
||||
v-model="startDate"
|
||||
@dp-change="changeStartDate"
|
||||
value="startDate"
|
||||
:config="dateOptions"
|
||||
/>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
<b-col>
|
||||
<b-form-group label="To">
|
||||
<date-picker v-model="endDate" @dp-change="changeEndDate" value="endDate"
|
||||
:config="dateOptions"/>
|
||||
<date-picker
|
||||
v-model="endDate"
|
||||
@dp-change="changeEndDate"
|
||||
value="endDate"
|
||||
:config="dateOptions"
|
||||
/>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
<b-col>
|
||||
@ -56,60 +61,110 @@
|
||||
<b-card no-body>
|
||||
<b-tabs pills card vertical>
|
||||
<b-tab v-for="(observation, index) in observationData" v-bind:key="index">
|
||||
<p slot="title">{{ observation.date }}<br/>{{ observation.whom }} {{ observation.type }}<br/>{{ shortenedString(observation.observed) }}</p>
|
||||
<h2>{{ observation.date }}, {{ observation.whom }}<br/>{{ observation.type }}, {{ observation.observed }}</h2>
|
||||
<p slot="title">
|
||||
{{ observation.date }}
|
||||
<br>
|
||||
{{ observation.whom }} {{ observation.type }}
|
||||
<br>
|
||||
{{ shortenedString(observation.observed) }}
|
||||
</p>
|
||||
<h2>
|
||||
{{ observation.date }}, {{ observation.whom }}
|
||||
<br>
|
||||
{{ observation.type }} / {{ observation.observed }}
|
||||
</h2>
|
||||
<b-row align-h="center">
|
||||
<h4>Observed by: <span v-bind:key="index" v-for="(tutor, index) in observation.tutors"><i>{{ tutor.name }}<span v-if="index+1 < observation.tutors.length">, </span></i></span></h4>
|
||||
<h4>Observed by:
|
||||
<span v-bind:key="index" v-for="(tutor, index) in observation.tutors">
|
||||
<i>
|
||||
{{ tutor.name }}
|
||||
<span v-if="index+1 < observation.tutors.length">, </span>
|
||||
</i>
|
||||
</span>
|
||||
</h4>
|
||||
</b-row>
|
||||
<b-row align-h="center">
|
||||
<h4>Participants: <span v-bind:key="index" v-for="(person, index) in observation.persons"><i>{{ person.name }}<span v-if="index+1 < observation.persons.length">, </span></i></span></h4>
|
||||
<h4>Participant: {{ observation.person.name }}</h4>
|
||||
</b-row>
|
||||
<br />
|
||||
<br>
|
||||
<b-row class="mb-2">
|
||||
<b-col class="centered-image" v-if="observation.monitoring">
|
||||
<img src="../assets/Monitoring.svg" class="image-opacity"/>
|
||||
<img src="../assets/Monitoring.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.monitoring < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.monitoring.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.controlProcedural">
|
||||
<img src="../assets/Control.svg" class="image-opacity"/>
|
||||
<img src="../assets/Control.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.controlProcedural < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.controlProcedural.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.control">
|
||||
<img src="../assets/Control.svg" class="image-opacity"/>
|
||||
<img src="../assets/Control.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.control < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.control.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.conservatism">
|
||||
<img src="../assets/Conservatism.svg" class="image-opacity"/>
|
||||
<img src="../assets/Conservatism.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.conservatism < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.conservatism.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.teamworkCommunications">
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity"/>
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkCommunications < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.teamworkCommunications.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.teamworkLeadership">
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity"/>
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkLeadership < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.teamworkLeadership.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.teamworkWorkload">
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity"/>
|
||||
<img src="../assets/Teamwork.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.teamworkWorkload < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.teamworkWorkload.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
<b-col class="centered-image" v-if="observation.knowledge">
|
||||
<img src="../assets/Knowledge.svg" class="image-opacity"/>
|
||||
<img src="../assets/Knowledge.svg" class="image-opacity" v-bind:class="{ scorewarning: observation.knowledge < 2.5 }">
|
||||
<div class="image-centered-text">{{ observation.knowledge.toFixed(1) }}</div>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div v-for="(entry, index2) in observation.entries" v-bind:key="index2">
|
||||
<p>{{ entry.type }} - {{ entry.rating }}</p>
|
||||
<b-form-group label="Strengths">
|
||||
<b-form-textarea :value="entry.strengths" readonly>
|
||||
</b-form-textarea>
|
||||
</b-form-group>
|
||||
<b-form-group label="Areas of Improvement">
|
||||
<b-form-textarea :value="entry.improvements" readonly>
|
||||
</b-form-textarea>
|
||||
</b-form-group>
|
||||
</div>
|
||||
<b-row v-for="(entry, index2) in observation.scenarios" v-bind:key="index2">
|
||||
<b-col class="border">
|
||||
<b-row align-h="center">
|
||||
<h3>{{ entry.title }}</h3>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.monitoring"
|
||||
:description="'Monitoring'"
|
||||
></observation-entry>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.controlProcedural"
|
||||
:description="'Control Procedural'"
|
||||
></observation-entry>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<observation-entry :scenariofundamental="entry.control" :description="'Control'"></observation-entry>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.conservatism"
|
||||
:description="'Conservatism'"
|
||||
></observation-entry>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.teamworkCommunications"
|
||||
:description="'Teamwork Communications'"
|
||||
></observation-entry>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.teamworkLeadership"
|
||||
:description="'Teamwork Leadership'"
|
||||
></observation-entry>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.teamworkWorkload"
|
||||
:description="'Teamwork Workload'"
|
||||
></observation-entry>
|
||||
<observation-entry
|
||||
:scenariofundamental="entry.knowledge"
|
||||
:description="'Knowledge'"
|
||||
></observation-entry>
|
||||
</b-row>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-tab>
|
||||
</b-tabs>
|
||||
</b-card>
|
||||
@ -129,11 +184,13 @@
|
||||
<script>
|
||||
import Vue from "vue";
|
||||
import "vue-awesome/icons/search";
|
||||
import ObservationEntry from "../components/ObservationEntry.vue";
|
||||
|
||||
var moment = require("moment");
|
||||
export default {
|
||||
name: "viewobservations",
|
||||
title: "Observations History",
|
||||
components: { ObservationEntry },
|
||||
data: function() {
|
||||
return {
|
||||
dateOptions: {
|
||||
@ -158,7 +215,6 @@ export default {
|
||||
this.$router.push("/dberror");
|
||||
return;
|
||||
}
|
||||
console.log(error);
|
||||
});
|
||||
this.getTutors();
|
||||
this.getFiltered();
|
||||
@ -169,7 +225,7 @@ export default {
|
||||
return this.$store.state.search.start;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchStartDate', data);
|
||||
this.$store.commit("setSearchStartDate", data);
|
||||
}
|
||||
},
|
||||
endDate: {
|
||||
@ -177,7 +233,7 @@ export default {
|
||||
return this.$store.state.search.end;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchEndDate', data);
|
||||
this.$store.commit("setSearchEndDate", data);
|
||||
}
|
||||
},
|
||||
siteSelection: {
|
||||
@ -185,7 +241,7 @@ export default {
|
||||
return this.$store.state.search.site;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchSite', data);
|
||||
this.$store.commit("setSearchSite", data);
|
||||
}
|
||||
},
|
||||
tutorSelection: {
|
||||
@ -193,7 +249,7 @@ export default {
|
||||
return this.$store.state.search.tutor;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchTutor', data)
|
||||
this.$store.commit("setSearchTutor", data);
|
||||
}
|
||||
},
|
||||
whom: {
|
||||
@ -201,7 +257,7 @@ export default {
|
||||
return this.$store.state.search.whom;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchWhom', data)
|
||||
this.$store.commit("setSearchWhom", data);
|
||||
}
|
||||
},
|
||||
person: {
|
||||
@ -209,7 +265,7 @@ export default {
|
||||
return this.$store.state.search.person;
|
||||
},
|
||||
set(data) {
|
||||
this.$store.commit('setSearchPerson', data)
|
||||
this.$store.commit("setSearchPerson", data);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -278,8 +334,7 @@ export default {
|
||||
shortenedString: function(data) {
|
||||
if (data.len < 20) {
|
||||
return data;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return data.substr(0, 20) + "...";
|
||||
}
|
||||
}
|
||||
@ -302,6 +357,9 @@ export default {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
.scorewarning {
|
||||
background-color: red;
|
||||
}
|
||||
.image-centered-text {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
|
Loading…
Reference in New Issue
Block a user