From f8bafdfff431f08dd71dfd27ce9b49ca604542f8 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <code@dgerhardt.net>
Date: Thu, 27 Jun 2019 13:25:36 +0200
Subject: [PATCH] Fix code style violations regarding comments

* Removed obsolete commented-out code.
* Fixed indentation of commented out code.
* Added FIXME comments where old code still has to be migrated.
---
 .../couchdb/CouchDbCommentRepository.java     |   6 -
 .../couchdb/CouchDbRoomRepository.java        | 144 ------------------
 .../couchdb/CouchDbStatisticsRepository.java  |   2 +-
 .../websocket/ArsnovaSocketioServerImpl.java  |  33 ++--
 4 files changed, 13 insertions(+), 172 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbCommentRepository.java b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbCommentRepository.java
index b2bbeb1e3..d69406558 100644
--- a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbCommentRepository.java
+++ b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbCommentRepository.java
@@ -132,9 +132,6 @@ public class CouchDbCommentRepository extends CouchDbCrudRepository<Comment> imp
 						.endKey(ComplexKey.of(roomId))
 						.includeDocs(true),
 				Comment.class);
-//		for (Comment comment : comments) {
-//			comment.setRoomId(session.getKeyword());
-//		}
 
 		return comments;
 	}
@@ -153,9 +150,6 @@ public class CouchDbCommentRepository extends CouchDbCrudRepository<Comment> imp
 						.endKey(ComplexKey.of(roomId, userId))
 						.includeDocs(true),
 				Comment.class);
-//		for (Comment comment : comments) {
-//			comment.setRoomId(session.getKeyword());
-//		}
 
 		return comments;
 	}
diff --git a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbRoomRepository.java b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbRoomRepository.java
index 82c5a127b..792dc8f56 100644
--- a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbRoomRepository.java
+++ b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbRoomRepository.java
@@ -107,89 +107,6 @@ public class CouchDbRoomRepository extends CouchDbCrudRepository<Room> implement
 	public Room importRoom(final String userId, final ImportExportContainer importRoom) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
-//		final Room session = this.saveSession(user, importRoom.generateSessionEntity(user));
-//		final List<Document> questions = new ArrayList<>();
-//		// We need to remember which answers belong to which question.
-//		// The answers need a questionId, so we first store the questions to get the IDs.
-//		// Then we update the answer objects and store them as well.
-//		final Map<Document, ImportExportContainer.ImportExportContent> mapping = new HashMap<>();
-//		// Later, generate all answer documents
-//		List<Document> answers = new ArrayList<>();
-//		// We can then push answers together with comments in one large bulk request
-//		List<Document> interposedQuestions = new ArrayList<>();
-//		// Motds shouldn't be forgotten, too
-//		List<Document> motds = new ArrayList<>();
-//		try {
-//			// add session id to all questions and generate documents
-//			for (final ImportExportContainer.ImportExportContent question : importRoom.getQuestions()) {
-//				final Document doc = toQuestionDocument(session, question);
-//				question.setRoomId(session.getId());
-//				questions.add(doc);
-//				mapping.put(doc, question);
-//			}
-//			database.bulkSaveDocuments(questions.toArray(new Document[questions.size()]));
-//
-//			// bulk import answers together with interposed questions
-//			for (Map.Entry<Document, ImportExportContainer.ImportExportContent> entry : mapping.entrySet()) {
-//				final Document doc = entry.getKey();
-//				final ImportExportContainer.ImportExportContent question = entry.getValue();
-//				question.setId(doc.getId());
-//				question.setRevision(doc.getRev());
-//				for (final de.thm.arsnova.entities.transport.Answer answer : question.getAnswers()) {
-//					final Answer a = answer.generateAnswerEntity(user, question);
-//					final Document answerDoc = new Document();
-//					answerDoc.put("type", "skill_question_answer");
-//					answerDoc.put("sessionId", a.getRoomId());
-//					answerDoc.put("questionId", a.getContentId());
-//					answerDoc.put("answerSubject", a.getAnswerSubject());
-//					answerDoc.put("questionVariant", a.getGroups());
-//					answerDoc.put("questionValue", a.getQuestionValue());
-//					answerDoc.put("answerText", a.getAnswerText());
-//					answerDoc.put("answerTextRaw", a.getAnswerTextRaw());
-//					answerDoc.put("timestamp", a.getTimestamp());
-//					answerDoc.put("piRound", a.getPiRound());
-//					answerDoc.put("abstention", a.isAbstention());
-//					answerDoc.put("successfulFreeTextAnswer", a.isSuccessfulFreeTextAnswer());
-//					// we do not store the user's name
-//					answerDoc.put("user", "");
-//					answers.add(answerDoc);
-//				}
-//			}
-//			for (final de.thm.arsnova.entities.transport.Comment i : importRoom.getFeedbackQuestions()) {
-//				final Document q = new Document();
-//				q.put("type", "interposed_question");
-//				q.put("sessionId", session.getId());
-//				q.put("subject", i.getSubject());
-//				q.put("text", i.getText());
-//				q.put("timestamp", i.getTimestamp());
-//				q.put("read", i.isRead());
-//				// we do not store the creator's name
-//				q.put("creator", "");
-//				interposedQuestions.add(q);
-//			}
-//			for (final Motd m : importRoom.getMotds()) {
-//				final Document d = new Document();
-//				d.put("type", "motd");
-//				d.put("motdkey", m.getMotdkey());
-//				d.put("title", m.getTitle());
-//				d.put("text", m.getText());
-//				d.put("audience", m.getAudience());
-//				d.put("sessionkey", session.getKeyword());
-//				d.put("startdate", String.valueOf(m.getStartDate().getTime()));
-//				d.put("enddate", String.valueOf(m.getEndDate().getTime()));
-//				motds.add(d);
-//			}
-//			final List<Document> documents = new ArrayList<>(answers);
-//			database.bulkSaveDocuments(interposedQuestions.toArray(new Document[interposedQuestions.size()]));
-//			database.bulkSaveDocuments(motds.toArray(new Document[motds.size()]));
-//			database.bulkSaveDocuments(documents.toArray(new Document[documents.size()]));
-//		} catch (final IOException e) {
-//			logger.error("Could not import session.", e);
-//			// Something went wrong, delete this session since we do not want a partial import
-//			this.delete(session);
-//			return null;
-//		}
-//		return this.calculateSessionInfo(importRoom, session);
 	}
 
 	/* TODO: Move to service layer. */
@@ -200,73 +117,12 @@ public class CouchDbRoomRepository extends CouchDbCrudRepository<Room> implement
 			final Boolean withFeedbackQuestions) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
-//		final ImportExportContainer importExportSession = new ImportExportContainer();
-//		final Room session = getDatabaseDao().getSessionFromKeyword(sessionkey);
-//		importExportSession.setSessionFromSessionObject(session);
-//		final List<Content> questionList = getDatabaseDao().getAllSkillQuestions(session);
-//		for (final Content question : questionList) {
-//			final List<de.thm.arsnova.entities.transport.Answer> answerList = new ArrayList<>();
-//			if (withAnswers) {
-//				for (final Answer a : this.getDatabaseDao().getAllAnswers(question)) {
-//					final de.thm.arsnova.entities.transport.Answer transportAnswer =
-//							new de.thm.arsnova.entities.transport.Answer(a);
-//					answerList.add(transportAnswer);
-//				}
-//				// getAllAnswers does not grep for whole answer object so i need to add empty entries for abstentions
-//				int i = this.getDatabaseDao().getAbstentionAnswerCount(question.getId());
-//				for (int b = 0; b < i; b++) {
-//					final de.thm.arsnova.entities.transport.Answer ans = new de.thm.arsnova.entities.transport.Answer();
-//					ans.setAnswerSubject("");
-//					ans.setAnswerImage("");
-//					ans.setAnswerText("");
-//					ans.setAbstention(true);
-//					answerList.add(ans);
-//				}
-//			}
-//			importExportSession.addQuestionWithAnswers(question, answerList);
-//		}
-//		if (withFeedbackQuestions) {
-//			final List<de.thm.arsnova.entities.transport.Comment> interposedQuestionList = new ArrayList<>();
-//			for (final Comment i : getDatabaseDao().getInterposedQuestions(session, 0, 0)) {
-//				de.thm.arsnova.entities.transport.Comment transportInterposedQuestion =
-//						new de.thm.arsnova.entities.transport.Comment(i);
-//				interposedQuestionList.add(transportInterposedQuestion);
-//			}
-//			importExportSession.setFeedbackQuestions(interposedQuestionList);
-//		}
-//		if (withAnswers) {
-//			importExportSession.setSessionInfo(this.calculateSessionInfo(importExportSession, session));
-//		}
-//		importExportSession.setMotds(motdRepository.getMotdsForSession(session.getKeyword()));
-//		return importExportSession;
 	}
 
 	/* TODO: Move to service layer. */
 	private Room calculateSessionInfo(final ImportExportContainer importExportSession, final Room room) {
 		/* FIXME: not yet migrated - move to service layer */
 		throw new UnsupportedOperationException();
-//		int unreadComments = 0;
-//		int numUnanswered = 0;
-//		int numAnswers = 0;
-//		for (Comment i : importExportSession.getFeedbackQuestions()) {
-//			if (!i.isRead()) {
-//				unreadComments++;
-//			}
-//		}
-//		for (ImportExportContainer.ImportExportContent question : importExportSession.getQuestions()) {
-//			numAnswers += question.getAnswers().size();
-//			if (question.getAnswers().isEmpty()) {
-//				numUnanswered++;
-//			}
-//		}
-//		RoomStatistics stats = new RoomStatistics();
-//		stats.setContentCount(importExportSession.getQuestions().size());
-//		stats.setAnswerCount(numAnswers);
-//		stats.setUnreadAnswerCount(numUnanswered);
-//		stats.setCommentCount(importExportSession.getFeedbackQuestions().size());
-//		stats.setUnreadCommentCount(unreadComments);
-//
-//		return room;
 	}
 
 	@Override
diff --git a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbStatisticsRepository.java b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbStatisticsRepository.java
index a00d3fe7d..5020e8842 100644
--- a/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbStatisticsRepository.java
+++ b/src/main/java/de/thm/arsnova/persistence/couchdb/CouchDbStatisticsRepository.java
@@ -56,7 +56,7 @@ public class CouchDbStatisticsRepository extends CouchDbRepositorySupport implem
 							stats.setClosedSessions(stats.getClosedSessions() + value);
 							break;
 						case "deletedSessions":
-						/* Deleted sessions are not exposed separately for now. */
+							/* Deleted sessions are not exposed separately for now. */
 							stats.setClosedSessions(stats.getClosedSessions() + value);
 							break;
 						case "answers":
diff --git a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java
index 2bd266d5f..314ee9a2c 100644
--- a/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java
+++ b/src/main/java/de/thm/arsnova/websocket/ArsnovaSocketioServerImpl.java
@@ -247,14 +247,7 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer {
 					@Timed(name = "setLearningProgressOptionsEvent.onData")
 					public void onData(SocketIOClient client, ScoreOptions scoreOptions, AckRequest ack) {
 						throw new UnsupportedOperationException("Not implemented.");
-//						final ClientAuthentication user = userService.getUserToSocketId(client.getSessionId());
-//						final String shortRoomId = userService.getSessionByUsername(user.getUsername());
-//						final de.thm.arsnova.entities.Room room = roomService.getInternal(shortRoomId, user);
-//						if (room.getOwnerId().equals(user.getId())) {
-//							room.setLearningProgressOptions(scoreOptions);
-//							roomService.updateInternal(room, user);
-//							broadcastInRoom(room.getShortId(), "learningProgressOptions", scoreOptions);
-//						}
+						/* FIXME: missing implementation */
 					}
 				});
 
@@ -398,13 +391,15 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer {
 		client.sendEvent("countLectureQuestionAnswers", answerService.countTotalAnswersByRoomId(roomId));
 		client.sendEvent("countPreparationQuestionAnswers", answerService.countTotalAnswersByRoomId(roomId));
 		client.sendEvent("activeUserCountData", roomService.activeUsers(roomId));
-//		client.sendEvent("learningProgressOptions", room.getLearningProgressOptions());
+		/* FIXME: missing implementation */
+		//client.sendEvent("learningProgressOptions", room.getLearningProgressOptions());
 		final de.thm.arsnova.model.Feedback fb = feedbackService.getByRoomId(roomId);
 		client.sendEvent("feedbackData", fb.getValues());
 
 		if (settings.isFlashcardsEnabled()) {
 			client.sendEvent("countFlashcards", contentService.countFlashcardsForUserInternal(roomId));
-//			client.sendEvent("flipFlashcards", room.getFlipFlashcards());
+			/* FIXME: missing implementation */
+			//client.sendEvent("flipFlashcards", room.getFlipFlashcards());
 		}
 
 		try {
@@ -538,15 +533,9 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer {
 				answerService.countTotalAnswersByRoomId(roomId));
 
 		// Update the unanswered count for the content variant that was answered.
-		/* Is this still relevant? */
-//		final de.thm.arsnova.model.Content content = // event.getSource().getContentId();
-//		if (content.getGroups().contains("lecture")) {
-//			sendToUser(event.getSource().getCreatorId(), "unansweredLecturerQuestions",
-//					contentService.getUnAnsweredLectureContentIds(roomId, event.getSource().getCreatorId()));
-//		} else if (content.getGroups().contains("preparation")) {
-//			sendToUser(event.getSource().getCreatorId(), "unansweredPreparationQuestions",
-//					contentService.getUnAnsweredPreparationContentIds(roomId, event.getSource().getCreatorId()));
-//		}
+		/* Is this still relevant?
+		 * FIXME: Send unansweredLecturerQuestions and unansweredPreparationQuestions event messages.
+		 **/
 	}
 
 	@Async
@@ -637,7 +626,8 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer {
 		if (settings.isFlashcardsEnabled()) {
 			broadcastInRoom(roomId, "countFlashcards",
 					contentService.countFlashcardsForUserInternal(roomId));
-//			broadcastInRoom(roomId, "flipFlashcards", event.getEntity().getSettings().isFlipFlashcards());
+			/* FIXME: missing implementation */
+			//broadcastInRoom(roomId, "flipFlashcards", event.getEntity().getSettings().isFlipFlashcards());
 		}
 	}
 
@@ -650,7 +640,8 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer {
 
 	@EventListener
 	public void handleFlipFlashcards(FlipFlashcardsEvent event) {
-//		broadcastInRoom(event.getRoom().getId(), "flipFlashcards", event.getRoom().getFlipFlashcards());
+		/* FIXME: missing implementation */
+		//broadcastInRoom(event.getRoom().getId(), "flipFlashcards", event.getRoom().getFlipFlashcards());
 	}
 
 	@EventListener
-- 
GitLab