Skip to content
Snippets Groups Projects

Move Validate methods

19 files
+ 364
305
Compare changes
  • Side-by-side
  • Inline

Files

@@ -2,9 +2,6 @@ package nl.tudelft.ewi.tam.repositories;
import nl.tudelft.ewi.tam.JdbcDaoImpl;
import nl.tudelft.ewi.tam.beans.CourseEdition;
import nl.tudelft.ewi.tam.exceptions.CourseAlreadyExistsException;
import nl.tudelft.ewi.tam.exceptions.CourseNotActiveException;
import nl.tudelft.ewi.tam.exceptions.CourseNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;
@@ -216,40 +213,4 @@ public class CourseEditionRepository {
final int[] argumentTypes = {Types.INTEGER };
return jdbcDaoImpl.count(CHECK_ACTIVE, arguments, argumentTypes) > 0;
}
/**
* Validate whether a course exists with the given id.
*
* @param courseId the id of the course to look for
* @throws CourseNotFoundException thrown when the course is not found
*/
public void validateCourse(final int courseId) throws CourseNotFoundException {
if (!isCourse(courseId)) {
throw new CourseNotFoundException(courseId);
}
}
/**
* Validate whether the course code is unique.
*
* @param courseCode the course code to verify
* @throws CourseAlreadyExistsException thrown when there already is a course with the given course code
*/
public void validateCourseCode(final String courseCode) throws CourseAlreadyExistsException {
if (isCourse(courseCode)) {
throw new CourseAlreadyExistsException(courseCode);
}
}
/**
* Validate whether the course with the given id is active.
*
* @param courseId the id of the course to check
* @throws CourseNotActiveException thrown when the course is not active
*/
public void validateActive(final int courseId) throws CourseNotActiveException {
if (!isActive(courseId)) {
throw new CourseNotActiveException(courseId);
}
}
}
Loading