Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit ecfea7d

Browse files
remove addressentryids by creating new response object
1 parent c07ad3e commit ecfea7d

25 files changed

+235
-75
lines changed

demo-ui/app/uk/gov/ons/addressIndex/demoui/views/addressPartial.scala.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@import uk.gov.ons.addressIndex.parsers.Tokens
22
@import java.text.SimpleDateFormat
33

4-
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddress
4+
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddressNonIDS
55

66
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseRelative
77
@(
8-
address: AddressResponseAddress,
8+
address: AddressResponseAddressNonIDS,
99
filter: String,
1010
classification: Option[Map[String, String]],
1111
tokens: Map[String, String] = Map.empty[String, String],

demo-ui/app/uk/gov/ons/addressIndex/demoui/views/addressResult.scala.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
@import uk.gov.ons.addressIndex.parsers.Tokens
33
@import java.text.SimpleDateFormat
44

5-
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddress
5+
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddressNonIDS
66

77
@(
8-
address: AddressResponseAddress,
8+
address: AddressResponseAddressNonIDS,
99
startdate: String,
1010
enddate: String,
1111
classification: Option[Map[String, String]],

demo-ui/app/uk/gov/ons/addressIndex/demoui/views/addressShortForm.scala.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@import uk.gov.ons.addressIndex.parsers.Tokens
22
@import java.text.SimpleDateFormat
33

4-
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddress
4+
@import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddressNonIDS
55

66
@(
7-
address: AddressResponseAddress,
7+
address: AddressResponseAddressNonIDS,
88
filter: String,
99
historical: Boolean,
1010
matchthreshold: Int,

demo-ui/test/uk/gov/ons/addressIndex/demoui/client/AddressIndexClientMock.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AddressIndexClientMock @Inject()(override val client: WSClient, conf: Demo
3131

3232
val mockAddressBySearchResponse: AddressBySearchResponse = AddressBySearchResponse(
3333
tokens = mockAddressTokens,
34-
addresses = Seq(mockAddressResponseAddress: AddressResponseAddress),
34+
addresses = Seq(mockAddressResponseAddress: AddressResponseAddressNonIDS),
3535
limit = 1,
3636
offset = 1,
3737
filter = "",
@@ -51,7 +51,7 @@ class AddressIndexClientMock @Inject()(override val client: WSClient, conf: Demo
5151

5252
val mockAddressByPostcodeResponse: AddressByPostcodeResponse = AddressByPostcodeResponse(
5353
postcode = mockPostcode,
54-
addresses = Seq(mockAddressResponseAddress: AddressResponseAddress),
54+
addresses = Seq(mockAddressResponseAddress: AddressResponseAddressNonIDS),
5555
limit = 1,
5656
offset = 1,
5757
filter = "",
@@ -210,9 +210,7 @@ object AddressIndexClientMock {
210210
unitScoreDebug = "0",
211211
ambiguityPenalty = 1d)
212212

213-
val mockAddressResponseAddress: AddressResponseAddress = AddressResponseAddress(
214-
addressEntryId = "",
215-
addressEntryIdAlphanumericBackup = "",
213+
val mockAddressResponseAddress: AddressResponseAddressNonIDS = AddressResponseAddressNonIDS(
216214
uprn = "",
217215
parentUprn = "",
218216
relatives = Some(Seq(mockRelativeResponse)),
@@ -234,7 +232,7 @@ object AddressIndexClientMock {
234232
)
235233

236234
val mockAddressByUprnResponse: AddressByUprnResponse = AddressByUprnResponse(
237-
address = Some(mockAddressResponseAddress: AddressResponseAddress),
235+
address = Some(mockAddressResponseAddress: AddressResponseAddressNonIDS),
238236
historical = true,
239237
verbose = true,
240238
epoch = "",

demo-ui/test/uk/gov/ons/addressIndex/demoui/utils/RelativesExpanderNoAppTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import uk.gov.ons.addressIndex.demoui.client.AddressIndexClientMock.mockAddressR
1111
import uk.gov.ons.addressIndex.demoui.modules.DemouiConfigModuleMock
1212
import uk.gov.ons.addressIndex.model.AddressIndexUPRNRequest
1313
import uk.gov.ons.addressIndex.model.db.index.{ExpandedRelative, ExpandedSibling}
14-
import uk.gov.ons.addressIndex.model.server.response.address.{AddressResponseAddress, AddressResponseRelative}
15-
import uk.gov.ons.addressIndex.model.server.response.uprn.{AddressByUprnResponse, AddressByUprnResponseContainer}
14+
import uk.gov.ons.addressIndex.model.server.response.address.{AddressResponseAddressNonIDS, AddressResponseRelative}
15+
import uk.gov.ons.addressIndex.model.server.response.uprn.{AddressByUprnResponseNonIDS, AddressByUprnResponseContainer}
1616

1717
import scala.concurrent.{ExecutionContext, Future}
1818

@@ -43,7 +43,7 @@ class RelativesExpanderNoAppTest extends AnyFlatSpec with should.Matchers with M
4343
errors = Seq.empty)
4444
}
4545

46-
private def anAddressResponseFor(uprn: Long)(formattedAddress: String): AddressResponseAddress =
46+
private def anAddressResponseFor(uprn: Long)(formattedAddress: String): AddressResponseAddressNonIDS =
4747
AddressIndexClientMock.mockAddressResponseAddress.copy(uprn = uprn.toString, formattedAddress = formattedAddress)
4848

4949
def aUprnRequest(withUprn: BigInt, withApiKey: String, withHistorical: Boolean): FunctionAdapter2[AddressIndexUPRNRequest, ExecutionContext, Boolean] =

model/src/main/scala/uk/gov/ons/addressIndex/model/server/response/address/AddressBySearchResponse.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import play.api.libs.json.{Format, Json}
1212
* @param total total number of found addresses
1313
*/
1414
case class AddressBySearchResponse(tokens: Map[String, String],
15-
score: AddressResponseScoreSummary,
16-
addresses: Seq[AddressResponseAddress],
15+
addresses: Seq[AddressResponseAddressNonIDS],
16+
recommendationCode: String,
1717
filter: String,
1818
historical: Boolean,
1919
epoch: String,

model/src/main/scala/uk/gov/ons/addressIndex/model/server/response/address/AddressBySearchResponseIDS.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import play.api.libs.json.{Format, Json}
1212
* @param total total number of found addresses
1313
*/
1414
case class AddressBySearchResponseIDS(addresses: Seq[AddressResponseAddressIDS],
15-
matchtype: String
15+
matchtype: String,
16+
recommendationCode: String
1617
)
1718

1819
object AddressBySearchResponseIDS {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package uk.gov.ons.addressIndex.model.server.response.address
2+
3+
import play.api.libs.json.{Format, Json}
4+
import uk.gov.ons.addressIndex.model.db.index._
5+
6+
/**
7+
* Contains address information retrieved in ES (PAF or NAG)
8+
*
9+
* @param uprn uprn
10+
* @param formattedAddress cannonical address form
11+
* @param paf optional, information from Paf index
12+
* @param nag optional, information from Nag index
13+
* @param underlyingScore score from elastic search
14+
*
15+
*/
16+
case class AddressResponseAddressNonIDS(uprn: String,
17+
parentUprn: String,
18+
relatives: Option[Seq[AddressResponseRelative]],
19+
crossRefs: Option[Seq[AddressResponseCrossRef]],
20+
formattedAddress: String,
21+
formattedAddressNag: String,
22+
formattedAddressPaf: String,
23+
welshFormattedAddressNag: String,
24+
welshFormattedAddressPaf: String,
25+
highlights: Option[AddressResponseHighlight],
26+
paf: Option[AddressResponsePaf],
27+
nag: Option[Seq[AddressResponseNag]],
28+
geo: Option[AddressResponseGeo],
29+
classificationCode: String,
30+
countryCode:String,
31+
lpiLogicalStatus: String,
32+
confidenceScore: Double,
33+
underlyingScore: Float
34+
)
35+
36+
object AddressResponseAddressNonIDS {
37+
implicit lazy val addressResponseAddressNonIDSFormat: Format[AddressResponseAddressNonIDS] = Json.format[AddressResponseAddressNonIDS]
38+
39+
def fromAddress(addressIn: AddressResponseAddress): AddressResponseAddressNonIDS = {
40+
new AddressResponseAddressNonIDS(
41+
uprn = addressIn.uprn,
42+
parentUprn = addressIn.parentUprn,
43+
relatives = addressIn.relatives,
44+
crossRefs = addressIn.crossRefs,
45+
formattedAddress = addressIn.formattedAddress,
46+
formattedAddressNag = addressIn.formattedAddressNag,
47+
formattedAddressPaf = addressIn.formattedAddressPaf,
48+
welshFormattedAddressNag = addressIn.welshFormattedAddressNag,
49+
welshFormattedAddressPaf = addressIn.welshFormattedAddressPaf,
50+
highlights= addressIn.highlights,
51+
paf = addressIn.paf,
52+
nag = addressIn.nag,
53+
geo = addressIn.geo,
54+
classificationCode = addressIn.classificationCode,
55+
countryCode = addressIn.countryCode,
56+
lpiLogicalStatus = addressIn.lpiLogicalStatus,
57+
confidenceScore = addressIn.confidenceScore,
58+
underlyingScore = addressIn.underlyingScore
59+
)
60+
}
61+
62+
63+
}
64+
65+
66+

model/src/main/scala/uk/gov/ons/addressIndex/model/server/response/address/AddressResponseScoreSummary.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import play.api.libs.json.{Format, Json}
1212
* @param topMatchConfidenceZone H, M, L
1313
* @param unambiguityScore (best match vs. second best match)
1414
* @param topMatchUnambiguityZone H, M, L
15-
* @param reccomendationCode 1, 2, 3
16-
* @param reccomendationText don't use
15+
* @param recommendationCode A,I
16+
* @param recommendationText needed?
1717
*/
1818
case class AddressResponseScoreSummary(maxConfidenceScore: Double,
1919
maxUnderlyingScore: Double,
@@ -22,8 +22,8 @@ case class AddressResponseScoreSummary(maxConfidenceScore: Double,
2222
topMatchConfidenceZone: String,
2323
unambiguityScore: Double,
2424
topMatchUnambiguityZone: String,
25-
reccomendationCode: String,
26-
reccomendationText: String)
25+
recommendationCode: String,
26+
recommendationText: String)
2727
{
2828
def this() = this(0,0,"",0,"",0,"","","")
2929
}

model/src/main/scala/uk/gov/ons/addressIndex/model/server/response/bulk/AddressBulkResponseAddress.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package uk.gov.ons.addressIndex.model.server.response.bulk
22

33
import play.api.libs.json.{Format, Json}
44
import uk.gov.ons.addressIndex.model.db.BulkAddress
5-
import uk.gov.ons.addressIndex.model.server.response.address.AddressResponseAddress
5+
import uk.gov.ons.addressIndex.model.server.response.address.{AddressResponseAddress, AddressResponseAddressNonIDS}
66

77
/**
88
*
@@ -25,7 +25,7 @@ case class AddressBulkResponseAddress(id: String,
2525
addressEntryId: String,
2626
addressEntryIdAlphanumericBackup: String,
2727
matchedFormattedAddress: String,
28-
matchedAddress: Option[AddressResponseAddress],
28+
matchedAddress: Option[AddressResponseAddressNonIDS],
2929
tokens: Map[String, String],
3030
confidenceScore: Double,
3131
underlyingScore: Float,
@@ -36,7 +36,7 @@ object AddressBulkResponseAddress {
3636
implicit lazy val addressBulkResponseAddressFormat: Format[AddressBulkResponseAddress] = Json.format[AddressBulkResponseAddress]
3737

3838
def fromBulkAddress(bulkAddress: BulkAddress,
39-
addressResponseAddress: AddressResponseAddress,
39+
addressResponseAddress: AddressResponseAddressNonIDS,
4040
includeFullAddress: Boolean
4141
): AddressBulkResponseAddress = AddressBulkResponseAddress(
4242
id = bulkAddress.id,

0 commit comments

Comments
 (0)