Search in sources :

Example 1 with FeedbackResponseComment

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);
}
Also used : FeedbackResponseCommentAttributes(teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes) FeedbackResponseComment(teammates.storage.entity.FeedbackResponseComment) Text(com.google.appengine.api.datastore.Text) Test(org.testng.annotations.Test)

Example 2 with FeedbackResponseComment

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);
}
Also used : FeedbackResponseComment(teammates.storage.entity.FeedbackResponseComment)

Example 3 with FeedbackResponseComment

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);
}
Also used : FeedbackResponseComment(teammates.storage.entity.FeedbackResponseComment)

Example 4 with FeedbackResponseComment

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();
}
Also used : HashMap(java.util.HashMap) FeedbackResponseComment(teammates.storage.entity.FeedbackResponseComment)

Example 5 with FeedbackResponseComment

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);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) FeedbackResponseComment(teammates.storage.entity.FeedbackResponseComment) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

FeedbackResponseComment (teammates.storage.entity.FeedbackResponseComment)5 Text (com.google.appengine.api.datastore.Text)1 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1 FeedbackResponseCommentAttributes (teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes)1 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 InvalidParametersException (teammates.common.exception.InvalidParametersException)1