started to add string filter support

This commit is contained in:
2019-10-24 11:12:39 +01:00
parent 103b8348d0
commit 571386046d

View File

@ -442,11 +442,28 @@ public abstract class CommonAbstractController {
break;
case NOT_EQUAL:
predicate = cb.isNotNull(path);
break;
default:
throw new ControllerException(ControllerException.INTERNAL_ERROR, currentFilter.getComparator() + " not supported for searchValue null");
}
returnCondition = addFilterCondition(cb, returnCondition, predicate);
} else if (currentFilter.getSearchValue() instanceof String) {
String searchValue = (String) currentFilter.getSearchValue();
String wildCard = "%";
Predicate predicate;
switch (currentFilter.getComparator()) {
case EQUAL:
predicate = cb.equal(path, searchValue);
break;
case NOT_EQUAL:
predicate = cb.notEqual(path, searchValue);
break;
case CONTAINS:
String likeValue = wildCard + searchValue.toUpperCase(Locale.US) + wildCard;
predicate = cb.like(cb.upper(path), likeValue, '\\');
break;
default:
throw new ControllerException(ControllerException.INTERNAL_ERROR, currentFilter.getComparator() + "not support for searchValue " + searchValue);
}
} else {
throw new ControllerException(ControllerException.INTERNAL_ERROR, "Not yet implemented");
}