Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* PI-1745

* PI-1745

* add comment about creating new entity for dry run
  • Loading branch information
anthony-britton-moj authored Jan 4, 2024
1 parent d7f2395 commit 081d351
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ internal class IntegrationTest {
"""
LED 11/09/2025
ACR 26/11/2022
PED 26/10/2022
SED 10/09/2025
EXP 27/11/2022
HDE 28/10/2022
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,13 @@ class CustodyDateUpdateService(
sentenceDetail: SentenceDetail,
custody: Custody
): List<KeyDate> = CustodyDateType.entries.mapNotNull { cdt ->
val date = cdt.field.getter.call(sentenceDetail)
if (date == null) {
custody.keyDates.find(cdt.code)?.let {
val kd = KeyDate(it.id, it.custody, it.type, it.date)
kd.softDeleted = true
kd.version = it.version
kd
}
} else {
cdt.field.getter.call(sentenceDetail)?.let {
val existing = custody.keyDates.find(cdt.code)
if (existing != null) {
existing.changeDate(date)
existing.changeDate(it)
} else {
val kdt = referenceDataRepository.findKeyDateType(cdt.code)
KeyDate(null, custody, kdt, date)
KeyDate(null, custody, kdt, it)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ class KeyDate(
fun changeDate(date: LocalDate): KeyDate? = if (this.date == date) {
null
} else {
val keyDate = KeyDate(id, custody, type, date)
keyDate.version = version
keyDate
// create new entity to allow dry run to not make changes
KeyDate(id, custody, type, date).also {
it.createdDateTime = createdDateTime
it.createdUserId = createdUserId
it.version = version
}
}
}

0 comments on commit 081d351

Please sign in to comment.