From 1807629b93a6dfba691183ad0185e19f981727ee Mon Sep 17 00:00:00 2001 From: Yuriy M <95305560+yuremm@users.noreply.github.com> Date: Wed, 9 Nov 2022 15:43:42 +0300 Subject: [PATCH] feat: allow to use like with lower together (#2944) Co-authored-by: Yuriy Movchan --- .../jans/orm/couchbase/CouchbaseSample.java | 16 ++++++++++++ .../impl/CouchbaseFilterConverter.java | 2 +- .../io/jans/orm/search/filter/Filter.java | 25 ++++++++++++++++--- .../orm/search/filter/FilterProcessor.java | 6 ++--- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseSample.java b/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseSample.java index f0fd71fff0f..f03fde4692a 100644 --- a/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseSample.java +++ b/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseSample.java @@ -49,6 +49,22 @@ public static void main(String[] args) { newUser.getCustomAttributes().add(new CustomObjectAttribute("test", "test_value")); couchbaseEntryManager.persist(newUser); + // Find all with lower and or filters + Filter orFilterWithLower = Filter.createORFilter(Filter.createEqualityFilter(Filter.createLowercaseFilter("description"), "test1"), + Filter.createEqualityFilter(Filter.createLowercaseFilter("description"), "test2")); + List usersWithOrFilter = couchbaseEntryManager.findEntries("ou=sessions,o=gluu", SimpleUser.class, orFilterWithLower); + for (SimpleUser user : usersWithOrFilter) { + LOG.info("User with uid: '{}' with DN: '{}'", user.getUserId(), user.getDn()); + } + + // Find all with lower and or filters + Filter orFilterWithLower2 = Filter.createORFilter(Filter.createSubstringFilter(Filter.createLowercaseFilter("description"), null, new String[] { "test1" }, null), + Filter.createSubstringFilter(Filter.createLowercaseFilter("displayName"), null, new String[] { "test1" }, null)); + List usersWithOrFilter2 = couchbaseEntryManager.findEntries("ou=sessions,o=gluu", SimpleUser.class, orFilterWithLower2); + for (SimpleUser user : usersWithOrFilter2) { + LOG.info("User with uid: '{}' with DN: '{}'", user.getUserId(), user.getDn()); + } + // Find all users which have specified object classes defined in SimpleUser List users = couchbaseEntryManager.findEntries("ou=people,o=jans", SimpleUser.class, null); for (SimpleUser user : users) { diff --git a/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseFilterConverter.java b/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseFilterConverter.java index 8e81fe82603..a202f427df5 100644 --- a/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseFilterConverter.java +++ b/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseFilterConverter.java @@ -102,7 +102,7 @@ public ConvertedExpression convertToCouchbaseFilter(Filter genericFilter, Map