Skip to content

Commit 84362b6

Browse files
PRC-439: Sync CRUD for organisation phone numbers, emails, addresses, and web addresses (#11)
* PRC-439: Sync phone components and tests * PRC-439: Sync for organisation phone numbers * PRC-439: Adding sync CRUD for email and web addresses * PRC-439: Added integration tests for email and web address sync * PRC-439: Adding organisation address sync
1 parent aa14e3a commit 84362b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4825
-32
lines changed

helm_deploy/hmpps-organisations-api/values.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ generic-service:
2727
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_CREATED: true
2828
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_UPDATED: true
2929
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_DELETED: true
30+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_PHONE_CREATED: true
31+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_PHONE_UPDATED: true
32+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_PHONE_DELETED: true
33+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_WEB_CREATED: true
34+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_WEB_UPDATED: true
35+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_WEB_DELETED: true
36+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_EMAIL_CREATED: true
37+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_EMAIL_UPDATED: true
38+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_EMAIL_DELETED: true
39+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_ADDRESS_CREATED: true
40+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_ADDRESS_UPDATED: true
41+
FEATURE_EVENT_ORGANISATIONS_API_ORGANISATION_ADDRESS_DELETED: true
42+
3043

3144
# Pre-existing kubernetes secrets to load as environment variables in the deployment.
3245
# namespace_secrets:

helm_deploy/values-prod.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ generic-service:
77

88
env:
99
API_BASE_URL_HMPPS_AUTH: "https://sign-in.hmpps.service.justice.gov.uk/auth"
10+
FEATURE_EVENTS_SNS_ENABLED: false
1011

1112
# CloudPlatform AlertManager receiver to route prometheus alerts to slack
1213
# See https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts

src/main/kotlin/uk/gov/justice/digital/hmpps/organisationsapi/entity/OrganisationAddressEntity.kt

+17-17
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data class OrganisationAddressEntity(
1818

1919
val organisationId: Long,
2020

21-
val addressType: String?,
21+
val addressType: String? = null,
2222

2323
val primaryAddress: Boolean,
2424

@@ -28,41 +28,41 @@ data class OrganisationAddressEntity(
2828

2929
val noFixedAddress: Boolean,
3030

31-
val flat: String?,
31+
val flat: String? = null,
3232

33-
val property: String?,
33+
val property: String? = null,
3434

35-
val street: String?,
35+
val street: String? = null,
3636

37-
val area: String?,
37+
val area: String? = null,
3838

39-
val cityCode: String?,
39+
val cityCode: String? = null,
4040

41-
val countyCode: String?,
41+
val countyCode: String? = null,
4242

43-
val postCode: String?,
43+
val postCode: String? = null,
4444

45-
val countryCode: String?,
45+
val countryCode: String? = null,
4646

47-
val specialNeedsCode: String?,
47+
val specialNeedsCode: String? = null,
4848

49-
val contactPersonName: String?,
49+
val contactPersonName: String? = null,
5050

51-
val businessHours: String?,
51+
val businessHours: String? = null,
5252

53-
val comments: String?,
53+
val comments: String? = null,
5454

55-
val startDate: LocalDate?,
55+
val startDate: LocalDate? = null,
5656

57-
val endDate: LocalDate?,
57+
val endDate: LocalDate? = null,
5858

5959
@Column(updatable = false)
6060
val createdBy: String,
6161

6262
@Column(updatable = false)
6363
val createdTime: LocalDateTime,
6464

65-
val updatedBy: String?,
65+
val updatedBy: String? = null,
6666

67-
val updatedTime: LocalDateTime?,
67+
val updatedTime: LocalDateTime? = null,
6868
)

src/main/kotlin/uk/gov/justice/digital/hmpps/organisationsapi/entity/OrganisationEmailEntity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class OrganisationEmailEntity(
2525
@Column(updatable = false)
2626
val createdTime: LocalDateTime,
2727

28-
val updatedBy: String?,
28+
val updatedBy: String? = null,
2929

30-
val updatedTime: LocalDateTime?,
30+
val updatedTime: LocalDateTime? = null,
3131
)

src/main/kotlin/uk/gov/justice/digital/hmpps/organisationsapi/entity/OrganisationPhoneEntity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data class OrganisationPhoneEntity(
2929
@Column(updatable = false)
3030
val createdTime: LocalDateTime,
3131

32-
val updatedBy: String?,
32+
val updatedBy: String? = null,
3333

34-
val updatedTime: LocalDateTime?,
34+
val updatedTime: LocalDateTime? = null,
3535
)

src/main/kotlin/uk/gov/justice/digital/hmpps/organisationsapi/entity/OrganisationWebAddressEntity.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data class OrganisationWebAddressEntity(
2525
@Column(updatable = false)
2626
val createdTime: LocalDateTime,
2727

28-
val updatedBy: String?,
28+
val updatedBy: String? = null,
2929

30-
val updatedTime: LocalDateTime?,
30+
val updatedTime: LocalDateTime? = null,
3131
)

src/main/kotlin/uk/gov/justice/digital/hmpps/organisationsapi/facade/SyncFacade.kt

+165-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
package uk.gov.justice.digital.hmpps.organisationsapi.facade
22

33
import org.springframework.stereotype.Service
4+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncCreateAddressRequest
5+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncCreateEmailRequest
46
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncCreateOrganisationRequest
7+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncCreatePhoneRequest
8+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncCreateWebRequest
9+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncUpdateAddressRequest
10+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncUpdateEmailRequest
511
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncUpdateOrganisationRequest
12+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncUpdatePhoneRequest
13+
import uk.gov.justice.digital.hmpps.organisationsapi.model.request.sync.SyncUpdateWebRequest
614
import uk.gov.justice.digital.hmpps.organisationsapi.service.events.OutboundEvent
715
import uk.gov.justice.digital.hmpps.organisationsapi.service.events.OutboundEventsService
816
import uk.gov.justice.digital.hmpps.organisationsapi.service.events.Source
17+
import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncAddressService
18+
import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncEmailService
919
import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncOrganisationService
20+
import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncPhoneService
21+
import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncWebService
1022

1123
/**
1224
* This class is a facade over the sync services as a thin layer
@@ -28,16 +40,20 @@ import uk.gov.justice.digital.hmpps.organisationsapi.service.sync.SyncOrganisati
2840

2941
@Service
3042
class SyncFacade(
31-
private val syncService: SyncOrganisationService,
43+
private val syncOrganisationService: SyncOrganisationService,
44+
private val syncPhoneService: SyncPhoneService,
45+
private val syncEmailService: SyncEmailService,
46+
private val syncWebService: SyncWebService,
47+
private val syncAddressService: SyncAddressService,
3248
private val outboundEventsService: OutboundEventsService,
3349
) {
3450
// ================================================================
3551
// Organisations
3652
// ================================================================
3753

38-
fun getOrganisationById(organisationId: Long) = syncService.getOrganisationById(organisationId)
54+
fun getOrganisationById(organisationId: Long) = syncOrganisationService.getOrganisationById(organisationId)
3955

40-
fun createOrganisation(request: SyncCreateOrganisationRequest) = syncService.createOrganisation(request)
56+
fun createOrganisation(request: SyncCreateOrganisationRequest) = syncOrganisationService.createOrganisation(request)
4157
.also {
4258
outboundEventsService.send(
4359
outboundEvent = OutboundEvent.ORGANISATION_CREATED,
@@ -47,7 +63,7 @@ class SyncFacade(
4763
)
4864
}
4965

50-
fun updateOrganisation(organisationId: Long, request: SyncUpdateOrganisationRequest) = syncService.updateOrganisation(organisationId, request)
66+
fun updateOrganisation(organisationId: Long, request: SyncUpdateOrganisationRequest) = syncOrganisationService.updateOrganisation(organisationId, request)
5167
.also {
5268
outboundEventsService.send(
5369
outboundEvent = OutboundEvent.ORGANISATION_UPDATED,
@@ -57,7 +73,7 @@ class SyncFacade(
5773
)
5874
}
5975

60-
fun deleteOrganisation(organisationId: Long) = syncService.deleteOrganisation(organisationId)
76+
fun deleteOrganisation(organisationId: Long) = syncOrganisationService.deleteOrganisation(organisationId)
6177
.also {
6278
outboundEventsService.send(
6379
outboundEvent = OutboundEvent.ORGANISATION_DELETED,
@@ -66,4 +82,148 @@ class SyncFacade(
6682
source = Source.NOMIS,
6783
)
6884
}
85+
86+
// ================================================================
87+
// Organisation phone numbers
88+
// ================================================================
89+
90+
fun getPhoneById(organisationPhoneId: Long) = syncPhoneService.getPhoneById(organisationPhoneId)
91+
92+
fun createPhone(request: SyncCreatePhoneRequest) = syncPhoneService.createPhone(request)
93+
.also {
94+
outboundEventsService.send(
95+
outboundEvent = OutboundEvent.ORGANISATION_PHONE_CREATED,
96+
organisationId = it.organisationId,
97+
identifier = it.organisationPhoneId,
98+
source = Source.NOMIS,
99+
)
100+
}
101+
102+
fun updatePhone(organisationPhoneId: Long, request: SyncUpdatePhoneRequest) = syncPhoneService.updatePhone(organisationPhoneId, request)
103+
.also {
104+
outboundEventsService.send(
105+
outboundEvent = OutboundEvent.ORGANISATION_PHONE_UPDATED,
106+
organisationId = it.organisationId,
107+
identifier = it.organisationPhoneId,
108+
source = Source.NOMIS,
109+
)
110+
}
111+
112+
fun deletePhone(organisationPhoneId: Long) = syncPhoneService.deletePhone(organisationPhoneId)
113+
.also {
114+
outboundEventsService.send(
115+
outboundEvent = OutboundEvent.ORGANISATION_PHONE_DELETED,
116+
organisationId = it.organisationId,
117+
identifier = it.organisationPhoneId,
118+
source = Source.NOMIS,
119+
)
120+
}
121+
122+
// ================================================================
123+
// Organisation email
124+
// ================================================================
125+
126+
fun getEmailById(organisationEmailId: Long) = syncEmailService.getEmailById(organisationEmailId)
127+
128+
fun createEmail(request: SyncCreateEmailRequest) = syncEmailService.createEmail(request)
129+
.also {
130+
outboundEventsService.send(
131+
outboundEvent = OutboundEvent.ORGANISATION_EMAIL_CREATED,
132+
organisationId = it.organisationId,
133+
identifier = it.organisationEmailId,
134+
source = Source.NOMIS,
135+
)
136+
}
137+
138+
fun updateEmail(organisationEmailId: Long, request: SyncUpdateEmailRequest) = syncEmailService.updateEmail(organisationEmailId, request)
139+
.also {
140+
outboundEventsService.send(
141+
outboundEvent = OutboundEvent.ORGANISATION_EMAIL_UPDATED,
142+
organisationId = it.organisationId,
143+
identifier = it.organisationEmailId,
144+
source = Source.NOMIS,
145+
)
146+
}
147+
148+
fun deleteEmail(organisationEmailId: Long) = syncEmailService.deleteEmail(organisationEmailId)
149+
.also {
150+
outboundEventsService.send(
151+
outboundEvent = OutboundEvent.ORGANISATION_EMAIL_DELETED,
152+
organisationId = it.organisationId,
153+
identifier = it.organisationEmailId,
154+
source = Source.NOMIS,
155+
)
156+
}
157+
158+
// ================================================================
159+
// Organisation web address
160+
// ================================================================
161+
162+
fun getWebById(organisationWebId: Long) = syncWebService.getWebAddressById(organisationWebId)
163+
164+
fun createWeb(request: SyncCreateWebRequest) = syncWebService.createWeb(request)
165+
.also {
166+
outboundEventsService.send(
167+
outboundEvent = OutboundEvent.ORGANISATION_WEB_CREATED,
168+
organisationId = it.organisationId,
169+
identifier = it.organisationWebAddressId,
170+
source = Source.NOMIS,
171+
)
172+
}
173+
174+
fun updateWeb(organisationWebId: Long, request: SyncUpdateWebRequest) = syncWebService.updateWeb(organisationWebId, request)
175+
.also {
176+
outboundEventsService.send(
177+
outboundEvent = OutboundEvent.ORGANISATION_WEB_UPDATED,
178+
organisationId = it.organisationId,
179+
identifier = it.organisationWebAddressId,
180+
source = Source.NOMIS,
181+
)
182+
}
183+
184+
fun deleteWeb(organisationWebId: Long) = syncWebService.deleteWeb(organisationWebId)
185+
.also {
186+
outboundEventsService.send(
187+
outboundEvent = OutboundEvent.ORGANISATION_WEB_DELETED,
188+
organisationId = it.organisationId,
189+
identifier = it.organisationWebAddressId,
190+
source = Source.NOMIS,
191+
)
192+
}
193+
194+
// ================================================================
195+
// Organisation address
196+
// ================================================================
197+
198+
fun getAddressById(organisationAddressId: Long) = syncAddressService.getAddressById(organisationAddressId)
199+
200+
fun createAddress(request: SyncCreateAddressRequest) = syncAddressService.createAddress(request)
201+
.also {
202+
outboundEventsService.send(
203+
outboundEvent = OutboundEvent.ORGANISATION_ADDRESS_CREATED,
204+
organisationId = it.organisationId,
205+
identifier = it.organisationAddressId,
206+
source = Source.NOMIS,
207+
)
208+
}
209+
210+
fun updateAddress(organisationAddressId: Long, request: SyncUpdateAddressRequest) = syncAddressService.updateAddress(organisationAddressId, request)
211+
.also {
212+
outboundEventsService.send(
213+
outboundEvent = OutboundEvent.ORGANISATION_ADDRESS_UPDATED,
214+
organisationId = it.organisationId,
215+
identifier = it.organisationAddressId,
216+
source = Source.NOMIS,
217+
)
218+
}
219+
220+
fun deleteAddress(organisationAddressId: Long) = syncAddressService.deleteAddress(organisationAddressId)
221+
.also {
222+
outboundEventsService.send(
223+
outboundEvent = OutboundEvent.ORGANISATION_ADDRESS_DELETED,
224+
organisationId = it.organisationId,
225+
identifier = it.organisationAddressId,
226+
source = Source.NOMIS,
227+
)
228+
}
69229
}

0 commit comments

Comments
 (0)