コード例 #1
0
  public void delete(Course course) {

    courseVerifier.verifyCourseOnDelete(course);

    commonDao.deleteAllMeetingHoursForCourse(course.getId());
    courseDao.delete(course.getId());
  }
コード例 #2
0
  public Course create(Course course, Instructor instructor) {
    courseVerifier.verifyCourseOnCreate(course, instructor);

    Long locationId = commonDao.provideCourseLocation(course.getLocation());
    Course newlyCreatedCourse = courseDao.create(course, instructor.getId(), locationId);

    createMeetingHours(course);

    return courseDao.getById(newlyCreatedCourse.getId());
  }
コード例 #3
0
 private void createMeetingHours(Course course) {
   for (EventInformation eventInformation : course.getMeetingHours()) {
     Long eventInformationId = commonDao.getEventInformationId(eventInformation);
     if (eventInformationId == null) {
       commonDao.createEventInformation(eventInformation);
       eventInformationId = commonDao.getEventInformationId(eventInformation);
     }
     commonDao.createMeetingHours(course.getId(), eventInformationId);
   }
 }
コード例 #4
0
  public Course update(Course course) {
    courseVerifier.verifyCourseOnUpdate(course);

    commonDao.deleteAllMeetingHoursForCourse(course.getId());
    Long locationId = commonDao.provideCourseLocation(course.getLocation());

    courseDao.update(course, locationId);

    createMeetingHours(course);

    return courseDao.getById(course.getId());
  }
コード例 #5
0
  public List<Student> getStudentsByCourse(Course course) {

    courseVerifier.verifyCourseExists(course);
    List<Student> students = studentDao.getStudentsByCourse(course.getId());
    if (students.size() == 0) {
      logger.info("No students enrolled in this course were found");
    }
    return students;
  }
コード例 #6
0
 public Instructor getInstructorByCourse(Course course) {
   courseVerifier.verifyCourseExists(course);
   Instructor instructor = instructorDao.getInstructorByCourse(course.getId());
   if (instructor == null) {
     logger.error("The course doesn't have an instructor. This shouldn't have happened");
     throw new GeneralException(
         "The course doesn't have an instructor. This shouldn't have happened");
   }
   return instructor;
 }
コード例 #7
0
 public void updateInstructor(Course course, Instructor instructor) {
   courseVerifier.verifyUpdateInstructor(course, instructor);
   courseDao.updateInstructor(course.getId(), instructor.getId());
 }
コード例 #8
0
 public void unEnrollStudent(Course course, Student student) {
   courseVerifier.verifyUnenrollStudent(course, student);
   courseDao.unenrollStudent(course.getId(), student.getId());
 }