diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index f18961fd16c35c278bcde7e774094188767deb39..023b385f5cd10e38638ebbe64abc0d65854b89da 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -56,9 +56,9 @@ import com.fourspaces.couchdb.ViewResults; import de.thm.arsnova.entities.Feedback; import de.thm.arsnova.entities.LoggedIn; -import de.thm.arsnova.entities.LoggedIn.VisitedSession; import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.User; +import de.thm.arsnova.entities.VisitedSession; import de.thm.arsnova.exceptions.ForbiddenException; import de.thm.arsnova.exceptions.NotFoundException; import de.thm.arsnova.services.ISessionService; @@ -545,7 +545,10 @@ public class CouchDBDao implements IDatabaseDao { } this.getDatabase().saveDocument(doc); - return (LoggedIn) JSONObject.toBean(doc.getJSONObject(), LoggedIn.class); + LoggedIn l = (LoggedIn) JSONObject.toBean(doc.getJSONObject(), LoggedIn.class); + Collection<VisitedSession> visitedSessions = JSONArray.toCollection(doc.getJSONObject().getJSONArray("visitedSessions"), VisitedSession.class); + l.setVisitedSessions(new ArrayList<VisitedSession>(visitedSessions)); + return l; } catch (UnsupportedEncodingException e) { return null; } catch (IOException e) { diff --git a/src/main/java/de/thm/arsnova/entities/LoggedIn.java b/src/main/java/de/thm/arsnova/entities/LoggedIn.java index 42fd672836afb85d0654ee29dbafa5242a0dc261..fd081f3648236306de2426d2213ae33f2ddde93b 100644 --- a/src/main/java/de/thm/arsnova/entities/LoggedIn.java +++ b/src/main/java/de/thm/arsnova/entities/LoggedIn.java @@ -45,7 +45,7 @@ public class LoggedIn { private boolean isAlreadyVisited(Session s) { for (VisitedSession vs : this.visitedSessions) { - if (vs._id.equals(s.get_id())) { + if (vs.get_id().equals(s.get_id())) { return true; } } @@ -115,48 +115,4 @@ public class LoggedIn { + ", timestamp=" + timestamp + ", visitedSessions=" + visitedSessions + "]"; } - - public static class VisitedSession { - private String _id; - private String name; - private String keyword; - - public VisitedSession() {} - - public VisitedSession(Session s) { - this._id = s.get_id(); - this.name = s.getName(); - this.keyword = s.getKeyword(); - } - - public String get_id() { - return _id; - } - - public void set_id(String _id) { - this._id = _id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getKeyword() { - return keyword; - } - - public void setKeyword(String keyword) { - this.keyword = keyword; - } - - @Override - public String toString() { - return "VisitedSession [_id=" + _id + ", name=" + name - + ", keyword=" + keyword + "]"; - } - } } \ No newline at end of file diff --git a/src/main/java/de/thm/arsnova/entities/VisitedSession.java b/src/main/java/de/thm/arsnova/entities/VisitedSession.java new file mode 100644 index 0000000000000000000000000000000000000000..50cb8819917b52d405653c3ffc73999275e9d54d --- /dev/null +++ b/src/main/java/de/thm/arsnova/entities/VisitedSession.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 THM webMedia + * + * This file is part of ARSnova. + * + * ARSnova 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 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.entities; + +public class VisitedSession { + private String _id; + private String name; + private String keyword; + + public VisitedSession() {} + + public VisitedSession(Session s) { + this._id = s.get_id(); + this.name = s.getName(); + this.keyword = s.getKeyword(); + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getKeyword() { + return keyword; + } + + public void setKeyword(String keyword) { + this.keyword = keyword; + } + + @Override + public String toString() { + return "VisitedSession [_id=" + _id + ", name=" + name + + ", keyword=" + keyword + "]"; + } + } \ No newline at end of file