From cb226699d09467e1036a06298df61628ccc6f829 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 22 Feb 2020 11:30:53 +0100 Subject: BookmarkResource: Remove code duplication. Change-Id: I63cc5452b6690e6ef9a5a0d080d97e03a6952b13 --- .../eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/main/java/eu') diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java index ad75c4c..45eeb2e 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java @@ -267,12 +267,10 @@ public class BookmarkResource { From bm; if (identity.isAnonymous()) { - var root = query.from(Bookmark.class); - bm = root; - query.select(root); - root.fetch(Bookmark_.owner, JoinType.LEFT); + bm = query.from(Bookmark.class); + query.select(bm); - var target = root.join(Bookmark_.targets); + var target = bm.join(Bookmark_.targets); query.where(cb.equal(target, Role.getWorld())); } else { var userName = identity.getPrincipal().getName(); @@ -281,9 +279,9 @@ public class BookmarkResource { var root = query.from(User.class); query.where(cb.equal(root, user)); bm = root.join(User_.visibleBookmarks); - bm.fetch(Bookmark_.owner, JoinType.LEFT); } + bm.fetch(Bookmark_.owner, JoinType.LEFT); query.orderBy(cb.desc(bm.get(Bookmark_.date))); if (owner != null) { -- cgit v1.2.3