diff --git a/projects/create-and-vary-a-licence-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OfficeLocationGenerator.kt b/projects/create-and-vary-a-licence-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OfficeLocationGenerator.kt index 65c7927f9f..001de9b342 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OfficeLocationGenerator.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OfficeLocationGenerator.kt @@ -16,9 +16,10 @@ object OfficeLocationGenerator { description = "Bracknell Office", buildingNumber = "21", streetName = "Some Place", + district = "District 1", town = "Hearth", postcode = "H34 7TH", - district = DISTRICT_BRK + ldu = DISTRICT_BRK ) val LOCATION_BRK_2 = generateLocation( @@ -27,9 +28,10 @@ object OfficeLocationGenerator { buildingNumber = "23", buildingName = "The old hall", streetName = "Another Place", + district = "District 2", town = "Reading", postcode = "RG1 3EH", - district = DISTRICT_BRK + ldu = DISTRICT_BRK ) fun generateDistrict( @@ -41,36 +43,37 @@ object OfficeLocationGenerator { fun generateOfficeAddress( officeLocation: OfficeLocation, - officeDistrict: District + ldu: District ) = OfficeAddress( officeLocation.description, officeLocation.buildingName, officeLocation.buildingNumber, officeLocation.streetName, - officeDistrict.description, + officeLocation.district, officeLocation.townCity, officeLocation.county, officeLocation.postcode, + ldu.description, officeLocation.telephoneNumber, officeLocation.startDate, officeLocation.endDate ) - fun generateLocation(location: OfficeLocation, district: District) = + fun generateLocation(location: OfficeLocation, ldu: District) = OfficeLocation( location.code, location.description, location.buildingName, location.buildingNumber, location.streetName, - location.districtStr, + location.district, location.townCity, location.county, location.postcode, location.telephoneNumber, location.startDate, location.endDate, - district, + ldu, location.id ) @@ -80,14 +83,14 @@ object OfficeLocationGenerator { buildingName: String? = null, buildingNumber: String, streetName: String? = null, - districtStr: String? = null, + district: String? = null, town: String? = null, county: String? = null, postcode: String? = null, telephoneNumber: String? = null, startDate: LocalDate = LocalDate.now(), endDate: LocalDate? = null, - district: District, + ldu: District, id: Long = IdGenerator.getAndIncrement() ) = OfficeLocation( code, @@ -95,14 +98,14 @@ object OfficeLocationGenerator { buildingName, buildingNumber, streetName, - districtStr, + district, town, county, postcode, telephoneNumber, startDate, endDate, - district, + ldu, id ) } diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/OfficeAddress.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/OfficeAddress.kt index 9b7cdc84e4..3e40072480 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/OfficeAddress.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/OfficeAddress.kt @@ -11,6 +11,7 @@ data class OfficeAddress( val town: String?, val county: String?, val postcode: String?, + val ldu: String, val telephoneNumber: String?, val from: LocalDate, val to: LocalDate? diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Provider.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Provider.kt index a21120ebac..9a322e271d 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Provider.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Provider.kt @@ -123,10 +123,7 @@ class OfficeLocation( val buildingName: String?, val buildingNumber: String?, val streetName: String?, - - @Column(name = "district") - val districtStr: String?, - + val district: String?, val townCity: String?, val county: String?, val postcode: String?, @@ -136,7 +133,7 @@ class OfficeLocation( @JoinColumn(name = "district_id") @ManyToOne - val district: District, + val ldu: District, @Id @Column(name = "office_location_id") @@ -148,7 +145,7 @@ interface OfficeLocationRepository : JpaRepository { """ select ol from OfficeLocation ol where lower(ol.description) like lower(concat('%',:officeName,'%')) - and lower(ol.district.description) like lower(concat('%',:ldu,'%')) + and lower(ol.ldu.description) like lower(concat('%',:ldu,'%')) and (ol.endDate is null or ol.endDate > current_date) order by ol.description """ diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OfficeAddressService.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OfficeAddressService.kt index e146cce7d9..f8c4c89646 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OfficeAddressService.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OfficeAddressService.kt @@ -15,10 +15,11 @@ class OfficeAddressService(private val officeLocationRepository: OfficeLocationR it.buildingName, it.buildingNumber, it.streetName, - it.district.description, + it.district, it.townCity, it.county, it.postcode, + it.ldu.description, it.telephoneNumber, it.startDate, it.endDate