diff --git a/src/main/java/de/thm/arsnova/cache/CacheBusterImpl.java b/src/main/java/de/thm/arsnova/cache/CacheBusterImpl.java index 32f2b858b699fb432601668b1ec160def3d1ef84..ab506f7b02e9824ff80488b7da197b258ae31242 100644 --- a/src/main/java/de/thm/arsnova/cache/CacheBusterImpl.java +++ b/src/main/java/de/thm/arsnova/cache/CacheBusterImpl.java @@ -17,7 +17,12 @@ */ package de.thm.arsnova.cache; -import de.thm.arsnova.event.*; +import de.thm.arsnova.event.AfterCreationEvent; +import de.thm.arsnova.event.AfterDeletionEvent; +import de.thm.arsnova.event.ChangeScoreEvent; +import de.thm.arsnova.model.Answer; +import de.thm.arsnova.model.Comment; +import de.thm.arsnova.model.Room; import org.springframework.cache.annotation.CacheEvict; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; @@ -31,25 +36,25 @@ public class CacheBusterImpl implements CacheBuster { @CacheEvict(value = "statistics", allEntries = true) @EventListener - public void handleNewComment(NewCommentEvent event) { } + public void handleAfterCommentCreation(AfterCreationEvent<Comment> event) { } @CacheEvict(value = "statistics", allEntries = true) @EventListener - public void handleDeleteComment(DeleteCommentEvent event) { } + public void handleAfterCommentDeletion(AfterDeletionEvent<Comment> event) { } @CacheEvict(value = "answerlists", key = "#event.content.id") @EventListener - public void handleNewAnswer(NewAnswerEvent event) { } + public void handleAfterAnswerCreation(AfterCreationEvent<Answer> event) { } @CacheEvict(value = "statistics", allEntries = true) @EventListener - public void handleChangeScore(ChangeScoreEvent changeLearningProgress) { } + public void handleChangeScore(ChangeScoreEvent event) { } @CacheEvict(value = "statistics", allEntries = true) @EventListener - public void handleewRoom(NewRoomEvent newSessionEvent) { } + public void handleAfterRoomCreation(AfterCreationEvent<Room> event) { } @CacheEvict(value = "statistics", allEntries = true) @EventListener - public void handleDeleteRoom(DeleteRoomEvent deleteSessionEvent) { } + public void handleAfterRoomDeletion(AfterDeletionEvent<Room> event) { } } diff --git a/src/main/java/de/thm/arsnova/event/ChangeScoreEvent.java b/src/main/java/de/thm/arsnova/event/ChangeScoreEvent.java index 46cbaf639c533957e6b98b6c6adb4f267a8af75b..3e2014db5aa2ae43fa9503592b97b6c23d34ad5e 100644 --- a/src/main/java/de/thm/arsnova/event/ChangeScoreEvent.java +++ b/src/main/java/de/thm/arsnova/event/ChangeScoreEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever a score related value changes. */ @@ -26,8 +24,8 @@ public class ChangeScoreEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public ChangeScoreEvent(Object source, Room room) { - super(source, room); + public ChangeScoreEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/DeleteAllLectureAnswersEvent.java b/src/main/java/de/thm/arsnova/event/DeleteAllLectureAnswersEvent.java index 3ed09bb704b4ebaa347e8ef6c1e909e51f327522..0ad169a83f106857f86abfcde7e31bceed8600ab 100644 --- a/src/main/java/de/thm/arsnova/event/DeleteAllLectureAnswersEvent.java +++ b/src/main/java/de/thm/arsnova/event/DeleteAllLectureAnswersEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever all answers of all lecture questions of a session are deleted. */ @@ -26,8 +24,8 @@ public class DeleteAllLectureAnswersEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public DeleteAllLectureAnswersEvent(Object source, Room room) { - super(source, room); + public DeleteAllLectureAnswersEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/DeleteAllPreparationAnswersEvent.java b/src/main/java/de/thm/arsnova/event/DeleteAllPreparationAnswersEvent.java index a85f12e2f988013b1e0e170b48d794fbb24c6392..49a8d9342797071f7ebd37b6c75afcdcb9f47f78 100644 --- a/src/main/java/de/thm/arsnova/event/DeleteAllPreparationAnswersEvent.java +++ b/src/main/java/de/thm/arsnova/event/DeleteAllPreparationAnswersEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever all answers of all preparation questions of a session are deleted. */ @@ -26,7 +24,7 @@ public class DeleteAllPreparationAnswersEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public DeleteAllPreparationAnswersEvent(Object source, Room room) { - super(source, room); + public DeleteAllPreparationAnswersEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsAnswersEvent.java b/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsAnswersEvent.java index bf7142ed628ab77fa9bb6d2b2196b42730bc509f..aa671783fd1f776fa34607ad8827a497102149b7 100644 --- a/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsAnswersEvent.java +++ b/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsAnswersEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever all answers of all questions of a session are deleted. */ @@ -26,7 +24,7 @@ public class DeleteAllQuestionsAnswersEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public DeleteAllQuestionsAnswersEvent(Object source, Room room) { - super(source, room); + public DeleteAllQuestionsAnswersEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsEvent.java b/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsEvent.java index a6cd9558a2adeab4c0d9b89e283a072c60bbb805..2bf5bac225a909d0076af155c12c37a03123e581 100644 --- a/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsEvent.java +++ b/src/main/java/de/thm/arsnova/event/DeleteAllQuestionsEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever all questions of a session are deleted. Note that this implies that all answers are deleted as well, * even though the specific answer events are not fired. @@ -27,8 +25,8 @@ public class DeleteAllQuestionsEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public DeleteAllQuestionsEvent(Object source, Room room) { - super(source, room); + public DeleteAllQuestionsEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/DeleteAnswerEvent.java b/src/main/java/de/thm/arsnova/event/DeleteAnswerEvent.java deleted file mode 100644 index 8a7aa4ba1a3cf2ffc752fedd71b7be19f7cb9eec..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/DeleteAnswerEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a single answer is deleted. - */ -public class DeleteAnswerEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Content content; - - public DeleteAnswerEvent(Object source, Room room, Content content) { - super(source, room); - this.content = content; - } - - public Content getQuestion() { - return content; - } -} diff --git a/src/main/java/de/thm/arsnova/event/DeleteCommentEvent.java b/src/main/java/de/thm/arsnova/event/DeleteCommentEvent.java deleted file mode 100644 index 82ba83d101334b36facfb53fe06b0070771780e5..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/DeleteCommentEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Comment; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever an comment is deleted. - */ -public class DeleteCommentEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Comment comment; - - public DeleteCommentEvent(Object source, Room room, Comment comment) { - super(source, room); - this.comment = comment; - } - - public Comment getQuestion() { - return comment; - } - -} diff --git a/src/main/java/de/thm/arsnova/event/DeleteQuestionEvent.java b/src/main/java/de/thm/arsnova/event/DeleteQuestionEvent.java deleted file mode 100644 index bfafb5fe706c94fb3a1b292d20562435a25ea482..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/DeleteQuestionEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a content is deleted. - */ -public class DeleteQuestionEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Content content; - - public DeleteQuestionEvent(Object source, Room room, Content content) { - super(source, room); - this.content = content; - } - - public Content getQuestion() { - return this.content; - } - -} diff --git a/src/main/java/de/thm/arsnova/event/DeleteRoomEvent.java b/src/main/java/de/thm/arsnova/event/DeleteRoomEvent.java deleted file mode 100644 index a650c51a6d55a17273df313b4e5b86f81e2ca556..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/DeleteRoomEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a session is deleted. Note that this implies that all related data such as comments, - * lecturer questions, and answers are deleted as well, even though those events are not fired. - */ -public class DeleteRoomEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - public DeleteRoomEvent(Object source, Room room) { - super(source, room); - } - -} diff --git a/src/main/java/de/thm/arsnova/event/FeatureChangeEvent.java b/src/main/java/de/thm/arsnova/event/FeatureChangeEvent.java index 447631a91ab42bddf8a90f2c253ff45931952d53..790eaea277ef8862e588493afcf92f45d842c5ac 100644 --- a/src/main/java/de/thm/arsnova/event/FeatureChangeEvent.java +++ b/src/main/java/de/thm/arsnova/event/FeatureChangeEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever a new session is created. */ @@ -26,8 +24,8 @@ public class FeatureChangeEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public FeatureChangeEvent(Object source, Room room) { - super(source, room); + public FeatureChangeEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/FlipFlashcardsEvent.java b/src/main/java/de/thm/arsnova/event/FlipFlashcardsEvent.java index 5b94f9a21e4d3f1c2448fc3199d16ee263aaed8c..c33389f1a8e472624db56141f7779a019b1cd264 100644 --- a/src/main/java/de/thm/arsnova/event/FlipFlashcardsEvent.java +++ b/src/main/java/de/thm/arsnova/event/FlipFlashcardsEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever voting on a question is disabled. */ @@ -26,7 +24,7 @@ public class FlipFlashcardsEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public FlipFlashcardsEvent(Object source, Room room) { - super(source, room); + public FlipFlashcardsEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/LockFeedbackEvent.java b/src/main/java/de/thm/arsnova/event/LockFeedbackEvent.java index 1f907db30dd45109f78d841af905703dff368a6b..6c50fc4b8cad526d36ed7f5c30b68390515c7a2b 100644 --- a/src/main/java/de/thm/arsnova/event/LockFeedbackEvent.java +++ b/src/main/java/de/thm/arsnova/event/LockFeedbackEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever voting on a question is disabled. */ @@ -26,7 +24,7 @@ public class LockFeedbackEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public LockFeedbackEvent(Object source, Room room) { - super(source, room); + public LockFeedbackEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/LockQuestionEvent.java b/src/main/java/de/thm/arsnova/event/LockQuestionEvent.java index 2b0e38bd4c261b7af20efa8b31f1effd1b23e0f5..58d5b6fbf60e9fc0dd3d53591e1f36c2bc6c4f4a 100644 --- a/src/main/java/de/thm/arsnova/event/LockQuestionEvent.java +++ b/src/main/java/de/thm/arsnova/event/LockQuestionEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; /** * Fires whenever a content is disabled, i.e., it is hidden from students. @@ -29,8 +28,8 @@ public class LockQuestionEvent extends RoomEvent { private final Content content; - public LockQuestionEvent(Object source, Room room, Content content) { - super(source, room); + public LockQuestionEvent(Object source, String roomId, Content content) { + super(source, roomId); this.content = content; } diff --git a/src/main/java/de/thm/arsnova/event/LockQuestionsEvent.java b/src/main/java/de/thm/arsnova/event/LockQuestionsEvent.java index fb27e4e6cf5c31cba98dadb4ddafef2b2f40d475..869d0c1a0071a765140c5b277ecbb0e8947c5cbb 100644 --- a/src/main/java/de/thm/arsnova/event/LockQuestionsEvent.java +++ b/src/main/java/de/thm/arsnova/event/LockQuestionsEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.List; @@ -31,8 +30,8 @@ public class LockQuestionsEvent extends RoomEvent { private List<Content> contents; - public LockQuestionsEvent(Object source, Room room, List<Content> contents) { - super(source, room); + public LockQuestionsEvent(Object source, String roomId, List<Content> contents) { + super(source, roomId); this.contents = contents; } diff --git a/src/main/java/de/thm/arsnova/event/LockVoteEvent.java b/src/main/java/de/thm/arsnova/event/LockVoteEvent.java index 07456ac7b7f52605f596df1375088eb402c1db18..bf3ba29733e2fde71e0da5b6b701ef34f5847721 100644 --- a/src/main/java/de/thm/arsnova/event/LockVoteEvent.java +++ b/src/main/java/de/thm/arsnova/event/LockVoteEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.HashMap; import java.util.Map; @@ -32,8 +31,8 @@ public class LockVoteEvent extends RoomEvent { private final Content content; - public LockVoteEvent(Object source, Room room, Content content) { - super(source, room); + public LockVoteEvent(Object source, String roomId, Content content) { + super(source, roomId); this.content = content; } diff --git a/src/main/java/de/thm/arsnova/event/LockVotesEvent.java b/src/main/java/de/thm/arsnova/event/LockVotesEvent.java index ebff38234b700147bbdd1957e78c1e488ad5d3a6..7595c19a2ebc14b46bdb4429fd7e011548e9dc04 100644 --- a/src/main/java/de/thm/arsnova/event/LockVotesEvent.java +++ b/src/main/java/de/thm/arsnova/event/LockVotesEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.List; @@ -31,8 +30,8 @@ public class LockVotesEvent extends RoomEvent { private List<Content> contents; - public LockVotesEvent(Object source, Room room, List<Content> contents) { - super(source, room); + public LockVotesEvent(Object source, String roomId, List<Content> contents) { + super(source, roomId); this.contents = contents; } diff --git a/src/main/java/de/thm/arsnova/event/NewAnswerEvent.java b/src/main/java/de/thm/arsnova/event/NewAnswerEvent.java deleted file mode 100644 index 462494d9854ce5dc609f7bce65bef97e640cc378..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/NewAnswerEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Answer; -import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a new answer is added. - */ -public class NewAnswerEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Answer answer; - - private final String userId; - - private final Content content; - - public NewAnswerEvent(Object source, Room room, Answer answer, String userId, Content content) { - super(source, room); - this.answer = answer; - this.userId = userId; - this.content = content; - } - - public Answer getAnswer() { - return answer; - } - - public String getUserId() { - return userId; - } - - public Content getContent() { - return content; - } -} diff --git a/src/main/java/de/thm/arsnova/event/NewCommentEvent.java b/src/main/java/de/thm/arsnova/event/NewCommentEvent.java deleted file mode 100644 index 0ccf30272328b99e76767b984d9fea397295683a..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/NewCommentEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Comment; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a new comment is added. - */ -public class NewCommentEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Comment comment; - - public NewCommentEvent(Object source, Room room, Comment comment) { - super(source, room); - this.comment = comment; - } - - public Comment getQuestion() { - return comment; - } - -} diff --git a/src/main/java/de/thm/arsnova/event/NewFeedbackEvent.java b/src/main/java/de/thm/arsnova/event/NewFeedbackEvent.java index d663f2bb5d0607366800fa91b04e0bd2ce5a9d65..6a5d7290fb1daaa91be63a7ae4cc42091d4e095e 100644 --- a/src/main/java/de/thm/arsnova/event/NewFeedbackEvent.java +++ b/src/main/java/de/thm/arsnova/event/NewFeedbackEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever the feedback changes. */ @@ -26,8 +24,8 @@ public class NewFeedbackEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public NewFeedbackEvent(Object source, Room room) { - super(source, room); + public NewFeedbackEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/NewQuestionEvent.java b/src/main/java/de/thm/arsnova/event/NewQuestionEvent.java deleted file mode 100644 index 53281dceaaea6ad74dc49dd769509f22cf0ae821..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/NewQuestionEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a new content is added. - */ -public class NewQuestionEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - private final Content content; - - public NewQuestionEvent(Object source, Room room, Content content) { - super(source, room); - this.content = content; - } - - public Content getQuestion() { - return content; - } -} diff --git a/src/main/java/de/thm/arsnova/event/NewRoomEvent.java b/src/main/java/de/thm/arsnova/event/NewRoomEvent.java deleted file mode 100644 index 222fa7c0fdc7c16f55483e9299dc9780cd79f43e..0000000000000000000000000000000000000000 --- a/src/main/java/de/thm/arsnova/event/NewRoomEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.event; - -import de.thm.arsnova.model.Room; - -/** - * Fires whenever a new session is created. - */ -public class NewRoomEvent extends RoomEvent { - - private static final long serialVersionUID = 1L; - - public NewRoomEvent(Object source, Room room) { - super(source, room); - } - -} diff --git a/src/main/java/de/thm/arsnova/event/PiRoundCancelEvent.java b/src/main/java/de/thm/arsnova/event/PiRoundCancelEvent.java index 27cf4351d875d413fe5f037e803943f1c2e5b51f..73fadca6db1e3a9379dea4ebc691cbb59097d01b 100644 --- a/src/main/java/de/thm/arsnova/event/PiRoundCancelEvent.java +++ b/src/main/java/de/thm/arsnova/event/PiRoundCancelEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; /** * Fires whenever a peer instruction round is canceled. @@ -27,8 +26,8 @@ public class PiRoundCancelEvent extends PiRoundEndEvent { private static final long serialVersionUID = 1L; - public PiRoundCancelEvent(Object source, Room room, Content content) { - super(source, room, content); + public PiRoundCancelEvent(Object source, String roomId, Content content) { + super(source, roomId, content); } } diff --git a/src/main/java/de/thm/arsnova/event/PiRoundDelayedStartEvent.java b/src/main/java/de/thm/arsnova/event/PiRoundDelayedStartEvent.java index 43ac5f59bf4eb4e4681dd9effdc975f86ac451c9..c12cc8782616ad96191c46ab3fe592a2b06f79cd 100644 --- a/src/main/java/de/thm/arsnova/event/PiRoundDelayedStartEvent.java +++ b/src/main/java/de/thm/arsnova/event/PiRoundDelayedStartEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.Date; import java.util.HashMap; @@ -37,8 +36,8 @@ public class PiRoundDelayedStartEvent extends RoomEvent { private final String group; private int piRound; - public PiRoundDelayedStartEvent(Object source, Room room, Content content) { - super(source, room); + public PiRoundDelayedStartEvent(Object source, String roomId, Content content) { + super(source, roomId); this.questionId = content.getId(); /* FIXME: Event does not support content with multiple groups */ this.group = content.getGroups().toArray(new String[1])[0]; diff --git a/src/main/java/de/thm/arsnova/event/PiRoundEndEvent.java b/src/main/java/de/thm/arsnova/event/PiRoundEndEvent.java index 064ba458d611d2b9dd0f4567073f73e265ed4078..8d56a813950b1292eff2818bb6b5a54b2cc6d024 100644 --- a/src/main/java/de/thm/arsnova/event/PiRoundEndEvent.java +++ b/src/main/java/de/thm/arsnova/event/PiRoundEndEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.HashMap; import java.util.Map; @@ -33,8 +32,8 @@ public class PiRoundEndEvent extends RoomEvent { private final String contentId; private final String group; - public PiRoundEndEvent(Object source, Room room, Content content) { - super(source, room); + public PiRoundEndEvent(Object source, String roomId, Content content) { + super(source, roomId); contentId = content.getId(); /* FIXME: Event does not support content with multiple groups */ this.group = content.getGroups().toArray(new String[1])[0]; diff --git a/src/main/java/de/thm/arsnova/event/PiRoundResetEvent.java b/src/main/java/de/thm/arsnova/event/PiRoundResetEvent.java index 4d5d773ea302d36a4bdf5661242793e7d4f5f1c5..2b4cd53254f022f33241402c0e13cf595b455eb5 100644 --- a/src/main/java/de/thm/arsnova/event/PiRoundResetEvent.java +++ b/src/main/java/de/thm/arsnova/event/PiRoundResetEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.HashMap; import java.util.Map; @@ -33,8 +32,8 @@ public class PiRoundResetEvent extends RoomEvent { private final String contentId; private final String group; - public PiRoundResetEvent(Object source, Room room, Content content) { - super(source, room); + public PiRoundResetEvent(Object source, String roomId, Content content) { + super(source, roomId); contentId = content.getId(); /* FIXME: Event does not support content with multiple groups */ this.group = content.getGroups().toArray(new String[1])[0]; diff --git a/src/main/java/de/thm/arsnova/event/RoomEvent.java b/src/main/java/de/thm/arsnova/event/RoomEvent.java index eb32f2aaa923c64b342da10300ce938bfdeac1fe..62577df7a272ec5f316fc92c86f700bf64ce500f 100644 --- a/src/main/java/de/thm/arsnova/event/RoomEvent.java +++ b/src/main/java/de/thm/arsnova/event/RoomEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Base class for all {@link ArsnovaEvent}s that are related to a room. */ @@ -26,14 +24,14 @@ public abstract class RoomEvent extends ArsnovaEvent { private static final long serialVersionUID = 1L; - private final Room room; + private final String roomId; - public RoomEvent(Object source, Room room) { + public RoomEvent(Object source, String roomId) { super(source); - this.room = room; + this.roomId = roomId; } - public Room getRoom() { - return room; + public String getRoomId() { + return roomId; } } diff --git a/src/main/java/de/thm/arsnova/event/StatusRoomEvent.java b/src/main/java/de/thm/arsnova/event/StatusRoomEvent.java index d91026fde9c00daaab7fc1347e9f684e96581102..d7307cd7919c8fd161e5e1fd3522dc31b101338b 100644 --- a/src/main/java/de/thm/arsnova/event/StatusRoomEvent.java +++ b/src/main/java/de/thm/arsnova/event/StatusRoomEvent.java @@ -17,8 +17,6 @@ */ package de.thm.arsnova.event; -import de.thm.arsnova.model.Room; - /** * Fires whenever the status of a session changes, i.e., it is enabled or disabled. */ @@ -26,8 +24,8 @@ public class StatusRoomEvent extends RoomEvent { private static final long serialVersionUID = 1L; - public StatusRoomEvent(Object source, Room room) { - super(source, room); + public StatusRoomEvent(Object source, String roomId) { + super(source, roomId); } } diff --git a/src/main/java/de/thm/arsnova/event/UnlockQuestionEvent.java b/src/main/java/de/thm/arsnova/event/UnlockQuestionEvent.java index 3a53ff4427d17f2c6a746e8287c26b674e1fc8e0..deddf45f1f18a762ae3650fd6e8ebd817d967db3 100644 --- a/src/main/java/de/thm/arsnova/event/UnlockQuestionEvent.java +++ b/src/main/java/de/thm/arsnova/event/UnlockQuestionEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; /** * Fires whenever a content is enabled, i.e., it becomes visible to students. @@ -29,8 +28,8 @@ public class UnlockQuestionEvent extends RoomEvent { private final Content content; - public UnlockQuestionEvent(Object source, Room room, Content content) { - super(source, room); + public UnlockQuestionEvent(Object source, String roomId, Content content) { + super(source, roomId); this.content = content; } diff --git a/src/main/java/de/thm/arsnova/event/UnlockQuestionsEvent.java b/src/main/java/de/thm/arsnova/event/UnlockQuestionsEvent.java index 50c66f05acd183039a483eb19198349e7d67b6b8..81f38cc60c40641ccd22223e26d0f4a6b80fdc47 100644 --- a/src/main/java/de/thm/arsnova/event/UnlockQuestionsEvent.java +++ b/src/main/java/de/thm/arsnova/event/UnlockQuestionsEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.List; @@ -31,8 +30,8 @@ public class UnlockQuestionsEvent extends RoomEvent { private List<Content> contents; - public UnlockQuestionsEvent(Object source, Room room, List<Content> contents) { - super(source, room); + public UnlockQuestionsEvent(Object source, String roomId, List<Content> contents) { + super(source, roomId); this.contents = contents; } diff --git a/src/main/java/de/thm/arsnova/event/UnlockVoteEvent.java b/src/main/java/de/thm/arsnova/event/UnlockVoteEvent.java index d6206d6db140b09396f8a159b590e91fa8f1ae4b..3dd6996e3fd8cad2810ce3fd887088864d4a056f 100644 --- a/src/main/java/de/thm/arsnova/event/UnlockVoteEvent.java +++ b/src/main/java/de/thm/arsnova/event/UnlockVoteEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.HashMap; import java.util.Map; @@ -32,8 +31,8 @@ public class UnlockVoteEvent extends RoomEvent { private final Content content; - public UnlockVoteEvent(Object source, Room room, Content content) { - super(source, room); + public UnlockVoteEvent(Object source, String roomId, Content content) { + super(source, roomId); this.content = content; } diff --git a/src/main/java/de/thm/arsnova/event/UnlockVotesEvent.java b/src/main/java/de/thm/arsnova/event/UnlockVotesEvent.java index cf5fe5f2c95e3c9575eb1b908e167c0d75e14de1..85cf1d06f9a8ce5b55c3fd48b9cc6a0c4dc005bf 100644 --- a/src/main/java/de/thm/arsnova/event/UnlockVotesEvent.java +++ b/src/main/java/de/thm/arsnova/event/UnlockVotesEvent.java @@ -18,7 +18,6 @@ package de.thm.arsnova.event; import de.thm.arsnova.model.Content; -import de.thm.arsnova.model.Room; import java.util.List; @@ -31,8 +30,8 @@ public class UnlockVotesEvent extends RoomEvent { private List<Content> contents; - public UnlockVotesEvent(Object source, Room room, List<Content> contents) { - super(source, room); + public UnlockVotesEvent(Object source, String roomId, List<Content> contents) { + super(source, roomId); this.contents = contents; } diff --git a/src/main/java/de/thm/arsnova/service/AnswerServiceImpl.java b/src/main/java/de/thm/arsnova/service/AnswerServiceImpl.java index 93e7c1bfd4fb0b990544ed8012a9d724a35b0faf..fdbe22ff3653a0bd2c4db0e4bcbcd83399912203 100644 --- a/src/main/java/de/thm/arsnova/service/AnswerServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/AnswerServiceImpl.java @@ -17,8 +17,8 @@ */ package de.thm.arsnova.service; -import de.thm.arsnova.event.DeleteAnswerEvent; -import de.thm.arsnova.event.NewAnswerEvent; +import de.thm.arsnova.event.AfterCreationEvent; +import de.thm.arsnova.event.BeforeCreationEvent; import de.thm.arsnova.model.Answer; import de.thm.arsnova.model.AnswerStatistics; import de.thm.arsnova.model.ChoiceQuestionContent; @@ -95,11 +95,12 @@ public class AnswerServiceImpl extends DefaultEntityServiceImpl<Answer> implemen elements.add(entry); } try { + for (AnswerQueueElement e : elements) { + this.eventPublisher.publishEvent(new BeforeCreationEvent<>(e.getAnswer())); + } answerRepository.saveAll(answerList); - - // Send NewAnswerEvents ... for (AnswerQueueElement e : elements) { - this.eventPublisher.publishEvent(new NewAnswerEvent(this, e.getRoom(), e.getAnswer(), e.getUserId(), e.getQuestion())); + this.eventPublisher.publishEvent(new AfterCreationEvent<>(e.getAnswer())); } } catch (final DbAccessException e) { logger.error("Could not bulk save answers from queue.", e); @@ -352,6 +353,7 @@ public class AnswerServiceImpl extends DefaultEntityServiceImpl<Answer> implemen return answer; } + /* FIXME: Remove, this should be handled by EntityService! */ @Override @PreAuthorize("isAuthenticated()") @CacheEvict(value = "answerlists", allEntries = true) @@ -373,12 +375,14 @@ public class AnswerServiceImpl extends DefaultEntityServiceImpl<Answer> implemen answer.setCreatorId(user.getId()); answer.setContentId(content.getId()); answer.setRoomId(room.getId()); + this.eventPublisher.publishEvent(new BeforeCreationEvent<>(realAnswer)); answerRepository.save(realAnswer); - this.eventPublisher.publishEvent(new NewAnswerEvent(this, room, answer, user.getId(), content)); + this.eventPublisher.publishEvent(new AfterCreationEvent<>(realAnswer)); return answer; } + /* FIXME: Remove, this should be handled by EntityService! */ @Override @PreAuthorize("isAuthenticated()") @CacheEvict(value = "answerlists", allEntries = true) @@ -392,9 +396,9 @@ public class AnswerServiceImpl extends DefaultEntityServiceImpl<Answer> implemen if (user == null || room == null || !room.getOwnerId().equals(user.getId())) { throw new UnauthorizedException(); } + //this.eventPublisher.publishEvent(new BeforeDeletionEvent<>(answer)); answerRepository.deleteById(answerId); - - this.eventPublisher.publishEvent(new DeleteAnswerEvent(this, room, content)); + //this.eventPublisher.publishEvent(new AfterDeletionEvent<>(answer)); } /* diff --git a/src/main/java/de/thm/arsnova/service/CommentServiceImpl.java b/src/main/java/de/thm/arsnova/service/CommentServiceImpl.java index 8fbab006cda55003a732131d2f863c3eeeabacee..48f055635662389bf974d7a68cde51d173113d75 100644 --- a/src/main/java/de/thm/arsnova/service/CommentServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/CommentServiceImpl.java @@ -1,6 +1,7 @@ package de.thm.arsnova.service; -import de.thm.arsnova.event.DeleteCommentEvent; +import de.thm.arsnova.event.AfterDeletionEvent; +import de.thm.arsnova.event.BeforeDeletionEvent; import de.thm.arsnova.model.Comment; import de.thm.arsnova.model.Room; import de.thm.arsnova.model.migration.v2.CommentReadingCount; @@ -56,6 +57,7 @@ public class CommentServiceImpl extends DefaultEntityServiceImpl<Comment> implem /* TODO: fire event */ } + /* FIXME: Remove, EntityService should handle this! */ @Override @PreAuthorize("hasPermission(#commentId, 'comment', 'owner')") public void delete(final String commentId) { @@ -63,11 +65,9 @@ public class CommentServiceImpl extends DefaultEntityServiceImpl<Comment> implem if (comment == null) { throw new NotFoundException(); } + eventPublisher.publishEvent(new BeforeDeletionEvent<>(comment)); commentRepository.delete(comment); - - final Room room = roomRepository.findOne(comment.getRoomId()); - final DeleteCommentEvent event = new DeleteCommentEvent(this, room, comment); - this.eventPublisher.publishEvent(event); + eventPublisher.publishEvent(new AfterDeletionEvent<>(comment)); } @Override diff --git a/src/main/java/de/thm/arsnova/service/ContentServiceImpl.java b/src/main/java/de/thm/arsnova/service/ContentServiceImpl.java index ea65cbe35889a5bc68bea4876eea08b7e770448a..f905d2b1a7668d7b3c6fb7c771209afc8538e1ab 100644 --- a/src/main/java/de/thm/arsnova/service/ContentServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/ContentServiceImpl.java @@ -194,10 +194,9 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem newGroup.setContentIds(newContentIds); room.getContentGroups().add(newGroup); } + eventPublisher.publishEvent(new BeforeCreationEvent<>(content)); roomRepository.save(room); - - final NewQuestionEvent event = new NewQuestionEvent(this, room, content); - this.eventPublisher.publishEvent(event); + eventPublisher.publishEvent(new AfterCreationEvent<>(content)); } @Override @@ -290,14 +289,13 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem try { final int count = answerRepository.deleteByContentId(contentId); + eventPublisher.publishEvent(new BeforeDeletionEvent<>(content)); contentRepository.deleteById(contentId); + eventPublisher.publishEvent(new AfterDeletionEvent<>(content)); dbLogger.log("delete", "type", "content", "answerCount", count); } catch (final IllegalArgumentException e) { logger.error("Could not delete content {}.", contentId, e); } - - final DeleteQuestionEvent event = new DeleteQuestionEvent(this, room, content); - this.eventPublisher.publishEvent(event); } @PreAuthorize("hasPermission(#session, 'owner')") @@ -320,7 +318,7 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem dbLogger.log("delete", "type", "question", "questionCount", contentCount); dbLogger.log("delete", "type", "answer", "answerCount", answerCount); - final DeleteAllQuestionsEvent event = new DeleteAllQuestionsEvent(this, room); + final DeleteAllQuestionsEvent event = new DeleteAllQuestionsEvent(this, room.getId()); this.eventPublisher.publishEvent(event); } @@ -367,9 +365,9 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem } ArsnovaEvent event; if (disableVoting) { - event = new LockVoteEvent(this, room, content); + event = new LockVoteEvent(this, room.getId(), content); } else { - event = new UnlockVoteEvent(this, room, content); + event = new UnlockVoteEvent(this, room.getId(), content); } this.eventPublisher.publishEvent(event); } @@ -397,9 +395,9 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem List<Content> list = new ArrayList<>(); contents.forEach(list::add); if (disableVoting) { - event = new LockVotesEvent(this, room, list); + event = new LockVotesEvent(this, room.getId(), list); } else { - event = new UnlockVotesEvent(this, room, list); + event = new UnlockVotesEvent(this, room.getId(), list); } this.eventPublisher.publishEvent(event); } catch (IOException e) { @@ -498,9 +496,9 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem List<Content> list = new ArrayList<>(); contents.forEach(list::add); if (publish) { - event = new UnlockQuestionsEvent(this, room, list); + event = new UnlockQuestionsEvent(this, room.getId(), list); } else { - event = new LockQuestionsEvent(this, room, list); + event = new LockQuestionsEvent(this, room.getId(), list); } this.eventPublisher.publishEvent(event); } @@ -521,7 +519,7 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList()); answerRepository.deleteAllAnswersForQuestions(contentIds); - this.eventPublisher.publishEvent(new DeleteAllQuestionsAnswersEvent(this, room)); + this.eventPublisher.publishEvent(new DeleteAllQuestionsAnswersEvent(this, room.getId())); } /* TODO: Split and move answer part to AnswerService */ @@ -537,7 +535,7 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList()); answerRepository.deleteAllAnswersForQuestions(contentIds); - this.eventPublisher.publishEvent(new DeleteAllPreparationAnswersEvent(this, room)); + this.eventPublisher.publishEvent(new DeleteAllPreparationAnswersEvent(this, room.getId())); } /* TODO: Split and move answer part to AnswerService */ @@ -553,7 +551,7 @@ public class ContentServiceImpl extends DefaultEntityServiceImpl<Content> implem final List<String> contentIds = contents.stream().map(Content::getId).collect(Collectors.toList()); answerRepository.deleteAllAnswersForQuestions(contentIds); - this.eventPublisher.publishEvent(new DeleteAllLectureAnswersEvent(this, room)); + this.eventPublisher.publishEvent(new DeleteAllLectureAnswersEvent(this, room.getId())); } @Caching(evict = { diff --git a/src/main/java/de/thm/arsnova/service/FeedbackServiceImpl.java b/src/main/java/de/thm/arsnova/service/FeedbackServiceImpl.java index 842322bfa14a2b490ee5bca5426e09ef2a83eda3..ea4b87312625056348c3d7d38f5bdc3c9916b396 100644 --- a/src/main/java/de/thm/arsnova/service/FeedbackServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/FeedbackServiceImpl.java @@ -90,12 +90,12 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub // Send feedback reset event to all affected users for (Map.Entry<String, Set<Room>> entry : affectedSessionsOfUsers.entrySet()) { final String userId = entry.getKey(); - final Set<Room> arsSessions = entry.getValue(); - this.publisher.publishEvent(new DeleteFeedbackForRoomsEvent(this, arsSessions, userId)); + final Set<Room> rooms = entry.getValue(); + this.publisher.publishEvent(new DeleteFeedbackForRoomsEvent(this, rooms, userId)); } // For each session that has deleted feedback, send the new feedback to all clients - for (Room session : deletedFeedbackOfUsersInSession.keySet()) { - this.publisher.publishEvent(new NewFeedbackEvent(this, session)); + for (Room room : deletedFeedbackOfUsersInSession.keySet()) { + this.publisher.publishEvent(new NewFeedbackEvent(this, room.getId())); } } @@ -111,7 +111,7 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub this.publisher.publishEvent(new DeleteFeedbackForRoomsEvent(this, sessionSet, userId)); } // send the new feedback to all clients in affected session - this.publisher.publishEvent(new NewFeedbackEvent(this, room)); + this.publisher.publishEvent(new NewFeedbackEvent(this, room.getId())); } @Override @@ -163,7 +163,7 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub } feedbackStorage.save(room, value, userId); - this.publisher.publishEvent(new NewFeedbackEvent(this, room)); + this.publisher.publishEvent(new NewFeedbackEvent(this, room.getId())); return true; } diff --git a/src/main/java/de/thm/arsnova/service/RoomServiceImpl.java b/src/main/java/de/thm/arsnova/service/RoomServiceImpl.java index 4f6e2f96e2501c8ded24ab8eb51c7e45ed1f21ec..9f7de91a136bece44c95a097d5c946d9b49cb656 100644 --- a/src/main/java/de/thm/arsnova/service/RoomServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/RoomServiceImpl.java @@ -19,7 +19,8 @@ package de.thm.arsnova.service; import de.thm.arsnova.connector.client.ConnectorClient; import de.thm.arsnova.connector.model.Course; -import de.thm.arsnova.event.DeleteRoomEvent; +import de.thm.arsnova.event.AfterDeletionEvent; +import de.thm.arsnova.event.BeforeDeletionEvent; import de.thm.arsnova.event.FeatureChangeEvent; import de.thm.arsnova.event.FlipFlashcardsEvent; import de.thm.arsnova.event.LockFeedbackEvent; @@ -403,7 +404,7 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R public Room setActive(final String id, final Boolean lock) { final Room room = roomRepository.findOne(id); room.setClosed(!lock); - this.eventPublisher.publishEvent(new StatusRoomEvent(this, room)); + this.eventPublisher.publishEvent(new StatusRoomEvent(this, room.getId())); roomRepository.save(room); return room; @@ -454,12 +455,12 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R count[2] = commentRepository.deleteByRoomId(room.getId()); count[1] = answerRepository.deleteByContentIds(contentIds); count[0] = contentRepository.deleteByRoomId(room.getId()); + this.eventPublisher.publishEvent(new BeforeDeletionEvent<>(room)); roomRepository.delete(room); + this.eventPublisher.publishEvent(new AfterDeletionEvent<>(room)); logger.debug("Deleted room document {} and related data.", room.getId()); dbLogger.log("delete", "type", "session", "id", room.getId()); - this.eventPublisher.publishEvent(new DeleteRoomEvent(this, room)); - return count; } @@ -518,7 +519,7 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R public Room.Settings updateFeatures(String id, Room.Settings settings) { final Room room = roomRepository.findOne(id); room.setSettings(settings); - this.eventPublisher.publishEvent(new FeatureChangeEvent(this, room)); + this.eventPublisher.publishEvent(new FeatureChangeEvent(this, room.getId())); roomRepository.save(room); return room.getSettings(); @@ -533,7 +534,7 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R } room.getSettings().setFeedbackLocked(lock); - this.eventPublisher.publishEvent(new LockFeedbackEvent(this, room)); + this.eventPublisher.publishEvent(new LockFeedbackEvent(this, room.getId())); roomRepository.save(room); return room.getSettings().isFeedbackLocked(); @@ -543,7 +544,7 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R @PreAuthorize("hasPermission(#id, 'room', 'owner')") public boolean flipFlashcards(String id, Boolean flip) { final Room room = roomRepository.findOne(id); - this.eventPublisher.publishEvent(new FlipFlashcardsEvent(this, room)); + this.eventPublisher.publishEvent(new FlipFlashcardsEvent(this, room.getId())); return flip; } diff --git a/src/main/java/de/thm/arsnova/service/TimerServiceImpl.java b/src/main/java/de/thm/arsnova/service/TimerServiceImpl.java index 263ef8caa95e706227d99e16df7e8e1718e01d86..386a49c3b26c196792d92c1a1592917e88b1985d 100644 --- a/src/main/java/de/thm/arsnova/service/TimerServiceImpl.java +++ b/src/main/java/de/thm/arsnova/service/TimerServiceImpl.java @@ -51,7 +51,7 @@ public class TimerServiceImpl implements TimerService, ApplicationEventPublisher updateRoundManagementState(content); contentRepository.save(content); - this.publisher.publishEvent(new PiRoundEndEvent(this, room, content)); + this.publisher.publishEvent(new PiRoundEndEvent(this, room.getId(), content)); } @Override @@ -67,7 +67,7 @@ public class TimerServiceImpl implements TimerService, ApplicationEventPublisher updateRoundStartVariables(content, date, endDate); contentRepository.save(content); - this.publisher.publishEvent(new PiRoundDelayedStartEvent(this, room, content)); + this.publisher.publishEvent(new PiRoundDelayedStartEvent(this, room.getId(), content)); timerList.put(contentId, timer); timer.schedule(new TimerTask() { @@ -93,7 +93,7 @@ public class TimerServiceImpl implements TimerService, ApplicationEventPublisher content.getState().setRoundEndTimestamp(null); contentRepository.save(content); - this.publisher.publishEvent(new PiRoundCancelEvent(this, room, content)); + this.publisher.publishEvent(new PiRoundCancelEvent(this, room.getId(), content)); } @Override @@ -124,7 +124,7 @@ public class TimerServiceImpl implements TimerService, ApplicationEventPublisher resetRoundManagementState(content); answerRepository.deleteByContentId(content.getId()); contentRepository.save(content); - this.publisher.publishEvent(new PiRoundResetEvent(this, room, content)); + this.publisher.publishEvent(new PiRoundResetEvent(this, room.getId(), content)); } private void updateRoundStartVariables(final Content content, final Date start, final Date end) { diff --git a/src/main/java/de/thm/arsnova/service/score/ScoreCalculatorFactoryImpl.java b/src/main/java/de/thm/arsnova/service/score/ScoreCalculatorFactoryImpl.java index d8267dfae9c16a03901dc4b08d97df4faa37613e..46a50546d459772a98e6969dc703a5e488d3ca7e 100644 --- a/src/main/java/de/thm/arsnova/service/score/ScoreCalculatorFactoryImpl.java +++ b/src/main/java/de/thm/arsnova/service/score/ScoreCalculatorFactoryImpl.java @@ -18,6 +18,8 @@ package de.thm.arsnova.service.score; import de.thm.arsnova.event.*; +import de.thm.arsnova.model.Answer; +import de.thm.arsnova.model.Content; import de.thm.arsnova.persistence.SessionStatisticsRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; @@ -53,80 +55,80 @@ public class ScoreCalculatorFactoryImpl implements ScoreCalculatorFactory, Appli @CacheEvict(value = "score", key = "#event.Room") @EventListener - public void handleNewQuestion(NewQuestionEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + public void handleAfterContentCreation(AfterCreationEvent<Content> event) { + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getSource().getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleUnlockQuestion(UnlockQuestionEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleUnlockQuestions(UnlockQuestionsEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleLockQuestion(LockQuestionEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleLockQuestions(LockQuestionsEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener - public void handleNewAnswer(NewAnswerEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + public void handleNewAnswer(AfterCreationEvent<Answer> event) { + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getSource().getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener - public void handleDeleteAnswer(DeleteAnswerEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + public void handleDeleteAnswer(AfterDeletionEvent<Answer> event) { + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getSource().getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener - public void handleDeleteQuestion(DeleteQuestionEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + public void handleDeleteQuestion(AfterDeletionEvent<Content> event) { + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getSource().getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleDeleteAllQuestions(DeleteAllQuestionsEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleDeleteAllQuestionsAnswers(DeleteAllQuestionsAnswersEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleDeleteAllPreparationAnswers(DeleteAllPreparationAnswersEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handleDeleteAllLectureAnswers(DeleteAllLectureAnswersEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @CacheEvict(value = "score", key = "#event.Room") @EventListener public void handlePiRoundReset(PiRoundResetEvent event) { - this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoom())); + this.publisher.publishEvent(new ChangeScoreEvent(this, event.getRoomId())); } @Override diff --git a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java index d17fd69b5d656925cc31233131586b886c26bf20..8ec0ac0752b08fc868446ec6008a62a35fc6566d 100644 --- a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java +++ b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java @@ -29,6 +29,7 @@ import com.corundumstudio.socketio.listener.DisconnectListener; import com.corundumstudio.socketio.protocol.Packet; import com.corundumstudio.socketio.protocol.PacketType; import de.thm.arsnova.event.*; +import de.thm.arsnova.model.Answer; import de.thm.arsnova.model.Comment; import de.thm.arsnova.model.ScoreOptions; import de.thm.arsnova.model.migration.ToV2Migrator; @@ -491,61 +492,62 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { } @EventListener - public void handleNewQuestion(NewQuestionEvent event) { - this.reportContentAvailable(event.getRoom().getId(), Collections.singletonList(event.getQuestion())); + public void handleAfterContentCreation(AfterCreationEvent<de.thm.arsnova.model.Content> event) { + this.reportContentAvailable(event.getSource().getId(), Collections.singletonList(event.getSource())); } @EventListener public void handleUnlockQuestion(UnlockQuestionEvent event) { - this.reportContentAvailable(event.getRoom().getId(), Collections.singletonList(event.getQuestion())); + this.reportContentAvailable(event.getRoomId(), Collections.singletonList(event.getQuestion())); } @EventListener public void handleLockQuestion(LockQuestionEvent event) { - this.reportContentsLocked(event.getRoom().getId(), Collections.singletonList(event.getQuestion())); + this.reportContentsLocked(event.getRoomId(), Collections.singletonList(event.getQuestion())); } @EventListener public void handleUnlockQuestions(UnlockQuestionsEvent event) { - this.reportContentAvailable(event.getRoom().getId(), event.getQuestions()); + this.reportContentAvailable(event.getRoomId(), event.getQuestions()); } @EventListener public void handleLockQuestions(LockQuestionsEvent event) { - this.reportContentsLocked(event.getRoom().getId(), event.getQuestions()); + this.reportContentsLocked(event.getRoomId(), event.getQuestions()); } @EventListener - public void handleNewComment(NewCommentEvent event) { - this.reportCommentAvailable(event.getRoom().getId(), event.getQuestion().getId()); + public void handleAfterCommentCreation(AfterCreationEvent<Comment> event) { + this.reportCommentAvailable(event.getSource().getId(), event.getSource().getId()); } @Async @EventListener @Timed - public void handleNewAnswer(NewAnswerEvent event) { - final String roomId = event.getRoom().getId(); - this.reportAnswersToContentAvailable(event.getRoom().getId(), event.getContent().getId()); - broadcastInRoom(roomId, "countQuestionAnswersByQuestionId", answerService.countAnswersAndAbstentionsInternal(event.getContent().getId())); + public void handleNewAnswer(AfterCreationEvent<Answer> event) { + final String roomId = event.getSource().getRoomId(); + this.reportAnswersToContentAvailable(event.getSource().getRoomId(), event.getSource().getContentId()); + broadcastInRoom(roomId, "countQuestionAnswersByQuestionId", answerService.countAnswersAndAbstentionsInternal(event.getSource().getContentId())); /* FIXME: Content variant is ignored for now */ broadcastInRoom(roomId, "countLectureQuestionAnswers", answerService.countTotalAnswersByRoomId(roomId)); broadcastInRoom(roomId, "countPreparationQuestionAnswers", answerService.countTotalAnswersByRoomId(roomId)); // Update the unanswered count for the content variant that was answered. - final de.thm.arsnova.model.Content content = event.getContent(); - if (content.getGroups().contains("lecture")) { - sendToUser(event.getUserId(), "unansweredLecturerQuestions", contentService.getUnAnsweredLectureContentIds(roomId, event.getUserId())); - } else if (content.getGroups().contains("preparation")) { - sendToUser(event.getUserId(), "unansweredPreparationQuestions", contentService.getUnAnsweredPreparationContentIds(roomId, event.getUserId())); - } + /* Is this still relevant? */ +// final de.thm.arsnova.model.Content content = // event.getSource().getContentId(); +// if (content.getGroups().contains("lecture")) { +// sendToUser(event.getSource().getCreatorId(), "unansweredLecturerQuestions", contentService.getUnAnsweredLectureContentIds(roomId, event.getSource().getCreatorId())); +// } else if (content.getGroups().contains("preparation")) { +// sendToUser(event.getSource().getCreatorId(), "unansweredPreparationQuestions", contentService.getUnAnsweredPreparationContentIds(roomId, event.getSource().getCreatorId())); +// } } @Async @EventListener @Timed - public void handleDeleteAnswer(DeleteAnswerEvent event) { - final String roomId = event.getRoom().getId(); - this.reportAnswersToContentAvailable(event.getRoom().getId(), event.getQuestion().getId()); + public void handleAfterAnswerDeletion(AfterDeletionEvent<Answer> event) { + final String roomId = event.getSource().getRoomId(); + this.reportAnswersToContentAvailable(event.getSource().getRoomId(), event.getSource().getContentId()); // We do not know which user's answer was deleted, so we can't update his 'unanswered' list of questions... /* FIXME: Content variant is ignored for now */ broadcastInRoom(roomId, "countLectureQuestionAnswers", answerService.countTotalAnswersByRoomId(roomId)); @@ -556,7 +558,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { @EventListener @Timed public void handlePiRoundDelayedStart(PiRoundDelayedStartEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "startDelayedPiRound", event.getPiRoundInformations()); } @@ -564,7 +566,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { @EventListener @Timed public void handlePiRoundEnd(PiRoundEndEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "endPiRound", event.getPiRoundEndInformations()); } @@ -572,25 +574,25 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { @EventListener @Timed public void handlePiRoundCancel(PiRoundCancelEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "cancelPiRound", event.getContentId()); } @EventListener public void handlePiRoundReset(PiRoundResetEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "resetPiRound", event.getPiRoundResetInformations()); } @EventListener public void handleLockVote(LockVoteEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "lockVote", event.getVotingAdmission()); } @EventListener public void handleUnlockVote(UnlockVoteEvent event) { - final String roomId = event.getRoom().getId(); + final String roomId = event.getRoomId(); broadcastInRoom(roomId, "unlockVote", event.getVotingAdmission()); } @@ -600,7 +602,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { for (de.thm.arsnova.model.Content q : event.getQuestions()) { contents.add(new Content(q)); } - broadcastInRoom(event.getRoom().getId(), "lockVotes", contents); + broadcastInRoom(event.getRoomId(), "lockVotes", contents); } @EventListener @@ -609,24 +611,24 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { for (de.thm.arsnova.model.Content q : event.getQuestions()) { contents.add(new Content(q)); } - broadcastInRoom(event.getRoom().getId(), "unlockVotes", contents); + broadcastInRoom(event.getRoomId(), "unlockVotes", contents); } @EventListener public void handleFeatureChange(FeatureChangeEvent event) { - final String roomId = event.getRoom().getId(); - final de.thm.arsnova.model.Room.Settings settings = event.getRoom().getSettings(); - broadcastInRoom(roomId, "featureChange", toV2Migrator.migrate(settings)); - - if (settings.isFlashcardsEnabled()) { - broadcastInRoom(roomId, "countFlashcards", contentService.countFlashcardsForUserInternal(roomId)); +// final String roomId = event.getRoomId(); +// final de.thm.arsnova.model.Room.Settings settings = event.getRoom().getSettings(); +// broadcastInRoom(roomId, "featureChange", toV2Migrator.migrate(settings)); +// +// if (settings.isFlashcardsEnabled()) { +// broadcastInRoom(roomId, "countFlashcards", contentService.countFlashcardsForUserInternal(roomId)); // broadcastInRoom(roomId, "flipFlashcards", event.getRoom().getFlipFlashcards()); - } +// } } @EventListener public void handleLockFeedback(LockFeedbackEvent event) { - broadcastInRoom(event.getRoom().getId(), "lockFeedback", event.getRoom().getSettings().isFeedbackLocked()); +// broadcastInRoom(event.getRoomId(), "lockFeedback", event.getRoom().getSettings().isFeedbackLocked()); } @EventListener @@ -636,7 +638,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { @EventListener public void handleNewFeedback(NewFeedbackEvent event) { - this.reportUpdatedFeedbackForRoom(event.getRoom().getId()); + this.reportUpdatedFeedbackForRoom(event.getRoomId()); } @EventListener @@ -647,11 +649,11 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer { @EventListener public void handleStatusRoom(StatusRoomEvent event) { - this.reportRoomStatus(event.getRoom().getId(), !event.getRoom().isClosed()); +// this.reportRoomStatus(event.getRoomId(), !event.getRoom().isClosed()); } @EventListener public void handleChangeScore(ChangeScoreEvent event) { - broadcastInRoom(event.getRoom().getId(), "learningProgressChange", null); + broadcastInRoom(event.getRoomId(), "learningProgressChange", null); } }