From c1833a2da3777a2b2e4e2c0c5b2e76c969cad932 Mon Sep 17 00:00:00 2001 From: tekay <tom.kaesler@mni.thm.de> Date: Fri, 16 Mar 2018 13:11:16 +0100 Subject: [PATCH] Add FindQueryService for Comment Currently supports finding comments by `roomId`. See !83. --- .../services/CommentFindQueryService.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/de/thm/arsnova/services/CommentFindQueryService.java diff --git a/src/main/java/de/thm/arsnova/services/CommentFindQueryService.java b/src/main/java/de/thm/arsnova/services/CommentFindQueryService.java new file mode 100644 index 000000000..d80b47a00 --- /dev/null +++ b/src/main/java/de/thm/arsnova/services/CommentFindQueryService.java @@ -0,0 +1,48 @@ +/* + * This file is part of ARSnova Backend. + * Copyright (C) 2012-2018 The ARSnova Team and Contributors + * + * ARSnova Backend is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ARSnova Backend is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +package de.thm.arsnova.services; + +import de.thm.arsnova.entities.FindQuery; +import de.thm.arsnova.entities.Comment; +import org.springframework.stereotype.Service; + +import java.util.HashSet; +import java.util.Set; + +@Service +public class CommentFindQueryService implements FindQueryService<Comment> { + private CommentService commentService; + private UserService userService; + + public CommentFindQueryService(final CommentService commentService, final UserService userService) { + this.commentService = commentService; + this.userService = userService; + } + + @Override + public Set<String> resolveQuery(final FindQuery<Comment> findQuery) { + Set<String> ids = new HashSet<>(); + if (findQuery.getProperties().getRoomId() != null) { + for (Comment c : commentService.getByRoomId(findQuery.getProperties().getRoomId(), 0, 0)) { + ids.add(c.getId()); + } + } + + return ids; + } +} -- GitLab