Search in sources :

Example 96 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsLogic method addInstructorRespondent.

public void addInstructorRespondent(String email, String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, email);
    FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
    if (sessionToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
    }
    fsDb.addInstructorRespondent(email, sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 97 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackQuestionsDb method updateFeedbackQuestion.

/**
 * Updates the feedback question identified by `{@code newAttributes.getId()}
 * For the remaining parameters, the existing value is preserved
 *   if the parameter is null (due to 'keep existing' policy).<br>
 * The timestamp for {@code updatedAt} is independent of the {@code newAttributes}
 *   and depends on the value of {@code keepUpdateTimestamp}
 * Preconditions: <br>
 * * {@code newAttributes.getId()} is non-null and
 *  correspond to an existing feedback question. <br>
 */
public void updateFeedbackQuestion(FeedbackQuestionAttributes newAttributes, boolean keepUpdateTimestamp) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, newAttributes);
    if (!newAttributes.isValid()) {
        throw new InvalidParametersException(newAttributes.getInvalidityInfo());
    }
    FeedbackQuestion fq = getEntity(newAttributes);
    if (fq == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + newAttributes.toString());
    }
    fq.setQuestionNumber(newAttributes.questionNumber);
    fq.setQuestionText(newAttributes.questionMetaData);
    fq.setQuestionDescription(newAttributes.questionDescription);
    fq.setQuestionType(newAttributes.questionType);
    fq.setGiverType(newAttributes.giverType);
    fq.setRecipientType(newAttributes.recipientType);
    fq.setShowResponsesTo(newAttributes.showResponsesTo);
    fq.setShowGiverNameTo(newAttributes.showGiverNameTo);
    fq.setShowRecipientNameTo(newAttributes.showRecipientNameTo);
    fq.setNumberOfEntitiesToGiveFeedbackTo(newAttributes.numberOfEntitiesToGiveFeedbackTo);
    // set true to prevent changes to last update timestamp
    fq.keepUpdateTimestamp = keepUpdateTimestamp;
    saveEntity(fq, newAttributes);
}
Also used : FeedbackQuestion(teammates.storage.entity.FeedbackQuestion) InvalidParametersException(teammates.common.exception.InvalidParametersException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 98 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException 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)

Example 99 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsDb method addStudentRespondents.

// The objectify library does not support throwing checked exceptions inside transactions
@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
public void addStudentRespondents(List<String> emails, FeedbackSessionAttributes feedbackSession) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, emails);
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, feedbackSession);
    feedbackSession.sanitizeForSaving();
    if (!feedbackSession.isValid()) {
        throw new InvalidParametersException(feedbackSession.getInvalidityInfo());
    }
    try {
        ofy().transact(new VoidWork() {

            @Override
            public void vrun() {
                FeedbackSession fs = getEntity(feedbackSession);
                if (fs == null) {
                    throw new RuntimeException(new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + feedbackSession.toString()));
                }
                fs.getRespondingStudentList().addAll(emails);
                saveEntity(fs, feedbackSession);
            }
        });
    } catch (RuntimeException e) {
        if (e.getCause() instanceof EntityDoesNotExistException) {
            throw (EntityDoesNotExistException) e.getCause();
        }
        throw e;
    }
}
Also used : FeedbackSession(teammates.storage.entity.FeedbackSession) VoidWork(com.googlecode.objectify.VoidWork) InvalidParametersException(teammates.common.exception.InvalidParametersException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 100 with EntityDoesNotExistException

use of teammates.common.exception.EntityDoesNotExistException in project teammates by TEAMMATES.

the class FeedbackSessionsDb method clearInstructorRespondents.

public void clearInstructorRespondents(FeedbackSessionAttributes feedbackSession) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, feedbackSession);
    feedbackSession.sanitizeForSaving();
    if (!feedbackSession.isValid()) {
        throw new InvalidParametersException(feedbackSession.getInvalidityInfo());
    }
    FeedbackSession fs = getEntity(feedbackSession);
    if (fs == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT + feedbackSession.toString());
    }
    fs.getRespondingInstructorList().clear();
    saveEntity(fs, feedbackSession);
}
Also used : FeedbackSession(teammates.storage.entity.FeedbackSession) InvalidParametersException(teammates.common.exception.InvalidParametersException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)107 InvalidParametersException (teammates.common.exception.InvalidParametersException)35 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)29 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)26 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)24 ArrayList (java.util.ArrayList)21 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)17 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)15 List (java.util.List)10 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)10 HashMap (java.util.HashMap)9 Test (org.testng.annotations.Test)9 FeedbackSession (teammates.storage.entity.FeedbackSession)9 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)8 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)7 Text (com.google.appengine.api.datastore.Text)6 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)6 VoidWork (com.googlecode.objectify.VoidWork)4 HashSet (java.util.HashSet)4