Search in sources :

Example 31 with EntityDoesNotExistException

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

the class FeedbackSessionsLogic method deleteInstructorRespondent.

public void deleteInstructorRespondent(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.deleteInstructorRespondent(email, sessionToUpdate);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 32 with EntityDoesNotExistException

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

the class FeedbackSessionsLogic method updateFeedbackSession.

public void updateFeedbackSession(FeedbackSessionAttributes newSession) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, newSession);
    FeedbackSessionAttributes oldSession = fsDb.getFeedbackSession(newSession.getCourseId(), newSession.getFeedbackSessionName());
    if (oldSession == null) {
        throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + newSession.getCourseId() + "/" + newSession.getFeedbackSessionName());
    }
    // These can't be changed anyway. Copy values to defensively avoid
    // invalid parameters.
    newSession.setCreatorEmail(oldSession.getCreatorEmail());
    newSession.setCreatedTime(oldSession.getCreatedTime());
    if (newSession.getInstructions() == null) {
        newSession.setInstructions(oldSession.getInstructions());
    }
    if (newSession.getStartTime() == null) {
        newSession.setStartTime(oldSession.getStartTime());
    }
    if (newSession.getEndTime() == null) {
        newSession.setEndTime(oldSession.getEndTime());
    }
    if (newSession.getFeedbackSessionType() == null) {
        newSession.setFeedbackSessionType(oldSession.getFeedbackSessionType());
    }
    if (newSession.getSessionVisibleFromTime() == null) {
        newSession.setSessionVisibleFromTime(oldSession.getSessionVisibleFromTime());
    }
    if (newSession.getResultsVisibleFromTime() == null) {
        newSession.setResultsVisibleFromTime(oldSession.getResultsVisibleFromTime());
    }
    makeEmailStateConsistent(oldSession, newSession);
    fsDb.updateFeedbackSession(newSession);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 33 with EntityDoesNotExistException

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

the class FeedbackSessionsLogic method clearInstructorRespondents.

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

Example 34 with EntityDoesNotExistException

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

the class FeedbackSessionsLogic method deleteFeedbackSessionCascade.

/**
 * Deletes a specific feedback session, and all its question and responses.
 */
public void deleteFeedbackSessionCascade(String feedbackSessionName, String courseId) {
    try {
        fqLogic.deleteFeedbackQuestionsForSession(feedbackSessionName, courseId);
    } catch (EntityDoesNotExistException e) {
        // Silently fail if session does not exist
        log.warning(TeammatesException.toStringWithStackTrace(e));
    }
    FeedbackSessionAttributes sessionToDelete = FeedbackSessionAttributes.builder(feedbackSessionName, courseId, "").build();
    fsDb.deleteEntity(sessionToDelete);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 35 with EntityDoesNotExistException

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

the class AdminAccountDetailsPageAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    String googleId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
    AccountAttributes accountInformation = logic.getAccount(googleId);
    List<CourseDetailsBundle> instructorCourseList;
    try {
        instructorCourseList = new ArrayList<>(logic.getCourseSummariesForInstructor(googleId).values());
    } catch (EntityDoesNotExistException e) {
        // Not an instructor of any course
        instructorCourseList = null;
    }
    List<CourseAttributes> studentCourseList;
    try {
        studentCourseList = logic.getCoursesForStudentAccount(googleId);
    } catch (EntityDoesNotExistException e) {
        // Not a student of any course
        studentCourseList = null;
    }
    AdminAccountDetailsPageData data = new AdminAccountDetailsPageData(account, sessionToken, accountInformation, instructorCourseList, studentCourseList);
    statusToAdmin = "adminAccountDetails Page Load<br>" + "Viewing details for " + data.getAccountInformation().name + "(" + googleId + ")";
    return createShowPageResult(Const.ViewURIs.ADMIN_ACCOUNT_DETAILS, data);
}
Also used : AdminAccountDetailsPageData(teammates.ui.pagedata.AdminAccountDetailsPageData) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

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