From aced7782875c0dc070ac77b33de17d8bef83895e Mon Sep 17 00:00:00 2001 From: Daniel Gerhardt <code@dgerhardt.net> Date: Thu, 3 Aug 2017 17:52:54 +0200 Subject: [PATCH] Rename service layer methods for consistency --- .../de/thm/arsnova/aop/UserSessionAspect.java | 2 +- .../arsnova/controller/CommentController.java | 12 ++-- .../arsnova/controller/ContentController.java | 38 ++++++------ .../controller/FeedbackController.java | 14 ++--- .../arsnova/controller/LegacyController.java | 2 +- .../arsnova/controller/MotdController.java | 20 +++--- .../arsnova/controller/SessionController.java | 18 +++--- .../arsnova/controller/UserController.java | 10 +-- .../couchdb/CouchDbMotdRepository.java | 2 +- .../couchdb/CouchDbSessionRepository.java | 2 +- .../thm/arsnova/services/CommentService.java | 16 ++--- .../arsnova/services/CommentServiceImpl.java | 18 +++--- .../thm/arsnova/services/ContentService.java | 36 +++++------ .../arsnova/services/ContentServiceImpl.java | 62 +++++++++---------- .../thm/arsnova/services/EntityService.java | 2 +- .../thm/arsnova/services/FeedbackService.java | 14 ++--- .../arsnova/services/FeedbackServiceImpl.java | 30 ++++----- .../services/FeedbackStorageService.java | 10 +-- .../services/FeedbackStorageServiceImpl.java | 14 ++--- .../de/thm/arsnova/services/MotdService.java | 20 +++--- .../thm/arsnova/services/MotdServiceImpl.java | 22 +++---- .../thm/arsnova/services/SessionService.java | 28 ++++----- .../arsnova/services/SessionServiceImpl.java | 38 ++++++------ .../de/thm/arsnova/services/UserService.java | 12 ++-- .../thm/arsnova/services/UserServiceImpl.java | 20 +++--- .../websocket/ArsnovaSocketioServerImpl.java | 42 ++++++------- 26 files changed, 252 insertions(+), 252 deletions(-) diff --git a/src/main/java/de/thm/arsnova/aop/UserSessionAspect.java b/src/main/java/de/thm/arsnova/aop/UserSessionAspect.java index e08c83d88..a5bda87fd 100644 --- a/src/main/java/de/thm/arsnova/aop/UserSessionAspect.java +++ b/src/main/java/de/thm/arsnova/aop/UserSessionAspect.java @@ -39,7 +39,7 @@ public class UserSessionAspect { /** Sets current user and ARSnova session in session scoped UserSessionService */ @AfterReturning( - pointcut = "execution(public * de.thm.arsnova.services.SessionService.joinSession(..)) && args(keyword)", + pointcut = "execution(public * de.thm.arsnova.services.SessionService.join(..)) && args(keyword)", returning = "session" ) public void joinSessionAdvice(final JoinPoint jp, final String keyword, final Session session) { diff --git a/src/main/java/de/thm/arsnova/controller/CommentController.java b/src/main/java/de/thm/arsnova/controller/CommentController.java index 0fc96762b..656e54b69 100644 --- a/src/main/java/de/thm/arsnova/controller/CommentController.java +++ b/src/main/java/de/thm/arsnova/controller/CommentController.java @@ -57,7 +57,7 @@ public class CommentController extends PaginationController { @DeprecatedApi @Deprecated public int getInterposedCount(@ApiParam(value = "Session-Key from current session", required = true) @RequestParam final String sessionkey) { - return commentService.getInterposedCount(sessionkey); + return commentService.count(sessionkey); } @ApiOperation(value = "count all unread comments", @@ -66,7 +66,7 @@ public class CommentController extends PaginationController { @DeprecatedApi @Deprecated public CommentReadingCount getUnreadInterposedCount(@ApiParam(value = "Session-Key from current session", required = true) @RequestParam("sessionkey") final String sessionkey, String user) { - return commentService.getInterposedReadingCount(sessionkey, user); + return commentService.countRead(sessionkey, user); } @ApiOperation(value = "Retrieves all Comments for a Session", @@ -74,14 +74,14 @@ public class CommentController extends PaginationController { @RequestMapping(value = "/", method = RequestMethod.GET) @Pagination public List<Comment> getInterposedQuestions(@ApiParam(value = "Session-Key from current session", required = true) @RequestParam final String sessionkey) { - return Comment.fromList(commentService.getInterposedQuestions(sessionkey, offset, limit)); + return Comment.fromList(commentService.getBySessionKey(sessionkey, offset, limit)); } @ApiOperation(value = "Retrieves an Comment", nickname = "getInterposedQuestion") @RequestMapping(value = "/{questionId}", method = RequestMethod.GET) public Comment getInterposedQuestion(@ApiParam(value = "ID of the Comment that needs to be deleted", required = true) @PathVariable final String questionId) { - return new Comment(commentService.readInterposedQuestion(questionId)); + return new Comment(commentService.getAndMarkRead(questionId)); } @ApiOperation(value = "Creates a new Comment for a Session and returns the Comment's data", @@ -95,7 +95,7 @@ public class CommentController extends PaginationController { @ApiParam(value = "Session-Key from current session", required = true) @RequestParam final String sessionkey, @ApiParam(value = "the body from the new comment", required = true) @RequestBody final de.thm.arsnova.entities.Comment comment ) { - if (commentService.saveQuestion(comment)) { + if (commentService.save(comment)) { return; } @@ -106,6 +106,6 @@ public class CommentController extends PaginationController { nickname = "deleteInterposedQuestion") @RequestMapping(value = "/{questionId}", method = RequestMethod.DELETE) public void deleteInterposedQuestion(@ApiParam(value = "ID of the comment that needs to be deleted", required = true) @PathVariable final String questionId) { - commentService.deleteInterposedQuestion(questionId); + commentService.delete(questionId); } } diff --git a/src/main/java/de/thm/arsnova/controller/ContentController.java b/src/main/java/de/thm/arsnova/controller/ContentController.java index f2c77d5e3..691a1e261 100644 --- a/src/main/java/de/thm/arsnova/controller/ContentController.java +++ b/src/main/java/de/thm/arsnova/controller/ContentController.java @@ -63,7 +63,7 @@ public class ContentController extends PaginationController { }) @RequestMapping(value = "/{questionId}", method = RequestMethod.GET) public Content getQuestion(@PathVariable final String questionId) { - final Content content = contentService.getQuestion(questionId); + final Content content = contentService.get(questionId); if (content != null) { return content; } @@ -79,7 +79,7 @@ public class ContentController extends PaginationController { @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Content postQuestion(@RequestBody final Content content) { - if (contentService.saveQuestion(content) != null) { + if (contentService.save(content) != null) { return content; } throw new BadRequestException(); @@ -93,7 +93,7 @@ public class ContentController extends PaginationController { @ResponseStatus(HttpStatus.CREATED) public List<Content> bulkPostQuestions(@RequestBody final List<Content> contents) { for (final Content content : contents) { - if (contentService.saveQuestion(content) == null) { + if (contentService.save(content) == null) { throw new BadRequestException(); } } @@ -291,7 +291,7 @@ public class ContentController extends PaginationController { } else if (preparationQuestionsOnly) { contents = contentService.getPreparationQuestions(sessionkey); } else { - contents = contentService.getSkillQuestions(sessionkey); + contents = contentService.getBySessionKey(sessionkey); } if (contents == null || contents.isEmpty()) { response.setStatus(HttpStatus.NO_CONTENT.value()); @@ -320,7 +320,7 @@ public class ContentController extends PaginationController { } else if (preparationQuestionsOnly) { contentService.deletePreparationQuestions(sessionkey); } else { - contentService.deleteAllQuestions(sessionkey); + contentService.deleteBySessionKey(sessionkey); } } @@ -336,13 +336,13 @@ public class ContentController extends PaginationController { @RequestParam(value = "preparationquestionsonly", defaultValue = "false") final boolean preparationQuestionsOnly ) { if (lectureQuestionsOnly) { - return contentService.getLectureQuestionCount(sessionkey); + return contentService.countLectureQuestions(sessionkey); } else if (flashcardsOnly) { - return contentService.getFlashcardCount(sessionkey); + return contentService.countFlashcards(sessionkey); } else if (preparationQuestionsOnly) { - return contentService.getPreparationQuestionCount(sessionkey); + return contentService.countPreparationQuestions(sessionkey); } else { - return contentService.getSkillQuestionCount(sessionkey); + return contentService.countBySessionKey(sessionkey); } } @@ -352,7 +352,7 @@ public class ContentController extends PaginationController { public void deleteAnswersAndQuestion( @PathVariable final String questionId ) { - contentService.deleteQuestion(questionId); + contentService.delete(questionId); } @ApiOperation(value = "Get unanswered skill question ID by provided session ID", @@ -544,7 +544,7 @@ public class ContentController extends PaginationController { @Deprecated @RequestMapping(value = "/{questionId}/answercount", method = RequestMethod.GET) public int getAnswerCount(@PathVariable final String questionId) { - return contentService.getAnswerCount(questionId); + return contentService.countAnswersByQuestionIdAndRound(questionId); } @ApiOperation(value = "Get the amount of answers for a question, identified by the question ID", @@ -552,8 +552,8 @@ public class ContentController extends PaginationController { @RequestMapping(value = "/{questionId}/allroundanswercount", method = RequestMethod.GET) public List<Integer> getAllAnswerCount(@PathVariable final String questionId) { return Arrays.asList( - contentService.getAnswerCount(questionId, 1), - contentService.getAnswerCount(questionId, 2) + contentService.countAnswersByQuestionIdAndRound(questionId, 1), + contentService.countAnswersByQuestionIdAndRound(questionId, 2) ); } @@ -561,7 +561,7 @@ public class ContentController extends PaginationController { nickname = "getTotalAnswerCountByQuestion") @RequestMapping(value = "/{questionId}/totalanswercount", method = RequestMethod.GET) public int getTotalAnswerCountByQuestion(@PathVariable final String questionId) { - return contentService.getTotalAnswerCountByQuestion(questionId); + return contentService.countTotalAnswersByQuestionId(questionId); } @ApiOperation(value = "Get the amount of answers and abstention answers by a question, identified by the question ID", @@ -569,8 +569,8 @@ public class ContentController extends PaginationController { @RequestMapping(value = "/{questionId}/answerandabstentioncount", method = RequestMethod.GET) public List<Integer> getAnswerAndAbstentionCount(@PathVariable final String questionId) { return Arrays.asList( - contentService.getAnswerCount(questionId), - contentService.getAbstentionAnswerCount(questionId) + contentService.countAnswersByQuestionIdAndRound(questionId), + contentService.countTotalAbstentionsByQuestionId(questionId) ); } @@ -579,7 +579,7 @@ public class ContentController extends PaginationController { @RequestMapping(value = "/{questionId}/freetextanswer/", method = RequestMethod.GET) @Pagination public List<Answer> getFreetextAnswers(@PathVariable final String questionId) { - return contentService.getFreetextAnswers(questionId, offset, limit); + return contentService.getFreetextAnswersByQuestionId(questionId, offset, limit); } @ApiOperation(value = "Get my answers of an session, identified by the sessionkey", @@ -588,7 +588,7 @@ public class ContentController extends PaginationController { @Deprecated @RequestMapping(value = "/myanswers", method = RequestMethod.GET) public List<Answer> getMyAnswers(@RequestParam final String sessionkey) { - return contentService.getMyAnswers(sessionkey); + return contentService.getMyAnswersBySessionKey(sessionkey); } @ApiOperation(value = "Get the total amount of answers of an session, identified by the sessionkey", @@ -606,7 +606,7 @@ public class ContentController extends PaginationController { } else if (preparationQuestionsOnly) { return contentService.countPreparationQuestionAnswers(sessionkey); } else { - return contentService.getTotalAnswerCount(sessionkey); + return contentService.countTotalAnswersBySessionKey(sessionkey); } } } diff --git a/src/main/java/de/thm/arsnova/controller/FeedbackController.java b/src/main/java/de/thm/arsnova/controller/FeedbackController.java index 000176a21..0d6c54d3d 100644 --- a/src/main/java/de/thm/arsnova/controller/FeedbackController.java +++ b/src/main/java/de/thm/arsnova/controller/FeedbackController.java @@ -51,14 +51,14 @@ public class FeedbackController extends AbstractController { @Deprecated @RequestMapping(value = "/session/{sessionkey}/feedback", method = RequestMethod.GET) public Feedback getFeedback(@PathVariable final String sessionkey) { - return feedbackService.getFeedback(sessionkey); + return feedbackService.getBySessionKey(sessionkey); } @DeprecatedApi @Deprecated @RequestMapping(value = "/session/{sessionkey}/myfeedback", method = RequestMethod.GET) public Integer getMyFeedback(@PathVariable final String sessionkey) { - Integer value = feedbackService.getMyFeedback(sessionkey, userService.getCurrentUser()); + Integer value = feedbackService.getBySessionKeyAndUser(sessionkey, userService.getCurrentUser()); if (value != null && value >= Feedback.MIN_FEEDBACK_TYPE && value <= Feedback.MAX_FEEDBACK_TYPE) { return value; } @@ -69,21 +69,21 @@ public class FeedbackController extends AbstractController { @Deprecated @RequestMapping(value = "/session/{sessionkey}/feedbackcount", method = RequestMethod.GET) public int getFeedbackCount(@PathVariable final String sessionkey) { - return feedbackService.getFeedbackCount(sessionkey); + return feedbackService.countFeedbackBySessionKey(sessionkey); } @DeprecatedApi @Deprecated @RequestMapping(value = "/session/{sessionkey}/roundedaveragefeedback", method = RequestMethod.GET) public long getAverageFeedbackRounded(@PathVariable final String sessionkey) { - return feedbackService.getAverageFeedbackRounded(sessionkey); + return feedbackService.calculateRoundedAverageFeedback(sessionkey); } @DeprecatedApi @Deprecated @RequestMapping(value = "/session/{sessionkey}/averagefeedback", method = RequestMethod.GET) public double getAverageFeedback(@PathVariable final String sessionkey) { - return feedbackService.getAverageFeedback(sessionkey); + return feedbackService.calculateAverageFeedback(sessionkey); } @DeprecatedApi @@ -95,8 +95,8 @@ public class FeedbackController extends AbstractController { @RequestBody final int value ) { User user = userService.getCurrentUser(); - feedbackService.saveFeedback(sessionkey, value, user); - Feedback feedback = feedbackService.getFeedback(sessionkey); + feedbackService.save(sessionkey, value, user); + Feedback feedback = feedbackService.getBySessionKey(sessionkey); return feedback; } diff --git a/src/main/java/de/thm/arsnova/controller/LegacyController.java b/src/main/java/de/thm/arsnova/controller/LegacyController.java index d58adad0a..384c02da1 100644 --- a/src/main/java/de/thm/arsnova/controller/LegacyController.java +++ b/src/main/java/de/thm/arsnova/controller/LegacyController.java @@ -99,7 +99,7 @@ public class LegacyController extends AbstractController { @RequestMapping(value = "/session/{sessionKey}/interposed", method = RequestMethod.DELETE) @ResponseBody public void deleteAllInterposedQuestions(@PathVariable final String sessionKey) { - commentService.deleteAllInterposedQuestions(sessionKey); + commentService.deleteBySessionKey(sessionKey); } @DeprecatedApi diff --git a/src/main/java/de/thm/arsnova/controller/MotdController.java b/src/main/java/de/thm/arsnova/controller/MotdController.java index c566a602e..acc933533 100644 --- a/src/main/java/de/thm/arsnova/controller/MotdController.java +++ b/src/main/java/de/thm/arsnova/controller/MotdController.java @@ -93,9 +93,9 @@ public class MotdController extends AbstractController { if (motd != null) { Motd newMotd; if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) { - newMotd = motdService.saveSessionMotd(motd.getSessionkey(), motd); + newMotd = motdService.save(motd.getSessionkey(), motd); } else { - newMotd = motdService.saveMotd(motd); + newMotd = motdService.save(motd); } if (newMotd == null) { response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value()); @@ -115,20 +115,20 @@ public class MotdController extends AbstractController { @ApiParam(value = "current motd", required = true) @RequestBody final Motd motd ) { if ("session".equals(motd.getAudience()) && motd.getSessionkey() != null) { - return motdService.updateSessionMotd(motd.getSessionkey(), motd); + return motdService.update(motd.getSessionkey(), motd); } else { - return motdService.updateMotd(motd); + return motdService.update(motd); } } @ApiOperation(value = "deletes a message of the day", nickname = "deleteMotd") @RequestMapping(value = "/{motdkey}", method = RequestMethod.DELETE) public void deleteMotd(@ApiParam(value = "Motd-key from the message that shall be deleted", required = true) @PathVariable final String motdkey) { - Motd motd = motdService.getMotd(motdkey); + Motd motd = motdService.getByKey(motdkey); if ("session".equals(motd.getAudience())) { - motdService.deleteSessionMotd(motd.getSessionkey(), motd); + motdService.deleteBySessionKey(motd.getSessionkey(), motd); } else { - motdService.deleteMotd(motd); + motdService.delete(motd); } } @@ -136,7 +136,7 @@ public class MotdController extends AbstractController { @RequestMapping(value = "/userlist", method = RequestMethod.GET) public MotdList getUserMotdList( @ApiParam(value = "users name", required = true) @RequestParam(value = "username", defaultValue = "null", required = true) final String username) { - return motdService.getMotdListForUser(username); + return motdService.getMotdListByUsername(username); } @ApiOperation(value = "create a list of the motdkeys the current user has confirmed to be read") @@ -144,7 +144,7 @@ public class MotdController extends AbstractController { public MotdList postUserMotdList( @ApiParam(value = "current motdlist", required = true) @RequestBody final MotdList userMotdList ) { - return motdService.saveUserMotdList(userMotdList); + return motdService.saveMotdList(userMotdList); } @ApiOperation(value = "update a list of the motdkeys the current user has confirmed to be read") @@ -152,6 +152,6 @@ public class MotdController extends AbstractController { public MotdList updateUserMotdList( @ApiParam(value = "current motdlist", required = true) @RequestBody final MotdList userMotdList ) { - return motdService.updateUserMotdList(userMotdList); + return motdService.updateMotdList(userMotdList); } } diff --git a/src/main/java/de/thm/arsnova/controller/SessionController.java b/src/main/java/de/thm/arsnova/controller/SessionController.java index 77ee2bfac..3f11525fa 100644 --- a/src/main/java/de/thm/arsnova/controller/SessionController.java +++ b/src/main/java/de/thm/arsnova/controller/SessionController.java @@ -76,9 +76,9 @@ public class SessionController extends PaginationController { @ApiParam(value = "Adminflag", required = false) @RequestParam(value = "admin", defaultValue = "false") final boolean admin ) { if (admin) { - return sessionService.getSessionForAdmin(sessionkey); + return sessionService.getForAdmin(sessionkey); } else { - return sessionService.getSession(sessionkey); + return sessionService.getByKey(sessionkey); } } @@ -86,7 +86,7 @@ public class SessionController extends PaginationController { nickname = "deleteSession") @RequestMapping(value = "/{sessionkey}", method = RequestMethod.DELETE) public void deleteSession(@ApiParam(value = "Session-Key from current session", required = true) @PathVariable final String sessionkey) { - sessionService.deleteSession(sessionkey); + sessionService.delete(sessionkey); } @ApiOperation(value = "count active users", @@ -112,7 +112,7 @@ public class SessionController extends PaginationController { final Course course = new Course(); course.setId(session.getCourseId()); courses.add(course); - final int sessionCount = sessionService.countSessions(courses); + final int sessionCount = sessionService.countSessionsByCourses(courses); if (sessionCount > 0) { final String appendix = " (" + (sessionCount + 1) + ")"; session.setName(session.getName() + appendix); @@ -120,7 +120,7 @@ public class SessionController extends PaginationController { } } - final Session newSession = sessionService.saveSession(session); + final Session newSession = sessionService.save(session); if (newSession == null) { response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value()); @@ -137,7 +137,7 @@ public class SessionController extends PaginationController { @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, @ApiParam(value = "current session", required = true) @RequestBody final Session session ) { - return sessionService.updateSession(sessionkey, session); + return sessionService.update(sessionkey, session); } @ApiOperation(value = "change the session creator (owner)", nickname = "changeSessionCreator") @@ -146,7 +146,7 @@ public class SessionController extends PaginationController { @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, @ApiParam(value = "new session creator", required = true) @RequestBody final String newCreator ) { - return sessionService.changeSessionCreator(sessionkey, newCreator); + return sessionService.updateCreator(sessionkey, newCreator); } @ApiOperation(value = "Retrieves a list of Sessions", @@ -376,7 +376,7 @@ public class SessionController extends PaginationController { @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, final HttpServletResponse response ) { - return sessionService.getSessionFeatures(sessionkey); + return sessionService.getFeatures(sessionkey); } @RequestMapping(value = "/{sessionkey}/features", method = RequestMethod.PUT) @@ -387,7 +387,7 @@ public class SessionController extends PaginationController { @ApiParam(value = "session feature", required = true) @RequestBody final SessionFeature features, final HttpServletResponse response ) { - return sessionService.changeSessionFeatures(sessionkey, features); + return sessionService.updateFeatures(sessionkey, features); } @RequestMapping(value = "/{sessionkey}/lockfeedbackinput", method = RequestMethod.POST) diff --git a/src/main/java/de/thm/arsnova/controller/UserController.java b/src/main/java/de/thm/arsnova/controller/UserController.java index e9b2d5c25..c0fa9eade 100644 --- a/src/main/java/de/thm/arsnova/controller/UserController.java +++ b/src/main/java/de/thm/arsnova/controller/UserController.java @@ -50,7 +50,7 @@ public class UserController extends AbstractController { public void register(@RequestParam final String username, @RequestParam final String password, final HttpServletRequest request, final HttpServletResponse response) { - if (null != userService.createDbUser(username, password)) { + if (null != userService.create(username, password)) { return; } @@ -64,10 +64,10 @@ public class UserController extends AbstractController { @PathVariable final String username, @RequestParam final String key, final HttpServletRequest request, final HttpServletResponse response) { - DbUser dbUser = userService.getDbUser(username); + DbUser dbUser = userService.getByUsername(username); if (null != dbUser && key.equals(dbUser.getActivationKey())) { dbUser.setActivationKey(null); - userService.updateDbUser(dbUser); + userService.update(dbUser); return; } @@ -80,7 +80,7 @@ public class UserController extends AbstractController { @PathVariable final String username, final HttpServletRequest request, final HttpServletResponse response) { - if (null == userService.deleteDbUser(username)) { + if (null == userService.deleteByUsername(username)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } @@ -92,7 +92,7 @@ public class UserController extends AbstractController { @RequestParam(required = false) final String password, final HttpServletRequest request, final HttpServletResponse response) { - DbUser dbUser = userService.getDbUser(username); + DbUser dbUser = userService.getByUsername(username); if (null == dbUser) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java index 38ccd027e..8c2de65f8 100644 --- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java +++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbMotdRepository.java @@ -105,7 +105,7 @@ public class CouchDbMotdRepository extends CouchDbCrudRepository<Motd> implement motd.setMotdkey(oldMotd.getMotdkey()); update(motd); } else { - motd.setMotdkey(sessionService.generateKeyword()); + motd.setMotdkey(sessionService.generateKey()); add(motd); } diff --git a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java index c4e1a2cdc..11671d5c4 100644 --- a/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java +++ b/src/main/java/de/thm/arsnova/persistance/couchdb/CouchDbSessionRepository.java @@ -89,7 +89,7 @@ public class CouchDbSessionRepository extends CouchDbCrudRepository<Session> imp @Override @Caching(evict = @CacheEvict(cacheNames = "sessions", key = "#result.keyword")) public Session save(final User user, final Session session) { - session.setKeyword(sessionService.generateKeyword()); + session.setKeyword(sessionService.generateKey()); session.setCreator(user.getUsername()); session.setActive(true); session.setFeedbackLock(false); diff --git a/src/main/java/de/thm/arsnova/services/CommentService.java b/src/main/java/de/thm/arsnova/services/CommentService.java index e255011ad..6ffc38c91 100644 --- a/src/main/java/de/thm/arsnova/services/CommentService.java +++ b/src/main/java/de/thm/arsnova/services/CommentService.java @@ -7,19 +7,19 @@ import de.thm.arsnova.entities.User; import java.util.List; public interface CommentService { - boolean saveQuestion(Comment comment); + boolean save(Comment comment); - int getInterposedCount(String sessionKey); + int count(String sessionKey); - CommentReadingCount getInterposedReadingCount(String sessionKey, String username); + CommentReadingCount countRead(String sessionKey, String username); - List<Comment> getInterposedQuestions(String sessionKey, int offset, int limit); + List<Comment> getBySessionKey(String sessionKey, int offset, int limit); - Comment readInterposedQuestion(String commentId); + Comment getAndMarkRead(String commentId); - Comment readInterposedQuestionInternal(String commentId, User user); + Comment getAndMarkReadInternal(String commentId, User user); - void deleteInterposedQuestion(String commentId); + void delete(String commentId); - void deleteAllInterposedQuestions(String sessionKeyword); + void deleteBySessionKey(String sessionKeyword); } diff --git a/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java b/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java index d0717a9f6..2b44caf6d 100644 --- a/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/CommentServiceImpl.java @@ -36,7 +36,7 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated()") - public boolean saveQuestion(final Comment comment) { + public boolean save(final Comment comment) { final Session session = sessionRepository.findByKeyword(comment.getSessionId()); final Comment result = commentRepository.save(session.getId(), comment, userService.getCurrentUser()); @@ -50,7 +50,7 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated() and hasPermission(#commentId, 'comment', 'owner')") - public void deleteInterposedQuestion(final String commentId) { + public void delete(final String commentId) { final Comment comment = commentRepository.findOne(commentId); if (comment == null) { throw new NotFoundException(); @@ -64,7 +64,7 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated()") - public void deleteAllInterposedQuestions(final String sessionKeyword) { + public void deleteBySessionKey(final String sessionKeyword) { final Session session = sessionRepository.findByKeyword(sessionKeyword); if (session == null) { throw new UnauthorizedException(); @@ -79,13 +79,13 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated()") - public int getInterposedCount(final String sessionKey) { + public int count(final String sessionKey) { return commentRepository.countBySessionKey(sessionKey); } @Override @PreAuthorize("isAuthenticated()") - public CommentReadingCount getInterposedReadingCount(final String sessionKey, String username) { + public CommentReadingCount countRead(final String sessionKey, String username) { final Session session = sessionRepository.findByKeyword(sessionKey); if (session == null) { throw new NotFoundException(); @@ -104,7 +104,7 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated()") - public List<Comment> getInterposedQuestions(final String sessionKey, final int offset, final int limit) { + public List<Comment> getBySessionKey(final String sessionKey, final int offset, final int limit) { final Session session = this.getSession(sessionKey); final User user = getCurrentUser(); if (session.isCreator(user)) { @@ -116,9 +116,9 @@ public class CommentServiceImpl implements CommentService { @Override @PreAuthorize("isAuthenticated()") - public Comment readInterposedQuestion(final String commentId) { + public Comment getAndMarkRead(final String commentId) { final User user = userService.getCurrentUser(); - return this.readInterposedQuestionInternal(commentId, user); + return this.getAndMarkReadInternal(commentId, user); } /* @@ -126,7 +126,7 @@ public class CommentServiceImpl implements CommentService { * TODO: Find a better way of doing this... */ @Override - public Comment readInterposedQuestionInternal(final String commentId, User user) { + public Comment getAndMarkReadInternal(final String commentId, User user) { final Comment comment = commentRepository.findOne(commentId); if (comment == null) { throw new NotFoundException(); diff --git a/src/main/java/de/thm/arsnova/services/ContentService.java b/src/main/java/de/thm/arsnova/services/ContentService.java index 9fae2e8ac..fc9e6c5a1 100644 --- a/src/main/java/de/thm/arsnova/services/ContentService.java +++ b/src/main/java/de/thm/arsnova/services/ContentService.java @@ -30,17 +30,17 @@ import java.util.Map; * The functionality the question service should provide. */ public interface ContentService { - Content saveQuestion(Content content); + Content save(Content content); - Content getQuestion(String id); + Content get(String id); - List<Content> getSkillQuestions(String sessionkey); + List<Content> getBySessionKey(String sessionkey); - int getSkillQuestionCount(String sessionkey); + int countBySessionKey(String sessionkey); - void deleteQuestion(String questionId); + void delete(String questionId); - void deleteAllQuestions(String sessionKeyword); + void deleteBySessionKey(String sessionKeyword); void startNewPiRound(String questionId, User user); @@ -56,7 +56,7 @@ public interface ContentService { Answer getMyAnswer(String questionId); - void readFreetextAnswer(String answerId, User user); + void getFreetextAnswerAndMarkRead(String answerId, User user); List<Answer> getAnswers(String questionId, int piRound, int offset, int limit); @@ -64,17 +64,17 @@ public interface ContentService { List<Answer> getAllAnswers(String questionId, int offset, int limit); - int getAnswerCount(String questionId); + int countAnswersByQuestionIdAndRound(String questionId); - int getAnswerCount(String questionId, int piRound); + int countAnswersByQuestionIdAndRound(String questionId, int piRound); - List<Answer> getFreetextAnswers(String questionId, int offset, int limit); + List<Answer> getFreetextAnswersByQuestionId(String questionId, int offset, int limit); - List<Answer> getMyAnswers(String sessionKey); + List<Answer> getMyAnswersBySessionKey(String sessionKey); - int getTotalAnswerCount(String sessionKey); + int countTotalAnswersBySessionKey(String sessionKey); - int getTotalAnswerCountByQuestion(String questionId); + int countTotalAnswersByQuestionId(String questionId); Content update(Content content); @@ -94,13 +94,13 @@ public interface ContentService { List<Content> getPreparationQuestions(String sessionkey); - int getLectureQuestionCount(String sessionkey); + int countLectureQuestions(String sessionkey); - int getFlashcardCount(String sessionkey); + int countFlashcards(String sessionkey); - int getPreparationQuestionCount(String sessionkey); + int countPreparationQuestions(String sessionkey); - Map<String, Object> getAnswerAndAbstentionCountInternal(String questionid); + Map<String, Object> countAnswersAndAbstentionsInternal(String questionid); int countLectureQuestionAnswers(String sessionkey); @@ -136,7 +136,7 @@ public interface ContentService { void deleteAllLectureAnswers(String sessionkey); - int getAbstentionAnswerCount(String questionId); + int countTotalAbstentionsByQuestionId(String questionId); String getImage(String questionId, String answerId); diff --git a/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java b/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java index 12b0746d4..e63bab822 100644 --- a/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/ContentServiceImpl.java @@ -77,7 +77,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public List<Content> getSkillQuestions(final String sessionkey) { + public List<Content> getBySessionKey(final String sessionkey) { final Session session = getSession(sessionkey); final User user = userService.getCurrentUser(); if (session.isCreator(user)) { @@ -89,7 +89,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getSkillQuestionCount(final String sessionkey) { + public int countBySessionKey(final String sessionkey) { final Session session = sessionRepository.findByKeyword(sessionkey); return contentRepository.countBySessionId(session.getId()); } @@ -97,7 +97,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli /* FIXME: #content.getSessionKeyword() cannot be checked since keyword is no longer set for content. */ @Override @PreAuthorize("isAuthenticated() and hasPermission(#content.getSessionKeyword(), 'session', 'owner')") - public Content saveQuestion(final Content content) { + public Content save(final Content content) { final Session session = sessionRepository.findByKeyword(content.getSessionKeyword()); content.setSessionId(session.getId()); content.setTimestamp(System.currentTimeMillis() / 1000L); @@ -128,7 +128,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public Content getQuestion(final String id) { + public Content get(final String id) { final Content result = contentRepository.findOne(id); if (result == null) { return null; @@ -143,7 +143,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated() and hasPermission(#questionId, 'content', 'owner')") - public void deleteQuestion(final String questionId) { + public void delete(final String questionId) { final Content content = contentRepository.findOne(questionId); if (content == null) { throw new NotFoundException(); @@ -161,7 +161,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated() and hasPermission(#sessionKeyword, 'session', 'owner')") - public void deleteAllQuestions(final String sessionKeyword) { + public void deleteBySessionKey(final String sessionKeyword) { final Session session = getSessionWithAuthCheck(sessionKeyword); contentRepository.deleteAllQuestionsWithAnswers(session.getId()); @@ -359,7 +359,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") public Answer getMyAnswer(final String questionId) { - final Content content = getQuestion(questionId); + final Content content = get(questionId); if (content == null) { throw new NotFoundException(); } @@ -367,7 +367,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli } @Override - public void readFreetextAnswer(final String answerId, final User user) { + public void getFreetextAnswerAndMarkRead(final String answerId, final User user) { final Answer answer = answerRepository.findOne(answerId); if (answer == null) { throw new NotFoundException(); @@ -390,19 +390,19 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli throw new NotFoundException(); } return "freetext".equals(content.getQuestionType()) - ? getFreetextAnswers(questionId, offset, limit) + ? getFreetextAnswersByQuestionId(questionId, offset, limit) : answerRepository.findByContentIdPiRound(content.getId(), piRound); } @Override @PreAuthorize("isAuthenticated()") public List<Answer> getAnswers(final String questionId, final int offset, final int limit) { - final Content content = getQuestion(questionId); + final Content content = get(questionId); if (content == null) { throw new NotFoundException(); } if ("freetext".equals(content.getQuestionType())) { - return getFreetextAnswers(questionId, offset, limit); + return getFreetextAnswersByQuestionId(questionId, offset, limit); } else { return answerRepository.findByContentIdPiRound(content.getId(), content.getPiRound()); } @@ -411,12 +411,12 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") public List<Answer> getAllAnswers(final String questionId, final int offset, final int limit) { - final Content content = getQuestion(questionId); + final Content content = get(questionId); if (content == null) { throw new NotFoundException(); } if ("freetext".equals(content.getQuestionType())) { - return getFreetextAnswers(questionId, offset, limit); + return getFreetextAnswersByQuestionId(questionId, offset, limit); } else { return answerRepository.findByContentId(content.getId()); } @@ -424,8 +424,8 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getAnswerCount(final String questionId) { - final Content content = getQuestion(questionId); + public int countAnswersByQuestionIdAndRound(final String questionId) { + final Content content = get(questionId); if (content == null) { return 0; } @@ -439,8 +439,8 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getAnswerCount(final String questionId, final int piRound) { - final Content content = getQuestion(questionId); + public int countAnswersByQuestionIdAndRound(final String questionId, final int piRound) { + final Content content = get(questionId); if (content == null) { return 0; } @@ -450,8 +450,8 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getAbstentionAnswerCount(final String questionId) { - final Content content = getQuestion(questionId); + public int countTotalAbstentionsByQuestionId(final String questionId) { + final Content content = get(questionId); if (content == null) { return 0; } @@ -461,8 +461,8 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getTotalAnswerCountByQuestion(final String questionId) { - final Content content = getQuestion(questionId); + public int countTotalAnswersByQuestionId(final String questionId) { + final Content content = get(questionId); if (content == null) { return 0; } @@ -472,7 +472,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public List<Answer> getFreetextAnswers(final String questionId, final int offset, final int limit) { + public List<Answer> getFreetextAnswersByQuestionId(final String questionId, final int offset, final int limit) { final List<Answer> answers = answerRepository.findByContentId(questionId, offset, limit); if (answers == null) { throw new NotFoundException(); @@ -487,7 +487,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public List<Answer> getMyAnswers(final String sessionKey) { + public List<Answer> getMyAnswersBySessionKey(final String sessionKey) { final Session session = getSession(sessionKey); // Load contents first because we are only interested in answers of the latest piRound. final List<Content> contents = contentRepository.findBySessionIdForUsers(session.getId()); @@ -521,7 +521,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getTotalAnswerCount(final String sessionKey) { + public int countTotalAnswersBySessionKey(final String sessionKey) { return answerRepository.countBySessionKey(sessionKey); } @@ -567,7 +567,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @PreAuthorize("isAuthenticated()") public Answer saveAnswer(final String questionId, final de.thm.arsnova.entities.transport.Answer answer) { final User user = getCurrentUser(); - final Content content = getQuestion(questionId); + final Content content = get(questionId); if (content == null) { throw new NotFoundException(); } @@ -602,7 +602,7 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli throw new UnauthorizedException(); } - final Content content = getQuestion(answer.getQuestionId()); + final Content content = get(answer.getQuestionId()); if ("freetext".equals(content.getQuestionType())) { imageUtils.generateThumbnailImage(realAnswer); content.checkTextStrictOptions(realAnswer); @@ -692,19 +692,19 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public int getLectureQuestionCount(final String sessionkey) { + public int countLectureQuestions(final String sessionkey) { return contentRepository.countLectureVariantBySessionId(getSession(sessionkey).getId()); } @Override @PreAuthorize("isAuthenticated()") - public int getFlashcardCount(final String sessionkey) { + public int countFlashcards(final String sessionkey) { return contentRepository.countFlashcardVariantBySessionId(getSession(sessionkey).getId()); } @Override @PreAuthorize("isAuthenticated()") - public int getPreparationQuestionCount(final String sessionkey) { + public int countPreparationQuestions(final String sessionkey) { return contentRepository.countPreparationVariantBySessionId(getSession(sessionkey).getId()); } @@ -724,8 +724,8 @@ public class ContentServiceImpl implements ContentService, ApplicationEventPubli } @Override - public Map<String, Object> getAnswerAndAbstentionCountInternal(final String questionId) { - final Content content = getQuestion(questionId); + public Map<String, Object> countAnswersAndAbstentionsInternal(final String questionId) { + final Content content = get(questionId); HashMap<String, Object> map = new HashMap<>(); if (content == null) { diff --git a/src/main/java/de/thm/arsnova/services/EntityService.java b/src/main/java/de/thm/arsnova/services/EntityService.java index 042d40fbd..25e53aa0d 100644 --- a/src/main/java/de/thm/arsnova/services/EntityService.java +++ b/src/main/java/de/thm/arsnova/services/EntityService.java @@ -23,7 +23,7 @@ public class EntityService<T extends Entity> { } @PreAuthorize("hasPermission(type, #id, 'read')") - public T findOne(final String id) { + public T get(final String id) { return repository.findOne(id); } diff --git a/src/main/java/de/thm/arsnova/services/FeedbackService.java b/src/main/java/de/thm/arsnova/services/FeedbackService.java index 8e0d8842e..efa40e16e 100644 --- a/src/main/java/de/thm/arsnova/services/FeedbackService.java +++ b/src/main/java/de/thm/arsnova/services/FeedbackService.java @@ -26,17 +26,17 @@ import de.thm.arsnova.entities.User; public interface FeedbackService { void cleanFeedbackVotes(); - void cleanFeedbackVotesInSession(String keyword, int cleanupFeedbackDelayInMins); + void cleanFeedbackVotesBySessionKey(String keyword, int cleanupFeedbackDelayInMins); - Feedback getFeedback(String keyword); + Feedback getBySessionKey(String keyword); - int getFeedbackCount(String keyword); + int countFeedbackBySessionKey(String keyword); - double getAverageFeedback(String sessionkey); + double calculateAverageFeedback(String sessionkey); - long getAverageFeedbackRounded(String sessionkey); + long calculateRoundedAverageFeedback(String sessionkey); - boolean saveFeedback(String keyword, int value, User user); + boolean save(String keyword, int value, User user); - Integer getMyFeedback(String keyword, User user); + Integer getBySessionKeyAndUser(String keyword, User user); } diff --git a/src/main/java/de/thm/arsnova/services/FeedbackServiceImpl.java b/src/main/java/de/thm/arsnova/services/FeedbackServiceImpl.java index e83210ef0..3290cc2b6 100644 --- a/src/main/java/de/thm/arsnova/services/FeedbackServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/FeedbackServiceImpl.java @@ -66,7 +66,7 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub @Override @Scheduled(fixedDelay = DEFAULT_SCHEDULER_DELAY) public void cleanFeedbackVotes() { - Map<Session, List<User>> deletedFeedbackOfUsersInSession = feedbackStorage.cleanFeedbackVotes(cleanupFeedbackDelay); + Map<Session, List<User>> deletedFeedbackOfUsersInSession = feedbackStorage.cleanVotes(cleanupFeedbackDelay); /* * mapping (Session -> Users) is not suitable for web sockets, because we want to sent all affected * sessions to a single user in one go instead of sending multiple messages for each session. Hence, @@ -101,9 +101,9 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub } @Override - public void cleanFeedbackVotesInSession(final String keyword, final int cleanupFeedbackDelayInMins) { + public void cleanFeedbackVotesBySessionKey(final String keyword, final int cleanupFeedbackDelayInMins) { final Session session = sessionRepository.findByKeyword(keyword); - List<User> affectedUsers = feedbackStorage.cleanFeedbackVotesInSession(session, cleanupFeedbackDelayInMins); + List<User> affectedUsers = feedbackStorage.cleanVotesBySession(session, cleanupFeedbackDelayInMins); Set<Session> sessionSet = new HashSet<>(); sessionSet.add(session); @@ -116,29 +116,29 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub } @Override - public Feedback getFeedback(final String keyword) { + public Feedback getBySessionKey(final String keyword) { final Session session = sessionRepository.findByKeyword(keyword); if (session == null) { throw new NotFoundException(); } - return feedbackStorage.getFeedback(session); + return feedbackStorage.getBySession(session); } @Override - public int getFeedbackCount(final String keyword) { - final Feedback feedback = this.getFeedback(keyword); + public int countFeedbackBySessionKey(final String keyword) { + final Feedback feedback = this.getBySessionKey(keyword); final List<Integer> values = feedback.getValues(); return values.get(Feedback.FEEDBACK_FASTER) + values.get(Feedback.FEEDBACK_OK) + values.get(Feedback.FEEDBACK_SLOWER) + values.get(Feedback.FEEDBACK_AWAY); } @Override - public double getAverageFeedback(final String sessionkey) { + public double calculateAverageFeedback(final String sessionkey) { final Session session = sessionRepository.findByKeyword(sessionkey); if (session == null) { throw new NotFoundException(); } - final Feedback feedback = feedbackStorage.getFeedback(session); + final Feedback feedback = feedbackStorage.getBySession(session); final List<Integer> values = feedback.getValues(); final double count = values.get(Feedback.FEEDBACK_FASTER) + values.get(Feedback.FEEDBACK_OK) + values.get(Feedback.FEEDBACK_SLOWER) + values.get(Feedback.FEEDBACK_AWAY); @@ -152,29 +152,29 @@ public class FeedbackServiceImpl implements FeedbackService, ApplicationEventPub } @Override - public long getAverageFeedbackRounded(final String sessionkey) { - return Math.round(getAverageFeedback(sessionkey)); + public long calculateRoundedAverageFeedback(final String sessionkey) { + return Math.round(calculateAverageFeedback(sessionkey)); } @Override - public boolean saveFeedback(final String keyword, final int value, final User user) { + public boolean save(final String keyword, final int value, final User user) { final Session session = sessionRepository.findByKeyword(keyword); if (session == null) { throw new NotFoundException(); } - feedbackStorage.saveFeedback(session, value, user); + feedbackStorage.save(session, value, user); this.publisher.publishEvent(new NewFeedbackEvent(this, session)); return true; } @Override - public Integer getMyFeedback(final String keyword, final User user) { + public Integer getBySessionKeyAndUser(final String keyword, final User user) { final Session session = sessionRepository.findByKeyword(keyword); if (session == null) { throw new NotFoundException(); } - return feedbackStorage.getMyFeedback(session, user); + return feedbackStorage.getBySessionAndUser(session, user); } @Override diff --git a/src/main/java/de/thm/arsnova/services/FeedbackStorageService.java b/src/main/java/de/thm/arsnova/services/FeedbackStorageService.java index 5451ccfac..279f703e7 100644 --- a/src/main/java/de/thm/arsnova/services/FeedbackStorageService.java +++ b/src/main/java/de/thm/arsnova/services/FeedbackStorageService.java @@ -8,9 +8,9 @@ import java.util.List; import java.util.Map; public interface FeedbackStorageService { - Feedback getFeedback(Session session); - Integer getMyFeedback(Session session, User u); - void saveFeedback(Session session, int value, User user); - Map<Session, List<User>> cleanFeedbackVotes(int cleanupFeedbackDelay); - List<User> cleanFeedbackVotesInSession(Session session, int cleanupFeedbackDelayInMins); + Feedback getBySession(Session session); + Integer getBySessionAndUser(Session session, User u); + void save(Session session, int value, User user); + Map<Session, List<User>> cleanVotes(int cleanupFeedbackDelay); + List<User> cleanVotesBySession(Session session, int cleanupFeedbackDelayInMins); } diff --git a/src/main/java/de/thm/arsnova/services/FeedbackStorageServiceImpl.java b/src/main/java/de/thm/arsnova/services/FeedbackStorageServiceImpl.java index 4dc11ef63..9c9f3940e 100644 --- a/src/main/java/de/thm/arsnova/services/FeedbackStorageServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/FeedbackStorageServiceImpl.java @@ -63,7 +63,7 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { new ConcurrentHashMap<>(); @Override - public Feedback getFeedback(final Session session) { + public Feedback getBySession(final Session session) { int a = 0; int b = 0; int c = 0; @@ -95,7 +95,7 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { } @Override - public Integer getMyFeedback(final Session session, final User u) { + public Integer getBySessionAndUser(final Session session, final User u) { if (data.get(session) == null) { return null; } @@ -111,7 +111,7 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { @Override @Transactional(isolation = Isolation.READ_COMMITTED) - public void saveFeedback(final Session session, final int value, final User user) { + public void save(final Session session, final int value, final User user) { if (data.get(session) == null) { data.put(session, new ConcurrentHashMap<User, FeedbackStorageObject>()); } @@ -121,11 +121,11 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { @Override @Transactional(isolation = Isolation.READ_COMMITTED) - public Map<Session, List<User>> cleanFeedbackVotes(final int cleanupFeedbackDelay) { + public Map<Session, List<User>> cleanVotes(final int cleanupFeedbackDelay) { final Map<Session, List<User>> removedFeedbackOfUsersInSession = new HashMap<>(); for (final Session session : data.keySet()) { if (!session.getFeatures().isLiveClicker()) { - List<User> affectedUsers = cleanFeedbackVotesInSession(session, cleanupFeedbackDelay); + List<User> affectedUsers = cleanVotesBySession(session, cleanupFeedbackDelay); if (!affectedUsers.isEmpty()) { removedFeedbackOfUsersInSession.put(session, affectedUsers); } @@ -136,7 +136,7 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { @Override @Transactional(isolation = Isolation.READ_COMMITTED) - public List<User> cleanFeedbackVotesInSession(final Session session, final int cleanupFeedbackDelayInMins) { + public List<User> cleanVotesBySession(final Session session, final int cleanupFeedbackDelayInMins) { final long timelimitInMillis = TimeUnit.MILLISECONDS.convert(cleanupFeedbackDelayInMins, TimeUnit.MINUTES); final Date maxAllowedTime = new Date(System.currentTimeMillis() - timelimitInMillis); final boolean forceClean = cleanupFeedbackDelayInMins == 0; @@ -149,7 +149,7 @@ public class FeedbackStorageServiceImpl implements FeedbackStorageService { final User user = entry.getKey(); final FeedbackStorageObject feedback = entry.getValue(); final boolean timeIsUp = feedback.getTimestamp().before(maxAllowedTime); - final boolean isAwayFeedback = getMyFeedback(session, user).equals(Feedback.FEEDBACK_AWAY); + final boolean isAwayFeedback = getBySessionAndUser(session, user).equals(Feedback.FEEDBACK_AWAY); if (forceClean || timeIsUp && !isAwayFeedback) { sessionFeedbacks.remove(user); affectedUsers.add(user); diff --git a/src/main/java/de/thm/arsnova/services/MotdService.java b/src/main/java/de/thm/arsnova/services/MotdService.java index 9df6a5afd..c010663a9 100644 --- a/src/main/java/de/thm/arsnova/services/MotdService.java +++ b/src/main/java/de/thm/arsnova/services/MotdService.java @@ -27,7 +27,7 @@ import java.util.List; * The functionality the motd service should provide. */ public interface MotdService { - Motd getMotd(String keyword); + Motd getByKey(String keyword); List<Motd> getAdminMotds(); //all w/o the sessionmotds @@ -39,21 +39,21 @@ public interface MotdService { List<Motd> filterMotdsByList(List<Motd> list, MotdList motdList); - void deleteMotd(Motd motd); + void delete(Motd motd); - void deleteSessionMotd(final String sessionkey, Motd motd); + void deleteBySessionKey(final String sessionkey, Motd motd); - Motd saveMotd(Motd motd); + Motd save(Motd motd); - Motd saveSessionMotd(final String sessionkey, final Motd motd); + Motd save(final String sessionkey, final Motd motd); - Motd updateMotd(Motd motd); + Motd update(Motd motd); - Motd updateSessionMotd(final String sessionkey, Motd motd); + Motd update(final String sessionkey, Motd motd); - MotdList getMotdListForUser(final String username); + MotdList getMotdListByUsername(final String username); - MotdList saveUserMotdList(MotdList motdList); + MotdList saveMotdList(MotdList motdList); - MotdList updateUserMotdList(MotdList userMotdList); + MotdList updateMotdList(MotdList motdList); } diff --git a/src/main/java/de/thm/arsnova/services/MotdServiceImpl.java b/src/main/java/de/thm/arsnova/services/MotdServiceImpl.java index 9828fb5e5..b51a6ccc5 100644 --- a/src/main/java/de/thm/arsnova/services/MotdServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/MotdServiceImpl.java @@ -52,7 +52,7 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated()") - public Motd getMotd(final String key) { + public Motd getByKey(final String key) { return motdRepository.findByKey(key); } @@ -115,14 +115,14 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated() and hasPermission(1,'motd','admin')") - public Motd saveMotd(final Motd motd) { + public Motd save(final Motd motd) { return createOrUpdateMotd(motd); } @Override @PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')") - public Motd saveSessionMotd(final String sessionkey, final Motd motd) { - Session session = sessionService.getSession(sessionkey); + public Motd save(final String sessionkey, final Motd motd) { + Session session = sessionService.getByKey(sessionkey); motd.setSessionId(session.getId()); @@ -131,13 +131,13 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated() and hasPermission(1,'motd','admin')") - public Motd updateMotd(final Motd motd) { + public Motd update(final Motd motd) { return createOrUpdateMotd(motd); } @Override @PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')") - public Motd updateSessionMotd(final String sessionkey, final Motd motd) { + public Motd update(final String sessionkey, final Motd motd) { return createOrUpdateMotd(motd); } @@ -155,19 +155,19 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated() and hasPermission(1,'motd','admin')") - public void deleteMotd(Motd motd) { + public void delete(Motd motd) { motdRepository.delete(motd); } @Override @PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')") - public void deleteSessionMotd(final String sessionkey, Motd motd) { + public void deleteBySessionKey(final String sessionkey, Motd motd) { motdRepository.delete(motd); } @Override @PreAuthorize("isAuthenticated()") - public MotdList getMotdListForUser(final String username) { + public MotdList getMotdListByUsername(final String username) { final User user = userService.getCurrentUser(); if (username.equals(user.getUsername()) && !"guest".equals(user.getType())) { return motdListRepository.findByUsername(username); @@ -177,7 +177,7 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated()") - public MotdList saveUserMotdList(MotdList motdList) { + public MotdList saveMotdList(MotdList motdList) { final User user = userService.getCurrentUser(); if (user.getUsername().equals(motdList.getUsername())) { return motdListRepository.save(motdList); @@ -187,7 +187,7 @@ public class MotdServiceImpl implements MotdService { @Override @PreAuthorize("isAuthenticated()") - public MotdList updateUserMotdList(MotdList motdList) { + public MotdList updateMotdList(MotdList motdList) { final User user = userService.getCurrentUser(); if (user.getUsername().equals(motdList.getUsername())) { return motdListRepository.save(motdList); diff --git a/src/main/java/de/thm/arsnova/services/SessionService.java b/src/main/java/de/thm/arsnova/services/SessionService.java index 25e7fe199..1aaba3134 100644 --- a/src/main/java/de/thm/arsnova/services/SessionService.java +++ b/src/main/java/de/thm/arsnova/services/SessionService.java @@ -32,17 +32,17 @@ import java.util.UUID; * The functionality the session service should provide. */ public interface SessionService { - Session getSession(String keyword); + Session getByKey(String keyword); - Session getSessionForAdmin(final String keyword); + Session getForAdmin(final String keyword); - Session getSessionInternal(String keyword, User user); + Session getInternal(String keyword, User user); - Session saveSession(Session session); + Session save(Session session); - boolean sessionKeyAvailable(String keyword); + boolean isKeyAvailable(String keyword); - String generateKeyword(); + String generateKey(); List<Session> getUserSessions(String username); @@ -52,21 +52,21 @@ public interface SessionService { List<Session> getMyVisitedSessions(int offset, int limit); - int countSessions(List<Course> courses); + int countSessionsByCourses(List<Course> courses); int activeUsers(String sessionkey); Session setActive(String sessionkey, Boolean lock); - Session joinSession(String keyword, UUID socketId); + Session join(String keyword, UUID socketId); - Session updateSession(String sessionkey, Session session); + Session update(String sessionkey, Session session); - Session changeSessionCreator(String sessionkey, String newCreator); + Session updateCreator(String sessionkey, String newCreator); - Session updateSessionInternal(Session session, User user); + Session updateInternal(Session session, User user); - void deleteSession(String sessionkey); + void delete(String sessionkey); ScoreStatistics getLearningProgress(String sessionkey, String type, String questionVariant); @@ -86,9 +86,9 @@ public interface SessionService { SessionInfo copySessionToPublicPool(String sessionkey, de.thm.arsnova.entities.transport.ImportExportSession.PublicPool pp); - SessionFeature getSessionFeatures(String sessionkey); + SessionFeature getFeatures(String sessionkey); - SessionFeature changeSessionFeatures(String sessionkey, SessionFeature features); + SessionFeature updateFeatures(String sessionkey, SessionFeature features); boolean lockFeedbackInput(String sessionkey, Boolean lock); diff --git a/src/main/java/de/thm/arsnova/services/SessionServiceImpl.java b/src/main/java/de/thm/arsnova/services/SessionServiceImpl.java index 44b70026b..8763ffdf8 100644 --- a/src/main/java/de/thm/arsnova/services/SessionServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/SessionServiceImpl.java @@ -153,7 +153,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli } @Override - public Session joinSession(final String keyword, final UUID socketId) { + public Session join(final String keyword, final UUID socketId) { /* Socket.IO solution */ Session session = null != keyword ? sessionRepository.findByKeyword(keyword) : null; @@ -183,13 +183,13 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public Session getSession(final String keyword) { + public Session getByKey(final String keyword) { final User user = userService.getCurrentUser(); - return Session.anonymizedCopy(this.getSessionInternal(keyword, user)); + return Session.anonymizedCopy(this.getInternal(keyword, user)); } @PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')") - public Session getSessionForAdmin(final String keyword) { + public Session getForAdmin(final String keyword) { return sessionRepository.findByKeyword(keyword); } @@ -198,7 +198,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli * TODO: Find a better way of doing this... */ @Override - public Session getSessionInternal(final String keyword, final User user) { + public Session getInternal(final String keyword, final User user) { final Session session = sessionRepository.findByKeyword(keyword); if (session == null) { throw new NotFoundException(); @@ -270,7 +270,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated()") - public Session saveSession(final Session session) { + public Session save(final Session session) { if (connectorClient != null && session.getCourseId() != null) { if (!connectorClient.getMembership( userService.getCurrentUser().getUsername(), session.getCourseId()).isMember() @@ -300,25 +300,25 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli } @Override - public boolean sessionKeyAvailable(final String keyword) { + public boolean isKeyAvailable(final String keyword) { return sessionRepository.sessionKeyAvailable(keyword); } @Override - public String generateKeyword() { + public String generateKey() { final int low = 10000000; final int high = 100000000; final String keyword = String .valueOf((int) (Math.random() * (high - low) + low)); - if (sessionKeyAvailable(keyword)) { + if (isKeyAvailable(keyword)) { return keyword; } - return generateKeyword(); + return generateKey(); } @Override - public int countSessions(final List<Course> courses) { + public int countSessionsByCourses(final List<Course> courses) { final List<Session> sessions = sessionRepository.findSessionsByCourses(courses); if (sessions == null) { return 0; @@ -328,7 +328,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override public int activeUsers(final String sessionkey) { - return userService.getUsersInSession(sessionkey).size(); + return userService.getUsersBySessionKey(sessionkey).size(); } @Override @@ -347,7 +347,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated() and hasPermission(#session, 'owner')") - public Session updateSession(final String sessionkey, final Session session) { + public Session update(final String sessionkey, final Session session) { final Session existingSession = sessionRepository.findByKeyword(sessionkey); existingSession.setActive(session.isActive()); @@ -375,7 +375,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated() and hasPermission(1,'motd','admin')") - public Session changeSessionCreator(String sessionkey, String newCreator) { + public Session updateCreator(String sessionkey, String newCreator) { final Session existingSession = sessionRepository.findByKeyword(sessionkey); if (existingSession == null) { throw new NullPointerException("Could not load session " + sessionkey + "."); @@ -388,7 +388,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli * TODO: Find a better way of doing this... */ @Override - public Session updateSessionInternal(final Session session, final User user) { + public Session updateInternal(final Session session, final User user) { if (session.isCreator(user)) { sessionRepository.update(session); return session; @@ -398,7 +398,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli @Override @PreAuthorize("isAuthenticated() and hasPermission(#sessionkey, 'session', 'owner')") - public void deleteSession(final String sessionkey) { + public void delete(final String sessionkey) { final Session session = sessionRepository.findByKeyword(sessionkey); sessionRepository.deleteSession(session); @@ -456,12 +456,12 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli } @Override - public SessionFeature getSessionFeatures(String sessionkey) { + public SessionFeature getFeatures(String sessionkey) { return sessionRepository.findByKeyword(sessionkey).getFeatures(); } @Override - public SessionFeature changeSessionFeatures(String sessionkey, SessionFeature features) { + public SessionFeature updateFeatures(String sessionkey, SessionFeature features) { final Session session = sessionRepository.findByKeyword(sessionkey); final User user = userService.getCurrentUser(); if (!session.isCreator(user)) { @@ -482,7 +482,7 @@ public class SessionServiceImpl implements SessionService, ApplicationEventPubli throw new UnauthorizedException("User is not session creator."); } if (!lock) { - feedbackService.cleanFeedbackVotesInSession(sessionkey, 0); + feedbackService.cleanFeedbackVotesBySessionKey(sessionkey, 0); } session.setFeedbackLock(lock); diff --git a/src/main/java/de/thm/arsnova/services/UserService.java b/src/main/java/de/thm/arsnova/services/UserService.java index 5052c4a1a..d48a3bf38 100644 --- a/src/main/java/de/thm/arsnova/services/UserService.java +++ b/src/main/java/de/thm/arsnova/services/UserService.java @@ -44,9 +44,9 @@ public interface UserService { boolean isUserInSession(User user, String keyword); - Set<User> getUsersInSession(String keyword); + Set<User> getUsersBySessionKey(String keyword); - String getSessionForUser(String username); + String getSessionByUsername(String username); void addUserToSessionBySocketId(UUID socketId, String keyword); @@ -56,13 +56,13 @@ public interface UserService { int loggedInUsers(); - DbUser getDbUser(String username); + DbUser getByUsername(String username); - DbUser createDbUser(String username, String password); + DbUser create(String username, String password); - DbUser updateDbUser(DbUser dbUser); + DbUser update(DbUser dbUser); - DbUser deleteDbUser(String username); + DbUser deleteByUsername(String username); void initiatePasswordReset(String username); diff --git a/src/main/java/de/thm/arsnova/services/UserServiceImpl.java b/src/main/java/de/thm/arsnova/services/UserServiceImpl.java index 08fdf672d..c6e5d18e7 100644 --- a/src/main/java/de/thm/arsnova/services/UserServiceImpl.java +++ b/src/main/java/de/thm/arsnova/services/UserServiceImpl.java @@ -278,7 +278,7 @@ public class UserServiceImpl implements UserService { } @Override - public Set<User> getUsersInSession(final String keyword) { + public Set<User> getUsersBySessionKey(final String keyword) { final Set<User> result = new HashSet<>(); for (final Entry<User, String> e : user2session.entrySet()) { if (e.getValue().equals(keyword)) { @@ -309,7 +309,7 @@ public class UserServiceImpl implements UserService { } @Override - public String getSessionForUser(final String username) { + public String getSessionByUsername(final String username) { for (final Entry<User, String> entry : user2session.entrySet()) { if (entry.getKey().getUsername().equals(username)) { return entry.getValue(); @@ -338,12 +338,12 @@ public class UserServiceImpl implements UserService { } @Override - public DbUser getDbUser(String username) { + public DbUser getByUsername(String username) { return userRepository.findByUsername(username.toLowerCase()); } @Override - public DbUser createDbUser(String username, String password) { + public DbUser create(String username, String password) { String lcUsername = username.toLowerCase(); if (null == keygen) { @@ -434,7 +434,7 @@ public class UserServiceImpl implements UserService { } @Override - public DbUser updateDbUser(DbUser dbUser) { + public DbUser update(DbUser dbUser) { if (null != dbUser.getId()) { return userRepository.save(dbUser); } @@ -443,7 +443,7 @@ public class UserServiceImpl implements UserService { } @Override - public DbUser deleteDbUser(String username) { + public DbUser deleteByUsername(String username) { User user = getCurrentUser(); if (!user.getUsername().equals(username.toLowerCase()) && !SecurityContextHolder.getContext().getAuthentication().getAuthorities() @@ -451,7 +451,7 @@ public class UserServiceImpl implements UserService { throw new UnauthorizedException(); } - DbUser dbUser = getDbUser(username); + DbUser dbUser = getByUsername(username); if (null == dbUser) { throw new NotFoundException(); } @@ -463,7 +463,7 @@ public class UserServiceImpl implements UserService { @Override public void initiatePasswordReset(String username) { - DbUser dbUser = getDbUser(username); + DbUser dbUser = getByUsername(username); if (null == dbUser) { logger.info("Password reset failed. User {} does not exist.", username); @@ -513,14 +513,14 @@ public class UserServiceImpl implements UserService { dbUser.setPasswordResetKey(null); dbUser.setPasswordResetTime(0); - updateDbUser(dbUser); + update(dbUser); return false; } dbUser.setPassword(encodePassword(password)); dbUser.setPasswordResetKey(null); - if (null == updateDbUser(dbUser)) { + if (null == update(dbUser)) { logger.error("Password reset failed. {} could not be updated.", dbUser.getUsername()); } diff --git a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java index 3fad4fc48..0b5a27cb7 100644 --- a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java +++ b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java @@ -142,15 +142,15 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova return; } - final String sessionKey = userService.getSessionForUser(u.getUsername()); - final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(sessionKey, u); + final String sessionKey = userService.getSessionByUsername(u.getUsername()); + final de.thm.arsnova.entities.Session session = sessionService.getInternal(sessionKey, u); if (session.getFeedbackLock()) { logger.debug("Feedback save blocked: {}", u, sessionKey, data.getValue()); } else { logger.debug("Feedback recieved: {}", u, sessionKey, data.getValue()); if (null != sessionKey) { - feedbackService.saveFeedback(sessionKey, data.getValue(), u); + feedbackService.save(sessionKey, data.getValue(), u); } } } @@ -166,12 +166,12 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova return; } - final String oldSessionKey = userService.getSessionForUser(u.getUsername()); + final String oldSessionKey = userService.getSessionByUsername(u.getUsername()); if (null != session.getKeyword() && session.getKeyword().equals(oldSessionKey)) { return; } - if (null != sessionService.joinSession(session.getKeyword(), client.getSessionId())) { + if (null != sessionService.join(session.getKeyword(), client.getSessionId())) { /* active user count has to be sent to the client since the broadcast is * not always sent as long as the polling solution is active simultaneously */ reportActiveUserCountForSession(session.getKeyword()); @@ -195,7 +195,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova AckRequest ackRequest) { final User user = userService.getUser2SocketId(client.getSessionId()); try { - commentService.readInterposedQuestionInternal(comment.getId(), user); + commentService.getAndMarkReadInternal(comment.getId(), user); } catch (NotFoundException | UnauthorizedException e) { logger.error("Loading of comment {} failed for user {} with exception {}", comment.getId(), user, e.getMessage()); } @@ -207,7 +207,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova public void onData(SocketIOClient client, String answerId, AckRequest ackRequest) { final User user = userService.getUser2SocketId(client.getSessionId()); try { - contentService.readFreetextAnswer(answerId, user); + contentService.getFreetextAnswerAndMarkRead(answerId, user); } catch (NotFoundException | UnauthorizedException e) { logger.error("Marking answer {} as read failed for user {} with exception {}", answerId, user, e.getMessage()); } @@ -222,10 +222,10 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova @Timed(name = "setLearningProgressOptionsEvent.onData") public void onData(SocketIOClient client, ScoreOptions scoreOptions, AckRequest ack) { final User user = userService.getUser2SocketId(client.getSessionId()); - final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(scoreOptions.getSessionKeyword(), user); + final de.thm.arsnova.entities.Session session = sessionService.getInternal(scoreOptions.getSessionKeyword(), user); if (session.isCreator(user)) { session.setLearningProgressOptions(scoreOptions.toEntity()); - sessionService.updateSessionInternal(session, user); + sessionService.updateInternal(session, user); broadcastInSession(session.getKeyword(), "learningProgressOptions", scoreOptions.toEntity()); } } @@ -251,7 +251,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova return; } final String username = userService.getUser2SocketId(client.getSessionId()).getUsername(); - final String sessionKey = userService.getSessionForUser(username); + final String sessionKey = userService.getSessionByUsername(username); userService.removeUserFromSessionBySocketId(client.getSessionId()); userService.removeUser2SocketId(client.getSessionId()); if (null != sessionKey) { @@ -361,8 +361,8 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova * relevant Socket.IO data, the client needs to know after joining a session. */ public void reportSessionDataToClient(final String sessionKey, final User user, final SocketIOClient client) { - final de.thm.arsnova.entities.Session session = sessionService.getSessionInternal(sessionKey, user); - final de.thm.arsnova.entities.SessionFeature features = sessionService.getSessionFeatures(sessionKey); + final de.thm.arsnova.entities.Session session = sessionService.getInternal(sessionKey, user); + final de.thm.arsnova.entities.SessionFeature features = sessionService.getFeatures(sessionKey); client.sendEvent("unansweredLecturerQuestions", contentService.getUnAnsweredLectureQuestionIds(sessionKey, user)); client.sendEvent("unansweredPreparationQuestions", contentService.getUnAnsweredPreparationQuestionIds(sessionKey, user)); @@ -370,7 +370,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova client.sendEvent("countPreparationQuestionAnswers", contentService.countPreparationQuestionAnswersInternal(sessionKey)); client.sendEvent("activeUserCountData", sessionService.activeUsers(sessionKey)); client.sendEvent("learningProgressOptions", session.getLearningProgressOptions()); - final de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(sessionKey); + final de.thm.arsnova.entities.Feedback fb = feedbackService.getBySessionKey(sessionKey); client.sendEvent("feedbackData", fb.getValues()); if (features.isFlashcard() || features.isFlashcardFeature()) { @@ -379,7 +379,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova } try { - final long averageFeedback = feedbackService.getAverageFeedbackRounded(sessionKey); + final long averageFeedback = feedbackService.calculateRoundedAverageFeedback(sessionKey); client.sendEvent("feedbackDataRoundedAverage", averageFeedback); } catch (final NoContentException e) { final Object object = null; // can't directly use "null". @@ -388,10 +388,10 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova } public void reportUpdatedFeedbackForSession(final de.thm.arsnova.entities.Session session) { - final de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(session.getKeyword()); + final de.thm.arsnova.entities.Feedback fb = feedbackService.getBySessionKey(session.getKeyword()); broadcastInSession(session.getKeyword(), "feedbackData", fb.getValues()); try { - final long averageFeedback = feedbackService.getAverageFeedbackRounded(session.getKeyword()); + final long averageFeedback = feedbackService.calculateRoundedAverageFeedback(session.getKeyword()); broadcastInSession(session.getKeyword(), "feedbackDataRoundedAverage", averageFeedback); } catch (final NoContentException e) { broadcastInSession(session.getKeyword(), "feedbackDataRoundedAverage", null); @@ -399,10 +399,10 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova } public void reportFeedbackForUserInSession(final de.thm.arsnova.entities.Session session, final User user) { - final de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(session.getKeyword()); + final de.thm.arsnova.entities.Feedback fb = feedbackService.getBySessionKey(session.getKeyword()); Long averageFeedback; try { - averageFeedback = feedbackService.getAverageFeedbackRounded(session.getKeyword()); + averageFeedback = feedbackService.calculateRoundedAverageFeedback(session.getKeyword()); } catch (final NoContentException e) { averageFeedback = null; } @@ -420,7 +420,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova } public void reportActiveUserCountForSession(final String sessionKey) { - final int count = userService.getUsersInSession(sessionKey).size(); + final int count = userService.getUsersBySessionKey(sessionKey).size(); broadcastInSession(sessionKey, "activeUserCountData", count); } @@ -464,7 +464,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova * all connected clients and if send feedback, if user is in current * session */ - final Set<User> users = userService.getUsersInSession(sessionKey); + final Set<User> users = userService.getUsersBySessionKey(sessionKey); for (final SocketIOClient c : server.getAllClients()) { final User u = userService.getUser2SocketId(c.getSessionId()); @@ -510,7 +510,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova public void visit(NewAnswerEvent event) { final String sessionKey = event.getSession().getKeyword(); this.reportAnswersToLecturerQuestionAvailable(event.getSession(), new Content(event.getContent())); - broadcastInSession(sessionKey, "countQuestionAnswersByQuestionId", contentService.getAnswerAndAbstentionCountInternal(event.getContent().getId())); + broadcastInSession(sessionKey, "countQuestionAnswersByQuestionId", contentService.countAnswersAndAbstentionsInternal(event.getContent().getId())); broadcastInSession(sessionKey, "countLectureQuestionAnswers", contentService.countLectureQuestionAnswersInternal(sessionKey)); broadcastInSession(sessionKey, "countPreparationQuestionAnswers", contentService.countPreparationQuestionAnswersInternal(sessionKey)); -- GitLab