Skip to content

Commit

Permalink
Refactor: Updated Doctor and Patient specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
elwyncrestha committed Jul 15, 2020
1 parent dadaec7 commit 1b48c17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Predicate toPredicate(Root<Doctor> root, CriteriaQuery<?> criteriaQuery,
CriteriaBuilder criteriaBuilder) {
switch (property) {
case FILTER_BY_NAME:
return criteriaBuilder.equal(root.join("user").get("name"), value.toLowerCase());
return criteriaBuilder.like(root.join("user").get("name"), "%" + value.toLowerCase() + "%");
case FILTER_BY_USER_ID:
return criteriaBuilder.equal(root.join("user").get("id"), Long.valueOf(value));
case FILTER_BY_DEPARTMENT_ID:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class PatientSpec implements Specification<Patient> {

private static final String FILTER_BY_USER_ID = "user.id";
private static final String FILTER_BY_NAME = "user.name";

private final String property;
private final String value;
Expand All @@ -30,6 +31,8 @@ public Predicate toPredicate(Root<Patient> root, CriteriaQuery<?> criteriaQuery,
switch (property) {
case FILTER_BY_USER_ID:
return criteriaBuilder.equal(root.join("user").get("id"), Long.valueOf(value));
case FILTER_BY_NAME:
return criteriaBuilder.like(root.join("user").get("name"), "%" + value.toLowerCase() + "%");
default:
return null;
}
Expand Down

0 comments on commit 1b48c17

Please sign in to comment.