Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/com.google.cloud.tools.jib…
Browse files Browse the repository at this point in the history
…-3.4.3
  • Loading branch information
pmcphee77 authored Jun 6, 2024
2 parents 2526036 + e488ecf commit 58682d7
Show file tree
Hide file tree
Showing 40 changed files with 1,821 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .github/actions/format-code/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ runs:
env:
mask: ${{ inputs.mask }}

- uses: planetscale/ghcommit-action@c8ba2501e51d7257efb393109e6e10bc36a3f769 # v0.1.40
- uses: planetscale/ghcommit-action@84c52a5164423e2cd66371ecae81d9049a2cf105 # v0.1.41
with:
commit_message: ${{ inputs.commit_message }}
repo: ${{ github.repository }}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionSha256Sum=a4b4158601f8636cdeeab09bd76afb640030bb5b144aafe261a5e8af027dc612
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
import uk.gov.justice.digital.hmpps.api.model.DocumentType
import uk.gov.justice.digital.hmpps.data.generator.*
import uk.gov.justice.digital.hmpps.integrations.delius.event.courtappearance.entity.Outcome
import uk.gov.justice.digital.hmpps.user.AuditUserRepository
import java.time.LocalDate
import java.time.LocalTime
import java.time.ZoneId
import java.time.ZonedDateTime

@Component
Expand All @@ -29,23 +30,23 @@ class DataLoader(
@Transactional
override fun onApplicationEvent(are: ApplicationReadyEvent) {
em.saveAll(

DocumentEntityGenerator.COURT,
DocumentEntityGenerator.INSTITUTIONAL_REPORT_TYPE,
DocumentEntityGenerator.INSTITUTIONAL_REPORT,
DocumentEntityGenerator.R_INSTITUTION,
AreaGenerator.PARTITION_AREA,
ProviderEmployeeGenerator.PROVIDER_EMPLOYEE,
ProviderGenerator.DEFAULT,
LDUGenerator.DEFAULT,
BoroughGenerator.DEFAULT,
DistrictGenerator.DEFAULT,
TeamGenerator.DEFAULT,
ReferenceDataGenerator.VIOLENCE,
SentenceGenerator.MAIN_OFFENCE,
SentenceGenerator.ADDITIONAL_OFFENCE,
BusinessInteractionGenerator.UPDATE_CONTACT,
ContactTypeGenerator.CONTACT_TYPE,

DisposalTypeGenerator.CURFEW_ORDER,
ReferenceDataGenerator.DISPOSAL_TYPE,
ReferenceDataGenerator.LENGTH_UNITS,
ReferenceDataGenerator.TERMINATION_REASON,
Expand Down Expand Up @@ -79,6 +80,21 @@ class DataLoader(
ReferenceDataGenerator.DEFAULT_ADDRESS_STATUS,
ReferenceDataGenerator.DEFAULT_ALLOCATION_REASON,
ReferenceDataGenerator.DEFAULT_TIER,
ReferenceDataGenerator.REF_DISQ,
ReferenceDataGenerator.PRISON,
ReferenceDataGenerator.ACR,
ReferenceDataGenerator.EXP,
ReferenceDataGenerator.HDE,
ReferenceDataGenerator.LED,
ReferenceDataGenerator.PED,
ReferenceDataGenerator.PSSED,
ReferenceDataGenerator.POM1,
ReferenceDataGenerator.POM2,
ReferenceDataGenerator.SED,
ReferenceDataGenerator.CRN,
ReferenceDataGenerator.TRIAL,
CourtGenerator.PROBATIONARE_AREA,
CourtGenerator.BHAM,
PersonGenerator.NEW_TO_PROBATION,
PersonGenerator.CURRENTLY_MANAGED,
PersonGenerator.PREVIOUSLY_MANAGED,
Expand All @@ -97,50 +113,72 @@ class DataLoader(
PersonGenerator.generatePersonManager(PersonGenerator.CURRENTLY_MANAGED)
)

val noSentenceEvent = SentenceGenerator.generateEvent(PersonGenerator.NO_SENTENCE)
val noSentenceManager = SentenceGenerator.generateOrderManager(noSentenceEvent, StaffGenerator.UNALLOCATED)
val outcome = Outcome(Outcome.Code.AWAITING_PSR.value, IdGenerator.getAndIncrement())
val courtAppearance = SentenceGenerator.generateCourtAppearance(noSentenceEvent, outcome)
val noSentenceEvent =
SentenceGenerator.generateEvent(PersonGenerator.NO_SENTENCE, referralDate = LocalDate.now())
val noSentenceManager =
SentenceGenerator.generateOrderManager(
noSentenceEvent,
StaffGenerator.UNALLOCATED,
CourtGenerator.PROBATIONARE_AREA,
ZonedDateTime.of(LocalDate.now(), LocalTime.NOON, ZoneId.of("Europe/London")),
ZonedDateTime.of(LocalDate.now().minusDays(1), LocalTime.NOON, ZoneId.of("Europe/London"))
)
val outcome = SentenceGenerator.OUTCOME
val courtAppearance = SentenceGenerator.generateCourtAppearance(noSentenceEvent, outcome, ZonedDateTime.now())
em.saveAll(noSentenceEvent, noSentenceManager, outcome, courtAppearance)

val newEvent = SentenceGenerator.generateEvent(PersonGenerator.NEW_TO_PROBATION)
val newEvent = SentenceGenerator.generateEvent(PersonGenerator.NEW_TO_PROBATION, referralDate = LocalDate.now())
val newSentence =
SentenceGenerator.generateSentence(newEvent, ZonedDateTime.now(), ReferenceDataGenerator.DISPOSAL_TYPE)
val newManager = SentenceGenerator.generateOrderManager(newEvent, StaffGenerator.UNALLOCATED)
SentenceGenerator.generateSentence(newEvent, LocalDate.now(), DisposalTypeGenerator.CURFEW_ORDER)
val newManager =
SentenceGenerator.generateOrderManager(
newEvent,
StaffGenerator.UNALLOCATED,
CourtGenerator.PROBATIONARE_AREA,
ZonedDateTime.of(LocalDate.now().minusDays(1), LocalTime.NOON, ZoneId.of("Europe/London")),
ZonedDateTime.of(LocalDate.now().minusDays(3), LocalTime.NOON, ZoneId.of("Europe/London"))
)
em.saveAll(newEvent, newSentence, newManager)

val currentEvent = SentenceGenerator.generateEvent(PersonGenerator.CURRENTLY_MANAGED, inBreach = true)
val currentSentence =
SentenceGenerator.generateSentence(
currentEvent,
ZonedDateTime.now(),
ReferenceDataGenerator.DISPOSAL_TYPE,
entryLength = 12,
entryLengthUnits = ReferenceDataGenerator.LENGTH_UNITS,
lengthInDays = 99
)
val custody = SentenceGenerator.generateCustody(currentSentence, ReferenceDataGenerator.CUSTODIAL_STATUS)
val currentManager = SentenceGenerator.generateOrderManager(currentEvent, StaffGenerator.ALLOCATED)
val mainOffence =
SentenceGenerator.generateMainOffence(currentEvent, SentenceGenerator.MAIN_OFFENCE, LocalDate.now())
val additionalOffence = SentenceGenerator.generateAdditionalOffence(
currentEvent,
SentenceGenerator.ADDITIONAL_OFFENCE,
LocalDate.now()
)
val currentEvent = SentenceGenerator.CURRENTLY_MANAGED
val currentSentence = SentenceGenerator.CURRENT_SENTENCE
val custody = SentenceGenerator.CURRENT_CUSTODY
val currentManager = SentenceGenerator.CURRENT_ORDER_MANAGER
val mainOffence = SentenceGenerator.MAIN_OFFENCE_DEFAULT
val additionalOffence = SentenceGenerator.ADDITIONAL_OFFENCE_DEFAULT
val requirement = SentenceGenerator.generateRequirement(disposal = currentSentence)
val licenceCondition = SentenceGenerator.generateLicenseCondition(disposal = currentSentence)
val breachNsi = SentenceGenerator.generateBreachNsi(disposal = currentSentence)
val pssRequirement = SentenceGenerator.generatePssRequirement(custody.id)
val currentCourtAppearance = SentenceGenerator.generateCourtAppearance(currentEvent, outcome)
val currentCourtAppearance = SentenceGenerator.COURT_APPEARANCE
val currentCourtReport = SentenceGenerator.generateCourtReport(currentCourtAppearance)
val reportManager = SentenceGenerator.generateCourtReportManager(currentCourtReport)

em.saveAll(
currentEvent,
currentSentence,
AdditionalSentenceGenerator.SENTENCE_DISQ,
ReferenceDataGenerator.HOURS_WORKED,
UnpaidWorkGenerator.UNPAID_WORK_DETAILS_1,
UnpaidWorkGenerator.APPT1,
UnpaidWorkGenerator.APPT2,
UnpaidWorkGenerator.APPT3,
UnpaidWorkGenerator.APPT4,
UnpaidWorkGenerator.APPT5,
UnpaidWorkGenerator.APPT6,
UnpaidWorkGenerator.APPT7,
currentManager,
InstitutionGenerator.WSIHMP,
custody,
SentenceGenerator.CONDITIONAL_RELEASE_KEY_DATE,
SentenceGenerator.LED_KEY_DATE,
SentenceGenerator.HDC_KEY_DATE,
SentenceGenerator.PAROLE_KEY_DATE,
SentenceGenerator.SENTENCE_KEY_DATE,
SentenceGenerator.EXPECTED_RELEASE_KEY_DATE,
SentenceGenerator.SUPERVISION_KEY_DATE,
SentenceGenerator.HANDOVER_START_KEY_DATE,
SentenceGenerator.HANDOVER_KEY_DATE,
mainOffence,
additionalOffence,
requirement,
Expand All @@ -152,15 +190,27 @@ class DataLoader(
reportManager
)

val preEvent = SentenceGenerator.generateEvent(PersonGenerator.PREVIOUSLY_MANAGED, active = false)
val preEvent =
SentenceGenerator.generateEvent(
PersonGenerator.PREVIOUSLY_MANAGED,
referralDate = LocalDate.now(),
active = false
)
val preSentence = SentenceGenerator.generateSentence(
preEvent,
ZonedDateTime.now(),
ReferenceDataGenerator.DISPOSAL_TYPE,
terminationDate = ZonedDateTime.now().minusDays(7),
LocalDate.now(),
DisposalTypeGenerator.CURFEW_ORDER,
terminationDate = LocalDate.now().minusDays(7),
active = false
)
val preManager = SentenceGenerator.generateOrderManager(preEvent, StaffGenerator.ALLOCATED)
val preManager =
SentenceGenerator.generateOrderManager(
preEvent,
StaffGenerator.ALLOCATED,
CourtGenerator.PROBATIONARE_AREA,
ZonedDateTime.of(LocalDate.now().minusDays(7), LocalTime.NOON, ZoneId.of("Europe/London")),
ZonedDateTime.of(LocalDate.now().minusDays(10), LocalTime.NOON, ZoneId.of("Europe/London"))
)
em.saveAll(preEvent, preSentence, preManager)

em.merge(CourtCaseNoteGenerator.CASE_NOTE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
package uk.gov.justice.digital.hmpps.data.entity

import jakarta.persistence.Column
import jakarta.persistence.Convert
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import org.hibernate.annotations.Immutable
import jakarta.persistence.*
import org.hibernate.type.YesNoConverter
import java.time.LocalDate

Expand Down Expand Up @@ -87,18 +82,3 @@ class User(
val surname: String
)

@Entity
@Immutable
@Table(name = "r_institution")
class Institution(
@Id
@Column(name = "institution_id")
val id: Long,

@Column(name = "institution_name")
val name: String,

@Column
@Convert(converter = YesNoConverter::class)
val establishment: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.REF_DISQ
import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator.CURRENTLY_MANAGED
import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData
import uk.gov.justice.digital.hmpps.integrations.delius.event.entity.Event
import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.AdditionalSentence
import java.math.BigDecimal

object AdditionalSentenceGenerator {

val SENTENCE_DISQ =
generateSentence(amount = BigDecimal(7), length = 3, referenceData = REF_DISQ, event = CURRENTLY_MANAGED)

fun generateSentence(
length: Long? = null,
amount: BigDecimal? = null,
notes: String? = null,
event: Event,
referenceData: ReferenceData
) = AdditionalSentence(
IdGenerator.getAndIncrement(),
event,
referenceData,
amount,
length,
notes,
false,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.Court
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.ProbationAreaEntity
import java.time.LocalDate
import java.time.LocalTime
import java.time.ZoneId
import java.time.ZonedDateTime

object CourtGenerator {

val PROBATIONARE_AREA = ProbationAreaEntity(
true,
"West Midlands Region",
"N52",
null,
false,
IdGenerator.getAndIncrement(),
)

val BHAM = Court(
IdGenerator.getAndIncrement(),
"BRMNCC",
true,
"Birmingham Crown Court",
"0121 111 2222",
"0121 333 4444",
"Queen Elizabeth II Law Courts",
"1 Newton Street",
null,
"Birmingham",
"West Midlands",
"B4 7NA",
"England",
ReferenceDataGenerator.CRN.id,
ZonedDateTime.of(LocalDate.now().minusDays(7), LocalTime.NOON, ZoneId.of("Europe/London")),
ZonedDateTime.of(LocalDate.now(), LocalTime.NOON, ZoneId.of("Europe/London")),
PROBATIONARE_AREA.id,
null,
PROBATIONARE_AREA,
ReferenceDataGenerator.CRN
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.DisposalType

object DisposalTypeGenerator {

val CURFEW_ORDER =
DisposalType(IdGenerator.getAndIncrement(), "Curfew Order", "SP", cja2003Order = false, legacyOrder = true, 2)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.data.entity.Court
import uk.gov.justice.digital.hmpps.data.entity.Institution
//import uk.gov.justice.digital.hmpps.data.entity.Institution
import uk.gov.justice.digital.hmpps.data.entity.InstitutionalReport
import uk.gov.justice.digital.hmpps.integrations.delius.entity.DocumentEntity
import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData
Expand All @@ -20,7 +20,7 @@ object DocumentEntityGenerator {
dateRequested = LocalDate.of(2000, 1, 2)
)

val R_INSTITUTION = Institution(IdGenerator.getAndIncrement(), "test", false)
// val R_INSTITUTION = Institution(IdGenerator.getAndIncrement(), "test", false)

fun generateDocument(personId: Long, primaryKeyId: Long?, type: String, tableName: String?) =
DocumentEntity(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.Institution
import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.InstitutionId

object InstitutionGenerator {

val WSIHMP = generate("WSIHMP", "WSI")

fun generate(code: String, prisonId: String): Institution {
return Institution(
id = InstitutionId(IdGenerator.getAndIncrement(), true),
code = code,
description = "Test institution ($code)",
institutionName = "Test institution $code",
establishmentType = ReferenceDataGenerator.PRISON,
nomisCdeCode = prisonId
)
}
}
Loading

0 comments on commit 58682d7

Please sign in to comment.