generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter Courts reference data by business unit
- Loading branch information
1 parent
eee1f7e
commit 209f172
Showing
16 changed files
with
149 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/java/uk/gov/hmcts/opal/entity/projection/CourtReferenceData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package uk.gov.hmcts.opal.entity.projection; | ||
|
||
public record CourtReferenceData(Long courtId, Short courtCode, String name, String nameCy, String nationalCourtCode) { | ||
public record CourtReferenceData(Long courtId, Short businessUnitId, Short courtCode, String name, | ||
String nameCy, String nationalCourtCode) { | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/uk/gov/hmcts/opal/repository/jpa/AddressCySpecs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package uk.gov.hmcts.opal.repository.jpa; | ||
|
||
import org.springframework.data.jpa.domain.Specification; | ||
import uk.gov.hmcts.opal.dto.search.AddressCySearch; | ||
import uk.gov.hmcts.opal.entity.AddressCyEntity; | ||
import uk.gov.hmcts.opal.entity.AddressCyEntity_; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
|
||
public abstract class AddressCySpecs<E extends AddressCyEntity> extends AddressSpecs<E> { | ||
|
||
@SuppressWarnings("unchecked") | ||
public List<Optional<Specification<E>>> findByBaseCourtCriteria(AddressCySearch criteria) { | ||
return combine(findByAddressCriteria(criteria), | ||
notBlank(criteria.getNameCy()).map(this::likeNameCy), | ||
notBlank(criteria.getAddressLineCy()).map(this::likeAnyAddressLineCy)); | ||
} | ||
|
||
public Specification<E> likeNameCy(String nameCy) { | ||
return (root, query, builder) -> | ||
likeWildcardPredicate(root.get(AddressCyEntity_.nameCy), builder, nameCy); | ||
} | ||
|
||
public Specification<E> likeAnyAddressLineCy(String addressLine) { | ||
String addressLinePattern = "%" + addressLine.toLowerCase() + "%"; | ||
return Specification.anyOf( | ||
likeAddressLine1Cy(addressLinePattern), | ||
likeAddressLine2Cy(addressLinePattern), | ||
likeAddressLine3Cy(addressLinePattern)); | ||
} | ||
|
||
private Specification<E> likeAddressLine1Cy(String addressLinePattern) { | ||
return (root, query, builder) -> | ||
likeLowerCasePredicate(root.get(AddressCyEntity_.addressLine1Cy), builder, addressLinePattern); | ||
} | ||
|
||
private Specification<E> likeAddressLine2Cy(String addressLinePattern) { | ||
return (root, query, builder) -> | ||
likeLowerCasePredicate(root.get(AddressCyEntity_.addressLine2Cy), builder, addressLinePattern); | ||
} | ||
|
||
private Specification<E> likeAddressLine3Cy(String addressLinePattern) { | ||
return (root, query, builder) -> | ||
likeLowerCasePredicate(root.get(AddressCyEntity_.addressLine3Cy), builder, addressLinePattern); | ||
} | ||
} |
65 changes: 0 additions & 65 deletions
65
src/main/java/uk/gov/hmcts/opal/repository/jpa/BaseCourtSpecs.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.