From a844d440c6f631927d9bbe58e0f11db4200de07a Mon Sep 17 00:00:00 2001 From: tekay <tom.kaesler@mni.thm.de> Date: Fri, 16 Mar 2018 12:05:14 +0100 Subject: [PATCH] Add FindQueryService for Content Currently supports finding contents by `roomId`. --- .../service/ContentFindQueryService.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/de/thm/arsnova/service/ContentFindQueryService.java diff --git a/src/main/java/de/thm/arsnova/service/ContentFindQueryService.java b/src/main/java/de/thm/arsnova/service/ContentFindQueryService.java new file mode 100644 index 000000000..8bbc43b89 --- /dev/null +++ b/src/main/java/de/thm/arsnova/service/ContentFindQueryService.java @@ -0,0 +1,50 @@ +/* + * 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.service; + +import de.thm.arsnova.model.Content; +import de.thm.arsnova.model.FindQuery; +import org.springframework.stereotype.Service; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Service +public class ContentFindQueryService implements FindQueryService<Content> { + private RoomService roomService; + private ContentService contentService; + + public ContentFindQueryService(final RoomService roomService, final ContentService contentService) { + this.roomService = roomService; + this.contentService = contentService; + } + + @Override + public Set<String> resolveQuery(final FindQuery<Content> findQuery) { + Set<String> contentIds = new HashSet<>(); + if (findQuery.getProperties().getRoomId() != null) { + List<Content> contentList = contentService.getByRoomId(findQuery.getProperties().getRoomId()); + for (Content c : contentList) { + contentIds.add(c.getId()); + } + } + + return contentIds; + } +} -- GitLab