use of teammates.storage.entity.FeedbackResponseComment in project teammates by TEAMMATES.
the class FeedbackResponseCommentAttributesTest method testValueOf.
@Test
public void testValueOf() {
FeedbackResponseComment responseComment = new FeedbackResponseComment("course", "name", "question", "giver", "response", Instant.now(), new Text("comment"), "giverSection", "receiverSection", null, null, null, null);
FeedbackResponseCommentAttributes feedbackAttributes = FeedbackResponseCommentAttributes.valueOf(responseComment);
assertEquals(responseComment, feedbackAttributes);
}
use of teammates.storage.entity.FeedbackResponseComment in project teammates by TEAMMATES.
the class FeedbackResponseCommentsDb method updateLastEditorEmailOfFeedbackResponseComments.
/*
* Updates last editor for all comments last edited by the given instructor with the instructor's new email
*/
public void updateLastEditorEmailOfFeedbackResponseComments(String courseId, String oldEmail, String updatedEmail) {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, courseId);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, oldEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, updatedEmail);
if (oldEmail.equals(updatedEmail)) {
return;
}
List<FeedbackResponseComment> responseComments = getFeedbackResponseCommentEntitiesForLastEditorInCourse(courseId, oldEmail);
for (FeedbackResponseComment responseComment : responseComments) {
responseComment.setLastEditorEmail(updatedEmail);
}
saveEntities(responseComments);
log.info("updating last editor email from: " + oldEmail + " to: " + updatedEmail + " for feedback response comments in the course: " + courseId);
}
use of teammates.storage.entity.FeedbackResponseComment in project teammates by TEAMMATES.
the class FeedbackResponseCommentsDb method updateGiverEmailOfFeedbackResponseComments.
/*
* Update giver email (normally an instructor email) with the new one
*/
public void updateGiverEmailOfFeedbackResponseComments(String courseId, String oldEmail, String updatedEmail) {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, courseId);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, oldEmail);
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, updatedEmail);
if (oldEmail.equals(updatedEmail)) {
return;
}
List<FeedbackResponseComment> responseComments = getFeedbackResponseCommentEntitiesForGiverInCourse(courseId, oldEmail);
for (FeedbackResponseComment responseComment : responseComments) {
responseComment.setGiverEmail(updatedEmail);
}
saveEntities(responseComments);
}
use of teammates.storage.entity.FeedbackResponseComment in project teammates by TEAMMATES.
the class FeedbackResponseCommentsDb method getFeedbackResponseCommentEntitiesForSessionInSection.
private Collection<FeedbackResponseComment> getFeedbackResponseCommentEntitiesForSessionInSection(String courseId, String feedbackSessionName, String section) {
Map<Long, FeedbackResponseComment> comments = new HashMap<>();
List<FeedbackResponseComment> firstQueryResponseComments = load().filter("courseId =", courseId).filter("feedbackSessionName =", feedbackSessionName).filter("giverSection =", section).list();
for (FeedbackResponseComment comment : firstQueryResponseComments) {
comments.put(comment.getFeedbackResponseCommentId(), comment);
}
List<FeedbackResponseComment> secondQueryResponseComments = load().filter("courseId =", courseId).filter("feedbackSessionName =", feedbackSessionName).filter("receiverSection =", section).list();
for (FeedbackResponseComment comment : secondQueryResponseComments) {
comments.put(comment.getFeedbackResponseCommentId(), comment);
}
return comments.values();
}
use of teammates.storage.entity.FeedbackResponseComment in project teammates by TEAMMATES.
the class FeedbackResponseCommentsDb method updateFeedbackResponseComment.
/**
* Preconditions: <br>
* * All parameters are non-null.
*/
public FeedbackResponseCommentAttributes updateFeedbackResponseComment(FeedbackResponseCommentAttributes newAttributes) throws InvalidParametersException, EntityDoesNotExistException {
Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newAttributes);
newAttributes.sanitizeForSaving();
if (!newAttributes.isValid()) {
throw new InvalidParametersException(newAttributes.getInvalidityInfo());
}
FeedbackResponseComment frc = getEntity(newAttributes);
if (frc == null) {
throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + newAttributes.toString());
}
frc.setCommentText(newAttributes.commentText);
frc.setGiverSection(newAttributes.giverSection);
frc.setReceiverSection(newAttributes.receiverSection);
frc.setShowCommentTo(newAttributes.showCommentTo);
frc.setShowGiverNameTo(newAttributes.showGiverNameTo);
frc.setIsVisibilityFollowingFeedbackQuestion(false);
frc.setLastEditorEmail(newAttributes.giverEmail);
frc.setLastEditedAt(newAttributes.createdAt);
if (newAttributes.feedbackResponseId != null) {
frc.setFeedbackResponseId(newAttributes.feedbackResponseId);
}
saveEntity(frc, newAttributes);
return makeAttributes(frc);
}
Aggregations