Skip to content

Commit

Permalink
Corrected district and added ldu to model (#2980)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 authored Jan 4, 2024
1 parent 3ce51fa commit d7f2395
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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
)

Expand All @@ -80,29 +83,29 @@ 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,
description,
buildingName,
buildingNumber,
streetName,
districtStr,
district,
town,
county,
postcode,
telephoneNumber,
startDate,
endDate,
district,
ldu,
id
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -136,7 +133,7 @@ class OfficeLocation(

@JoinColumn(name = "district_id")
@ManyToOne
val district: District,
val ldu: District,

@Id
@Column(name = "office_location_id")
Expand All @@ -148,7 +145,7 @@ interface OfficeLocationRepository : JpaRepository<OfficeLocation, Long> {
"""
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
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7f2395

Please sign in to comment.