From b0a8b9fc25b8a1045f0968a0dac6a5edf6f098c1 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Tue, 17 Jun 2025 17:32:04 +0300 Subject: [PATCH] EDQS - ignore case for name and not ignore for filters --- .../server/edqs/util/RepositoryUtils.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/edqs/src/main/java/org/thingsboard/server/edqs/util/RepositoryUtils.java b/common/edqs/src/main/java/org/thingsboard/server/edqs/util/RepositoryUtils.java index 6a3fb0fe40..fab98027ed 100644 --- a/common/edqs/src/main/java/org/thingsboard/server/edqs/util/RepositoryUtils.java +++ b/common/edqs/src/main/java/org/thingsboard/server/edqs/util/RepositoryUtils.java @@ -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