generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/pi 1939 mas overview offence tab convictions (#3493)
* PI-1939 - remove duplicate entity class * PI-1939 - add new entities and generators * PI-1939 - refactor and update sql to get conviction information * PI-1939 - refactor model * PI-1939 - further refactor * PI-1939 - add conviction section and tests * PI-1939 - update integration tests * PI-1939 - add additional sentences * PI-1939 - update integration tests * Formatting changes * PI-1939 - add additional sentences to Conviction and update tests * Formatting changes * PI-1939 - rename repository method * PI-1939 - remove debug logging frm integration test * PI-1939 - update service test * PI-1939 - refactor entity class to make fk fields not null * Formatting changes * PI-1939 - apply review comments * PI-1939 - apply review comments * PI-1939 - apply review comments --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c40b9d6
commit 3de265a
Showing
18 changed files
with
360 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AdditionalSentenceGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event | ||
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData | ||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.AdditionalSentence | ||
|
||
object AdditionalSentenceGenerator { | ||
|
||
val REF_DISQ = generateReferenceData("DISQ", "Disqualified from Driving") | ||
val REF_FINE = generateReferenceData("FINE", "Fine") | ||
|
||
val SENTENCE_DISQ = generateSentence(length = 3, referenceData = REF_DISQ, event = PersonGenerator.EVENT_1) | ||
val SENTENCE_FINE = | ||
generateSentence(amount = 500, referenceData = REF_FINE, notes = "fine notes", event = PersonGenerator.EVENT_2) | ||
|
||
fun generateSentence( | ||
length: Long? = null, | ||
amount: Long? = null, | ||
notes: String? = null, | ||
event: Event, | ||
referenceData: ReferenceData | ||
) = AdditionalSentence( | ||
IdGenerator.getAndIncrement(), | ||
length, | ||
amount, | ||
notes, | ||
false, | ||
event, | ||
referenceData | ||
) | ||
|
||
private fun generateReferenceData(code: String, description: String) = | ||
ReferenceData(IdGenerator.getAndIncrement(), code, description) | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
...us/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtAppearanceGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event | ||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.Court | ||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.CourtAppearance | ||
import java.time.LocalDate | ||
|
||
object CourtAppearanceGenerator { | ||
|
||
fun generate( | ||
court: Court = CourtGenerator.DEFAULT, | ||
date: LocalDate = LocalDate.now().minusMonths(5), | ||
id: Long = IdGenerator.getAndIncrement(), | ||
event: Event = PersonGenerator.EVENT_1 | ||
): CourtAppearance { | ||
return CourtAppearance( | ||
id, | ||
date, | ||
court, | ||
event | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...n-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.Court | ||
|
||
object CourtGenerator { | ||
val DEFAULT = Court( | ||
IdGenerator.getAndIncrement(), | ||
"Hull Court" | ||
) | ||
|
||
val BHAM = Court( | ||
IdGenerator.getAndIncrement(), | ||
"Birmingham Court" | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/AdditionalSentence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.sentence | ||
|
||
data class AdditionalSentence( | ||
val length: Long?, | ||
val amount: Long?, | ||
val notes: String?, | ||
val description: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
...-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/Conviction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.sentence | ||
|
||
import java.time.LocalDate | ||
|
||
data class Conviction( | ||
val sentencingCourt: String?, | ||
val responsibleCourt: String?, | ||
val convictionDate: LocalDate?, | ||
val additionalSentences: List<AdditionalSentence> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...on-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/Sentence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.sentence | ||
|
||
data class Sentence( | ||
val offence: OffenceDetails, | ||
val conviction: Conviction? = null, | ||
|
||
) |
3 changes: 1 addition & 2 deletions
3
...elius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/SentenceOverview.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package uk.gov.justice.digital.hmpps.api.model.sentence | ||
|
||
data class SentenceOverview( | ||
val offence: List<MainOffence?> | ||
|
||
val sentences: List<Sentence>, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...in/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/AdditionalSentence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity | ||
|
||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import org.hibernate.annotations.SQLRestriction | ||
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event | ||
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData | ||
|
||
@Immutable | ||
@Entity | ||
@Table(name = "additional_sentence") | ||
@SQLRestriction("soft_deleted = 0") | ||
class AdditionalSentence( | ||
|
||
@Id | ||
@Column(name = "additional_sentence_id") | ||
val id: Long, | ||
|
||
@Column(name = "length") | ||
val length: Long? = null, | ||
|
||
@Column(name = "amount") | ||
val amount: Long? = null, | ||
|
||
@Column(name = "notes", columnDefinition = "clob") | ||
val notes: String? = null, | ||
|
||
@Column(columnDefinition = "number") | ||
val softDeleted: Boolean = false, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "event_id", nullable = false) | ||
val event: Event, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "additional_sentence_type_id", nullable = false) | ||
val type: ReferenceData, | ||
|
||
) |
19 changes: 19 additions & 0 deletions
19
...src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Court.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import org.hibernate.annotations.Immutable | ||
|
||
@Entity | ||
@Immutable | ||
class Court( | ||
|
||
@Id | ||
@Column(name = "court_id") | ||
val id: Long, | ||
|
||
@Column(name = "court_name", nullable = true) | ||
val name: String? | ||
|
||
) |
30 changes: 30 additions & 0 deletions
30
...otlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/CourtAppearance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity | ||
|
||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import org.hibernate.annotations.SQLRestriction | ||
import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event | ||
import java.time.LocalDate | ||
|
||
@Entity | ||
@Immutable | ||
@SQLRestriction("soft_deleted = 0") | ||
class CourtAppearance( | ||
@Id | ||
@Column(name = "court_appearance_id") | ||
val id: Long, | ||
|
||
@Column(name = "appearance_date") | ||
val date: LocalDate, | ||
|
||
@JoinColumn(name = "court_id") | ||
@ManyToOne | ||
val court: Court, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "event_id") | ||
val event: Event, | ||
|
||
@Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) | ||
var softDeleted: Boolean = false | ||
) |
Oops, something went wrong.