Skip to content

Commit cbaaa79

Browse files
1 parent dc1d7b4 commit cbaaa79

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/entity/BreachNoticeEntity.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ data class BreachNoticeEntity(
4040
var nextAppointmentDate: LocalDateTime? = null,
4141
var nextAppointmentLocation: String? = null,
4242
var nextAppointmentOfficer: String? = null,
43-
@OneToOne(cascade = [CascadeType.ALL], orphanRemoval = true)
44-
@JoinColumn(name = "next_appointment_contact_id", unique = true)
45-
var nextAppointmentContact: BreachNoticeContactEntity? = null,
43+
var nextAppointmentId: Long? = null,
4644
var completedDate: LocalDateTime? = null,
4745
@CreatedBy
4846
var createdByUser: String? = null,
@@ -68,4 +66,6 @@ data class BreachNoticeEntity(
6866
val breachNoticeContactList: List<BreachNoticeContactEntity> = emptyList(),
6967
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, mappedBy = "breachNotice")
7068
val breachNoticeRequirementList: List<BreachNoticeRequirementEntity> = emptyList(),
69+
var optionalNumberChecked: Boolean? = null,
70+
var optionalNumber: String? = null,
7171
)

src/main/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/model/BreachNotice.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data class BreachNotice(
2323
val nextAppointmentDate: LocalDateTime? = null,
2424
val nextAppointmentLocation: String? = null,
2525
val nextAppointmentOfficer: String? = null,
26-
val nextAppointmentContact: BreachNoticeContact? = null,
26+
val nextAppointmentId: Long? = null,
2727
val completedDate: LocalDateTime? = null,
2828
val offenderAddress: Address? = null,
2929
val replyAddress: Address? = null,
@@ -37,4 +37,6 @@ data class BreachNotice(
3737
val breachNoticeContactList: List<BreachNoticeContact> = emptyList(),
3838
@field:JsonSetter(nulls = Nulls.AS_EMPTY)
3939
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
40+
val optionalNumberChecked: Boolean? = null,
41+
val optionalNumber: String? = null,
4042
)

src/main/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/model/BreachNoticeDetails.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class BreachNoticeDetails(
2525
val nextAppointmentDate: LocalDateTime? = null,
2626
val nextAppointmentLocation: String? = null,
2727
val nextAppointmentOfficer: String? = null,
28-
val nextAppointmentContact: BreachNoticeContact? = null,
28+
val nextAppointmentId: Long? = null,
2929
val completedDate: LocalDateTime? = null,
3030
val offenderAddress: Address? = null,
3131
val replyAddress: Address? = null,
@@ -39,4 +39,6 @@ data class BreachNoticeDetails(
3939
val breachNoticeContactList: List<BreachNoticeContact> = emptyList(),
4040
@field:JsonSetter(nulls = Nulls.AS_EMPTY)
4141
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
42+
val optionalNumberChecked: Boolean? = null,
43+
val optionalNumber: String? = null,
4244
)

src/main/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/service/BreachNoticeService.kt

+10-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BreachNoticeService(
7070
nextAppointmentDate = nextAppointmentDate,
7171
nextAppointmentLocation = nextAppointmentLocation,
7272
nextAppointmentOfficer = nextAppointmentOfficer,
73-
nextAppointmentContact = nextAppointmentContact?.toEntity(existingEntity.nextAppointmentContact),
73+
nextAppointmentId = nextAppointmentId,
7474
completedDate = completedDate,
7575
offenderAddress = offenderAddress?.toEntity(existingEntity.offenderAddress),
7676
replyAddress = replyAddress?.toEntity(existingEntity.replyAddress),
@@ -115,7 +115,7 @@ class BreachNoticeService(
115115
nextAppointmentDate = nextAppointmentDate,
116116
nextAppointmentLocation = nextAppointmentLocation,
117117
nextAppointmentOfficer = nextAppointmentOfficer,
118-
nextAppointmentContact = nextAppointmentContact?.toEntity(),
118+
nextAppointmentId = nextAppointmentId,
119119
completedDate = completedDate,
120120
offenderAddress = offenderAddress?.toEntity(),
121121
replyAddress = replyAddress?.toEntity(),
@@ -125,6 +125,8 @@ class BreachNoticeService(
125125
nextAppointmentSaved = nextAppointmentSaved,
126126
useDefaultAddress = useDefaultAddress,
127127
useDefaultReplyAddress = useDefaultReplyAddress,
128+
optionalNumberChecked = optionalNumberChecked,
129+
optionalNumber = optionalNumber,
128130
breachNoticeRequirementList = breachNoticeRequirementList.map { it.toEntity() },
129131
breachNoticeContactList = breachNoticeContactList.map { it.toEntity() },
130132
)
@@ -148,7 +150,7 @@ class BreachNoticeService(
148150
nextAppointmentDate = nextAppointmentDate,
149151
nextAppointmentLocation = nextAppointmentLocation,
150152
nextAppointmentOfficer = nextAppointmentOfficer,
151-
nextAppointmentContact = nextAppointmentContact?.toModel(),
153+
nextAppointmentId = nextAppointmentId,
152154
completedDate = completedDate,
153155
offenderAddress = offenderAddress?.toModel(),
154156
replyAddress = replyAddress?.toModel(),
@@ -160,6 +162,8 @@ class BreachNoticeService(
160162
useDefaultReplyAddress = useDefaultReplyAddress,
161163
breachNoticeContactList = breachNoticeContactList.map { it.toModel() },
162164
breachNoticeRequirementList = breachNoticeRequirementList.map { it.toModel() },
165+
optionalNumberChecked = optionalNumberChecked,
166+
optionalNumber = optionalNumber,
163167
)
164168

165169
fun getBreachNoticeById(uuid: UUID) = breachNoticeRepository.findById(uuid).getOrNull()?.let {
@@ -182,6 +186,7 @@ class BreachNoticeService(
182186
nextAppointmentDate = it.nextAppointmentDate,
183187
nextAppointmentLocation = it.nextAppointmentLocation,
184188
nextAppointmentOfficer = it.nextAppointmentOfficer,
189+
nextAppointmentId = it.nextAppointmentId,
185190
completedDate = it.completedDate,
186191
offenderAddress = it.offenderAddress?.toModel(),
187192
replyAddress = it.replyAddress?.toModel(),
@@ -193,7 +198,8 @@ class BreachNoticeService(
193198
useDefaultReplyAddress = it.useDefaultReplyAddress,
194199
breachNoticeContactList = it.breachNoticeContactList.map { it.toModel() },
195200
breachNoticeRequirementList = it.breachNoticeRequirementList.map { it.toModel() },
196-
201+
optionalNumberChecked = it.optionalNumberChecked,
202+
optionalNumber = it.optionalNumber,
197203
)
198204
}
199205

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE public.breach_notice DROP CONSTRAINT xfk1_breach_notice_contact;
2+
ALTER TABLE public.breach_notice DROP COLUMN next_appointment_contact_id;
3+
ALTER TABLE public.breach_notice ADD optional_number_checked boolean NULL;
4+
ALTER TABLE public.breach_notice ADD optional_number varchar(255) NULL;
5+
ALTER TABLE public.breach_notice ADD next_appointment_id integer NULL;
6+

src/test/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/integration/BreachNoticeCrudTests.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BreachNoticeCrudTests : IntegrationTestBase() {
6464
nextAppointmentDate = LocalDateTime.now(),
6565
nextAppointmentLocation = "NXT_LOCATION",
6666
nextAppointmentOfficer = "APPT_OFFICER",
67-
nextAppointmentContact = null,
67+
nextAppointmentId = null,
6868
completedDate = LocalDateTime.now(),
6969
offenderAddress = Address(
7070
addressId = 25,
@@ -143,7 +143,7 @@ class BreachNoticeCrudTests : IntegrationTestBase() {
143143
nextAppointmentDate = LocalDateTime.now(),
144144
nextAppointmentLocation = "NXT_LOCATION",
145145
nextAppointmentOfficer = "APPT_OFFICER",
146-
nextAppointmentContact = null,
146+
nextAppointmentId = null,
147147
completedDate = LocalDateTime.now(),
148148
offenderAddress = Address(
149149
addressId = 25,

0 commit comments

Comments
 (0)