Skip to content

Commit

Permalink
PI-2396 - include custody when getting latest conviction, to match co… (
Browse files Browse the repository at this point in the history
#4079)

PI-2396 - include custody when getting latest conviction, to match community api
  • Loading branch information
achimber-moj authored Jul 29, 2024
1 parent 87888e4 commit 65eb7bb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ object KeyDateGenerator {
IdGenerator.getAndIncrement(),
ConvictionEventGenerator.DISPOSAL_2.id,
"1234BN",
CUSTODY_STATUS
CUSTODY_STATUS,
disposal = ConvictionEventGenerator.DISPOSAL_2
)
val KEYDATE = KeyDate(
IdGenerator.getAndIncrement(),
Expand All @@ -32,7 +33,8 @@ object KeyDateGenerator {
IdGenerator.getAndIncrement(),
ConvictionEventGenerator.DISPOSAL.id,
"2234BN",
CUSTODY_STATUS
CUSTODY_STATUS,
disposal = ConvictionEventGenerator.DISPOSAL
)
val KEYDATE_1 = KeyDate(
IdGenerator.getAndIncrement(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class Disposal(
@Column(name = "entered_notional_end_date")
val enteredEndDate: LocalDate? = null,

@OneToOne(mappedBy = "disposal")
val custody: Custody? = null,

@Column(name = "active_flag", columnDefinition = "number")
val active: Boolean = true,

Expand Down Expand Up @@ -201,9 +204,11 @@ interface ConvictionEventRepository : JpaRepository<ConvictionEventEntity, Long>
join fetch d.type dt
join fetch c.mainOffence mo
join fetch mo.offence
join fetch d.custody cust
left join fetch c.additionalOffences ao
left join fetch ao.offence
where c.convictionEventPerson.id = :personId and c.active = true
and cust.status.code <> 'P'
order by c.convictionDate desc
"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class Custody(
@OneToMany(mappedBy = "custody")
val keyDates: List<KeyDate> = listOf(),

@OneToOne
@JoinColumn(name = "disposal_id", updatable = false, insertable = false)
val disposal: Disposal,

@Column(name = "soft_deleted", columnDefinition = "number", nullable = false)
val softDeleted: Boolean = false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DetailService(
if (c != null) {
mainOffence = c.mainOffence!!.offence.description
if (c.disposal != null) {
val custody = custodyRepository.getCustodyByDisposalId(c.disposal.id)
val custody = c.disposal.custody
if (custody != null) {
val release = detailReleaseRepository.findFirstByCustodyIdOrderByDateDesc(custody.id)
releaseLocation = release?.institution?.name
Expand Down

0 comments on commit 65eb7bb

Please sign in to comment.