@Override public List<Module> getAll(String course) throws ServiceException { try { Course associatedCourse = new Course(); associatedCourse.setTitle(course); if (coursesDAO.isCourseExistent(associatedCourse)) { return moduleDAO.getAll(course); } else { throw new ServiceException(ServiceException.FAILED_COURSE_INNEXISTENT); } } catch (DAOException daoException) { throw new ServiceException(daoException.getMessage()); } }
@Override public void storeModule(Module module) throws ServiceException { try { Course associatedCourse = new Course(); associatedCourse.setTitle(module.getCourse()); if (coursesDAO.isCourseExistent(associatedCourse)) { if (!moduleDAO.isModuleExistent(module)) { moduleDAO.storeModule(module); } else { throw new ServiceException(ServiceException.FAILED_MODULE_ALREADY_EXISTS); } } else { throw new ServiceException(ServiceException.FAILED_COURSE_INNEXISTENT); } } catch (DAOException daoException) { throw new ServiceException(daoException.getMessage()); } }