From 27c5cff6f59fa326c7c0a134a4ca084b6438a960 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 18 Jun 2024 10:37:41 +0200 Subject: [PATCH] SEBSERV-417 fixed predicate --- .../webservice/servicelayer/dao/impl/UserDAOImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java index 54e95458..a4716b49 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/UserDAOImpl.java @@ -173,10 +173,13 @@ public class UserDAOImpl implements UserDAO { public Result> allMatching(final FilterMap filterMap, final Predicate predicate) { return Result.tryCatch(() -> { final String userRole = filterMap.getUserRole(); - final Set userRoles = new HashSet<>(Arrays.asList(StringUtils.split(userRole, Constants.LIST_SEPARATOR))); - final Predicate _predicate = (StringUtils.isNotBlank(userRole)) - ? predicate.and(ui -> userRoles.stream().anyMatch(ui.roles::contains)) - : predicate; + final Predicate _predicate; + if (StringUtils.isNotBlank(userRole)) { + final Set userRoles = new HashSet<>(Arrays.asList(StringUtils.split(userRole, Constants.LIST_SEPARATOR))); + _predicate = predicate.and(ui -> userRoles.stream().anyMatch(ui.roles::contains)); + } else { + _predicate = predicate; + } final QueryExpressionDSL>>.QueryExpressionWhereBuilder sqlWhereClause = (filterMap.getBoolean(FilterMap.ATTR_ADD_INSITUTION_JOIN))