From 6154958359ad02da3d9c90e46c252a2ef12ef57b Mon Sep 17 00:00:00 2001 From: Russell Dodd Date: Tue, 23 Jan 2024 09:32:30 +0000 Subject: [PATCH] Updates following review comments --- .../uk/gov/hmcts/opal/dto/AccountSearchDto.java | 7 ++++--- .../legacy/DefendantAccountSearchCriteria.java | 16 ++-------------- .../repository/jpa/DefendantAccountSpecs.java | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/opal/dto/AccountSearchDto.java b/src/main/java/uk/gov/hmcts/opal/dto/AccountSearchDto.java index d4aeb55c5..5e6d46147 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/AccountSearchDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/AccountSearchDto.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.opal.dto; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Builder; import lombok.Data; import java.util.Optional; @@ -31,10 +32,10 @@ public class AccountSearchDto implements ToJsonString { /** Unsure. */ private String tillNumber; - public Long getNumericCourt() { + @JsonIgnore + public Optional getNumericCourt() { return Optional.ofNullable(getCourt()) .filter(s -> s.matches("[0-9]+")) - .map(Long::parseLong) - .orElse(null); + .map(Long::parseLong); } } diff --git a/src/main/java/uk/gov/hmcts/opal/dto/legacy/DefendantAccountSearchCriteria.java b/src/main/java/uk/gov/hmcts/opal/dto/legacy/DefendantAccountSearchCriteria.java index e30c26953..0e23824eb 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/legacy/DefendantAccountSearchCriteria.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/legacy/DefendantAccountSearchCriteria.java @@ -15,52 +15,40 @@ @Builder @NoArgsConstructor @AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) public class DefendantAccountSearchCriteria implements ToJsonString { - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("account_number") private String accountNumber; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("business_unit_id") private Long businessUnitId; - @JsonInclude(JsonInclude.Include.NON_NULL) private Boolean organisation; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("organisation_name") private String organisationName; - @JsonInclude(JsonInclude.Include.NON_NULL) private String surname; - @JsonInclude(JsonInclude.Include.NON_NULL) private String forenames; - @JsonInclude(JsonInclude.Include.NON_NULL) private String initials; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("birth_date") private String birthDate; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("national_insurance_number") private String nationalInsuranceNumber; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("prosecutor_case_reference") private String prosecutorCaseReference; - @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("address_line_1") private String addressLine1; - @JsonInclude(JsonInclude.Include.NON_NULL) private Boolean searchAliases; - @JsonInclude(JsonInclude.Include.NON_NULL) private Boolean liveOnly; private Integer firstRowNumber; @@ -77,7 +65,7 @@ public static DefendantAccountSearchCriteria fromAccountSearchDto(AccountSearchD .addressLine1(dto.getAddressLineOne()) .nationalInsuranceNumber(dto.getNiNumber()) .prosecutorCaseReference(dto.getPcr()) - .businessUnitId(dto.getNumericCourt()) + .businessUnitId(dto.getNumericCourt().orElse(null)) //.organisation_name(no organisation name) //.searchAliases( dunno ) //.liveOnly( dunno ) diff --git a/src/main/java/uk/gov/hmcts/opal/repository/jpa/DefendantAccountSpecs.java b/src/main/java/uk/gov/hmcts/opal/repository/jpa/DefendantAccountSpecs.java index 20dfa919d..d34924026 100644 --- a/src/main/java/uk/gov/hmcts/opal/repository/jpa/DefendantAccountSpecs.java +++ b/src/main/java/uk/gov/hmcts/opal/repository/jpa/DefendantAccountSpecs.java @@ -32,7 +32,7 @@ public static Specification findByAccountSearch(AccountS notBlank(accountSearchDto.getNiNumber()).map(DefendantAccountSpecs::likeNiNumber), notBlank(accountSearchDto.getAddressLineOne()).map(DefendantAccountSpecs::likeAddressLine1), notNullLocalDate(accountSearchDto.getDateOfBirth()).map(DefendantAccountSpecs::equalsDateOfBirth), - Optional.ofNullable(accountSearchDto.getNumericCourt()).map(DefendantAccountSpecs::equalsAnyCourtId) + accountSearchDto.getNumericCourt().map(DefendantAccountSpecs::equalsAnyCourtId) )); }