Skip to content

Commit 22a0d65

Browse files
authored
PI-2094: Added offender detail all endpoint (#3803)
* PI-2094: Added offender detail all endpoint
1 parent cb04aca commit 22a0d65

File tree

14 files changed

+916
-252
lines changed

14 files changed

+916
-252
lines changed

projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class DataLoader(
3434
DocumentEntityGenerator.INSTITUTIONAL_REPORT_TYPE,
3535
DocumentEntityGenerator.INSTITUTIONAL_REPORT,
3636
DocumentEntityGenerator.R_INSTITUTION,
37-
37+
AreaGenerator.PARTITION_AREA,
38+
ProviderEmployeeGenerator.PROVIDER_EMPLOYEE,
3839
ProviderGenerator.DEFAULT,
3940
LDUGenerator.DEFAULT,
4041
BoroughGenerator.DEFAULT,
@@ -74,17 +75,22 @@ class DataLoader(
7475
ReferenceDataGenerator.SECOND_NATIONALITY,
7576
ReferenceDataGenerator.SEXUAL_ORIENTATION,
7677
ReferenceDataGenerator.TITLE,
77-
PersonGenerator.PARTITION_AREA,
78+
ReferenceDataGenerator.DEFAULT_ADDRESS_TYPE,
79+
ReferenceDataGenerator.DEFAULT_ADDRESS_STATUS,
80+
ReferenceDataGenerator.DEFAULT_ALLOCATION_REASON,
81+
ReferenceDataGenerator.DEFAULT_TIER,
7882
PersonGenerator.NEW_TO_PROBATION,
7983
PersonGenerator.CURRENTLY_MANAGED,
8084
PersonGenerator.PREVIOUSLY_MANAGED,
8185
PersonGenerator.NO_SENTENCE,
8286
PersonGenerator.PROVISION_1,
8387
PersonGenerator.DISABILITY_1,
84-
PersonGenerator.PREVIOUS_CONVICTION_DOC
88+
PersonGenerator.PREVIOUS_CONVICTION_DOC,
89+
PersonGenerator.ADDRESS,
90+
PersonGenerator.ALIAS
8591
)
8692

87-
em.saveAll(StaffGenerator.ALLOCATED, StaffGenerator.UNALLOCATED)
93+
em.saveAll(StaffGenerator.ALLOCATED, StaffGenerator.UNALLOCATED, StaffGenerator.OFFICER)
8894

8995
em.saveAll(
9096
PersonGenerator.generatePersonManager(PersonGenerator.NEW_TO_PROBATION),

projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Entities.kt

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import org.hibernate.annotations.Immutable
99
import org.hibernate.type.YesNoConverter
1010
import java.time.LocalDate
1111

12-
@Entity
13-
class AddressAssessment(@Id val addressAssessmentId: Long, val assessmentDate: LocalDate)
14-
1512
@Entity
1613
class ApprovedPremisesReferral(
1714
@Id val approvedPremisesReferralId: Long,

projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt

+61-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package uk.gov.justice.digital.hmpps.data.generator
22

33
import uk.gov.justice.digital.hmpps.api.model.DocumentType
4+
import uk.gov.justice.digital.hmpps.data.generator.AreaGenerator.PARTITION_AREA
5+
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DEFAULT_ADDRESS_STATUS
6+
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DEFAULT_ADDRESS_TYPE
7+
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DEFAULT_ALLOCATION_REASON
8+
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DEFAULT_TIER
49
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_CONDITION_1
510
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_TYPE_1
611
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.ETHNICITY
@@ -20,7 +25,7 @@ import java.time.LocalDate
2025
import java.time.ZonedDateTime
2126

2227
object PersonGenerator {
23-
val PARTITION_AREA = PartitionArea(IdGenerator.getAndIncrement(), "Partition Area")
28+
2429
val NEW_TO_PROBATION = generate("N123456")
2530
val CURRENTLY_MANAGED = generate("C123456", currentDisposal = true)
2631
val PREVIOUSLY_MANAGED = generate("P123456")
@@ -35,6 +40,9 @@ object PersonGenerator {
3540
null
3641
)
3742

43+
val ADDRESS = generateAddress(CURRENTLY_MANAGED.id, false)
44+
val ALIAS = generatePersonAlias(CURRENTLY_MANAGED)
45+
3846
fun generate(
3947
crn: String,
4048
softDeleted: Boolean = false,
@@ -81,17 +89,41 @@ object PersonGenerator {
8189
immigrationNumber = "IMA123",
8290
mostRecentPrisonerNumber = "PRS123",
8391
previousSurname = "Previous",
84-
title = TITLE
92+
title = TITLE,
93+
offenderManagers = emptyList(),
94+
restrictionMessage = "restrictionMessage",
95+
exclusionMessage = "exclusionMessage",
96+
currentTier = DEFAULT_TIER
8597
)
8698

8799
fun generatePersonManager(person: Person) =
88100
PersonManager(
89-
IdGenerator.getAndIncrement(),
90-
person,
91-
TeamGenerator.DEFAULT,
92-
StaffGenerator.ALLOCATED,
93-
ProviderGenerator.DEFAULT,
94-
ZonedDateTime.now()
101+
id = IdGenerator.getAndIncrement(),
102+
trustProviderFlag = false,
103+
person = person,
104+
team = TeamGenerator.DEFAULT,
105+
staff = StaffGenerator.ALLOCATED,
106+
provider = ProviderGenerator.DEFAULT,
107+
date = ZonedDateTime.now(),
108+
allocationReason = DEFAULT_ALLOCATION_REASON,
109+
officer = StaffGenerator.OFFICER,
110+
partitionArea = PARTITION_AREA,
111+
startDate = LocalDate.now().minusDays(2),
112+
staffEmployeeId = StaffGenerator.ALLOCATED.id,
113+
providerEmployee = ProviderEmployeeGenerator.PROVIDER_EMPLOYEE
114+
)
115+
116+
fun generatePersonAlias(person: Person) =
117+
OffenderAlias(
118+
aliasID = IdGenerator.getAndIncrement(),
119+
personId = person.id,
120+
dateOfBirth = LocalDate.of(1968, 1, 1),
121+
firstName = "Bob",
122+
secondName = "Reg",
123+
thirdName = "Xavier",
124+
surname = "Potts",
125+
gender = GENDER_MALE,
126+
softDeleted = false
95127
)
96128

97129
fun generateProvision(personId: Long, end: LocalDate?) = Provision(
@@ -115,4 +147,25 @@ object PersonGenerator {
115147
notes = null,
116148
finishDate = end,
117149
)
150+
151+
fun generateAddress(personId: Long, softDeleted: Boolean) = PersonAddress(
152+
id = IdGenerator.getAndIncrement(),
153+
personId = personId,
154+
type = DEFAULT_ADDRESS_TYPE,
155+
status = DEFAULT_ADDRESS_STATUS,
156+
streetName = "A Street",
157+
town = "A town",
158+
county = "A county",
159+
postcode = "NE209XL",
160+
telephoneNumber = "089876765",
161+
buildingName = "The building",
162+
district = "A District",
163+
addressNumber = "20",
164+
noFixedAbode = false,
165+
typeVerified = true,
166+
startDate = LocalDate.now().minusDays(1),
167+
endDate = null,
168+
softDeleted = false,
169+
createdDatetime = ZonedDateTime.now().minusDays(1),
170+
)
118171
}

projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferenceDataGenerator.kt

+24
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,28 @@ object ReferenceDataGenerator {
175175
"Mr",
176176
IdGenerator.getAndIncrement()
177177
)
178+
179+
val DEFAULT_ADDRESS_TYPE = ReferenceData(
180+
"AT",
181+
"Address Type",
182+
IdGenerator.getAndIncrement()
183+
)
184+
185+
val DEFAULT_ADDRESS_STATUS = ReferenceData(
186+
"AS",
187+
"Address Status",
188+
IdGenerator.getAndIncrement()
189+
)
190+
191+
val DEFAULT_ALLOCATION_REASON = ReferenceData(
192+
"AR",
193+
"Allocation Reason",
194+
IdGenerator.getAndIncrement()
195+
)
196+
197+
val DEFAULT_TIER = ReferenceData(
198+
"B2",
199+
"B2",
200+
IdGenerator.getAndIncrement()
201+
)
178202
}

projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/StaffGenerator.kt

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
package uk.gov.justice.digital.hmpps.data.generator
22

3-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Borough
4-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.District
5-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.LocalDeliveryUnit
6-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.ProbationAreaEntity
7-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Staff
8-
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Team
3+
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Officer
4+
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.OfficerPk
5+
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.PartitionArea
6+
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.ProviderEmployee
7+
import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.*
98

109
object StaffGenerator {
1110
val UNALLOCATED = generate("N01UATU")
1211
val ALLOCATED = generate("N01ABBA")
12+
val OFFICER = generateOfficer()
1313
fun generate(code: String, id: Long = IdGenerator.getAndIncrement()) = Staff(code, "Bob", "Micheal", "Smith", id)
14+
15+
fun generateOfficer() =
16+
Officer(
17+
id = OfficerPk(
18+
trustProviderFlag = 0,
19+
staffEmployeeId = ALLOCATED.id
20+
),
21+
surname = "OffSurname",
22+
forename = "Off1",
23+
forename2 = "Off2"
24+
)
1425
}
1526

1627
object ProviderGenerator {
1728
val DEFAULT = generate()
18-
fun generate(id: Long = IdGenerator.getAndIncrement()) = ProbationAreaEntity(true, "London", "LN1", null, id)
29+
fun generate(id: Long = IdGenerator.getAndIncrement()) = ProbationAreaEntity(true, "London", "LN1", null, true, id)
30+
}
31+
32+
object AreaGenerator {
33+
val PARTITION_AREA = PartitionArea(IdGenerator.getAndIncrement(), "Partition Area")
34+
}
35+
36+
object ProviderEmployeeGenerator {
37+
val PROVIDER_EMPLOYEE = generateProviderEmployee()
38+
fun generateProviderEmployee() = ProviderEmployee(
39+
providerEmployeeId = IdGenerator.getAndIncrement(),
40+
surname = "ProvEmpSurname",
41+
forename = "ProvEmpForename1",
42+
forename2 = "ProvEmpForename2"
43+
)
1944
}
2045

2146
object LDUGenerator {

0 commit comments

Comments
 (0)