From 754a812db833fa8ec06de4830c52456c374ebe93 Mon Sep 17 00:00:00 2001 From: Felix Schmidt <felix.schmidt@mni.thm.de> Date: Sun, 1 Feb 2015 22:26:48 +0100 Subject: [PATCH] Added few pp Attributes to SessionInfo. Requests for Public Pool Sessions now return SessionInfo instead of Session. --- .../arsnova/controller/SessionController.java | 4 ++-- .../java/de/thm/arsnova/dao/CouchDBDao.java | 8 +++++++- .../java/de/thm/arsnova/dao/IDatabaseDao.java | 2 ++ .../de/thm/arsnova/entities/SessionInfo.java | 20 +++++++++++++++++++ .../thm/arsnova/services/ISessionService.java | 4 ++-- .../thm/arsnova/services/SessionService.java | 4 ++-- .../de/thm/arsnova/dao/StubDatabaseDao.java | 6 ++++++ 7 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/thm/arsnova/controller/SessionController.java b/src/main/java/de/thm/arsnova/controller/SessionController.java index 3383c290..c142291d 100644 --- a/src/main/java/de/thm/arsnova/controller/SessionController.java +++ b/src/main/java/de/thm/arsnova/controller/SessionController.java @@ -205,10 +205,10 @@ public class SessionController extends AbstractController { } @RequestMapping(value = "/publicpool", method = RequestMethod.GET) - public final List<Session> getPublicPoolSessions( + public final List<SessionInfo> getPublicPoolSessions( final HttpServletResponse response ) { - List<Session> sessions = sessionService.getPublicPoolSessions(); + List<SessionInfo> sessions = sessionService.getPublicPoolSessionsInfo(); if (sessions == null || sessions.isEmpty()) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index f439cbac..8cd04946 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -140,12 +140,18 @@ public class CouchDBDao implements IDatabaseDao { d.getJSONObject().getJSONObject("value"), Session.class ); - //session.set_id(d.getId()); + session.set_id(d.getId()); result.add(session); } return result; } + @Override + public final List<SessionInfo> getPublicPoolSessionsInfo() { + final List<Session> sessions = this.getPublicPoolSessions(); + return getInfosForSessions(sessions); + } + @Override public final List<Session> getMyPublicPoolSessions(final User user) { final NovaView view = new NovaView("session/public_pool_by_creator"); diff --git a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java index 80224015..8d9b1974 100644 --- a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java +++ b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java @@ -179,6 +179,8 @@ public interface IDatabaseDao { SimpleEntry<Integer, Integer> getMyLearningProgress(Session session, User user); List<SessionInfo> getMySessionsInfo(User user); + + List<SessionInfo> getPublicPoolSessionsInfo(); List<SessionInfo> getMyPublicPoolSessionsInfo(final User user); diff --git a/src/main/java/de/thm/arsnova/entities/SessionInfo.java b/src/main/java/de/thm/arsnova/entities/SessionInfo.java index 45bf093c..ee218748 100644 --- a/src/main/java/de/thm/arsnova/entities/SessionInfo.java +++ b/src/main/java/de/thm/arsnova/entities/SessionInfo.java @@ -29,6 +29,8 @@ public class SessionInfo { private String courseType; private long creationTime; private String sessionType; + private String ppLevel; + private String ppSubject; private int numQuestions; private int numAnswers; @@ -44,6 +46,8 @@ public class SessionInfo { this.courseType = session.getCourseType(); this.creationTime = session.getCreationTime(); this.sessionType = session.getSessionType(); + this.ppLevel = session.getPpLevel(); + this.ppSubject = session.getPpSubject(); } public static List<SessionInfo> fromSessionList(List<Session> sessions) { @@ -101,6 +105,22 @@ public class SessionInfo { public void setSessionType(String sessionType) { this.sessionType = sessionType; } + + public String getPpLevel() { + return ppLevel; + } + + public void setPpLevel(String ppLevel) { + this.ppLevel = ppLevel; + } + + public String getPpSubject() { + return ppSubject; + } + + public void setPpSubject(String ppSubject) { + this.ppSubject = ppSubject; + } public int getNumQuestions() { return numQuestions; diff --git a/src/main/java/de/thm/arsnova/services/ISessionService.java b/src/main/java/de/thm/arsnova/services/ISessionService.java index 0ded048f..f4ecc3e1 100644 --- a/src/main/java/de/thm/arsnova/services/ISessionService.java +++ b/src/main/java/de/thm/arsnova/services/ISessionService.java @@ -37,8 +37,6 @@ public interface ISessionService { String generateKeyword(); List<Session> getMySessions(); - - List<Session> getPublicPoolSessions(); List<Session> getMyVisitedSessions(); @@ -60,6 +58,8 @@ public interface ISessionService { List<SessionInfo> getMySessionsInfo(); + List<SessionInfo> getPublicPoolSessionsInfo(); + List<SessionInfo> getMyPublicPoolSessionsInfo(); List<SessionInfo> getMyVisitedSessionsInfo(); diff --git a/src/main/java/de/thm/arsnova/services/SessionService.java b/src/main/java/de/thm/arsnova/services/SessionService.java index 47954ec1..9084ab01 100644 --- a/src/main/java/de/thm/arsnova/services/SessionService.java +++ b/src/main/java/de/thm/arsnova/services/SessionService.java @@ -168,8 +168,8 @@ public class SessionService implements ISessionService { @Override @PreAuthorize("isAuthenticated()") - public final List<Session> getPublicPoolSessions() { - return databaseDao.getPublicPoolSessions(); + public final List<SessionInfo> getPublicPoolSessionsInfo() { + return databaseDao.getPublicPoolSessionsInfo(); } @Override diff --git a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java index 8a09d652..51b41580 100644 --- a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java +++ b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java @@ -200,6 +200,12 @@ public class StubDatabaseDao implements IDatabaseDao { return null; } + @Override + public List<SessionInfo> getPublicPoolSessionsInfo() { + // TODO Auto-generated method stub + return null; + } + @Override public List<Session> getMyPublicPoolSessions(User user) { // TODO Auto-generated method stub -- GitLab