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.
* PI-1952 * update before install in format action
- Loading branch information
1 parent
90b09b4
commit 39552ef
Showing
16 changed files
with
510 additions
and
10 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
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
4 changes: 3 additions & 1 deletion
4
...-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.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
2 changes: 1 addition & 1 deletion
2
...elius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RegistrationGenerator.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
86 changes: 86 additions & 0 deletions
86
...nd-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/SentenceGenerator.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,86 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integration.delius.person.entity.Person | ||
import uk.gov.justice.digital.hmpps.integration.delius.provider.entity.Institution | ||
import uk.gov.justice.digital.hmpps.integration.delius.reference.entity.ReferenceData | ||
import uk.gov.justice.digital.hmpps.integration.delius.sentence.entity.* | ||
import java.time.ZonedDateTime | ||
|
||
object SentenceGenerator { | ||
val INSTITUTION_TYPE = ReferenceDataGenerator.generate("INST1") | ||
val DEFAULT_INSTITUTION = generateInstitution("HMPDEF", nomisCdeCode = "DEF") | ||
val CUSTODY_STATUS = ReferenceDataGenerator.generate("C") | ||
val RELEASE_TYPE = ReferenceDataGenerator.generate("REL") | ||
val RECALL_REASON = generateRecallReason("REC") | ||
val CUSTODIAL_SENTENCE = generateCustodialSentence(PersonGenerator.CUSTODY_PERSON) | ||
val RELEASED_SENTENCE = generateCustodialSentence(PersonGenerator.RELEASED_PERSON) | ||
val RELEASE = | ||
generateRelease(RELEASED_SENTENCE, date = ZonedDateTime.now().minusDays(1), institution = DEFAULT_INSTITUTION) | ||
val RECALL = generateRecall(RELEASE) | ||
|
||
fun generateCustodialSentence( | ||
person: Person, | ||
status: ReferenceData = CUSTODY_STATUS, | ||
institution: Institution? = DEFAULT_INSTITUTION, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Custody( | ||
generateDisposal(generateEvent(person)), | ||
status, | ||
institution, | ||
emptyList(), | ||
softDeleted, | ||
id | ||
) | ||
|
||
fun generateDisposal( | ||
event: Event, | ||
active: Boolean = true, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Disposal(event, active, softDeleted, id) | ||
|
||
fun generateEvent( | ||
person: Person, | ||
active: Boolean = true, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Event(person, null, active, softDeleted, id) | ||
|
||
fun generateInstitution( | ||
code: String, | ||
description: String = "Description of $code", | ||
type: ReferenceData? = INSTITUTION_TYPE, | ||
name: String? = "Name of $code", | ||
nomisCdeCode: String? = "NOM$code", | ||
establishment: Boolean = true, | ||
private: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Institution(code, description, type, name, nomisCdeCode, establishment, private, id) | ||
|
||
fun generateRelease( | ||
custody: Custody, | ||
type: ReferenceData = RELEASE_TYPE, | ||
date: ZonedDateTime = ZonedDateTime.now(), | ||
institution: Institution? = null, | ||
notes: String? = null, | ||
softDeleted: Boolean = false, | ||
createdDateTime: ZonedDateTime = ZonedDateTime.now(), | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Release(custody, type, date, institution, notes, null, softDeleted, createdDateTime, id) | ||
|
||
fun generateRecall( | ||
release: Release, | ||
date: ZonedDateTime = ZonedDateTime.now(), | ||
reason: RecallReason = RECALL_REASON, | ||
notes: String? = null, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = Recall(release, date, reason, notes, softDeleted, id) | ||
|
||
fun generateRecallReason( | ||
code: String, | ||
description: String = "Description of $code", | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = RecallReason(code, description, id) | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...cts/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/SentenceResource.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,16 @@ | ||
package uk.gov.justice.digital.hmpps.api | ||
|
||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import uk.gov.justice.digital.hmpps.service.SentenceService | ||
|
||
@RestController | ||
@RequestMapping("probation-cases/{crn}") | ||
class SentenceResource(private val sentenceService: SentenceService) { | ||
@PreAuthorize("hasRole('PROBATION_API__OASYS__CASE_DETAIL')") | ||
@GetMapping(value = ["/release"]) | ||
fun getReleaseRecall(@PathVariable("crn") crn: String) = sentenceService.findLatestReleaseRecall(crn) | ||
} |
33 changes: 33 additions & 0 deletions
33
.../oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/ReleaseRecall.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,33 @@ | ||
package uk.gov.justice.digital.hmpps.api.model | ||
|
||
import java.time.LocalDate | ||
|
||
data class ReleaseRecall( | ||
val lastRelease: Release?, | ||
val lastRecall: Recall? | ||
) | ||
|
||
data class Release( | ||
val date: LocalDate, | ||
val notes: String?, | ||
val institution: Institution?, | ||
val reason: CodeDescription | ||
) | ||
|
||
data class Recall( | ||
val date: LocalDate, | ||
val reason: CodeDescription, | ||
val notes: String? | ||
) | ||
|
||
data class Institution( | ||
val institutionId: Long, | ||
val isEstablishment: Boolean, | ||
val code: String, | ||
val description: String, | ||
val institutionName: String?, | ||
val establishmentType: CodeDescription?, | ||
val isPrivate: Boolean?, | ||
val nomsPrisonInstitutionCode: String? | ||
) | ||
|
2 changes: 1 addition & 1 deletion
2
...hmpps/integration/delius/person/Person.kt → ...ntegration/delius/person/entity/Person.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
34 changes: 34 additions & 0 deletions
34
...ain/kotlin/uk/gov/justice/digital/hmpps/integration/delius/provider/entity/Institution.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,34 @@ | ||
package uk.gov.justice.digital.hmpps.integration.delius.provider.entity | ||
|
||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import org.hibernate.type.YesNoConverter | ||
import uk.gov.justice.digital.hmpps.integration.delius.reference.entity.ReferenceData | ||
|
||
@Immutable | ||
@Entity | ||
@Table(name = "r_institution") | ||
class Institution( | ||
|
||
@Column(columnDefinition = "char(6)") | ||
val code: String, | ||
val description: String, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "establishment_type_id") | ||
val type: ReferenceData?, | ||
|
||
@Column(name = "institution_name") | ||
val name: String?, | ||
val nomisCdeCode: String?, | ||
|
||
@Convert(converter = YesNoConverter::class) | ||
val establishment: Boolean, | ||
|
||
@Convert(converter = YesNoConverter::class) | ||
val private: Boolean?, | ||
|
||
@Id | ||
@Column(name = "institution_id") | ||
val id: Long | ||
) |
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
Oops, something went wrong.