diff --git a/.github/workflows/access.yml b/.github/workflows/access.yml
index 1c28178032..6f53002e2c 100644
--- a/.github/workflows/access.yml
+++ b/.github/workflows/access.yml
@@ -57,6 +57,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
+ - '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bb4ec23d2d..117be5e114 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -80,6 +80,7 @@ jobs:
- common-platform-and-delius
- ims-and-delius
- appointment-reminders-and-delius
+ - justice-email-and-delius
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 902f1081a5..d22a0bad5e 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -72,6 +72,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
+ - '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
diff --git a/.github/workflows/service-catalogue.yml b/.github/workflows/service-catalogue.yml
index 4fff9783d8..8250e66ce2 100644
--- a/.github/workflows/service-catalogue.yml
+++ b/.github/workflows/service-catalogue.yml
@@ -57,6 +57,7 @@ on:
- '["common-platform-and-delius"]'
- '["ims-and-delius"]'
- '["appointment-reminders-and-delius"]'
+ - '["justice-email-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
diff --git a/.idea/runConfigurations/justice_email_and_delius.xml b/.idea/runConfigurations/justice_email_and_delius.xml
new file mode 100644
index 0000000000..7d547a24f7
--- /dev/null
+++ b/.idea/runConfigurations/justice_email_and_delius.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/tech-docs/source/services.html.md.erb b/doc/tech-docs/source/services.html.md.erb
index e2adb4427d..8225b8c9e8 100644
--- a/doc/tech-docs/source/services.html.md.erb
+++ b/doc/tech-docs/source/services.html.md.erb
@@ -84,4 +84,5 @@ weight: 20
* [Common Platform And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/common-platform-and-delius)
* [Ims And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/ims-and-delius)
* [Appointment Reminders And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/appointment-reminders-and-delius)
+* [Justice Email And Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius)
^ add new projects here
diff --git a/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/repository/UpwAppointmentRepository.kt b/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/repository/UpwAppointmentRepository.kt
index 041b290036..b4222f0bf6 100644
--- a/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/repository/UpwAppointmentRepository.kt
+++ b/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/repository/UpwAppointmentRepository.kt
@@ -11,42 +11,62 @@ interface UpwAppointmentRepository : JpaRepository {
"""
select
any_value(first_name) as "firstName",
- any_value(mobile_number) as "mobileNumber",
+ any_value(formatted_mobile_number) as "mobileNumber",
any_value(to_char(appointment_date, 'DD/MM/YYYY')) as "appointmentDate",
-- for testing --
crn as "crn",
listagg(distinct event_number, ', ') as "eventNumbers",
listagg(distinct upw_appointment_id, ', ') as "upwAppointmentIds"
from (
+ with unique_mobile_numbers as (
+ select
+ replace(mobile_number, ' ', '') as formatted_mobile_number,
+ any_value(offender_id) as offender_id
+ from offender where soft_deleted = 0
+ -- no other cases with the same mobile number
+ group by replace(mobile_number, ' ', '') having count(*) = 1)
select
first_name,
- replace(mobile_number, ' ', '') as mobile_number,
+ formatted_mobile_number,
upw_appointment.appointment_date as appointment_date,
crn,
event_number,
upw_appointment.upw_appointment_id
- from offender
+ from unique_mobile_numbers
+ join offender on offender.offender_id = unique_mobile_numbers.offender_id
join event on event.offender_id = offender.offender_id and event.active_flag = 1 and event.soft_deleted = 0
join disposal on disposal.event_id = event.event_id and disposal.active_flag = 1 and disposal.soft_deleted = 0
join r_disposal_type on r_disposal_type.disposal_type_id = disposal.disposal_type_id
join upw_details on upw_details.disposal_id = disposal.disposal_id and upw_details.soft_deleted = 0
join upw_appointment on upw_appointment.upw_details_id = upw_details.upw_details_id and upw_appointment.soft_deleted = 0 and trunc(upw_appointment.appointment_date) = :date
- left join r_contact_outcome_type on r_contact_outcome_type.contact_outcome_type_id = upw_appointment.contact_outcome_type_id
join upw_project on upw_project.upw_project_id = upw_appointment.upw_project_id
join r_standard_reference_list upw_project_type on upw_project_type.standard_reference_list_id = upw_project.project_type_id and upw_project_type.code_value in ('ES','ICP','NP1','NP2','PI','PIP','PIP2','PL','PS','PSP','WH1')
join probation_area on probation_area.probation_area_id = upw_project.probation_area_id and probation_area.code = :providerCode
left join exclusion on exclusion.offender_id = offender.offender_id and exclusion_date < current_date and (exclusion_end_date is null or current_date < exclusion_end_date)
left join restriction on restriction.offender_id = offender.offender_id and restriction_date < current_date and (restriction_end_date is null or current_date < restriction_end_date)
- where offender.soft_deleted = 0
- -- valid mobile number and sms allowed
- and replace(mobile_number, ' ', '') like '07%'
- and length(replace(mobile_number, ' ', '')) = 11
- and validate_conversion(replace(mobile_number, ' ', '') as number) = 1
+ -- valid mobile number
+ where formatted_mobile_number like '07%' and length(formatted_mobile_number) = 11 and validate_conversion(formatted_mobile_number as number) = 1
+ -- sms is allowed
and (allow_sms is null or allow_sms = 'Y')
- -- no other cases with the same mobile number
- and not exists (
- select 1 from offender duplicate where duplicate.soft_deleted = 0 and replace(duplicate.mobile_number, ' ', '') = replace(offender.mobile_number, ' ', '') and duplicate.offender_id <> offender.offender_id
- )
+ -- no access limitations
+ and restriction_id is null and exclusion_id is null
+ -- appointment does not have an outcome
+ and upw_appointment.contact_outcome_type_id is null
+ -- not on remand
+ and (current_remand_status is null or (current_remand_status not in ('Warrant With Bail', 'Warrant Without Bail', 'Remanded In Custody', 'Unlawfully at Large') and current_remand_status not like 'UAL%'))
+ and not exists (select 1 from personal_circumstance
+ join r_circumstance_type on r_circumstance_type.circumstance_type_id = personal_circumstance.circumstance_type_id and r_circumstance_type.code_value = 'RIC'
+ where personal_circumstance.offender_id = offender.offender_id and personal_circumstance.soft_deleted = 0 and (personal_circumstance.end_date is null or personal_circumstance.end_date > current_date))
+ -- not in custody
+ and not exists (select 1 from custody
+ join disposal custody_disposal on custody_disposal.disposal_id = custody.disposal_id and custody_disposal.active_flag = 1 and custody_disposal.soft_deleted = 0
+ join event custody_event on custody_event.event_id = custody_disposal.event_id and custody_event.offender_id = offender.offender_id and custody_event.active_flag = 1 and custody_event.soft_deleted = 0
+ join r_standard_reference_list custodial_status on custodial_status.standard_reference_list_id = custody.custodial_status_id and custodial_status.code_value in ('A', 'C', 'D')
+ where custody.soft_deleted = 0)
+ -- not on warrant or unlawfully at large
+ and not exists (select 1 from registration
+ join r_register_type on r_register_type.register_type_id = registration.register_type_id and r_register_type.code in ('IWWO', 'IWWB', 'WRSM', 'HUAL')
+ where registration.offender_id = offender.offender_id and registration.deregistered = 0 and registration.soft_deleted = 0)
-- has an active unpaid work requirement
and exists (select 1 from rqmnt
join r_rqmnt_type_main_category on r_rqmnt_type_main_category.rqmnt_type_main_category_id = rqmnt.rqmnt_type_main_category_id and r_rqmnt_type_main_category.code in ('W', 'W0', 'W1', 'W2')
@@ -67,29 +87,6 @@ interface UpwAppointmentRepository : JpaRepository {
(select coalesce(sum(appts.minutes_credited), 0) from upw_appointment appts where appts.upw_details_id = upw_details.upw_details_id and appts.soft_deleted = 0)
as minutes_credited
from dual)) > 0
- -- appointment does not have an outcome
- and r_contact_outcome_type.description is null
- -- not in custody
- and not exists (select 1 from custody
- join disposal custody_disposal on custody_disposal.disposal_id = custody.disposal_id and custody_disposal.active_flag = 1 and custody_disposal.soft_deleted = 0
- join event custody_event on custody_event.event_id = custody_disposal.event_id and custody_event.offender_id = offender.offender_id and custody_event.active_flag = 1 and custody_event.soft_deleted = 0
- join r_standard_reference_list custodial_status on custodial_status.standard_reference_list_id = custody.custodial_status_id and custodial_status.code_value in ('A', 'C', 'D')
- where custody.soft_deleted = 0)
- -- not on remand
- and (current_remand_status is null or (current_remand_status not in ('Warrant With Bail', 'Warrant Without Bail', 'Remanded In Custody', 'Unlawfully at Large') and current_remand_status not like 'UAL%'))
- and not exists (select 1 from personal_circumstance
- join r_circumstance_type on r_circumstance_type.circumstance_type_id = personal_circumstance.circumstance_type_id and r_circumstance_type.code_value = 'RIC'
- where personal_circumstance.offender_id = offender.offender_id and personal_circumstance.soft_deleted = 0 and (personal_circumstance.end_date is null or personal_circumstance.end_date > current_date))
- -- not unlawfully at large
- and not exists (select 1 from registration
- join r_register_type on r_register_type.register_type_id = registration.register_type_id and r_register_type.code in ('HUAL')
- where registration.offender_id = offender.offender_id and registration.deregistered = 0 and registration.soft_deleted = 0)
- -- not on warrant
- and not exists (select 1 from registration
- join r_register_type on r_register_type.register_type_id = registration.register_type_id and r_register_type.code in ('IWWO', 'IWWB', 'WRSM')
- where registration.offender_id = offender.offender_id and registration.deregistered = 0 and registration.soft_deleted = 0)
- -- no access limitations
- and restriction_id is null and exclusion_id is null
)
group by crn
order by crn
diff --git a/projects/appointment-reminders-and-delius/src/main/resources/application.yml b/projects/appointment-reminders-and-delius/src/main/resources/application.yml
index e1929eea8f..dcccd3a6b6 100644
--- a/projects/appointment-reminders-and-delius/src/main/resources/application.yml
+++ b/projects/appointment-reminders-and-delius/src/main/resources/application.yml
@@ -62,7 +62,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DocumentDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DocumentDataLoader.kt
index 416732931c..54cac11653 100644
--- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DocumentDataLoader.kt
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DocumentDataLoader.kt
@@ -2,12 +2,13 @@ package uk.gov.justice.digital.hmpps.data
import org.springframework.stereotype.Component
import uk.gov.justice.digital.hmpps.data.generator.DocumentGenerator
+import uk.gov.justice.digital.hmpps.data.generator.DocumentGenerator.generate
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator
import uk.gov.justice.digital.hmpps.data.generator.ProbationCaseGenerator
import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.EventRepository
import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentRepository
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocumentType
import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.person.getByCrn
import java.util.*
@Component
@@ -17,38 +18,51 @@ class DocumentDataLoader(
private val eventRepository: EventRepository
) {
fun loadData() {
- documentRepository.save(DocumentGenerator.EVENT_DOC)
- documentRepository.save(DocumentGenerator.PERSON_DOC)
-
- val person = personRepository.findByCrnAndSoftDeletedIsFalse(ProbationCaseGenerator.CASE_X320741.crn)!!
-
- documentRepository.save(
- DocumentGenerator.generatePersonDoc(
- person = person,
- name = "Random offender document.pdf",
- alfrescoId = UUID.randomUUID().toString(),
- documentType = DocumentType.DOCUMENT
+ documentRepository.saveAll(
+ listOf(
+ DocumentGenerator.EVENT,
+ DocumentGenerator.PERSON,
+ DocumentGenerator.PREVIOUS_CONVICTIONS,
+ DocumentGenerator.CPS_PACK,
+ DocumentGenerator.ADDRESSASSESSMENT,
+ DocumentGenerator.PERSONALCONTACT,
+ DocumentGenerator.PERSONAL_CIRCUMSTANCE,
+ DocumentGenerator.OFFENDER_CONTACT,
+ DocumentGenerator.OFFENDER_NSI,
)
)
- val personEvent = PersonGenerator.generateEvent(
- "1",
- person.id
- ).apply(eventRepository::save)
+ val person = personRepository.getByCrn(ProbationCaseGenerator.CASE_X320741.crn)
+ val personEvent = PersonGenerator.generateEvent("1", person.id)
+ .apply(eventRepository::save)
- listOf(
- Pair("CPS pack.pdf", DocumentType.CPS_PACK),
- Pair("Conviction document.pdf", DocumentType.PREVIOUS_CONVICTION)
- ).forEach {
- documentRepository.save(
- DocumentGenerator.generateEventDoc(
- person = person,
- event = personEvent,
- name = it.first,
- alfrescoId = UUID.randomUUID().toString(),
- documentType = it.second,
- )
+ val personDocument = generate(
+ tableName = "OFFENDER",
+ person = person,
+ name = "Random offender document.pdf",
+ alfrescoId = UUID.randomUUID().toString()
+ )
+ val cpsPack = generate(
+ tableName = "EVENT",
+ type = "CPS_PACK",
+ name = "CPS pack.pdf",
+ person = person,
+ primaryKeyId = personEvent.id
+ )
+ val previousConvictions = generate(
+ tableName = "OFFENDER",
+ type = "PREVIOUS_CONVICTION",
+ name = "Conviction document.pdf",
+ person = person,
+ primaryKeyId = person.id
+ )
+
+ documentRepository.saveAll(
+ listOf(
+ personDocument,
+ cpsPack,
+ previousConvictions
)
- }
+ )
}
}
\ No newline at end of file
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
index eab4a0090d..8e9d8f3615 100644
--- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
@@ -13,9 +13,6 @@ import uk.gov.justice.digital.hmpps.entity.Exclusion
import uk.gov.justice.digital.hmpps.entity.LimitedAccessPerson
import uk.gov.justice.digital.hmpps.entity.Restriction
import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.EventRepository
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceRepository
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceSubType
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceType
import uk.gov.justice.digital.hmpps.integrations.delius.person.Ldu
import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCaseRepository
import uk.gov.justice.digital.hmpps.integrations.delius.person.manager.probation.PersonManagerRepository
@@ -24,6 +21,9 @@ import uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity.Ma
import uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity.Offence
import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.RegisterType
import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.RegistrationRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.PersonalCircumstanceRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstanceSubType
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstanceType
import uk.gov.justice.digital.hmpps.integrations.delius.staff.StaffRepository
import uk.gov.justice.digital.hmpps.integrations.delius.team.TeamRepository
import java.time.LocalDate
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Entities.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Entities.kt
new file mode 100644
index 0000000000..6522370c0d
--- /dev/null
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Entities.kt
@@ -0,0 +1,106 @@
+package uk.gov.justice.digital.hmpps.data.entity
+
+import jakarta.persistence.*
+import org.hibernate.type.YesNoConverter
+import java.time.LocalDate
+
+@Entity
+class AddressAssessment(@Id val addressAssessmentId: Long, val assessmentDate: LocalDate)
+
+@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(name = "ContactTypeEntity")
+@Table(name = "r_contact_type")
+class ContactType(@Id @Column(name = "contact_type_id") val id: Long, val description: String)
+
+@Entity
+class CourtAppearance(@Id val courtAppearanceId: Long, val courtId: Long, val eventId: Long)
+
+@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 Custody(@Id val custodyId: Long, val disposalId: Long)
+
+@Entity
+class Disposal(@Id val disposalId: Long, val eventId: Long)
+
+@Entity
+@Table(name = "r_institution")
+class Institution(
+ @Id
+ val institutionId: Long,
+ val institutionName: String,
+ @Convert(converter = YesNoConverter::class)
+ val establishment: Boolean,
+)
+
+@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(name = "NsiEntity")
+@Table(name = "nsi")
+class Nsi(@Id @Column(name = "nsi_id") val id: Long, val eventId: Long?)
+
+@Entity(name = "PersonalCircumstanceEntity")
+@Table(name = "personal_circumstance")
+class PersonalCircumstance(@Id @Column(name = "personal_circumstance_id") val id: Long, val startDate: LocalDate)
+
+@Entity
+class PersonalContact(@Id val personalContactId: Long, val relationshipTypeId: Long, val relationship: String)
+
+@Entity(name = "ReferralEntity")
+@Table(name = "referral")
+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)
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DocumentGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DocumentGenerator.kt
index 0607563684..8a29f6559f 100644
--- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DocumentGenerator.kt
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DocumentGenerator.kt
@@ -1,57 +1,52 @@
package uk.gov.justice.digital.hmpps.data.generator
-import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.Event
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocEvent
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocumentType
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.EventDocument
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.OffenderDocument
+import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocumentEntity
import uk.gov.justice.digital.hmpps.integrations.delius.person.Person
import java.time.ZonedDateTime
+import java.util.*
object DocumentGenerator {
- val EVENT_DOC = generateEventDoc()
- val PERSON_DOC = generatePersonDoc()
+ val EVENT = generate(
+ tableName = "EVENT",
+ name = "test.doc",
+ primaryKeyId = PersonGenerator.ANOTHER_EVENT.id,
+ alfrescoId = "uuid1"
+ )
- fun generateEventDoc(
- event: Event = PersonGenerator.ANOTHER_EVENT,
- person: Person = PersonGenerator.DEFAULT,
- id: Long = IdGenerator.getAndIncrement(),
- name: String = "test.doc",
- alfrescoId: String = "uuid1",
- documentType: DocumentType = DocumentType.DOCUMENT
- ): EventDocument {
- val doc = EventDocument(event.toDocEvent())
- doc.id = id
- doc.person = person
- doc.name = name
- doc.primaryKeyId = doc.event?.id!!
- doc.alfrescoId = alfrescoId
- doc.lastSaved = ZonedDateTime.now().minusDays(7)
- doc.dateProduced = null
- doc.type = documentType
- return doc
- }
-
- fun generatePersonDoc(
- id: Long = IdGenerator.getAndIncrement(),
- person: Person = PersonGenerator.DEFAULT,
- name: String = "offender.doc",
- alfrescoId: String = "uuid2",
- documentType: DocumentType = DocumentType.DOCUMENT
- ): OffenderDocument {
- val doc = OffenderDocument()
- doc.id = id
- doc.person = person
- doc.name = name
- doc.primaryKeyId = person.id
- doc.alfrescoId = alfrescoId
- doc.lastSaved = ZonedDateTime.now().minusDays(7)
- doc.dateProduced = null
- doc.type = documentType
+ val PERSON = generate(
+ tableName = "OFFENDER",
+ name = "offender.doc",
+ primaryKeyId = PersonGenerator.DEFAULT.id,
+ alfrescoId = "uuid2"
+ )
- return doc
- }
+ val PREVIOUS_CONVICTIONS = generate("OFFENDER", "PREVIOUS_CONVICTION", primaryKeyId = PersonGenerator.DEFAULT.id)
+ val CPS_PACK = generate("EVENT", "CPS_PACK", primaryKeyId = PersonGenerator.EVENT.id)
+ val ADDRESSASSESSMENT = generate("ADDRESSASSESSMENT")
+ val PERSONALCONTACT = generate("PERSONALCONTACT")
+ val PERSONAL_CIRCUMSTANCE = generate("PERSONAL_CIRCUMSTANCE")
+ val OFFENDER_CONTACT = generate("CONTACT")
+ val OFFENDER_NSI = generate("NSI")
- private fun Event.toDocEvent() =
- DocEvent(id, Person(personId, "", false), true, number, null, null)
+ fun generate(
+ tableName: String,
+ type: String = "DOCUMENT",
+ name: String = "$tableName-related document",
+ person: Person = PersonGenerator.DEFAULT,
+ primaryKeyId: Long = 0,
+ alfrescoId: String = UUID.randomUUID().toString()
+ ) = DocumentEntity(
+ id = IdGenerator.getAndIncrement(),
+ person = person,
+ alfrescoId = alfrescoId,
+ primaryKeyId = primaryKeyId,
+ name = name,
+ type = type,
+ tableName = tableName,
+ createdAt = ZonedDateTime.now(),
+ createdByUserId = 0,
+ lastSaved = ZonedDateTime.now().minusDays(7),
+ lastUpdatedUserId = 0,
+ softDeleted = false
+ )
}
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonalCircumstanceGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonalCircumstanceGenerator.kt
index 443f71528d..790b036375 100644
--- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonalCircumstanceGenerator.kt
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonalCircumstanceGenerator.kt
@@ -1,8 +1,8 @@
package uk.gov.justice.digital.hmpps.data.generator
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstance
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceSubType
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceType
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstance
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstanceSubType
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstanceType
object PersonalCircumstanceGenerator {
val PC_TYPES = listOf(
diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/DocIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/DocIntegrationTest.kt
index 13c325d0a8..fb16906be9 100644
--- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/DocIntegrationTest.kt
+++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/DocIntegrationTest.kt
@@ -46,12 +46,12 @@ internal class DocIntegrationTest {
.andExpect(jsonPath("$[0].level", equalTo("Conviction")))
.andExpect(jsonPath("$[0].eventNumber", equalTo("8")))
.andExpect(jsonPath("$[0].filename", equalTo("test.doc")))
- .andExpect(jsonPath("$[0].typeCode", equalTo("EVENT")))
- .andExpect(jsonPath("$[0].typeDescription", equalTo("Event")))
+ .andExpect(jsonPath("$[0].typeCode", equalTo("CONVICTION_DOCUMENT")))
+ .andExpect(jsonPath("$[0].typeDescription", equalTo("Sentence related")))
.andExpect(jsonPath("$[1].id", equalTo("uuid2")))
.andExpect(jsonPath("$[1].level", equalTo("Offender")))
.andExpect(jsonPath("$[1].filename", equalTo("offender.doc")))
- .andExpect(jsonPath("$[1].typeCode", equalTo("PERSON")))
- .andExpect(jsonPath("$[1].typeDescription", equalTo("Person")))
+ .andExpect(jsonPath("$[1].typeCode", equalTo("OFFENDER_DOCUMENT")))
+ .andExpect(jsonPath("$[1].typeDescription", equalTo("Offender related")))
}
}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/DocumentController.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/DocumentController.kt
index 39e0ecbd9d..7d43f58d79 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/DocumentController.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/DocumentController.kt
@@ -7,7 +7,7 @@ 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.integrations.delius.document.entity.APDocument
+import uk.gov.justice.digital.hmpps.model.DocumentResponse
import uk.gov.justice.digital.hmpps.service.DocumentService
@RestController
@@ -32,6 +32,6 @@ class DocumentController(private val documentService: DocumentService) {
"""
)
@GetMapping(value = ["/all"])
- fun findDocuments(@PathVariable crn: String): List =
+ fun findDocuments(@PathVariable crn: String): List =
documentService.getDocumentsByCrn(crn)
}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentRepository.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentRepository.kt
index 54c295ae2f..0e1dd0775d 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentRepository.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentRepository.kt
@@ -3,10 +3,99 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.Document
+import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocumentEntity
-interface DocumentRepository : JpaRepository {
- @Query("select d.name from Document d where d.person.crn = :crn and d.alfrescoId = :alfrescoId")
+interface DocumentRepository : JpaRepository {
+ @Query("select d.name from DocumentEntity d where d.person.crn = :crn and d.alfrescoId = :alfrescoId")
fun findNameByPersonCrnAndAlfrescoId(crn: String, alfrescoId: String): String?
- fun findAllByPersonIdAndSoftDeletedIsFalse(personId: Long): List
+ @Query(
+ """
+ select document.alfresco_document_id as "id",
+ related_event.event_number as "eventNumber",
+ document.document_name as name,
+ document.document_type as type,
+ document.table_name as "tableName",
+ document.last_saved as "dateSaved",
+ document.created_datetime as "dateCreated",
+ case
+ when address_assessment.address_assessment_id is not null
+ then 'Address assessment on ' || to_char(address_assessment.assessment_date, 'dd/MM/yyyy')
+ when approved_premises_referral.approved_premises_referral_id is not null
+ then 'Approved premises referral on ' || to_char(approved_premises_referral.referral_date, 'dd/MM/yyyy')
+ when assessment.assessment_id is not null
+ then 'Assessment for ' || r_assessment_type.description || ' on ' || to_char(assessment.assessment_date, 'dd/MM/yyyy')
+ when contact.contact_id is not null
+ then 'Contact on ' || to_char(contact.contact_date, 'dd/MM/yyyy') || ' for ' || r_contact_type.description
+ when court_report.court_report_id is not null
+ then r_court_report_type.description || ' requested by ' || court.court_name || ' on ' || to_char(court_report.date_requested, 'dd/MM/yyyy')
+ when institutional_report.institutional_report_id is not null
+ then institutional_report_type.code_description || ' at ' || r_institution.institution_name || ' requested on ' || to_char(institutional_report.date_requested, 'dd/MM/yyyy')
+ when nsi.nsi_id is not null
+ then 'Non Statutory Intervention for ' || r_nsi_type.description || ' on ' || to_char(nsi.referral_date, 'dd/MM/yyyy')
+ when personal_circumstance.personal_circumstance_id is not null
+ then 'Personal circumstance of ' || r_circumstance_type.code_description || ' started on ' || to_char(personal_circumstance.start_date, 'dd/MM/yyyy')
+ when personal_contact.personal_contact_id is not null
+ then 'Personal contact of type ' || personal_contact_relationship_type.code_description || ' with ' || personal_contact.relationship
+ when referral.referral_id is not null
+ then 'Referral for ' || r_referral_type.description || ' on ' || to_char(referral.referral_date, 'dd/MM/yyyy')
+ when upw_appointment.upw_appointment_id is not null
+ then 'Unpaid work appointment on ' || to_char(upw_appointment.appointment_date, 'dd/MM/yyyy') || ' for ' || upw_project.name
+ end as description
+ from document
+ -- the following joins are to get the event_id from the related entities, for event-level documents
+ left join event on document.table_name = 'EVENT' and document.primary_key_id = event.event_id
+ left join court_report on document.table_name = 'COURT_REPORT' and document.primary_key_id = court_report.court_report_id
+ left join court_appearance on court_report.court_appearance_id = court_appearance.court_appearance_id
+ left join court on court.court_id = court_appearance.court_id
+ left join r_court_report_type on r_court_report_type.court_report_type_id = court_report.court_report_type_id
+ left join institutional_report on document.table_name = 'INSTITUTIONAL_REPORT' and document.primary_key_id = institutional_report.institutional_report_id
+ left join custody on institutional_report.custody_id = custody.custody_id
+ left join disposal institutional_report_disposal on institutional_report_disposal.disposal_id = custody.disposal_id
+ left join r_institution on r_institution.institution_id = institutional_report.institution_id and r_institution.establishment = institutional_report.establishment
+ left join r_standard_reference_list institutional_report_type on institutional_report_type.standard_reference_list_id = institutional_report.institution_report_type_id
+ left join approved_premises_referral on document.table_name = 'APPROVED_PREMISES_REFERRAL' and document.primary_key_id = approved_premises_referral.approved_premises_referral_id
+ left join assessment on document.table_name = 'ASSESSMENT' and document.primary_key_id = assessment.assessment_id and assessment.referral_id is not null
+ left join r_assessment_type on assessment.assessment_type_id = r_assessment_type.assessment_type_id
+ left join referral assessment_referral on assessment.referral_id = assessment_referral.referral_id
+ left join case_allocation on document.table_name = 'CASE_ALLOCATION' and document.primary_key_id = case_allocation.case_allocation_id
+ left join referral on document.table_name = 'REFERRAL' and document.primary_key_id = referral.referral_id
+ left join r_referral_type on r_referral_type.referral_type_id = referral.referral_type_id
+ left join upw_appointment on document.table_name = 'UPW_APPOINTMENT' and document.primary_key_id = upw_appointment.upw_appointment_id
+ left join upw_details on upw_details.upw_details_id = upw_appointment.upw_details_id
+ left join upw_project on upw_project.upw_project_id = upw_appointment.upw_project_id
+ left join disposal upw_appointment_disposal on upw_appointment_disposal.disposal_id = upw_details.disposal_id
+ left join contact on document.table_name = 'CONTACT' and document.primary_key_id = contact.contact_id
+ left join r_contact_type on r_contact_type.contact_type_id = contact.contact_type_id
+ left join nsi on document.table_name = 'NSI' and document.primary_key_id = nsi.nsi_id
+ left join r_nsi_type on r_nsi_type.nsi_type_id = nsi.nsi_type_id
+ -- the following join is to populate the eventNumber field from the event attached to the related entity above
+ left join event related_event on related_event.event_id = coalesce(
+ event.event_id,
+ court_appearance.event_id,
+ institutional_report_disposal.event_id,
+ approved_premises_referral.event_id,
+ assessment_referral.event_id,
+ case_allocation.event_id,
+ referral.event_id,
+ upw_appointment_disposal.event_id,
+ contact.event_id,
+ nsi.event_id
+ )
+ -- the following joins are to get extra info for the description of offender-level docs
+ left join address_assessment on document.table_name = 'ADDRESSASSESSMENT' and document.primary_key_id = address_assessment.address_assessment_id
+ left join personal_circumstance on document.table_name = 'PERSONAL_CIRCUMSTANCE' and document.primary_key_id = personal_circumstance.personal_circumstance_id
+ left join r_circumstance_type on r_circumstance_type.circumstance_type_id = personal_circumstance.circumstance_type_id
+ left join personal_contact on document.table_name = 'PERSONALCONTACT' and document.primary_key_id = personal_contact.personal_contact_id
+ left join r_standard_reference_list personal_contact_relationship_type on personal_contact_relationship_type.standard_reference_list_id = personal_contact.relationship_type_id
+ where document.offender_id = :personId
+ and document.alfresco_document_id is not null
+ and document.soft_deleted = 0
+ and document.table_name in ('OFFENDER', 'ADDRESSASSESSMENT', 'PERSONALCONTACT', 'PERSONAL_CIRCUMSTANCE',
+ 'EVENT', 'COURT_REPORT', 'INSTITUTIONAL_REPORT', 'APPROVED_PREMISES_REFERRAL', 'ASSESSMENT', 'CASE_ALLOCATION', 'REFERRAL', 'UPW_APPOINTMENT',
+ 'CONTACT', 'NSI')
+ """,
+ nativeQuery = true
+ )
+ fun getPersonAndEventDocuments(personId: Long): List
}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentType.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentType.kt
new file mode 100644
index 0000000000..478c6d04af
--- /dev/null
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentType.kt
@@ -0,0 +1,40 @@
+package uk.gov.justice.digital.hmpps.integrations.delius.document
+
+enum class DocumentType(val description: String) {
+ OFFENDER_DOCUMENT("Offender related"),
+ CONVICTION_DOCUMENT("Sentence related"),
+ CPSPACK_DOCUMENT("Crown Prosecution Service case pack"),
+ PRECONS_DOCUMENT("PNC previous convictions"),
+ COURT_REPORT_DOCUMENT("Court report"),
+ INSTITUTION_REPORT_DOCUMENT("Institution report"),
+ ADDRESS_ASSESSMENT_DOCUMENT("Address assessment related document"),
+ APPROVED_PREMISES_REFERRAL_DOCUMENT("Approved premises referral related document"),
+ ASSESSMENT_DOCUMENT("Assessment document"),
+ CASE_ALLOCATION_DOCUMENT("Case allocation document"),
+ PERSONAL_CONTACT_DOCUMENT("Personal contact related document"),
+ REFERRAL_DOCUMENT("Referral related document"),
+ NSI_DOCUMENT("Non Statutory Intervention related document"),
+ PERSONAL_CIRCUMSTANCE_DOCUMENT("Personal circumstance related document"),
+ UPW_APPOINTMENT_DOCUMENT("Unpaid work appointment document"),
+ CONTACT_DOCUMENT("Contact related document");
+
+ companion object {
+ fun of(tableName: String, type: String): DocumentType = when (tableName) {
+ "OFFENDER" -> if (type == "PREVIOUS_CONVICTION") PRECONS_DOCUMENT else OFFENDER_DOCUMENT
+ "EVENT" -> if (type == "CPS_PACK") CPSPACK_DOCUMENT else CONVICTION_DOCUMENT
+ "COURT_REPORT" -> COURT_REPORT_DOCUMENT
+ "INSTITUTIONAL_REPORT" -> INSTITUTION_REPORT_DOCUMENT
+ "ADDRESSASSESSMENT" -> ADDRESS_ASSESSMENT_DOCUMENT
+ "APPROVED_PREMISES_REFERRAL" -> APPROVED_PREMISES_REFERRAL_DOCUMENT
+ "ASSESSMENT" -> ASSESSMENT_DOCUMENT
+ "CASE_ALLOCATION" -> CASE_ALLOCATION_DOCUMENT
+ "PERSONALCONTACT" -> PERSONAL_CONTACT_DOCUMENT
+ "REFERRAL" -> REFERRAL_DOCUMENT
+ "NSI" -> NSI_DOCUMENT
+ "PERSONAL_CIRCUMSTANCE" -> PERSONAL_CIRCUMSTANCE_DOCUMENT
+ "UPW_APPOINTMENT" -> UPW_APPOINTMENT_DOCUMENT
+ "CONTACT" -> CONTACT_DOCUMENT
+ else -> error("Un-mapped document type ($tableName/$type)")
+ }
+ }
+}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/ApprovedPremisesReferral.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/ApprovedPremisesReferral.kt
deleted file mode 100644
index d7563350cd..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/ApprovedPremisesReferral.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData
-
-@Entity
-@Immutable
-@Table(name = "approved_premises_referral")
-class ApprovedPremisesReferral(
- @Id
- @Column(name = "approved_premises_referral_id")
- val id: Long,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent,
-
- @JoinColumn(name = "referral_category_id", insertable = false, updatable = false)
- @ManyToOne
- val category: ReferenceData
-
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CaseAllocationDoc.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CaseAllocationDoc.kt
deleted file mode 100644
index 2a67d34554..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CaseAllocationDoc.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-@Table(name = "case_allocation")
-class CaseAllocationDoc(
- @Id
- @Column(name = "case_allocation_id")
- val id: Long,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CourtReportDoc.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CourtReportDoc.kt
deleted file mode 100644
index 2452778774..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/CourtReportDoc.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-@Table(name = "court_report")
-class CourtReportDoc(
- @Id
- @Column(name = "court_report_id")
- val id: Long,
-
- @JoinColumn(name = "court_appearance_id", insertable = false, updatable = false)
- @ManyToOne
- val documentCourtAppearance: DocumentCourtAppearance? = null,
-
- @ManyToOne
- @JoinColumn(name = "court_report_type_id", updatable = false)
- val type: CourtReportType
-)
-
-@Immutable
-@Entity
-@Table(name = "r_court_report_type")
-class CourtReportType(
- @Id
- @Column(name = "court_report_type_id")
- val id: Long,
-
- val description: String
-)
-
-@Entity
-@Immutable
-@Table(name = "court_appearance")
-class DocumentCourtAppearance(
-
- @Id
- @Column(name = "court_appearance_id")
- val id: Long,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocAddressAssessment.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocAddressAssessment.kt
deleted file mode 100644
index 16c0df11f6..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocAddressAssessment.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-class AddressAssessment(
- @Id
- @Column(name = "address_assessment_id")
- val id: Long,
-
- @ManyToOne
- @JoinColumn(name = "offender_address_id", insertable = false, updatable = false)
- val personAddress: DocPersonAddress?
-)
-
-@Entity
-@Table(name = "offender_address")
-@Immutable
-class DocPersonAddress(
- @Id
- @Column(name = "offender_address_id")
- val id: Long,
- val buildingName: String?,
- val addressNumber: String?,
- val streetName: String?
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocContact.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocContact.kt
deleted file mode 100644
index f518eded4f..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocContact.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-@Table(name = "contact")
-class DocContact(
- @Id
- @Column(name = "contact_id", updatable = false)
- val id: Long = 0,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent?,
-
- @ManyToOne
- @JoinColumn(name = "contact_type_id", updatable = false)
- val type: DocContactType
-)
-
-@Immutable
-@Entity
-@Table(name = "r_contact_type")
-class DocContactType(
- @Id
- @Column(name = "contact_type_id")
- val id: Long,
-
- val description: String
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt
deleted file mode 100644
index d3789abdf3..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt
+++ /dev/null
@@ -1,97 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.OneToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-import uk.gov.justice.digital.hmpps.integrations.delius.person.Person
-
-@Immutable
-@Entity
-@Table(name = "event")
-class DocEvent(
- @Id
- @Column(name = "event_id", nullable = false)
- val id: Long,
-
- @ManyToOne
- @JoinColumn(name = "offender_id", nullable = false)
- val person: Person,
-
- @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false)
- val active: Boolean,
-
- @Column(name = "event_number", nullable = false)
- val eventNumber: String,
-
- @OneToOne(mappedBy = "event")
- val disposal: DocDisposal? = null,
-
- @OneToOne(mappedBy = "event")
- val mainOffence: DocMainOffence? = null
-)
-
-@Immutable
-@Entity
-@Table(name = "disposal")
-class DocDisposal(
- @Id
- @Column(name = "disposal_id")
- val id: Long,
-
- @OneToOne
- @JoinColumn(name = "event_id", updatable = false)
- val event: DocEvent,
-
- @ManyToOne
- @JoinColumn(name = "disposal_type_id", updatable = false)
- val type: DocDisposalType,
-
- @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER")
- val active: Boolean = true,
-
- @Column(updatable = false, columnDefinition = "NUMBER")
- val softDeleted: Boolean = false
-)
-
-@Immutable
-@Entity
-@Table(name = "r_disposal_type")
-class DocDisposalType(
- @Id
- @Column(name = "disposal_type_id")
- val id: Long,
- val description: String
-)
-
-@Immutable
-@Entity
-@Table(name = "r_offence")
-class DocOffence(
- @Id
- @Column(name = "offence_id")
- val id: Long,
-
- val description: String
-)
-
-@Immutable
-@Entity
-@Table(name = "main_offence")
-class DocMainOffence(
- @Id
- @Column(name = "main_offence_id")
- val id: Long,
-
- @JoinColumn(name = "offence_id")
- @OneToOne
- val offence: DocOffence,
-
- @JoinColumn(name = "event_id")
- @OneToOne
- val event: DocEvent
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocNsi.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocNsi.kt
deleted file mode 100644
index a64fec2185..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocNsi.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-import uk.gov.justice.digital.hmpps.integrations.delius.nonstatutoryintervention.entity.NsiType
-
-@Entity
-@Immutable
-@Table(name = "nsi")
-class DocNsi(
- @Id
- @Column(name = "nsi_id", updatable = false)
- val id: Long = 0,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent?,
-
- @ManyToOne
- @JoinColumn(name = "nsi_type_id", updatable = false)
- val type: NsiType
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt
deleted file mode 100644
index 4bad01b188..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-import org.springframework.data.jpa.repository.JpaRepository
-
-@Immutable
-@Entity
-@Table(name = "offender")
-class DocPerson(
-
- @Id
- @Column(name = "offender_id")
- val id: Long,
-
- @Column(columnDefinition = "CHAR(7)")
- val crn: String,
-
- @Column(updatable = false, columnDefinition = "NUMBER")
- val softDeleted: Boolean = false
-)
-
-interface DocPersonRepository : JpaRepository {
- fun findByCrn(crn: String): DocPerson?
-}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPersonalContact.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPersonalContact.kt
deleted file mode 100644
index 1bd52fc1a5..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPersonalContact.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData
-
-@Entity
-@Immutable
-@Table(name = "personal_contact")
-class DocPersonalContact(
- @Id
- @Column(name = "personal_contact_id")
- val id: Long,
-
- @Column(name = "first_name")
- val forename: String,
-
- @Column(name = "surname")
- val surname: String,
-
- @ManyToOne
- @JoinColumn(name = "title_id", insertable = false, updatable = false)
- val title: ReferenceData?
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocReferral.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocReferral.kt
deleted file mode 100644
index afd2f9d3e1..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocReferral.kt
+++ /dev/null
@@ -1,63 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-@Table(name = "referral")
-class DocReferral(
- @Id
- @Column(name = "referral_id")
- val id: Long,
-
- @JoinColumn(name = "event_id", insertable = false, updatable = false)
- @ManyToOne
- val event: DocEvent,
-
- @JoinColumn(name = "REFERRAL_TYPE_ID")
- @ManyToOne
- val type: ReferralType
-)
-
-@Entity
-@Immutable
-@Table(name = "assessment")
-class DocAssessment(
- @Id
- @Column(name = "assessment_id")
- val id: Long,
-
- @JoinColumn(name = "referral_id", insertable = false, updatable = false)
- @ManyToOne
- val docReferral: DocReferral? = null,
-
- @JoinColumn(name = "ASSESSMENT_TYPE_ID")
- @ManyToOne
- val type: AssessmentType
-)
-
-@Entity
-@Immutable
-@Table(name = "r_assessment_type")
-class AssessmentType(
- @Id
- @Column(name = "assessment_type_id")
- val id: Long,
- val description: String
-)
-
-@Entity
-@Immutable
-@Table(name = "r_referral_type")
-class ReferralType(
- @Id
- @Column(name = "referral_type_id")
- val id: Long,
- val description: String
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocRegistration.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocRegistration.kt
deleted file mode 100644
index 3c107b0707..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocRegistration.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import jakarta.persistence.Table
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-@Table(name = "Registration")
-class DocRegistration(
- @Id
- @Column(name = "registration_id")
- val id: Long,
-
- @ManyToOne
- @JoinColumn(name = "register_type_id", updatable = false)
- val type: DocRegistrationType
-)
-
-@Entity
-@Table(name = "r_register_type")
-@Immutable
-class DocRegistrationType(
- @Id
- @Column(name = "REGISTER_TYPE_ID")
- val id: Long,
-
- @Column
- val description: String
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt
index 8c5793a13e..b763d011d1 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt
@@ -1,423 +1,19 @@
package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-import jakarta.persistence.Column
-import jakarta.persistence.Convert
-import jakarta.persistence.DiscriminatorColumn
-import jakarta.persistence.DiscriminatorType
-import jakarta.persistence.DiscriminatorValue
-import jakarta.persistence.Entity
-import jakarta.persistence.EnumType
-import jakarta.persistence.Enumerated
-import jakarta.persistence.Id
-import jakarta.persistence.Inheritance
-import jakarta.persistence.InheritanceType
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import org.hibernate.annotations.Immutable
-import org.hibernate.annotations.NotFound
-import org.hibernate.annotations.NotFoundAction
-import org.hibernate.type.YesNoConverter
-import uk.gov.justice.digital.hmpps.integrations.delius.person.Person
-import java.time.ZonedDateTime
-
-@Entity
-@Immutable
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorColumn(name = "table_name", discriminatorType = DiscriminatorType.STRING)
-abstract class Document : Relatable {
- @Id
- @Column(name = "document_id")
- open var id: Long = 0
-
- @Column(name = "document_name")
- open var name: String = ""
-
- @ManyToOne
- @JoinColumn(name = "offender_id")
- open var person: Person? = null
-
- @Column(name = "primary_key_id")
- open var primaryKeyId: Long = 0
-
- @Column(columnDefinition = "char(1)")
- open var status: String = "N"
- open var softDeleted: Boolean = false
-
- @Convert(converter = YesNoConverter::class)
- open var workInProgress: Boolean? = false
-
- @Column(name = "alfresco_document_id")
- open var alfrescoId: String? = null
- open var sensitive: Boolean = false
- open var lastSaved: ZonedDateTime? = ZonedDateTime.now()
- open var dateProduced: ZonedDateTime? = ZonedDateTime.now()
-
- @Column(name = "created_datetime")
- open var createdDate: ZonedDateTime? = ZonedDateTime.now()
-
- @Column(name = "document_type")
- @Enumerated(EnumType.STRING)
- open var type: DocumentType = DocumentType.DOCUMENT
-}
-
-enum class DocumentType {
- DOCUMENT,
- CPS_PACK,
- PREVIOUS_CONVICTION
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("EQUALITY")
-class Equality : Document() {
- override fun findRelatedTo(): RelatedTo = RelatedTo(RelatedType.EQUALITY)
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("DRUGS_TEST")
-class DrugTest : Document() {
- override fun findRelatedTo(): RelatedTo = RelatedTo(RelatedType.DRUGS_TEST)
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("OFFENDER")
-class OffenderDocument : Document() {
- override fun findRelatedTo(): RelatedTo =
- if (type == DocumentType.PREVIOUS_CONVICTION) {
- RelatedTo(RelatedType.PRECONS)
- } else {
- RelatedTo(RelatedType.PERSON)
- }
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("OFFENDER_ADDRESS")
-class OffenderAddress : Document() {
- override fun findRelatedTo(): RelatedTo = RelatedTo(RelatedType.OFFENDER_ADDRESS)
-}
-
-const val entityNotFound = "ENTITY_NOT_FOUND"
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("EVENT")
-class EventDocument(
- @JoinColumn(name = "primary_key_id", referencedColumnName = "event_id", insertable = false, updatable = false)
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val event: DocEvent?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- if (type == DocumentType.CPS_PACK) {
- RelatedTo(
- RelatedType.CPSPACK,
- event = event?.toDocumentEvent()
- )
- } else {
- RelatedTo(
- RelatedType.EVENT,
- if (event == null) entityNotFound else event.disposal?.type?.description ?: "",
- event?.toDocumentEvent()
- )
- }
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("ADDRESSASSESSMENT")
-class AddressAssessmentDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "address_assessment_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val addressAssessment: AddressAssessment?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.ADDRESS_ASSESSMENT,
- getPersonAddressLine(addressAssessment?.personAddress)
- )
-
- private fun getPersonAddressLine(personAddress: DocPersonAddress?): String {
- if (personAddress == null) {
- return entityNotFound
- } else {
- (
- return listOfNotNull(
- personAddress.buildingName,
- personAddress.addressNumber,
- personAddress.streetName
- ).joinToString(", ")
- )
- }
- }
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("APPROVED_PREMISES_REFERRAL")
-class ApprovedPremisesReferralDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "approved_premises_referral_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val approvedPremisesReferral: ApprovedPremisesReferral?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.APPROVED_PREMISES_REFERRAL,
- approvedPremisesReferral?.category?.description ?: entityNotFound,
- approvedPremisesReferral?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("ASSESSMENT")
-class AssessmentDocument(
- @JoinColumn(name = "primary_key_id", referencedColumnName = "assessment_id", insertable = false, updatable = false)
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val docAssessment: DocAssessment?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.ASSESSMENT,
- docAssessment?.type?.description ?: entityNotFound,
- docAssessment?.docReferral?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("CASE_ALLOCATION")
-class CaseAllocationDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "case_allocation_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val allocation: CaseAllocationDoc?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.CASE_ALLOCATION,
- allocation?.event?.disposal?.type?.description ?: entityNotFound,
- allocation?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("CONTACT")
-class ContactDocument(
- @JoinColumn(name = "primary_key_id", referencedColumnName = "contact_id", insertable = false, updatable = false)
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val contact: DocContact?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.CONTACT,
- contact?.type?.description ?: entityNotFound,
- contact?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("COURT_REPORT")
-class CourtReportDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "court_report_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val courtReportDoc: CourtReportDoc?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.COURT_REPORT,
- courtReportDoc?.type?.description ?: entityNotFound,
- courtReportDoc?.documentCourtAppearance?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("INSTITUTIONAL_REPORT")
-class InstitutionalReportDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "institutional_report_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val institutionalReport: InstitutionalReport?
-) : Document() {
-
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(RelatedType.INSTITUTIONAL_REPORT, institutionalReport?.type?.description ?: entityNotFound)
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("NSI")
-class NsiDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "nsi_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val docNsi: DocNsi?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.NSI,
- docNsi?.type?.description ?: entityNotFound,
- docNsi?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("PERSONAL_CIRCUMSTANCE")
-class PersonalCircumstanceDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "personal_circumstance_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val personalCircumstance: PersonalCircumstance?
-) : Document() {
-
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(RelatedType.PERSONAL_CIRCUMSTANCE, getCircName())
-
- private fun getCircName(): String {
- var circName: String = personalCircumstance?.type?.description ?: entityNotFound
- if (personalCircumstance?.subType != null) {
- circName += " - ${personalCircumstance.subType.description}"
- }
- return circName
- }
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("PERSONALCONTACT")
-class PersonalContactDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "personal_contact_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val personalContact: DocPersonalContact?
-) : Document() {
-
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(RelatedType.PERSONAL_CONTACT, getPersonalContactLine())
-
- private fun getPersonalContactLine(): String {
- return if (personalContact == null) {
- entityNotFound
- } else {
- listOfNotNull(
- personalContact.title?.description,
- personalContact.forename,
- personalContact.surname
- ).joinToString(" ")
- }
- }
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("REFERRAL")
-class ReferralDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "referral_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val docReferral: DocReferral?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.REFERRAL,
- docReferral?.type?.description ?: entityNotFound,
- docReferral?.event?.toDocumentEvent()
- )
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("REGISTRATION")
-class RegistrationDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "registration_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val registration: DocRegistration?
-) : Document() {
-
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(RelatedType.REGISTRATION, registration?.type?.description ?: entityNotFound)
-}
-
-@Entity
-@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
-@DiscriminatorValue("UPW_APPOINTMENT")
-class UPWAppointmentDocument(
- @JoinColumn(
- name = "primary_key_id",
- referencedColumnName = "upw_appointment_id",
- insertable = false,
- updatable = false
- )
- @ManyToOne
- @NotFound(action = NotFoundAction.IGNORE)
- val upwAppointment: UpwAppointment?
-) : Document() {
- override fun findRelatedTo(): RelatedTo =
- RelatedTo(
- RelatedType.UPW_APPOINTMENT,
- upwAppointment?.upwDetails?.disposal?.type?.description ?: entityNotFound,
- upwAppointment?.upwDetails?.disposal?.event?.toDocumentEvent()
- )
-}
+import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentType
+import java.time.Instant
+
+interface Document {
+ val id: String
+ val eventNumber: String?
+ val name: String
+ val type: String
+ val tableName: String
+ val dateSaved: Instant
+ val dateCreated: Instant?
+ val description: String?
+}
+
+val Document.documentType get(): DocumentType = DocumentType.of(tableName, type)
+val Document.typeCode get() = documentType.name
+val Document.typeDescription get() = documentType.description
\ No newline at end of file
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt
new file mode 100644
index 0000000000..fa11be4094
--- /dev/null
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt
@@ -0,0 +1,49 @@
+package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
+
+import jakarta.persistence.*
+import org.hibernate.annotations.Immutable
+import uk.gov.justice.digital.hmpps.integrations.delius.person.Person
+import java.time.ZonedDateTime
+
+@Entity
+@Immutable
+@Table(name = "document")
+class DocumentEntity(
+ @Id
+ @Column(name = "document_id")
+ val id: Long,
+
+ @ManyToOne
+ @JoinColumn(name = "offender_id")
+ val person: Person,
+
+ @Column(name = "alfresco_document_id")
+ val alfrescoId: String,
+
+ @Column
+ val primaryKeyId: Long,
+
+ @Column(name = "document_name")
+ val name: String,
+
+ @Column(name = "document_type")
+ val type: String,
+
+ @Column
+ val tableName: String,
+
+ @Column(name = "created_datetime")
+ val createdAt: ZonedDateTime,
+
+ @Column
+ val createdByUserId: Long = 0,
+
+ @Column
+ val lastSaved: ZonedDateTime,
+
+ @Column
+ val lastUpdatedUserId: Long = 0,
+
+ @Column(columnDefinition = "number")
+ val softDeleted: Boolean = false
+)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt
deleted file mode 100644
index 4e1c24978b..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import org.hibernate.annotations.Immutable
-import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData
-import java.time.LocalDate
-
-@Entity
-@Immutable
-class InstitutionalReport(
- @Id
- @Column(name = "institutional_report_id")
- val id: Long,
-
- @ManyToOne
- @JoinColumn(name = "institution_report_type_id", updatable = false)
- val type: ReferenceData,
-
- @Column(name = "date_required")
- val dateRequired: LocalDate,
-
- @Column(name = "date_completed")
- val dateCompleted: LocalDate? = null,
-
- @Column(updatable = false, columnDefinition = "NUMBER")
- val softDeleted: Boolean = false,
-
- @Column(name = "custody_id")
- val custodyId: Long
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonDocument.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonDocument.kt
deleted file mode 100644
index 8994dc0bce..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonDocument.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import java.time.ZonedDateTime
-
-data class APDocument(
- val id: String?,
- val level: String,
- val eventNumber: String?,
- val filename: String,
- val typeCode: String,
- val typeDescription: String,
- val dateSaved: ZonedDateTime?,
- val dateCreated: ZonedDateTime?,
- val description: String?
-)
-
-data class RelatedTo(
- val type: RelatedType,
- val name: String = "",
- val event: DocumentEvent? = null
-) {
- val description: String = type.description()
-}
-
-data class DocumentEvent(
- val eventType: EventType,
- val eventNumber: String,
- val mainOffence: String
-)
-
-enum class EventType {
- CURRENT, PREVIOUS
-}
-
-enum class RelatedType(private val displayName: String = "") {
- ADDRESS_ASSESSMENT,
- APPROVED_PREMISES_REFERRAL,
- ASSESSMENT,
- CASE_ALLOCATION,
- CONTACT,
- COURT_REPORT,
- CPSPACK("Crown Prosecution Service case pack"),
- DRUGS_TEST("Drug Test"),
- PRECONS("PNC previous convictions"),
- EVENT,
- EQUALITY("Equality Monitoring"),
- INSTITUTIONAL_REPORT,
- NSI("Non Statutory Intervention"),
- PERSON,
- OFFENDER_ADDRESS,
- PERSONAL_CONTACT,
- PERSONAL_CIRCUMSTANCE,
- REFERRAL,
- REGISTRATION,
- UPW_APPOINTMENT("Unpaid Work Appointment");
-
- fun description(): String =
- displayName.ifEmpty { name.split("_").joinToString(" ") { it.lowercase().replaceFirstChar(Char::titlecase) } }
-}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Relatable.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Relatable.kt
deleted file mode 100644
index 0993dd1033..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Relatable.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-interface Relatable {
- fun findRelatedTo(): RelatedTo
-}
-
-fun DocEvent.toDocumentEvent() = DocumentEvent(
- if (active) EventType.CURRENT else EventType.PREVIOUS,
- eventNumber,
- mainOffence?.offence?.description ?: ""
-)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/UpwAppointment.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/UpwAppointment.kt
deleted file mode 100644
index 936ff33a87..0000000000
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/UpwAppointment.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
-
-import jakarta.persistence.Column
-import jakarta.persistence.Entity
-import jakarta.persistence.Id
-import jakarta.persistence.JoinColumn
-import jakarta.persistence.ManyToOne
-import org.hibernate.annotations.Immutable
-
-@Entity
-@Immutable
-class UpwAppointment {
-
- @Id
- @Column(name = "upw_appointment_id", insertable = false, updatable = false)
- val id: Long = 0
-
- @JoinColumn(name = "upw_details_id", insertable = false, updatable = false)
- @ManyToOne
- val upwDetails: UpwDetails? = null
-}
-
-@Entity
-@Immutable
-class UpwDetails {
-
- @Id
- @Column(name = "upw_details_id", updatable = false)
- val id: Long = 0
-
- @JoinColumn(name = "DISPOSAL_ID")
- @ManyToOne
- val disposal: DocDisposal? = null
-}
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/PersonalCircumstanceRepository.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/PersonalCircumstanceRepository.kt
new file mode 100644
index 0000000000..7eeb92ffec
--- /dev/null
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/PersonalCircumstanceRepository.kt
@@ -0,0 +1,8 @@
+package uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance
+
+import org.springframework.data.jpa.repository.JpaRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstance
+
+interface PersonalCircumstanceRepository : JpaRepository {
+ fun findByPersonId(personId: Long): List
+}
\ No newline at end of file
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonalCircumstance.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/entity/PersonalCircumstance.kt
similarity index 79%
rename from projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonalCircumstance.kt
rename to projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/entity/PersonalCircumstance.kt
index c731072cb9..1860a7887b 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/PersonalCircumstance.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalcircumstance/entity/PersonalCircumstance.kt
@@ -1,11 +1,11 @@
-package uk.gov.justice.digital.hmpps.integrations.delius.document.entity
+package uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity
import jakarta.persistence.*
import org.hibernate.annotations.Immutable
-import org.springframework.data.jpa.repository.JpaRepository
@Entity
@Immutable
+@Table(name = "personal_circumstance")
class PersonalCircumstance(
@Id
@Column(name = "personal_circumstance_id")
@@ -54,7 +54,3 @@ class PersonalCircumstanceSubType(
@Column(name = "code_description")
val description: String
)
-
-interface PersonalCircumstanceRepository : JpaRepository {
- fun findByPersonId(personId: Long): List
-}
\ No newline at end of file
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/DocumentResponse.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/DocumentResponse.kt
new file mode 100644
index 0000000000..1d992ffee9
--- /dev/null
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/DocumentResponse.kt
@@ -0,0 +1,15 @@
+package uk.gov.justice.digital.hmpps.model
+
+import java.time.ZonedDateTime
+
+data class DocumentResponse(
+ val id: String?,
+ val level: String,
+ val eventNumber: String?,
+ val filename: String,
+ val typeCode: String,
+ val typeDescription: String,
+ val dateSaved: ZonedDateTime,
+ val dateCreated: ZonedDateTime,
+ val description: String?
+)
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseService.kt
index e96440851e..72b66d3bb8 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseService.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseService.kt
@@ -1,8 +1,6 @@
package uk.gov.justice.digital.hmpps.service
import org.springframework.stereotype.Service
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceRepository
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.PersonalCircumstanceType
import uk.gov.justice.digital.hmpps.integrations.delius.person.CommunityManager
import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCase
import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCaseRepository
@@ -10,6 +8,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity.Ca
import uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity.MainOffenceRepository
import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.*
import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.Registration
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.PersonalCircumstanceRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.personalcircumstance.entity.PersonalCircumstanceType
import uk.gov.justice.digital.hmpps.model.*
@Service
diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/DocumentService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/DocumentService.kt
index e22309793e..c38f8ab881 100644
--- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/DocumentService.kt
+++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/DocumentService.kt
@@ -4,15 +4,19 @@ import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Service
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody
import uk.gov.justice.digital.hmpps.alfresco.AlfrescoClient
+import uk.gov.justice.digital.hmpps.datetime.EuropeLondon
import uk.gov.justice.digital.hmpps.exception.NotFoundException
import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentRepository
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.APDocument
-import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.DocPersonRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.typeCode
+import uk.gov.justice.digital.hmpps.integrations.delius.document.entity.typeDescription
+import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository
+import uk.gov.justice.digital.hmpps.integrations.delius.person.getByCrn
+import uk.gov.justice.digital.hmpps.model.DocumentResponse
@Service
class DocumentService(
private val documentRepository: DocumentRepository,
- private val docPersonRepository: DocPersonRepository,
+ private val personRepository: PersonRepository,
private val alfrescoClient: AlfrescoClient
) {
fun downloadDocument(crn: String, id: String): ResponseEntity {
@@ -21,24 +25,20 @@ class DocumentService(
return alfrescoClient.streamDocument(id, filename)
}
- fun getDocumentsByCrn(crn: String): List {
- val person = docPersonRepository.findByCrn(crn) ?: throw NotFoundException("Person", "crn", crn)
- val documents = ArrayList()
- documents += documentRepository.findAllByPersonIdAndSoftDeletedIsFalse(person.id)
- .map {
- APDocument(
- it.alfrescoId,
- if (it.findRelatedTo().event == null) "Offender" else "Conviction",
- it.findRelatedTo().event?.eventNumber,
- it.name,
- it.findRelatedTo().type.name,
- it.findRelatedTo().description,
- it.createdDate,
- it.lastSaved,
- it.type.name
- )
- }
-
- return documents
+ fun getDocumentsByCrn(crn: String): List {
+ val person = personRepository.getByCrn(crn)
+ return documentRepository.getPersonAndEventDocuments(person.id).map {
+ DocumentResponse(
+ id = it.id,
+ level = if (it.eventNumber == null) "Offender" else "Conviction",
+ eventNumber = it.eventNumber,
+ filename = it.name,
+ typeCode = it.typeCode,
+ typeDescription = it.typeDescription,
+ dateSaved = it.dateSaved.atZone(EuropeLondon),
+ dateCreated = (it.dateCreated ?: it.dateSaved).atZone(EuropeLondon),
+ description = it.description,
+ )
+ }
}
}
diff --git a/projects/arns-and-delius/src/main/resources/application.yml b/projects/arns-and-delius/src/main/resources/application.yml
index 2b88d0bf53..84cc96ef46 100644
--- a/projects/arns-and-delius/src/main/resources/application.yml
+++ b/projects/arns-and-delius/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/assessment-summary-and-delius/src/main/resources/application.yml b/projects/assessment-summary-and-delius/src/main/resources/application.yml
index 2656bc1858..9800eec564 100644
--- a/projects/assessment-summary-and-delius/src/main/resources/application.yml
+++ b/projects/assessment-summary-and-delius/src/main/resources/application.yml
@@ -70,7 +70,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/cas2-and-delius/src/main/resources/application.yml b/projects/cas2-and-delius/src/main/resources/application.yml
index bbce67c045..89d62acd7f 100644
--- a/projects/cas2-and-delius/src/main/resources/application.yml
+++ b/projects/cas2-and-delius/src/main/resources/application.yml
@@ -75,7 +75,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/cas3-and-delius/src/main/resources/application.yml b/projects/cas3-and-delius/src/main/resources/application.yml
index 398cd5b629..395dce7df7 100644
--- a/projects/cas3-and-delius/src/main/resources/application.yml
+++ b/projects/cas3-and-delius/src/main/resources/application.yml
@@ -73,7 +73,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/core-person-record-and-delius/src/main/resources/application.yml b/projects/core-person-record-and-delius/src/main/resources/application.yml
index 77b5b74c1b..abdc991a32 100644
--- a/projects/core-person-record-and-delius/src/main/resources/application.yml
+++ b/projects/core-person-record-and-delius/src/main/resources/application.yml
@@ -55,7 +55,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/court-case-and-delius/src/main/resources/application.yml b/projects/court-case-and-delius/src/main/resources/application.yml
index a8a3017a14..645c0db0b9 100644
--- a/projects/court-case-and-delius/src/main/resources/application.yml
+++ b/projects/court-case-and-delius/src/main/resources/application.yml
@@ -87,7 +87,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml b/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml
index 418e020e8d..d5b93247de 100644
--- a/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml
+++ b/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml
@@ -80,7 +80,9 @@ messaging.consumer.queue: message-queue
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/custody-key-dates-and-delius/src/main/resources/application.yml b/projects/custody-key-dates-and-delius/src/main/resources/application.yml
index 83d87c5576..8106d13465 100644
--- a/projects/custody-key-dates-and-delius/src/main/resources/application.yml
+++ b/projects/custody-key-dates-and-delius/src/main/resources/application.yml
@@ -80,7 +80,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/domain-events-and-delius/src/main/resources/application.yml b/projects/domain-events-and-delius/src/main/resources/application.yml
index 3fb38c6c7c..c46d11cf15 100644
--- a/projects/domain-events-and-delius/src/main/resources/application.yml
+++ b/projects/domain-events-and-delius/src/main/resources/application.yml
@@ -68,7 +68,9 @@ poller:
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/dps-and-delius/src/main/resources/application.yml b/projects/dps-and-delius/src/main/resources/application.yml
index e06a583471..b67a17140e 100644
--- a/projects/dps-and-delius/src/main/resources/application.yml
+++ b/projects/dps-and-delius/src/main/resources/application.yml
@@ -60,7 +60,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml b/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml
index 08f5ddc662..57710b0631 100644
--- a/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml
+++ b/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/external-api-and-delius/src/main/resources/application.yml b/projects/external-api-and-delius/src/main/resources/application.yml
index cdab7592ab..94786907c1 100644
--- a/projects/external-api-and-delius/src/main/resources/application.yml
+++ b/projects/external-api-and-delius/src/main/resources/application.yml
@@ -62,7 +62,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/hdc-licences-and-delius/src/main/resources/application.yml b/projects/hdc-licences-and-delius/src/main/resources/application.yml
index 493a198bff..b509423485 100644
--- a/projects/hdc-licences-and-delius/src/main/resources/application.yml
+++ b/projects/hdc-licences-and-delius/src/main/resources/application.yml
@@ -65,7 +65,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/hmpps-auth-and-delius/src/main/resources/application.yml b/projects/hmpps-auth-and-delius/src/main/resources/application.yml
index 2709e8e8d7..d804ef5347 100644
--- a/projects/hmpps-auth-and-delius/src/main/resources/application.yml
+++ b/projects/hmpps-auth-and-delius/src/main/resources/application.yml
@@ -66,7 +66,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/ims-and-delius/src/main/resources/application.yml b/projects/ims-and-delius/src/main/resources/application.yml
index 7a2b0c5823..d00b4a9084 100644
--- a/projects/ims-and-delius/src/main/resources/application.yml
+++ b/projects/ims-and-delius/src/main/resources/application.yml
@@ -64,7 +64,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/justice-email-and-delius/.trivyignore b/projects/justice-email-and-delius/.trivyignore
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/projects/justice-email-and-delius/README.md b/projects/justice-email-and-delius/README.md
new file mode 100644
index 0000000000..5008f2dcbd
--- /dev/null
+++ b/projects/justice-email-and-delius/README.md
@@ -0,0 +1,3 @@
+# justice-email-and-delius
+
+// TODO Describe the service
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/applicationinsights.json b/projects/justice-email-and-delius/applicationinsights.json
new file mode 100644
index 0000000000..7217b948fa
--- /dev/null
+++ b/projects/justice-email-and-delius/applicationinsights.json
@@ -0,0 +1,62 @@
+{
+ "role": {
+ "name": "justice-email-and-delius"
+ },
+ "customDimensions": {
+ "service.version": "${VERSION}",
+ "service.team": "probation-integration"
+ },
+ "instrumentation": {
+ "logging": {
+ "level": "DEBUG"
+ },
+ "springScheduling": {
+ "enabled": false
+ }
+ },
+ "selfDiagnostics": {
+ "destination": "console"
+ },
+ "sampling": {
+ "percentage": 100
+ },
+ "preview": {
+ "sampling": {
+ "overrides": [
+ {
+ "telemetryType": "request",
+ "attributes": [
+ {
+ "key": "http.url",
+ "value": "https?://[^/]+/health/?.*",
+ "matchType": "regexp"
+ }
+ ],
+ "percentage": 0
+ },
+ {
+ "telemetryType": "request",
+ "attributes": [
+ {
+ "key": "http.url",
+ "value": "https?://[^/]+/info/?.*",
+ "matchType": "regexp"
+ }
+ ],
+ "percentage": 0
+ },
+ {
+ "telemetryType": "dependency",
+ "attributes": [
+ {
+ "key": "db.operation",
+ "value": "SELECT",
+ "matchType": "strict"
+ }
+ ],
+ "percentage": 10
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/build.gradle.kts b/projects/justice-email-and-delius/build.gradle.kts
new file mode 100644
index 0000000000..a089a2f210
--- /dev/null
+++ b/projects/justice-email-and-delius/build.gradle.kts
@@ -0,0 +1,36 @@
+import uk.gov.justice.digital.hmpps.extensions.ClassPathExtension
+
+apply(plugin = "com.google.cloud.tools.jib")
+
+dependencies {
+ implementation(project(":libs:audit"))
+ implementation(project(":libs:commons"))
+ implementation(project(":libs:oauth-server"))
+
+ implementation("org.springframework.boot:spring-boot-starter-actuator")
+ implementation("org.springframework.boot:spring-boot-starter-data-jpa")
+ implementation("org.springframework.boot:spring-boot-starter-security")
+ implementation("org.springframework.boot:spring-boot-starter-validation")
+ implementation("org.springframework.boot:spring-boot-starter-web")
+ implementation("org.jetbrains.kotlin:kotlin-reflect")
+ implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
+ implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
+ implementation(libs.springdoc)
+
+ dev(project(":libs:dev-tools"))
+ dev("com.h2database:h2")
+ dev("org.testcontainers:oracle-xe")
+
+ runtimeOnly("com.oracle.database.jdbc:ojdbc11")
+
+ testImplementation("org.springframework.boot:spring-boot-starter-test")
+ testImplementation(libs.bundles.mockito)
+}
+
+configure {
+ jacocoExclusions = listOf(
+ "**/config/**",
+ "**/entity/**",
+ "**/AppKt.class"
+ )
+}
diff --git a/projects/justice-email-and-delius/deploy/Chart.yaml b/projects/justice-email-and-delius/deploy/Chart.yaml
new file mode 100644
index 0000000000..bfe7f54e53
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/Chart.yaml
@@ -0,0 +1,13 @@
+apiVersion: v2
+appVersion: '1.0'
+description: A Helm chart for Kubernetes
+name: justice-email-and-delius
+version: 1.0.0
+
+dependencies:
+ - name: generic-service
+ version: "3.2"
+ repository: https://ministryofjustice.github.io/hmpps-helm-charts
+ - name: generic-prometheus-alerts
+ version: "1.4"
+ repository: https://ministryofjustice.github.io/hmpps-helm-charts
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/deploy/database/access.yml b/projects/justice-email-and-delius/deploy/database/access.yml
new file mode 100644
index 0000000000..f76a1e10c5
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/database/access.yml
@@ -0,0 +1,9 @@
+database:
+ access:
+ username_key: /justice-email-and-delius/db-username
+ password_key: /justice-email-and-delius/db-password
+
+ audit:
+ username: JusticeEmailAndDelius
+ forename: Justice Email Integration
+ surname: Service
diff --git a/projects/justice-email-and-delius/deploy/values-dev.yml b/projects/justice-email-and-delius/deploy/values-dev.yml
new file mode 100644
index 0000000000..a17a002cb4
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/values-dev.yml
@@ -0,0 +1,17 @@
+enabled: false # TODO set this to true when you're ready to deploy your service
+
+generic-service:
+ ingress:
+ host: justice-email-and-delius-dev.hmpps.service.justice.gov.uk
+
+ scheduledDowntime:
+ enabled: true
+
+ env:
+ SENTRY_ENVIRONMENT: dev
+ LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer
+
+generic-prometheus-alerts:
+ businessHoursOnly: true
diff --git a/projects/justice-email-and-delius/deploy/values-preprod.yml b/projects/justice-email-and-delius/deploy/values-preprod.yml
new file mode 100644
index 0000000000..d490b99daf
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/values-preprod.yml
@@ -0,0 +1,16 @@
+enabled: false # TODO set this to true when you're ready to deploy your service
+
+generic-service:
+ ingress:
+ host: justice-email-and-delius-preprod.hmpps.service.justice.gov.uk
+
+ scheduledDowntime:
+ enabled: true
+
+ env:
+ SENTRY_ENVIRONMENT: preprod
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/issuer
+
+generic-prometheus-alerts:
+ businessHoursOnly: true
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/deploy/values-prod.yml b/projects/justice-email-and-delius/deploy/values-prod.yml
new file mode 100644
index 0000000000..c4734ababd
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/values-prod.yml
@@ -0,0 +1,10 @@
+enabled: false # TODO set this to true when you're ready to deploy your service
+
+generic-service:
+ ingress:
+ host: justice-email-and-delius.hmpps.service.justice.gov.uk
+
+ env:
+ SENTRY_ENVIRONMENT: prod
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/.well-known/jwks.json
+ SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/issuer
diff --git a/projects/justice-email-and-delius/deploy/values.yaml b/projects/justice-email-and-delius/deploy/values.yaml
new file mode 100644
index 0000000000..e6f6c676cb
--- /dev/null
+++ b/projects/justice-email-and-delius/deploy/values.yaml
@@ -0,0 +1,23 @@
+# Common values
+generic-service:
+ productId: HMPPS518
+ nameOverride: justice-email-and-delius
+
+ image:
+ repository: ghcr.io/ministryofjustice/hmpps-probation-integration-services/justice-email-and-delius
+
+ ingress:
+ tlsSecretName: justice-email-and-delius-cert
+
+ namespace_secrets:
+ common:
+ SPRING_DATASOURCE_URL: DB_URL
+ justice-email-and-delius-database:
+ SPRING_DATASOURCE_USERNAME: DB_USERNAME
+ SPRING_DATASOURCE_PASSWORD: DB_PASSWORD
+ justice-email-and-delius-sentry:
+ SENTRY_DSN: SENTRY_DSN
+
+generic-prometheus-alerts:
+ targetApplication: justice-email-and-delius
+
diff --git a/projects/justice-email-and-delius/settings.gradle.kts b/projects/justice-email-and-delius/settings.gradle.kts
new file mode 100644
index 0000000000..ed8b0364e4
--- /dev/null
+++ b/projects/justice-email-and-delius/settings.gradle.kts
@@ -0,0 +1 @@
+rootProject.name = "justice-email-and-delius"
diff --git a/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt
new file mode 100644
index 0000000000..f6ea94c9a7
--- /dev/null
+++ b/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt
@@ -0,0 +1,25 @@
+package uk.gov.justice.digital.hmpps.data
+
+import jakarta.annotation.PostConstruct
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
+import org.springframework.boot.context.event.ApplicationReadyEvent
+import org.springframework.context.ApplicationListener
+import org.springframework.stereotype.Component
+import uk.gov.justice.digital.hmpps.data.generator.UserGenerator
+import uk.gov.justice.digital.hmpps.user.AuditUserRepository
+
+@Component
+@ConditionalOnProperty("seed.database")
+class DataLoader(
+ private val auditUserRepository: AuditUserRepository
+) : ApplicationListener {
+
+ @PostConstruct
+ fun saveAuditUser() {
+ auditUserRepository.save(UserGenerator.AUDIT_USER)
+ }
+
+ override fun onApplicationEvent(are: ApplicationReadyEvent) {
+ // Perform dev/test database setup here, using JPA repositories and generator classes...
+ }
+}
diff --git a/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/UserGenerator.kt b/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/UserGenerator.kt
new file mode 100644
index 0000000000..2dc835ad6e
--- /dev/null
+++ b/projects/justice-email-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/UserGenerator.kt
@@ -0,0 +1,7 @@
+package uk.gov.justice.digital.hmpps.data.generator
+
+import uk.gov.justice.digital.hmpps.user.AuditUser
+
+object UserGenerator {
+ val AUDIT_USER = AuditUser(IdGenerator.getAndIncrement(), "JusticeEmailAndDelius")
+}
diff --git a/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt
new file mode 100644
index 0000000000..d9006c74c5
--- /dev/null
+++ b/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt
@@ -0,0 +1,30 @@
+package uk.gov.justice.digital.hmpps
+
+import org.junit.jupiter.api.Test
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT
+import org.springframework.boot.test.mock.mockito.MockBean
+import org.springframework.test.web.servlet.MockMvc
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
+import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken
+import uk.gov.justice.digital.hmpps.telemetry.TelemetryService
+
+@AutoConfigureMockMvc
+@SpringBootTest(webEnvironment = RANDOM_PORT)
+internal class IntegrationTest {
+ @Autowired
+ lateinit var mockMvc: MockMvc
+
+ @MockBean
+ lateinit var telemetryService: TelemetryService
+
+ @Test
+ fun `API call retuns a success response`() {
+ mockMvc
+ .perform(get("/example/123").withToken())
+ .andExpect(status().is2xxSuccessful)
+ }
+}
diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt
new file mode 100644
index 0000000000..c7faac5b26
--- /dev/null
+++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt
@@ -0,0 +1,11 @@
+package uk.gov.justice.digital.hmpps
+
+import org.springframework.boot.autoconfigure.SpringBootApplication
+import org.springframework.boot.runApplication
+
+@SpringBootApplication
+class App
+
+fun main(args: Array) {
+ runApplication(*args)
+}
diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/ApiController.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/ApiController.kt
new file mode 100644
index 0000000000..6e4f24c46f
--- /dev/null
+++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/ApiController.kt
@@ -0,0 +1,17 @@
+package uk.gov.justice.digital.hmpps.controller
+
+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.RestController
+
+@RestController
+class ApiController {
+ @PreAuthorize("hasRole('EXAMPLE')")
+ @GetMapping(value = ["/example/{inputId}"])
+ fun handle(
+ @PathVariable("inputId") inputId: String
+ ) {
+ // TODO Not yet implemented
+ }
+}
diff --git a/projects/justice-email-and-delius/src/main/resources/application.yml b/projects/justice-email-and-delius/src/main/resources/application.yml
new file mode 100644
index 0000000000..f99b020d1b
--- /dev/null
+++ b/projects/justice-email-and-delius/src/main/resources/application.yml
@@ -0,0 +1,73 @@
+# Default config
+server.shutdown: graceful
+spring:
+ jackson:
+ default-property-inclusion: non_null
+ jpa:
+ hibernate.ddl-auto: validate
+ database-platform: org.hibernate.dialect.OracleDialect
+ properties:
+ hibernate:
+ timezone.default_storage: NORMALIZE
+ query.mutation_strategy: org.hibernate.query.sqm.mutation.internal.inline.InlineMutationStrategy
+ query.mutation_strategy.persistent:
+ create_tables: false
+ drop_tables: false
+ query.mutation_strategy.global_temporary:
+ create_tables: false
+ drop_tables: false
+ threads.virtual.enabled: true
+
+oauth2.roles:
+ - EXAMPLE
+
+springdoc.default-produces-media-type: application/json
+
+delius.db.username: JusticeEmailAndDelius # Should match value in [deploy/database/access.yml].
+
+management:
+ endpoints.web:
+ base-path: /
+ exposure.include: [ "health", "info" ]
+ endpoint.health.show-details: always
+
+info.productId: HMPPS518 # https://developer-portal.hmpps.service.justice.gov.uk/products/185
+
+---
+# Shared dev/test config
+spring.config.activate.on-profile: [ "dev", "integration-test" ]
+server.shutdown: immediate
+
+spring:
+ datasource.url: jdbc:h2:file:./dev;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;AUTO_SERVER=true;AUTO_SERVER_PORT=9092
+ jpa.hibernate.ddl-auto: create-drop
+
+seed.database: true
+wiremock.enabled: true
+context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser
+
+logging.level:
+ uk.gov.justice.digital.hmpps: DEBUG
+ org.hibernate.tool.schema: ERROR
+ org.apache.activemq: WARN
+
+---
+spring.config.activate.on-profile: integration-test
+spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
+
+---
+spring.config.activate.on-profile: oracle
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
+
+---
+spring.config.activate.on-profile: delius-db
+spring:
+ datasource:
+ url: 'jdbc:oracle:thin:@//localhost:1521/XEPDB1'
+ username: delius_pool
+ password: NDelius1
+ jpa.hibernate.ddl-auto: validate
+seed.database: false
+delius.db.username: NationalUser
diff --git a/projects/justice-email-and-delius/tech-docs/.gitignore b/projects/justice-email-and-delius/tech-docs/.gitignore
new file mode 100644
index 0000000000..80d5de85a7
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/.gitignore
@@ -0,0 +1,20 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the build directory
+/build
+
+# Ignore cache
+/.sass-cache
+/.cache
+
+# Ignore .DS_store file
+.DS_Store
+
+Staticfile.auth
diff --git a/projects/justice-email-and-delius/tech-docs/.template_version b/projects/justice-email-and-delius/tech-docs/.template_version
new file mode 100644
index 0000000000..57ff8862e1
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/.template_version
@@ -0,0 +1,3 @@
+---
+:remote: https://github.com/alphagov/tech-docs-template.git
+:revision: b37e894
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/tech-docs/Gemfile b/projects/justice-email-and-delius/tech-docs/Gemfile
new file mode 100644
index 0000000000..afef363c09
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/Gemfile
@@ -0,0 +1,12 @@
+# If you do not have OpenSSL installed, change
+# the following line to use 'http://'
+source 'https://rubygems.org'
+
+# For faster file watcher updates on Windows:
+gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw, :x64_mingw]
+
+# Windows does not come with time zone data
+gem 'tzinfo-data', platforms: [:mswin, :mingw, :x64_mingw, :jruby]
+
+# Include the tech docs gem
+gem 'govuk_tech_docs'
diff --git a/projects/justice-email-and-delius/tech-docs/Gemfile.lock b/projects/justice-email-and-delius/tech-docs/Gemfile.lock
new file mode 100644
index 0000000000..9fdb19f88e
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/Gemfile.lock
@@ -0,0 +1,177 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ activesupport (7.0.7.2)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 1.6, < 2)
+ minitest (>= 5.1)
+ tzinfo (~> 2.0)
+ addressable (2.8.4)
+ public_suffix (>= 2.0.2, < 6.0)
+ autoprefixer-rails (10.4.13.0)
+ execjs (~> 2)
+ backports (3.24.1)
+ chronic (0.10.2)
+ chunky_png (1.4.0)
+ coffee-script (2.4.1)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.12.2)
+ commonmarker (0.23.10)
+ compass (1.0.3)
+ chunky_png (~> 1.2)
+ compass-core (~> 1.0.2)
+ compass-import-once (~> 1.0.5)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
+ sass (>= 3.3.13, < 3.5)
+ compass-core (1.0.3)
+ multi_json (~> 1.0)
+ sass (>= 3.3.0, < 3.5)
+ compass-import-once (1.0.5)
+ sass (>= 3.2, < 3.5)
+ concurrent-ruby (1.2.2)
+ contracts (0.17)
+ dotenv (2.8.1)
+ em-websocket (0.5.3)
+ eventmachine (>= 0.12.9)
+ http_parser.rb (~> 0)
+ erubis (2.7.0)
+ eventmachine (1.2.7)
+ execjs (2.8.1)
+ fast_blank (1.0.1)
+ fastimage (2.2.6)
+ ffi (1.15.5)
+ govuk_tech_docs (3.3.1)
+ autoprefixer-rails (~> 10.2)
+ chronic (~> 0.10.2)
+ middleman (~> 4.0)
+ middleman-autoprefixer (~> 2.10.0)
+ middleman-compass (>= 4.0.0)
+ middleman-livereload
+ middleman-search-gds
+ middleman-sprockets (~> 4.0.0)
+ middleman-syntax (~> 3.2.0)
+ nokogiri
+ openapi3_parser (~> 0.9.0)
+ redcarpet (~> 3.5.1)
+ haml (5.2.2)
+ temple (>= 0.8.0)
+ tilt
+ hamster (3.0.0)
+ concurrent-ruby (~> 1.0)
+ hashie (3.6.0)
+ http_parser.rb (0.8.0)
+ i18n (1.6.0)
+ concurrent-ruby (~> 1.0)
+ kramdown (2.4.0)
+ rexml
+ listen (3.8.0)
+ rb-fsevent (~> 0.10, >= 0.10.3)
+ rb-inotify (~> 0.9, >= 0.9.10)
+ memoist (0.16.2)
+ middleman (4.4.3)
+ coffee-script (~> 2.2)
+ haml (>= 4.0.5, < 6.0)
+ kramdown (>= 2.3.0)
+ middleman-cli (= 4.4.3)
+ middleman-core (= 4.4.3)
+ middleman-autoprefixer (2.10.0)
+ autoprefixer-rails (>= 9.1.4)
+ middleman-core (>= 3.3.3)
+ middleman-cli (4.4.3)
+ thor (>= 0.17.0, < 2.0)
+ middleman-compass (4.0.1)
+ compass (>= 1.0.0, < 2.0.0)
+ middleman-core (>= 4.0.0)
+ middleman-core (4.4.3)
+ activesupport (>= 6.1, < 7.1)
+ addressable (~> 2.4)
+ backports (~> 3.6)
+ bundler (~> 2.0)
+ contracts (~> 0.13)
+ dotenv
+ erubis
+ execjs (~> 2.0)
+ fast_blank
+ fastimage (~> 2.0)
+ hamster (~> 3.0)
+ hashie (~> 3.4)
+ i18n (~> 1.6.0)
+ listen (~> 3.0)
+ memoist (~> 0.14)
+ padrino-helpers (~> 0.15.0)
+ parallel
+ rack (>= 1.4.5, < 3)
+ sassc (~> 2.0)
+ servolux
+ tilt (~> 2.0.9)
+ toml
+ uglifier (~> 3.0)
+ webrick
+ middleman-livereload (3.4.7)
+ em-websocket (~> 0.5.1)
+ middleman-core (>= 3.3)
+ rack-livereload (~> 0.3.15)
+ middleman-search-gds (0.11.2)
+ execjs (~> 2.6)
+ middleman-core (>= 3.2)
+ nokogiri (~> 1.6)
+ middleman-sprockets (4.0.0)
+ middleman-core (~> 4.0)
+ sprockets (>= 3.0)
+ middleman-syntax (3.2.0)
+ middleman-core (>= 3.2)
+ rouge (~> 3.2)
+ minitest (5.18.0)
+ multi_json (1.15.0)
+ nokogiri (1.16.5-x86_64-linux)
+ racc (~> 1.4)
+ openapi3_parser (0.9.2)
+ commonmarker (~> 0.17)
+ padrino-helpers (0.15.3)
+ i18n (>= 0.6.7, < 2)
+ padrino-support (= 0.15.3)
+ tilt (>= 1.4.1, < 3)
+ padrino-support (0.15.3)
+ parallel (1.22.1)
+ parslet (2.0.0)
+ public_suffix (5.0.1)
+ racc (1.7.3)
+ rack (2.2.8.1)
+ rack-livereload (0.3.17)
+ rack
+ rb-fsevent (0.11.2)
+ rb-inotify (0.10.1)
+ ffi (~> 1.0)
+ redcarpet (3.5.1)
+ rexml (3.3.9)
+ rouge (3.30.0)
+ sass (3.4.25)
+ sassc (2.4.0)
+ ffi (~> 1.9)
+ servolux (0.13.0)
+ sprockets (4.2.0)
+ concurrent-ruby (~> 1.0)
+ rack (>= 2.2.4, < 4)
+ temple (0.10.0)
+ thor (1.2.1)
+ tilt (2.0.11)
+ toml (0.3.0)
+ parslet (>= 1.8.0, < 3.0.0)
+ tzinfo (2.0.6)
+ concurrent-ruby (~> 1.0)
+ uglifier (3.2.0)
+ execjs (>= 0.3.0, < 3)
+ webrick (1.8.2)
+
+PLATFORMS
+ x86_64-linux
+
+DEPENDENCIES
+ govuk_tech_docs
+ tzinfo-data
+ wdm (~> 0.1.0)
+
+BUNDLED WITH
+ 2.3.26
diff --git a/projects/justice-email-and-delius/tech-docs/config.rb b/projects/justice-email-and-delius/tech-docs/config.rb
new file mode 100644
index 0000000000..76c77d53dd
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/config.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+require "govuk_tech_docs"
+
+GovukTechDocs.configure(self)
+
+activate :relative_assets
+set :relative_links, true
diff --git a/projects/justice-email-and-delius/tech-docs/config/tech-docs.yml b/projects/justice-email-and-delius/tech-docs/config/tech-docs.yml
new file mode 100644
index 0000000000..8c7b5c08b3
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/config/tech-docs.yml
@@ -0,0 +1,44 @@
+# Host to use for canonical URL generation (without trailing slash)
+host: https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius
+
+# Header-related options
+service_name: HMPPS Justice Email And Delius
+service_link: https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius
+
+# Links to show on right-hand-side of header
+header_links:
+ Home: https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs
+ GitHub: https://github.com/ministryofjustice/hmpps-probation-integration-services#readme
+ Slack: https://mojdt.slack.com/archives/C02HQ4M2YQN # #probation-integration-tech channel
+
+# Enables search functionality. This indexes pages only and is not recommended for single-page sites.
+enable_search: true
+
+# Tracking ID from Google Analytics (e.g. UA-XXXX-Y)
+ga_tracking_id:
+
+# Enable multipage navigation in the sidebar
+multipage_nav: true
+
+# Enable collapsible navigation in the sidebar
+collapsible_nav: true
+
+# Table of contents depth – how many levels to include in the table of contents.
+# If your ToC is too long, reduce this number and we'll only show higher-level
+# headings.
+max_toc_heading_level: 2
+
+# Prevent robots from indexing (e.g. whilst in development)
+prevent_indexing: false
+
+# Contribution
+show_contribution_banner: true
+github_repo: ministryofjustice/hmpps-probation-integration-services
+github_branch: main
+
+# Slack
+owner_slack_workspace: mojdt
+default_owner_slack: '#probation-integration-tech'
+
+# OpenAPI
+api_path: https://justice-email-and-delius-dev.hmpps.service.justice.gov.uk/v3/api-docs.yaml
diff --git a/projects/justice-email-and-delius/tech-docs/source/api-reference.html.md.erb b/projects/justice-email-and-delius/tech-docs/source/api-reference.html.md.erb
new file mode 100644
index 0000000000..e8a4f0baac
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/api-reference.html.md.erb
@@ -0,0 +1,19 @@
+---
+title: API Reference
+source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/justice-email-and-delius/tech-docs/source/api-reference.html.md.erb'
+weight: 20
+---
+
+
+
+
+The following documentation is also available in these formats:
+
+* [OpenAPI JSON](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius/api-docs.json)
+* [OpenAPI YAML](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/justice-email-and-delius/api-docs.yaml)
+* [Swagger UI](https://justice-email-and-delius-dev.hmpps.service.justice.gov.uk/swagger-ui/index.html)
+
+api>
diff --git a/projects/justice-email-and-delius/tech-docs/source/index.html.md.erb b/projects/justice-email-and-delius/tech-docs/source/index.html.md.erb
new file mode 100644
index 0000000000..42b5084135
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/index.html.md.erb
@@ -0,0 +1,7 @@
+---
+title: About
+source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/justice-email-and-delius/tech-docs/source/index.html.md.erb'
+weight: 10
+---
+
+<%= URI.open('https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/justice-email-and-delius/README.md').read.gsub(/tech-docs\/source\//, "./") %>
\ No newline at end of file
diff --git a/projects/justice-email-and-delius/tech-docs/source/javascripts/application.js b/projects/justice-email-and-delius/tech-docs/source/javascripts/application.js
new file mode 100644
index 0000000000..8a5d80b842
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/javascripts/application.js
@@ -0,0 +1 @@
+//= require govuk_tech_docs
diff --git a/projects/justice-email-and-delius/tech-docs/source/stylesheets/print.css.scss b/projects/justice-email-and-delius/tech-docs/source/stylesheets/print.css.scss
new file mode 100644
index 0000000000..82b181c017
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/stylesheets/print.css.scss
@@ -0,0 +1,3 @@
+$is-print: true;
+
+@import "govuk_tech_docs";
diff --git a/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen-old-ie.css.scss b/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen-old-ie.css.scss
new file mode 100644
index 0000000000..da90cca5b0
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen-old-ie.css.scss
@@ -0,0 +1,4 @@
+$is-ie: true;
+$ie-version: 8;
+
+@import "govuk_tech_docs";
diff --git a/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen.css.scss b/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen.css.scss
new file mode 100644
index 0000000000..f0456338fd
--- /dev/null
+++ b/projects/justice-email-and-delius/tech-docs/source/stylesheets/screen.css.scss
@@ -0,0 +1 @@
+@import "govuk_tech_docs";
diff --git a/projects/make-recall-decisions-and-delius/src/main/resources/application.yml b/projects/make-recall-decisions-and-delius/src/main/resources/application.yml
index 5f35bbdb7b..430830dd16 100644
--- a/projects/make-recall-decisions-and-delius/src/main/resources/application.yml
+++ b/projects/make-recall-decisions-and-delius/src/main/resources/application.yml
@@ -78,7 +78,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/manage-offences-and-delius/src/main/resources/application.yml b/projects/manage-offences-and-delius/src/main/resources/application.yml
index 48ecbbc9fb..73194bdcad 100644
--- a/projects/manage-offences-and-delius/src/main/resources/application.yml
+++ b/projects/manage-offences-and-delius/src/main/resources/application.yml
@@ -73,7 +73,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/manage-pom-cases-and-delius/src/main/resources/application.yml b/projects/manage-pom-cases-and-delius/src/main/resources/application.yml
index a69077e9f3..ae30966362 100644
--- a/projects/manage-pom-cases-and-delius/src/main/resources/application.yml
+++ b/projects/manage-pom-cases-and-delius/src/main/resources/application.yml
@@ -78,7 +78,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/manage-supervision-and-delius/src/main/resources/application.yml b/projects/manage-supervision-and-delius/src/main/resources/application.yml
index 467c3ee613..4992fe5e6a 100644
--- a/projects/manage-supervision-and-delius/src/main/resources/application.yml
+++ b/projects/manage-supervision-and-delius/src/main/resources/application.yml
@@ -68,7 +68,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/oasys-and-delius/src/main/resources/application.yml b/projects/oasys-and-delius/src/main/resources/application.yml
index a33032a881..7e8f59a6a4 100644
--- a/projects/oasys-and-delius/src/main/resources/application.yml
+++ b/projects/oasys-and-delius/src/main/resources/application.yml
@@ -56,7 +56,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/offender-events-and-delius/src/main/resources/application.yml b/projects/offender-events-and-delius/src/main/resources/application.yml
index 361a42c772..02583ab57c 100644
--- a/projects/offender-events-and-delius/src/main/resources/application.yml
+++ b/projects/offender-events-and-delius/src/main/resources/application.yml
@@ -60,7 +60,9 @@ offender-events:
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/opd-and-delius/src/main/resources/application.yml b/projects/opd-and-delius/src/main/resources/application.yml
index f8d0ee6646..01cac76996 100644
--- a/projects/opd-and-delius/src/main/resources/application.yml
+++ b/projects/opd-and-delius/src/main/resources/application.yml
@@ -63,7 +63,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/pathfinder-and-delius/src/main/resources/application.yml b/projects/pathfinder-and-delius/src/main/resources/application.yml
index 6649f7089c..29eb87ec22 100644
--- a/projects/pathfinder-and-delius/src/main/resources/application.yml
+++ b/projects/pathfinder-and-delius/src/main/resources/application.yml
@@ -65,7 +65,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml b/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml
index 5655c0f68a..fd3cd1627a 100644
--- a/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml
+++ b/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml
@@ -86,7 +86,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/prison-case-notes-to-probation/src/main/resources/application.yml b/projects/prison-case-notes-to-probation/src/main/resources/application.yml
index 410b239470..38b74da5f5 100644
--- a/projects/prison-case-notes-to-probation/src/main/resources/application.yml
+++ b/projects/prison-case-notes-to-probation/src/main/resources/application.yml
@@ -80,7 +80,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/prison-custody-status-to-delius/src/main/resources/application.yml b/projects/prison-custody-status-to-delius/src/main/resources/application.yml
index c0fae4bf0b..35f9a624ac 100644
--- a/projects/prison-custody-status-to-delius/src/main/resources/application.yml
+++ b/projects/prison-custody-status-to-delius/src/main/resources/application.yml
@@ -71,7 +71,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/prison-education-and-delius/src/main/resources/application.yml b/projects/prison-education-and-delius/src/main/resources/application.yml
index 350e814a52..8ffff5658f 100644
--- a/projects/prison-education-and-delius/src/main/resources/application.yml
+++ b/projects/prison-education-and-delius/src/main/resources/application.yml
@@ -62,7 +62,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/prison-identifier-and-delius/src/main/resources/application.yml b/projects/prison-identifier-and-delius/src/main/resources/application.yml
index 0697240cff..5406c0cfae 100644
--- a/projects/prison-identifier-and-delius/src/main/resources/application.yml
+++ b/projects/prison-identifier-and-delius/src/main/resources/application.yml
@@ -81,7 +81,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/prisoner-profile-and-delius/src/main/resources/application.yml b/projects/prisoner-profile-and-delius/src/main/resources/application.yml
index bda1a683fe..4b6bd8537b 100644
--- a/projects/prisoner-profile-and-delius/src/main/resources/application.yml
+++ b/projects/prisoner-profile-and-delius/src/main/resources/application.yml
@@ -63,7 +63,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/probation-search-and-delius/src/main/resources/application.yml b/projects/probation-search-and-delius/src/main/resources/application.yml
index 39f77f1a33..f38dc8f149 100644
--- a/projects/probation-search-and-delius/src/main/resources/application.yml
+++ b/projects/probation-search-and-delius/src/main/resources/application.yml
@@ -58,7 +58,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/redrive-dead-letter-queues/deploy/values.yaml b/projects/redrive-dead-letter-queues/deploy/values.yaml
index 7a180b8de3..16f5ff32db 100644
--- a/projects/redrive-dead-letter-queues/deploy/values.yaml
+++ b/projects/redrive-dead-letter-queues/deploy/values.yaml
@@ -1,2 +1,2 @@
dlq_redrive:
- schedule: 30 5 * * 1-5 # Every weekday at 05:30 UTC
+ schedule: 0 7 * * 1-5 # Every weekday at 07:00 UTC
diff --git a/projects/refer-and-monitor-and-delius/src/main/resources/application.yml b/projects/refer-and-monitor-and-delius/src/main/resources/application.yml
index d64759f180..366e7d9931 100644
--- a/projects/refer-and-monitor-and-delius/src/main/resources/application.yml
+++ b/projects/refer-and-monitor-and-delius/src/main/resources/application.yml
@@ -78,7 +78,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/resettlement-passport-and-delius/src/main/resources/application.yml b/projects/resettlement-passport-and-delius/src/main/resources/application.yml
index 0f7afd256e..2012d4e11c 100644
--- a/projects/resettlement-passport-and-delius/src/main/resources/application.yml
+++ b/projects/resettlement-passport-and-delius/src/main/resources/application.yml
@@ -63,7 +63,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/sentence-plan-and-delius/src/main/resources/application.yml b/projects/sentence-plan-and-delius/src/main/resources/application.yml
index e84df315f4..1fd61c2024 100644
--- a/projects/sentence-plan-and-delius/src/main/resources/application.yml
+++ b/projects/sentence-plan-and-delius/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/soc-and-delius/src/main/resources/application.yml b/projects/soc-and-delius/src/main/resources/application.yml
index 695ef91d96..9232d7ccff 100644
--- a/projects/soc-and-delius/src/main/resources/application.yml
+++ b/projects/soc-and-delius/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/subject-access-requests-and-delius/src/main/resources/application.yml b/projects/subject-access-requests-and-delius/src/main/resources/application.yml
index 6a82965067..6eedbe51fc 100644
--- a/projects/subject-access-requests-and-delius/src/main/resources/application.yml
+++ b/projects/subject-access-requests-and-delius/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/tier-to-delius/src/main/resources/application.yml b/projects/tier-to-delius/src/main/resources/application.yml
index 25511007c1..31b566ab12 100644
--- a/projects/tier-to-delius/src/main/resources/application.yml
+++ b/projects/tier-to-delius/src/main/resources/application.yml
@@ -76,7 +76,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/unpaid-work-and-delius/src/main/resources/application.yml b/projects/unpaid-work-and-delius/src/main/resources/application.yml
index cc37c5058a..eb9a95e550 100644
--- a/projects/unpaid-work-and-delius/src/main/resources/application.yml
+++ b/projects/unpaid-work-and-delius/src/main/resources/application.yml
@@ -78,7 +78,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/projects/workforce-allocations-to-delius/src/main/resources/application.yml b/projects/workforce-allocations-to-delius/src/main/resources/application.yml
index 697585dd63..e8e7e0ff9f 100644
--- a/projects/workforce-allocations-to-delius/src/main/resources/application.yml
+++ b/projects/workforce-allocations-to-delius/src/main/resources/application.yml
@@ -89,7 +89,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 2d76c63b22..ec4e0562b1 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,6 +1,7 @@
rootProject.name = "probation-integration-services"
include(
// ⌄ add new projects here
+ "justice-email-and-delius",
"appointment-reminders-and-delius",
"ims-and-delius",
"common-platform-and-delius",
diff --git a/templates/projects/api-client-and-server/src/main/resources/application.yml b/templates/projects/api-client-and-server/src/main/resources/application.yml
index a50e756ebb..84ec4fd640 100644
--- a/templates/projects/api-client-and-server/src/main/resources/application.yml
+++ b/templates/projects/api-client-and-server/src/main/resources/application.yml
@@ -76,7 +76,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/templates/projects/api-server/src/main/resources/application.yml b/templates/projects/api-server/src/main/resources/application.yml
index 26840437ae..9bcff00bfc 100644
--- a/templates/projects/api-server/src/main/resources/application.yml
+++ b/templates/projects/api-server/src/main/resources/application.yml
@@ -57,7 +57,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml b/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml
index e0b7ef3063..792a47e611 100644
--- a/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml
+++ b/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml
@@ -78,7 +78,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/templates/projects/message-listener-with-api-client/src/main/resources/application.yml b/templates/projects/message-listener-with-api-client/src/main/resources/application.yml
index 29029558dc..1021120ff6 100644
--- a/templates/projects/message-listener-with-api-client/src/main/resources/application.yml
+++ b/templates/projects/message-listener-with-api-client/src/main/resources/application.yml
@@ -73,7 +73,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db
diff --git a/templates/projects/message-listener/src/main/resources/application.yml b/templates/projects/message-listener/src/main/resources/application.yml
index 5bc371c72f..d12d2aa42b 100644
--- a/templates/projects/message-listener/src/main/resources/application.yml
+++ b/templates/projects/message-listener/src/main/resources/application.yml
@@ -53,7 +53,9 @@ spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH
---
spring.config.activate.on-profile: oracle
-spring.datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+spring:
+ datasource.url: 'jdbc:tc:oracle:slim-faststart:///XEPDB1'
+ jpa.hibernate.ddl-auto: create
---
spring.config.activate.on-profile: delius-db