Skip to content

Commit

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

* PI-1902

* PI-1902 formatting

* move lines to reduce duplication until refactor
  • Loading branch information
anthony-britton-moj authored Feb 13, 2024
1 parent 0592478 commit 4a50439
Show file tree
Hide file tree
Showing 27 changed files with 1,076 additions and 6 deletions.
6 changes: 6 additions & 0 deletions projects/prisoner-profile-and-delius/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dependencies {
implementation(project(":libs:audit"))
implementation(project(":libs:commons"))
implementation(project(":libs:oauth-server"))
implementation(project(":libs:document-management"))

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
Expand Down Expand Up @@ -35,4 +36,9 @@ configure<ClassPathExtension> {
"**/entity/**",
"**/AppKt.class"
)

sonarExclusions = listOf(
"**/entity/**",
"**/model/**"
)
}
2 changes: 2 additions & 0 deletions projects/prisoner-profile-and-delius/deploy/values-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ generic-service:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-dev.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer

INTEGRATIONS_ALFRESCO_URL: https://alfresco.test.delius.probation.hmpps.dsd.io/alfresco/service/noms-spg

LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG

generic-prometheus-alerts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ generic-service:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-preprod.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/issuer

INTEGRATIONS_ALFRESCO_URL: https://alfresco.pre-prod.delius.probation.hmpps.dsd.io/alfresco/service/noms-spg

generic-prometheus-alerts:
businessHoursOnly: true
2 changes: 2 additions & 0 deletions projects/prisoner-profile-and-delius/deploy/values-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ generic-service:
SENTRY_ENVIRONMENT: prod
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-prod.svc.cluster.local/auth/.well-known/jwks.json
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/issuer

INTEGRATIONS_ALFRESCO_URL: https://alfresco.probation.service.justice.gov.uk/alfresco/service/noms-spg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import uk.gov.justice.digital.hmpps.data.generator.CommunityManagerGenerator.TEA
import uk.gov.justice.digital.hmpps.data.generator.CommunityManagerGenerator.UNALLOCATED_PERSON
import uk.gov.justice.digital.hmpps.data.generator.CommunityManagerGenerator.UNALLOCATED_STAFF
import uk.gov.justice.digital.hmpps.data.generator.CommunityManagerGenerator.generateCommunityManager
import uk.gov.justice.digital.hmpps.data.generator.DocumentGenerator
import uk.gov.justice.digital.hmpps.data.generator.EventGenerator
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator
import uk.gov.justice.digital.hmpps.user.AuditUserRepository

Expand Down Expand Up @@ -47,7 +50,48 @@ class DataLoader(
UNALLOCATED_STAFF
)
).saveAll()
documentData().saveAll()
}

fun List<Any>.saveAll() = forEach { entityManager.persist(it) }

fun documentData() = listOfNotNull(
PersonGenerator.DEFAULT,
EventGenerator.EVENT.mainOffence.offence,
EventGenerator.EVENT,
EventGenerator.EVENT.mainOffence,
EventGenerator.UNSENTENCED_EVENT.mainOffence.offence,
EventGenerator.UNSENTENCED_EVENT,
EventGenerator.UNSENTENCED_EVENT.mainOffence,
EventGenerator.DISPOSAL.lengthUnits,
EventGenerator.DISPOSAL.type,
EventGenerator.DISPOSAL,
EventGenerator.INSTITUTION,
EventGenerator.CUSTODY,
EventGenerator.COURT,
EventGenerator.COURT_APPEARANCE,
EventGenerator.UNSENTENCED_COURT_APPEARANCE.outcome,
EventGenerator.UNSENTENCED_COURT_APPEARANCE,
EventGenerator.COURT_REPORT_TYPE,
EventGenerator.COURT_REPORT,
EventGenerator.INSTITUTIONAL_REPORT_TYPE,
EventGenerator.INSTITUTIONAL_REPORT,
EventGenerator.CONTACT_TYPE,
EventGenerator.CONTACT,
EventGenerator.NSI_TYPE,
EventGenerator.NSI,
DocumentGenerator.OFFENDER,
DocumentGenerator.PREVIOUS_CONVICTIONS,
DocumentGenerator.EVENT,
DocumentGenerator.CPS_PACK,
DocumentGenerator.ADDRESSASSESSMENT,
DocumentGenerator.PERSONALCONTACT,
DocumentGenerator.PERSONAL_CIRCUMSTANCE,
DocumentGenerator.COURT_REPORT,
DocumentGenerator.INSTITUTIONAL_REPORT,
DocumentGenerator.OFFENDER_CONTACT,
DocumentGenerator.EVENT_CONTACT,
DocumentGenerator.OFFENDER_NSI,
DocumentGenerator.EVENT_NSI
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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.type.YesNoConverter
import java.time.LocalDate

@Entity
class AddressAssessment(@Id val addressAssessmentId: Long, val assessmentDate: LocalDate)

@Entity
class ApprovedPremisesReferral(
@Id val approvedPremisesReferralId: Long,
val referralDate: LocalDate,
val eventId: Long?
)

@Entity
class Assessment(
@Id val assessmentId: Long,
val assessmentTypeId: Long,
val referralId: Long?,
val assessmentDate: LocalDate
)

@Entity
@Table(name = "r_assessment_type")
class AssessmentType(@Id val assessmentTypeId: Long, val description: String)

@Entity
class CaseAllocation(@Id val caseAllocationId: Long, val eventId: Long)

@Entity
class Contact(@Id val contactId: Long, val contactTypeId: Long, val eventId: Long?, val contactDate: LocalDate)

@Entity
@Table(name = "r_contact_type")
class ContactType(@Id val contactTypeId: Long, val description: String)

@Entity
class Court(@Id val courtId: Long, val courtName: String)

@Entity
@Table(name = "r_court_report_type")
class CourtReportType(@Id val courtReportTypeId: Long, val description: String)

@Entity
class CourtReport(
@Id val courtReportId: Long,
val courtReportTypeId: Long,
val courtAppearanceId: Long,
val dateRequested: LocalDate
)

@Entity
class InstitutionalReport(
@Id
val institutionalReportId: Long,
val institutionReportTypeId: Long,
val institutionId: Long,
@Convert(converter = YesNoConverter::class)
val establishment: Boolean,
val custodyId: Long,
val dateRequested: LocalDate
)

@Entity
class Nsi(@Id val nsiId: Long, val nsiTypeId: Long, val eventId: Long?, val referralDate: LocalDate)

@Entity
@Table(name = "r_nsi_type")
class NsiType(@Id val nsiTypeId: Long, val description: String)

@Entity
class PersonalCircumstance(@Id val personalCircumstanceId: Long, val circumstanceTypeId: Long, val startDate: LocalDate)

@Entity
@Table(name = "r_circumstance_type")
class PersonalCircumstanceType(@Id val circumstanceTypeId: Long, val codeDescription: String)

@Entity
class PersonalContact(@Id val personalContactId: Long, val relationshipTypeId: Long, val relationship: String)

@Entity
class Referral(@Id val referralId: Long, val referralTypeId: Long, val referralDate: LocalDate, val eventId: Long)

@Entity
@Table(name = "r_referral_type")
class ReferralType(@Id val referralTypeId: Long, val description: String)

@Entity
class UpwAppointment(
@Id val upwAppointmentId: Long,
val upwDetailsId: Long,
val upwProjectId: Long,
val appointmentDate: LocalDate
)

@Entity
class UpwDetails(@Id val upwDetailsId: Long, val disposalId: Long)

@Entity
class UpwProject(@Id val upwProjectId: Long, val name: String)

@Entity
@Table(name = "user_")
class User(
@Id
@Column(name = "user_id")
val userId: Long,
val forename: String,
val surname: String
)
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.integrations.delius.manager.entity.CommunityManager
import uk.gov.justice.digital.hmpps.integrations.delius.manager.entity.Person
import uk.gov.justice.digital.hmpps.integrations.delius.manager.entity.ManagedPerson
import uk.gov.justice.digital.hmpps.integrations.delius.manager.entity.Staff
import uk.gov.justice.digital.hmpps.integrations.delius.manager.entity.StaffUser
import uk.gov.justice.digital.hmpps.integrations.delius.manager.entity.Team
Expand Down Expand Up @@ -41,10 +41,10 @@ object CommunityManagerGenerator {
nomsId: String,
softDeleted: Boolean = false,
id: Long = IdGenerator.getAndIncrement()
) = Person(crn, nomsId, softDeleted, id)
) = ManagedPerson(crn, nomsId, softDeleted, id)

fun generateCommunityManager(
person: Person,
person: ManagedPerson,
staff: Staff,
team: Team = TEAM,
active: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.integrations.delius.documents.entity.DocumentEntity
import java.time.ZonedDateTime
import java.util.*

object DocumentGenerator {
val OFFENDER = generate("OFFENDER", primaryKeyId = PersonGenerator.DEFAULT.id, alfrescoId = "uuid1")
val PREVIOUS_CONVICTIONS = generate("OFFENDER", "PREVIOUS_CONVICTION", primaryKeyId = PersonGenerator.DEFAULT.id)
val EVENT = generate("EVENT", primaryKeyId = EventGenerator.EVENT.id)
val CPS_PACK = generate("EVENT", "CPS_PACK", primaryKeyId = EventGenerator.EVENT.id)
val ADDRESSASSESSMENT = generate("ADDRESSASSESSMENT")
val PERSONALCONTACT = generate("PERSONALCONTACT")
val PERSONAL_CIRCUMSTANCE = generate("PERSONAL_CIRCUMSTANCE")
val COURT_REPORT = generate("COURT_REPORT", primaryKeyId = EventGenerator.COURT_REPORT.courtReportId)
val INSTITUTIONAL_REPORT =
generate("INSTITUTIONAL_REPORT", primaryKeyId = EventGenerator.INSTITUTIONAL_REPORT.institutionalReportId)
val OFFENDER_CONTACT = generate("CONTACT")
val EVENT_CONTACT = generate("CONTACT", primaryKeyId = EventGenerator.CONTACT.contactId)
val OFFENDER_NSI = generate("NSI")
val EVENT_NSI = generate("NSI", primaryKeyId = EventGenerator.NSI.nsiId)

fun generate(
tableName: String,
type: String = "DOCUMENT",
primaryKeyId: Long = 0,
alfrescoId: String = UUID.randomUUID().toString()
) = DocumentEntity(
id = IdGenerator.getAndIncrement(),
personId = PersonGenerator.DEFAULT.id,
alfrescoId = alfrescoId,
primaryKeyId = primaryKeyId,
name = "$tableName-related document",
type = type,
tableName = tableName,
createdAt = ZonedDateTime.now(),
createdByUserId = 0,
lastUpdatedUserId = 0,
softDeleted = false
)
}
Loading

0 comments on commit 4a50439

Please sign in to comment.