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);
}
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);
}
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);
}
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;
}
}
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);
}
Aggregations