Skip to content

Commit

Permalink
Updates following review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS committed Jan 23, 2024
1 parent cb4a421 commit 6154958
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/main/java/uk/gov/hmcts/opal/dto/AccountSearchDto.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -31,10 +32,10 @@ public class AccountSearchDto implements ToJsonString {
/** Unsure. */
private String tillNumber;

public Long getNumericCourt() {
@JsonIgnore
public Optional<Long> getNumericCourt() {
return Optional.ofNullable(getCourt())
.filter(s -> s.matches("[0-9]+"))
.map(Long::parseLong)
.orElse(null);
.map(Long::parseLong);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Specification<DefendantAccountEntity> 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)
));
}

Expand Down

0 comments on commit 6154958

Please sign in to comment.