EDQS - ignore case for name and not ignore for filters

This commit is contained in:
Volodymyr Babak 2025-06-17 17:32:04 +03:00
parent 969b0fec00
commit b0a8b9fc25

View File

@ -324,14 +324,19 @@ public class RepositoryUtils {
public static Pattern toEntityNameSqlLikePattern(String filter) {
if (StringUtils.isNotBlank(filter)) {
return toSqlLikePattern(filter, "", ".*");
return toSqlLikePattern(filter, "", ".*", true);
}
return null;
}
private static Pattern toSqlLikePattern(String value, String prefix, String suffix) {
return toSqlLikePattern(value, prefix, suffix, false);
}
private static Pattern toSqlLikePattern(String value, String prefix, String suffix, boolean ignoreCase) {
String regexValue;
if (value.contains("%") || value.contains("_")) {
String regexValue = value
regexValue = value
.replace("_", ".")
.replace("%", ".*");
if ("^".equals(prefix)) {
@ -339,10 +344,10 @@ public class RepositoryUtils {
} else if ("$".equals(suffix)) {
regexValue = (regexValue.startsWith(".*") ? "" : ".*") + regexValue + "$";
}
return Pattern.compile(regexValue, Pattern.CASE_INSENSITIVE);
} else {
return Pattern.compile(prefix + Pattern.quote(value) + suffix, Pattern.CASE_INSENSITIVE);
regexValue = prefix + Pattern.quote(value) + suffix;
}
return ignoreCase ? Pattern.compile(regexValue, Pattern.CASE_INSENSITIVE) : Pattern.compile(regexValue);
}
@FunctionalInterface