コード例 #1
0
 public Instructor create(Instructor instructor) {
   instructorVerifier.verifyOnCreate(instructor);
   Long locationId = commonDao.provideCourseLocation(instructor.getOffice());
   instructorDao.create(instructor, locationId);
   createOfficeHours(instructor);
   return instructorDao.getById(instructor.getId());
 }
コード例 #2
0
  public Instructor update(Instructor instructor) {
    instructorVerifier.verifyOnUpdate(instructor);
    Long locationId = commonDao.provideCourseLocation(instructor.getOffice());

    instructorDao.update(instructor, locationId);

    commonDao.deleteAllOfficeHoursForInstructor(instructor.getId());
    createOfficeHours(instructor);

    return instructorDao.getById(instructor.getId());
  }
コード例 #3
0
 public List<Instructor> getAll() {
   List<Instructor> instructors = instructorDao.getAll();
   if (instructors.size() == 0) {
     logger.info("There were no entries in Instructor table");
   }
   return instructors;
 }
コード例 #4
0
 public Instructor getById(Long id) {
   Instructor instructor = instructorDao.getById(id);
   if (instructor == null) {
     logger.warn("The instructor with such id wasn't found");
     throw new NoSuchInstructorException("The instructor with such id wasn't found");
   }
   return instructor;
 }
コード例 #5
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;
 }
コード例 #6
0
 public void delete(Instructor instructor) {
   instructorVerifier.verifyOnDelete(instructor);
   commonDao.deleteAllOfficeHoursForInstructor(instructor.getId());
   instructorDao.delete(instructor.getId());
 }