Skip to content

Commit

Permalink
Rename database fields
Browse files Browse the repository at this point in the history
date to observation_time and end_date to observation_time_end
  • Loading branch information
pvannierop committed Jul 4, 2024
1 parent 0ec903b commit 8b33418
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class ObservationDto(
val category: String?,

/** Date or date-time of the observation. */
val date: String?,
val observation_time: String?,

/**
* For how long the observation was valid. Null if there is no duration, or if the observation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ObservationRepository(

return transact {
createQuery(
"SELECT o FROM Observation o WHERE o.project = :projectId AND o.subject = :subjectId AND o.topic = :topicId ORDER BY o.date DESC",
"SELECT o FROM Observation o WHERE o.project = :projectId AND o.subject = :subjectId AND o.topic = :topicId ORDER BY o.observationTime DESC",
Observation::class.java,
).apply {
setParameter("projectId", projectId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ fun Observation.toDto(): ObservationDto = ObservationDto(
source = source,
topic = topic,
category = category,
date = date.toString(),
period = if (endDate != null) {
Duration.between(date, endDate).toString()
observation_time = observationTime.toString(),
period = if (observationTimeEnd != null) {
Duration.between(observationTime, observationTimeEnd).toString()
} else {
null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data class Observation(
@Id
val source: String,

@Column(nullable = false)
@Column(nullable = false, name = "topic_name")
@Id
val topic: String,

Expand All @@ -49,12 +49,12 @@ data class Observation(
@Id
val variable: String,

@Column(nullable = false)
@Column(nullable = false, name = "observation_time")
@Id
val date: ZonedDateTime,
val observationTime: ZonedDateTime,

@Column(name = "end_date")
val endDate: ZonedDateTime?,
@Column(name = "observation_time_end")
val observationTimeEnd: ZonedDateTime?,

@Column(name = "value_textual")
val valueTextual: String?,
Expand All @@ -72,11 +72,11 @@ data class Observation(
topic == other.topic &&
category == other.category &&
variable == other.variable &&
date == other.date &&
endDate == other.endDate
observationTime == other.observationTime &&
observationTimeEnd == other.observationTimeEnd
}

override fun hashCode(): Int = Objects.hash(subject, variable, date)
override fun hashCode(): Int = Objects.hash(subject, variable, observationTime)

companion object {
internal fun String?.toPrintString() = if (this != null) "'$this'" else "null"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ class ObservationResourceTest : JerseyTest() {
topic = "topic-1",
category = "category-1",
variable = "variable-1",
date = ZonedDateTime.now(),
observationTime = ZonedDateTime.now(),
observationTimeEnd = null,
valueTextual = "value1",
valueNumeric = null,
endDate = null,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class ObservationServiceTest {
topic = "topic-1",
category = "category-1",
variable = "variable-1",
date = ZonedDateTime.now(),
observationTime = ZonedDateTime.now(),
observationTimeEnd = null,
valueTextual = "value1",
valueNumeric = null,
endDate = null,
)
}
}

0 comments on commit 8b33418

Please sign in to comment.