Search in sources :

Example 1 with Course

use of teammates.storage.entity.Course in project teammates by TEAMMATES.

the class CoursesDb method updateCourse.

/**
 * Updates the course.<br>
 * Updates only name and course archive status.<br>
 * Preconditions: <br>
 * * {@code courseToUpdate} is non-null.<br>
 */
public void updateCourse(CourseAttributes courseToUpdate) throws InvalidParametersException, EntityDoesNotExistException {
    Assumption.assertNotNull(Const.StatusCodes.DBLEVEL_NULL_INPUT, courseToUpdate);
    courseToUpdate.sanitizeForSaving();
    if (!courseToUpdate.isValid()) {
        throw new InvalidParametersException(courseToUpdate.getInvalidityInfo());
    }
    Course courseEntityToUpdate = getCourseEntity(courseToUpdate.getId());
    if (courseEntityToUpdate == null) {
        throw new EntityDoesNotExistException(ERROR_UPDATE_NON_EXISTENT_COURSE);
    }
    courseEntityToUpdate.setName(courseToUpdate.getName());
    courseEntityToUpdate.setTimeZone(courseToUpdate.getTimeZone().getId());
    saveEntity(courseEntityToUpdate, courseToUpdate);
}
Also used : InvalidParametersException(teammates.common.exception.InvalidParametersException) Course(teammates.storage.entity.Course) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Aggregations

EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)1 InvalidParametersException (teammates.common.exception.InvalidParametersException)1 Course (teammates.storage.entity.Course)1