Skip to content

Commit

Permalink
PI-1668 endpoint for updating noms numbers (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevomcallister authored Dec 5, 2023
1 parent 395e2c3 commit 95cb97b
Show file tree
Hide file tree
Showing 31 changed files with 1,238 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/prison_identifier_and_delius.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion projects/prison-identifier-and-delius/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ apply(plugin = "com.google.cloud.tools.jib")
dependencies {
implementation(project(":libs:audit"))
implementation(project(":libs:commons"))
implementation(project(":libs:messaging"))
implementation(project(":libs:oauth-client"))
implementation(project(":libs:oauth-server"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ database:
access:
username_key: /prison-identifier-and-delius/db-username
password_key: /prison-identifier-and-delius/db-password
tables:
- offender

audit:
username: PrisonIdentifierAndDelius
forename: Probation Integration # TODO change this to something meaningful for your service
forename: Prison Identifier
surname: Service
3 changes: 1 addition & 2 deletions projects/prison-identifier-and-delius/deploy/values-dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enabled: false # TODO set this to true when you're ready to deploy your service

generic-service:
ingress:
host: prison-identifier-and-delius-dev.hmpps.service.justice.gov.uk
Expand All @@ -12,6 +10,7 @@ generic-service:
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/oauth/token
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
INTEGRATIONS_PRISONER-SEARCH_URL: https://prisoner-search-dev.prison.service.justice.gov.uk

LOGGING_LEVEL_UK_GOV_DIGITAL_JUSTICE_HMPPS: DEBUG

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enabled: false # TODO set this to true when you're ready to deploy your service

generic-service:
ingress:
host: prison-identifier-and-delius-preprod.hmpps.service.justice.gov.uk
Expand All @@ -12,6 +10,7 @@ generic-service:
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/oauth/token
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
INTEGRATIONS_PRISONER-SEARCH_URL: https://prisoner-search-preprod.prison.service.justice.gov.uk

generic-prometheus-alerts:
businessHoursOnly: true
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ generic-service:
SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: https://sign-in.hmpps.service.justice.gov.uk/auth/oauth/token
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
INTEGRATIONS_PRISONER-SEARCH_URL: https://prisoner-search.prison.service.justice.gov.uk
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) }
}

This file was deleted.

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)
}
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-----

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwcm9iYXRpb24taW50ZWdyYXRpb24tZGV2IiwiZ3JhbnRfdHlwZSI6ImNsaWVudF9jcmVkZW50aWFscyIsInVzZXJfbmFtZSI6InByb2JhdGlvbi1pbnRlZ3JhdGlvbi1kZXYiLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiYXV0aF9zb3VyY2UiOiJub25lIiwiaXNzIjoiaHR0cHM6Ly9zaWduLWluLWRldi5obXBwcy5zZXJ2aWNlLmp1c3RpY2UuZ292LnVrL2F1dGgvaXNzdWVyIiwiZXhwIjo5OTk5OTk5OTk5LCJhdXRob3JpdGllcyI6WyJST0xFX0VYQU1QTEUiLCJST0xFX1dPUktMT0FEX1JFQUQiLCJST0xFX0FMTE9DQVRJT05fQ09OVEVYVCJdLCJqdGkiOiIyNUR1Um4xLWh5SFpld0xjZEpKeHdWTDAzS1UiLCJjbGllbnRfaWQiOiJwcm9iYXRpb24taW50ZWdyYXRpb24tZGV2IiwiaWF0IjoxNjYzNzU3MzExfQ.5FTCUjA7QZMPxO_EMzkGNSM-IkPk2hfPXyzuNiAa7uuqYva_yCducrC5FdetAiC1W6XpUB7wfoMNDmbW2xepj5oRhcxDx18r92aLPYnKkxaA68hLQF90euMtTzfBzOPg-rKDTNIJKrUC-YoQlFKuCauw0Z5cw1XT6R9GIfi5Yx4",
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwcm9iYXRpb24taW50ZWdyYXRpb24tZGV2IiwiZ3JhbnRfdHlwZSI6ImNsaWVudF9jcmVkZW50aWFscyIsInVzZXJfbmFtZSI6InByb2JhdGlvbi1pbnRlZ3JhdGlvbi1kZXYiLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiYXV0aF9zb3VyY2UiOiJub25lIiwiaXNzIjoiaHR0cHM6Ly9zaWduLWluLWRldi5obXBwcy5zZXJ2aWNlLmp1c3RpY2UuZ292LnVrL2F1dGgvaXNzdWVyIiwiZXhwIjo5OTk5OTk5OTk5LCJhdXRob3JpdGllcyI6WyJST0xFX1VQREFURV9OT01TX05VTUJFUiJdLCJqdGkiOiIyNUR1Um4xLWh5SFpld0xjZEpKeHdWTDAzS1UiLCJjbGllbnRfaWQiOiJwcm9iYXRpb24taW50ZWdyYXRpb24tZGV2IiwiaWF0IjoxNjYzNzU3MzExfQ.bAcMem3ScY0HuH1B156hsOPkNtpPCO2RiKmY_Dddj9v77HZUCAxuNyWw887OVRvMJYeCOhFC-6X5pjZQifNNbTobSJDl9T2iwjEbBpZji-AQlyAZSwzZ6800Y318S0GzmSf3DCxG0NnEdNWw6FuLXJAtalHhwRGS9BVovA71UIY",
"token_type": "bearer",
"expires_in": 9999999999,
"scope": "read write",
Expand Down
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
}
Loading

0 comments on commit 95cb97b

Please sign in to comment.