From dd749370abe8453056c69a587988b6b20e6a5a68 Mon Sep 17 00:00:00 2001 From: tekay <tom.kaesler@mni.thm.de> Date: Fri, 12 Feb 2016 10:40:02 +0100 Subject: [PATCH] add motdimport to sessionimport (added in bulk save) add empty test methods --- src/main/java/de/thm/arsnova/dao/CouchDBDao.java | 14 ++++++++++++++ .../java/de/thm/arsnova/dao/StubDatabaseDao.java | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index 1307ea84f..367f5e219 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -2117,6 +2117,8 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware List<Document> answers = new ArrayList<Document>(); // We can then push answers together with interposed questions in one large bulk request List<Document> interposedQuestions = new ArrayList<Document>(); + // Motds shouldn't be forgotten + List<Document> motds = new ArrayList<Document>(); try { // add session id to all questions and generate documents for (ImportExportQuestion question : importSession.getQuestions()) { @@ -2163,8 +2165,20 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware q.put("creator", ""); interposedQuestions.add(q); } + for (Motd m : importSession.getMotds()) { + final Document d = new Document(); + d.put("type", "motd"); + d.put("motdkey", m.getMotdkey()); + d.put("title", m.getTitle()); + d.put("audience", m.getAudience()); + d.put("sessionkey", session.getKeyword()); + d.put("startdate", String.valueOf(m.getStartdate())); + d.put("enddate", String.valueOf(m.getEnddate())); + motds.add(d); + } List<Document> documents = new ArrayList<Document>(answers); documents.addAll(interposedQuestions); + documents.addAll(motds); database.bulkSaveDocuments(documents.toArray(new Document[documents.size()])); } catch (IOException e) { LOGGER.error("Could not import this session: {}", e.getMessage()); diff --git a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java index c8b1ce0c1..cab3881f4 100644 --- a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java +++ b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java @@ -501,6 +501,12 @@ public class StubDatabaseDao implements IDatabaseDao { return null; } + @Override + public ImportExportSession exportSession(String sessionkey) { + // TODO Auto.generated method stub + return null; + } + @Override public List<Question> getSkillQuestionsForUsers(Session session) { // TODO Auto-generated method stub @@ -549,6 +555,12 @@ public class StubDatabaseDao implements IDatabaseDao { return null; } + @Override + public List<Question> getAllSkillQuestions(Session session) { + // TODO Auto-generated method stub + return null; + } + @Override public List<Answer> getAnswers(Question question, int piRound) { // TODO Auto-generated method stub -- GitLab