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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
395e2c3
commit 95cb97b
Showing
31 changed files
with
1,238 additions
and
190 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 34 additions & 2 deletions
36
...ison-identifier-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,57 @@ | ||
package uk.gov.justice.digital.hmpps.data | ||
|
||
import jakarta.annotation.PostConstruct | ||
import jakarta.persistence.EntityManager | ||
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 org.springframework.transaction.annotation.Transactional | ||
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 | ||
import java.time.LocalDate | ||
import java.time.format.DateTimeFormatter | ||
|
||
@Component | ||
@ConditionalOnProperty("seed.database") | ||
class DataLoader( | ||
private val auditUserRepository: AuditUserRepository | ||
private val auditUserRepository: AuditUserRepository, | ||
private val em: 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... | ||
val personWithNomsEvent = PersonGenerator.generateEvent(PersonGenerator.PERSON_WITH_NOMS) | ||
val personWithNoNomsNumberEvent = PersonGenerator.generateEvent(PersonGenerator.PERSON_WITH_NO_NOMS) | ||
val personWithMultiMatchEvent = PersonGenerator.generateEvent(PersonGenerator.PERSON_WITH_MULTI_MATCH) | ||
val personWithNoMatchEvent = PersonGenerator.generateEvent(PersonGenerator.PERSON_WITH_NO_MATCH) | ||
val personWithNomsInDeliusEvent = PersonGenerator.generateEvent(PersonGenerator.PERSON_WITH_NOMS_IN_DELIUS) | ||
|
||
em.saveAll( | ||
PersonGenerator.MALE, | ||
PersonGenerator.PERSON_WITH_NOMS, | ||
PersonGenerator.PERSON_WITH_NO_NOMS, | ||
PersonGenerator.PERSON_WITH_MULTI_MATCH, | ||
PersonGenerator.PERSON_WITH_NO_MATCH, | ||
PersonGenerator.PERSON_WITH_NOMS_IN_DELIUS, | ||
personWithNomsEvent, | ||
PersonGenerator.generateDisposal(LocalDate.now(), personWithNomsEvent), | ||
personWithNoNomsNumberEvent, | ||
PersonGenerator.generateDisposal(LocalDate.parse("12/12/2022", DateTimeFormatter.ofPattern("MM/dd/yyyy")), personWithNoNomsNumberEvent), | ||
personWithMultiMatchEvent, | ||
PersonGenerator.generateDisposal(LocalDate.parse("12/12/2022", DateTimeFormatter.ofPattern("MM/dd/yyyy")), personWithMultiMatchEvent), | ||
personWithNoMatchEvent, | ||
PersonGenerator.generateDisposal(LocalDate.parse("12/12/2022", DateTimeFormatter.ofPattern("MM/dd/yyyy")), personWithNoMatchEvent), | ||
personWithNomsInDeliusEvent, | ||
PersonGenerator.generateDisposal(LocalDate.parse("12/12/2022", DateTimeFormatter.ofPattern("MM/dd/yyyy")), personWithNomsInDeliusEvent) | ||
) | ||
} | ||
|
||
fun EntityManager.saveAll(vararg any: Any) = any.forEach { persist(it) } | ||
} |
8 changes: 0 additions & 8 deletions
8
...and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/MessageGenerator.kt
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
...-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,51 @@ | ||
package uk.gov.justice.digital.hmpps.data.generator | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.delius.entity.Disposal | ||
import uk.gov.justice.digital.hmpps.integrations.delius.entity.Event | ||
import uk.gov.justice.digital.hmpps.integrations.delius.entity.Person | ||
import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData | ||
import java.time.LocalDate | ||
import java.time.format.DateTimeFormatter | ||
|
||
object PersonGenerator { | ||
val MALE = generateGender("M") | ||
val PERSON_WITH_NOMS = generate("A000001", "1234567") | ||
val PERSON_WITH_NO_NOMS = generate("A000002", pncNumber = "07/220000004Q") | ||
val PERSON_WITH_NOMS_IN_DELIUS = generate("A000005", pncNumber = "07/220000004Q") | ||
val PERSON_WITH_MULTI_MATCH = generate("A000003", forename = "Jack", surname = "Jones") | ||
val PERSON_WITH_NO_MATCH = generate("A000004", forename = "Fred", surname = "Jones", dobString = "12/12/2001") | ||
|
||
fun generate( | ||
crn: String, | ||
noms: String? = null, | ||
pncNumber: String? = null, | ||
gender: ReferenceData = MALE, | ||
forename: String = "bob", | ||
surname: String = "smith", | ||
softDeleted: Boolean = false, | ||
dobString: String = "12/12/2000", | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = | ||
Person( | ||
id, | ||
crn, | ||
LocalDate.parse(dobString, DateTimeFormatter.ofPattern("MM/dd/yyyy")), | ||
forename, | ||
null, | ||
null, | ||
surname, | ||
noms, | ||
null, | ||
pncNumber, | ||
gender, | ||
softDeleted = softDeleted | ||
) | ||
|
||
fun generateEvent(person: Person, id: Long = IdGenerator.getAndIncrement()) = | ||
Event(id = id, person = person, active = true, softDeleted = false) | ||
|
||
fun generateDisposal(startDate: LocalDate, event: Event, id: Long = IdGenerator.getAndIncrement()) = | ||
Disposal(id, startDate, event, active = true, softDeleted = false) | ||
|
||
fun generateGender(code: String, id: Long = IdGenerator.getAndIncrement()) = ReferenceData(id, code) | ||
} |
8 changes: 4 additions & 4 deletions
8
projects/prison-identifier-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 | ||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDju2wS/xXRfjdRI9thM2yJ7xO4 | ||
cy5o8eJ1tljIrqJvKcdsmuflNv7IXGZP4OIQBhALkS3CQxIhBl9gNAtyu2AdYUdn | ||
bSlBS5qLtLg2EoPn2GyGSwRiZCmZcmDsHdn8DX0zNCgZN9i/B/yCL0gXgvHRGEqP | ||
QCtNM3Urqkvn97LVjQIDAQAB | ||
-----END PUBLIC KEY----- |
17 changes: 0 additions & 17 deletions
17
projects/prison-identifier-and-delius/src/dev/resources/messages/example-message.json
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...on-identifier-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
113 changes: 113 additions & 0 deletions
113
...ison-identifier-and-delius/src/dev/resources/simulations/__files/search-results-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"content": [ | ||
{ | ||
"prisonerNumber": "G5541UN", | ||
"pncNumber": "07/220000004Q", | ||
"pncNumberCanonicalShort": "07/220000004Q", | ||
"pncNumberCanonicalLong": "2007/220000004Q", | ||
"croNumber": "222823/07U", | ||
"bookingId": "1163007", | ||
"bookNumber": "13831A", | ||
"firstName": "Bob", | ||
"middleNames": "SHEMARIAH", | ||
"lastName": "Smith", | ||
"dateOfBirth": "2000-12-12", | ||
"gender": "Male", | ||
"ethnicity": "White: Eng./Welsh/Scot./N.Irish/British", | ||
"youthOffender": false, | ||
"maritalStatus": "Single-not married/in civil partnership", | ||
"religion": "No Religion", | ||
"nationality": "British", | ||
"status": "ACTIVE IN", | ||
"lastMovementTypeCode": "ADM", | ||
"lastMovementReasonCode": "INT", | ||
"inOutStatus": "IN", | ||
"prisonId": "MDI", | ||
"prisonName": "Moorland (HMP & YOI)", | ||
"cellLocation": "1-1-033", | ||
"aliases": [ | ||
{ | ||
"firstName": "EF'LIAICO", | ||
"lastName": "KATHUR", | ||
"dateOfBirth": "1994-10-11", | ||
"gender": "Male" | ||
} | ||
], | ||
"alerts": [ | ||
{ | ||
"alertType": "P", | ||
"alertCode": "PL2", | ||
"active": true, | ||
"expired": false | ||
} | ||
], | ||
"csra": "High", | ||
"category": "C", | ||
"legalStatus": "SENTENCED", | ||
"imprisonmentStatus": "SENT03", | ||
"imprisonmentStatusDescription": "Adult Imprisonment Without Option CJA03", | ||
"mostSeriousOffence": "Section 18 - wounding with intent", | ||
"recall": false, | ||
"indeterminateSentence": false, | ||
"sentenceStartDate": "2022-12-12", | ||
"releaseDate": "2018-09-07", | ||
"confirmedReleaseDate": "2018-09-07", | ||
"sentenceExpiryDate": "2019-12-21", | ||
"licenceExpiryDate": "2019-12-05", | ||
"homeDetentionCurfewEligibilityDate": "2018-01-12", | ||
"nonDtoReleaseDate": "2018-06-15", | ||
"nonDtoReleaseDateType": "CRD", | ||
"receptionDate": "2017-01-03", | ||
"conditionalReleaseDate": "2018-06-15", | ||
"locationDescription": "Moorland (HMP & YOI)", | ||
"restrictedPatient": false, | ||
"currentIncentive": { | ||
"level": { | ||
"code": "BAS", | ||
"description": "Basic" | ||
}, | ||
"dateTime": "2017-03-10T13:53:46", | ||
"nextReviewDate": "2017-03-17" | ||
}, | ||
"heightCentimetres": 165, | ||
"weightKilograms": 70, | ||
"hairColour": "Blonde", | ||
"rightEyeColour": "Blue", | ||
"leftEyeColour": "Blue", | ||
"facialHair": "Clean Shaven", | ||
"shapeOfFace": "Oval", | ||
"build": "Medium", | ||
"tattoos": [ | ||
{ | ||
"bodyPart": "Hand", | ||
"comment": "eveWeveW" | ||
} | ||
] | ||
} | ||
], | ||
"pageable": { | ||
"pageNumber": 0, | ||
"pageSize": 10, | ||
"sort": { | ||
"empty": true, | ||
"sorted": false, | ||
"unsorted": true | ||
}, | ||
"offset": 0, | ||
"unpaged": false, | ||
"paged": true | ||
}, | ||
"last": true, | ||
"totalPages": 1, | ||
"totalElements": 1, | ||
"first": true, | ||
"size": 10, | ||
"number": 0, | ||
"sort": { | ||
"empty": true, | ||
"sorted": false, | ||
"unsorted": true | ||
}, | ||
"numberOfElements": 1, | ||
"empty": false | ||
} |
Oops, something went wrong.