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()); }
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()); }
public List<Instructor> getAll() { List<Instructor> instructors = instructorDao.getAll(); if (instructors.size() == 0) { logger.info("There were no entries in Instructor table"); } return instructors; }
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; }
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; }
public void delete(Instructor instructor) { instructorVerifier.verifyOnDelete(instructor); commonDao.deleteAllOfficeHoursForInstructor(instructor.getId()); instructorDao.delete(instructor.getId()); }