generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PI-1505 DPS probation document endpoints
- Loading branch information
1 parent
a3e6bfa
commit 8d1146d
Showing
28 changed files
with
1,013 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Suppressed as we do not process any untrusted YML content | ||
# Note: this will be resolved in Spring Boot 3.2: https://github.com/spring-projects/spring-boot/issues/35982 | ||
CVE-2022-1471 exp:2023-12-01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 41 additions & 2 deletions
43
projects/dps-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,64 @@ | ||
package uk.gov.justice.digital.hmpps.data | ||
|
||
import jakarta.annotation.PostConstruct | ||
import jakarta.persistence.EntityManager | ||
import jakarta.transaction.Transactional | ||
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.DocumentGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.EventGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator | ||
import uk.gov.justice.digital.hmpps.user.AuditUserRepository | ||
|
||
@Component | ||
@ConditionalOnProperty("seed.database") | ||
class DataLoader( | ||
private val auditUserRepository: AuditUserRepository | ||
private val auditUserRepository: AuditUserRepository, | ||
private val entityManager: EntityManager | ||
) : ApplicationListener<ApplicationReadyEvent> { | ||
|
||
@PostConstruct | ||
fun saveAuditUser() { | ||
auditUserRepository.save(UserGenerator.AUDIT_USER) | ||
} | ||
|
||
@Transactional | ||
override fun onApplicationEvent(are: ApplicationReadyEvent) { | ||
// Perform dev/test database setup here, using JPA repositories and generator classes... | ||
entityManager.persist(PersonGenerator.DEFAULT) | ||
entityManager.persist(EventGenerator.EVENT.mainOffence.offence) | ||
entityManager.persist(EventGenerator.EVENT) | ||
entityManager.persist(EventGenerator.EVENT.mainOffence) | ||
entityManager.persist(EventGenerator.DISPOSAL.lengthUnits) | ||
entityManager.persist(EventGenerator.DISPOSAL.type) | ||
entityManager.persist(EventGenerator.DISPOSAL) | ||
entityManager.persist(EventGenerator.INSTITUTION) | ||
entityManager.persist(EventGenerator.CUSTODY) | ||
entityManager.persist(EventGenerator.COURT) | ||
entityManager.persist(EventGenerator.COURT_APPEARANCE.outcome) | ||
entityManager.persist(EventGenerator.COURT_APPEARANCE) | ||
entityManager.persist(EventGenerator.COURT_REPORT_TYPE) | ||
entityManager.persist(EventGenerator.COURT_REPORT) | ||
entityManager.persist(EventGenerator.INSTITUTIONAL_REPORT_TYPE) | ||
entityManager.persist(EventGenerator.INSTITUTIONAL_REPORT) | ||
entityManager.persist(EventGenerator.CONTACT_TYPE) | ||
entityManager.persist(EventGenerator.CONTACT) | ||
entityManager.persist(EventGenerator.NSI_TYPE) | ||
entityManager.persist(EventGenerator.NSI) | ||
entityManager.persist(DocumentGenerator.OFFENDER) | ||
entityManager.persist(DocumentGenerator.PREVIOUS_CONVICTIONS) | ||
entityManager.persist(DocumentGenerator.EVENT) | ||
entityManager.persist(DocumentGenerator.CPS_PACK) | ||
entityManager.persist(DocumentGenerator.ADDRESSASSESSMENT) | ||
entityManager.persist(DocumentGenerator.PERSONALCONTACT) | ||
entityManager.persist(DocumentGenerator.PERSONAL_CIRCUMSTANCE) | ||
entityManager.persist(DocumentGenerator.COURT_REPORT) | ||
entityManager.persist(DocumentGenerator.INSTITUTIONAL_REPORT) | ||
entityManager.persist(DocumentGenerator.OFFENDER_CONTACT) | ||
entityManager.persist(DocumentGenerator.EVENT_CONTACT) | ||
entityManager.persist(DocumentGenerator.OFFENDER_NSI) | ||
entityManager.persist(DocumentGenerator.EVENT_NSI) | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
projects/dps-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Entities.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package uk.gov.justice.digital.hmpps.data.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import java.time.LocalDate | ||
|
||
@Entity | ||
data class AddressAssessment(@Id val addressAssessmentId: Long, val assessmentDate: LocalDate) | ||
|
||
@Entity | ||
data class ApprovedPremisesReferral(@Id val approvedPremisesReferralId: Long, val referralDate: LocalDate, val eventId: Long?) | ||
|
||
@Entity | ||
data class Assessment(@Id val assessmentId: Long, val assessmentTypeId: Long, val referralId: Long?, val assessmentDate: LocalDate) | ||
|
||
@Entity | ||
@Table(name = "r_assessment_type") | ||
data class AssessmentType(@Id val assessmentTypeId: Long, val description: String) | ||
|
||
@Entity | ||
data class CaseAllocation(@Id val caseAllocationId: Long, val eventId: Long) | ||
|
||
@Entity | ||
data class Contact(@Id val contactId: Long, val contactTypeId: Long, val eventId: Long?, val contactDate: LocalDate) | ||
|
||
@Entity | ||
@Table(name = "r_contact_type") | ||
data class ContactType(@Id val contactTypeId: Long, val description: String) | ||
|
||
@Entity | ||
data class Court(@Id val courtId: Long, val courtName: String) | ||
|
||
@Entity | ||
@Table(name = "r_court_report_type") | ||
data class CourtReportType(@Id val courtReportTypeId: Long, val description: String) | ||
|
||
@Entity | ||
data class CourtReport(@Id val courtReportId: Long, val courtReportTypeId: Long, val courtAppearanceId: Long, val dateRequested: LocalDate) | ||
|
||
@Entity | ||
data class InstitutionalReport(@Id val institutionalReportId: Long, val institutionReportTypeId: Long, val institutionId: Long, val establishment: String, val custodyId: Long, val dateRequested: LocalDate) | ||
|
||
@Entity | ||
data class Nsi(@Id val nsiId: Long, val nsiTypeId: Long, val eventId: Long?, val referralDate: LocalDate) | ||
|
||
@Entity | ||
@Table(name = "r_nsi_type") | ||
data class NsiType(@Id val nsiTypeId: Long, val description: String) | ||
|
||
@Entity | ||
data class PersonalCircumstance(@Id val personalCircumstanceId: Long, val circumstanceTypeId: Long, val startDate: LocalDate) | ||
|
||
@Entity | ||
@Table(name = "r_circumstance_type") | ||
data class PersonalCircumstanceType(@Id val circumstanceTypeId: Long, val codeDescription: String) | ||
|
||
@Entity | ||
data class PersonalContact(@Id val personalContactId: Long, val relationshipTypeId: Long, val relationship: String) | ||
|
||
@Entity | ||
data class Referral(@Id val referralId: Long, val referralTypeId: Long, val referralDate: LocalDate, val eventId: Long) | ||
|
||
@Entity | ||
@Table(name = "r_referral_type") | ||
data class ReferralType(@Id val referralTypeId: Long, val description: String) | ||
|
||
@Entity | ||
data class UpwAppointment(@Id val upwAppointmentId: Long, val upwDetailsId: Long, val upwProjectId: Long, val appointmentDate: LocalDate) | ||
|
||
@Entity | ||
data class UpwDetails(@Id val upwDetailsId: Long, val disposalId: Long) | ||
|
||
@Entity | ||
data class UpwProject(@Id val upwProjectId: Long, val disposalId: Long, val name: String) | ||
|
||
@Entity | ||
@Table(name = "user_") | ||
data class User( | ||
@Id | ||
@Column(name = "user_id") | ||
val userId: Long, | ||
val forename: String, | ||
val surname: String | ||
) |
35 changes: 35 additions & 0 deletions
35
...nd-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DocumentGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.entity.Document | ||
import java.time.ZonedDateTime | ||
import java.util.UUID | ||
|
||
object DocumentGenerator { | ||
val OFFENDER = generate("OFFENDER", primaryKeyId = PersonGenerator.DEFAULT.id, alfrescoId = "uuid1") | ||
val PREVIOUS_CONVICTIONS = generate("OFFENDER", "PREVIOUS_CONVICTION", primaryKeyId = PersonGenerator.DEFAULT.id) | ||
val EVENT = generate("EVENT", primaryKeyId = EventGenerator.EVENT.id) | ||
val CPS_PACK = generate("EVENT", "CPS_PACK", primaryKeyId = EventGenerator.EVENT.id) | ||
val ADDRESSASSESSMENT = generate("ADDRESSASSESSMENT") | ||
val PERSONALCONTACT = generate("PERSONALCONTACT") | ||
val PERSONAL_CIRCUMSTANCE = generate("PERSONAL_CIRCUMSTANCE") | ||
val COURT_REPORT = generate("COURT_REPORT", primaryKeyId = EventGenerator.COURT_REPORT.courtReportId) | ||
val INSTITUTIONAL_REPORT = generate("INSTITUTIONAL_REPORT", primaryKeyId = EventGenerator.INSTITUTIONAL_REPORT.institutionalReportId) | ||
val OFFENDER_CONTACT = generate("CONTACT") | ||
val EVENT_CONTACT = generate("CONTACT", primaryKeyId = EventGenerator.CONTACT.contactId) | ||
val OFFENDER_NSI = generate("NSI") | ||
val EVENT_NSI = generate("NSI", primaryKeyId = EventGenerator.NSI.nsiId) | ||
|
||
fun generate(tableName: String, type: String = "DOCUMENT", primaryKeyId: Long = 0, alfrescoId: String = UUID.randomUUID().toString()) = Document( | ||
id = IdGenerator.getAndIncrement(), | ||
personId = PersonGenerator.DEFAULT.id, | ||
alfrescoId = alfrescoId, | ||
primaryKeyId = primaryKeyId, | ||
name = "$tableName-related document", | ||
type = type, | ||
tableName = tableName, | ||
createdAt = ZonedDateTime.now(), | ||
createdByUserId = 0, | ||
lastUpdatedUserId = 0, | ||
softDeleted = false | ||
) | ||
} |
100 changes: 100 additions & 0 deletions
100
...s-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.data.entity.Contact | ||
import uk.gov.justice.digital.hmpps.data.entity.ContactType | ||
import uk.gov.justice.digital.hmpps.data.entity.Court | ||
import uk.gov.justice.digital.hmpps.data.entity.CourtReport | ||
import uk.gov.justice.digital.hmpps.data.entity.CourtReportType | ||
import uk.gov.justice.digital.hmpps.data.entity.InstitutionalReport | ||
import uk.gov.justice.digital.hmpps.data.entity.Nsi | ||
import uk.gov.justice.digital.hmpps.data.entity.NsiType | ||
import uk.gov.justice.digital.hmpps.entity.CourtAppearance | ||
import uk.gov.justice.digital.hmpps.entity.Custody | ||
import uk.gov.justice.digital.hmpps.entity.Disposal | ||
import uk.gov.justice.digital.hmpps.entity.DisposalType | ||
import uk.gov.justice.digital.hmpps.entity.Event | ||
import uk.gov.justice.digital.hmpps.entity.Institution | ||
import uk.gov.justice.digital.hmpps.entity.MainOffence | ||
import uk.gov.justice.digital.hmpps.entity.Offence | ||
import uk.gov.justice.digital.hmpps.entity.ReferenceData | ||
import uk.gov.justice.digital.hmpps.set | ||
import java.time.LocalDate | ||
import java.time.ZonedDateTime | ||
|
||
object EventGenerator { | ||
val EVENT = Event( | ||
id = IdGenerator.getAndIncrement(), | ||
person = PersonGenerator.DEFAULT, | ||
referralDate = LocalDate.now(), | ||
mainOffence = MainOffence( | ||
id = IdGenerator.getAndIncrement(), | ||
offence = Offence( | ||
id = IdGenerator.getAndIncrement(), | ||
subCategoryDescription = "Burglary" | ||
) | ||
), | ||
courtAppearances = listOf() | ||
).also { it.mainOffence.set("event", it) } | ||
val DISPOSAL = Disposal( | ||
id = IdGenerator.getAndIncrement(), | ||
event = EVENT, | ||
type = DisposalType( | ||
id = IdGenerator.getAndIncrement(), | ||
description = "Sentenced" | ||
), | ||
length = 6, | ||
lengthUnits = ReferenceData(IdGenerator.getAndIncrement(), "M", "Months") | ||
) | ||
val INSTITUTION = Institution( | ||
id = IdGenerator.getAndIncrement(), | ||
name = "test institution", | ||
establishment = "Y" | ||
) | ||
val CUSTODY = Custody( | ||
id = IdGenerator.getAndIncrement(), | ||
disposal = DISPOSAL, | ||
institution = INSTITUTION | ||
) | ||
|
||
val COURT = Court(courtId = IdGenerator.getAndIncrement(), courtName = "test court") | ||
val COURT_REPORT_TYPE = CourtReportType(courtReportTypeId = IdGenerator.getAndIncrement(), description = "court report type") | ||
val COURT_APPEARANCE = CourtAppearance( | ||
id = IdGenerator.getAndIncrement(), | ||
date = ZonedDateTime.now(), | ||
courtId = COURT.courtId, | ||
event = EVENT, | ||
outcome = ReferenceData(IdGenerator.getAndIncrement(), "TEST", "Community Order") | ||
) | ||
val COURT_REPORT = CourtReport( | ||
courtReportId = IdGenerator.getAndIncrement(), | ||
courtReportTypeId = COURT_REPORT_TYPE.courtReportTypeId, | ||
courtAppearanceId = COURT_APPEARANCE.id, | ||
dateRequested = LocalDate.of(2000, 1, 1) | ||
) | ||
|
||
val INSTITUTIONAL_REPORT_TYPE = ReferenceData(IdGenerator.getAndIncrement(), "IR", "institutional report type") | ||
val INSTITUTIONAL_REPORT = InstitutionalReport( | ||
institutionalReportId = IdGenerator.getAndIncrement(), | ||
institutionId = INSTITUTION.id, | ||
institutionReportTypeId = INSTITUTIONAL_REPORT_TYPE.id, | ||
custodyId = CUSTODY.id, | ||
establishment = "Y", | ||
dateRequested = LocalDate.of(2000, 1, 2) | ||
) | ||
|
||
val CONTACT_TYPE = ContactType(contactTypeId = IdGenerator.getAndIncrement(), description = "contact type") | ||
val CONTACT = Contact( | ||
contactId = IdGenerator.getAndIncrement(), | ||
contactTypeId = CONTACT_TYPE.contactTypeId, | ||
eventId = EVENT.id, | ||
contactDate = LocalDate.of(2000, 1, 3) | ||
) | ||
|
||
val NSI_TYPE = NsiType(nsiTypeId = IdGenerator.getAndIncrement(), description = "nsi type") | ||
val NSI = Nsi( | ||
nsiId = IdGenerator.getAndIncrement(), | ||
nsiTypeId = NSI_TYPE.nsiTypeId, | ||
eventId = EVENT.id, | ||
referralDate = LocalDate.of(2000, 1, 4) | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
...-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.entity.Person | ||
|
||
object PersonGenerator { | ||
val DEFAULT = Person( | ||
id = IdGenerator.getAndIncrement(), | ||
forename = "First", | ||
secondName = "Middle", | ||
thirdName = null, | ||
surname = "Last", | ||
crn = "A000001", | ||
nomisId = "A0001AA", | ||
events = listOf(), | ||
softDeleted = false | ||
) | ||
} |
8 changes: 4 additions & 4 deletions
8
projects/dps-and-delius/src/dev/resources/local-public-key.pub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDo3hw1/oChbttEOxEH4NUDrH+Y | ||
n2x0DavAmDjMbhcSiQ6+/t8Nz/N03BauWzFOGBtftnQrHfnF+O7RAKj8zMjcbIq4 | ||
QrYeXEpnaFCGEwTtOBpxvSEWPrLEpr1gCarBQZDp67ag+SYqrDgkn2Vme/dMvMUQ | ||
xUO3DT6jg9921J6TlwIDAQAB | ||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+DhFN5a7rx/KAKw9zX4dlONZY | ||
YGrWPqjRaRlH91aLo/btXVWeXxwBiaAu1RSctoixnW0S5Wm0mpCieRjmSQH/COgC | ||
OAsouUsuBFUy8ohKiTpQaaOPNA8KDNMNhKQ0KT7KPPCGCB1BNvVgtZInwhyVKzTL | ||
UfvD+V/JnSwldl9uBQIDAQAB | ||
-----END PUBLIC KEY----- |
Binary file added
BIN
+14.5 KB
projects/dps-and-delius/src/dev/resources/simulations/__files/document.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
projects/dps-and-delius/src/dev/resources/simulations/__files/hmpps-auth-token-body.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
projects/dps-and-delius/src/dev/resources/simulations/mappings/alfresco.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"urlPath": "/alfresco/fetch/uuid1" | ||
}, | ||
"response": { | ||
"headers": { | ||
"Content-Type": "application/octet-stream", | ||
"Content-Disposition": "attachment; filename=\"doc1\"; filename*=UTF-8''doc1", | ||
"Custom-Alfresco-Header": "should be ignored" | ||
}, | ||
"status": 200, | ||
"bodyFileName": "document.pdf" | ||
} | ||
} |
Oops, something went wrong.