package de.nak.notendb.service;
import java.util.List;
import de.nak.notendb.dao.StudentDAO;
import de.nak.notendb.model.Student;
/**
* Implementation des StudentService fuer die Verwaltung von Studenten
*
* @author Julian Pusch
*
*/
public class StudentServiceImpl implements StudentService {
private StudentDAO studentDAO;
public void setStudentDAO(StudentDAO studentDAO) {
this.studentDAO = studentDAO;
}
@Override
public Student ladeStudent(Long id) throws StudentNichtGefundenException {
Student student = studentDAO.lade(id);
if (student == null) {
throw new StudentNichtGefundenException();
}
return student;
}
@Override
public List<Student> ladeAlle() {
return studentDAO.ladeAlle();
}
@Override
public List<Student> ladeStudentenZuManipel(Long manipelId) {
return studentDAO.ladeStudentenZuManipel(manipelId);
}
@Override
public void speichere(Student student) throws StudentExistentException {
if (studentDAO.ladeStudentenZuMatrikelNr(student.getMatrikelNr()).isEmpty() == false) {
throw new StudentExistentException();
} else {
studentDAO.speichere(student);
}
}
@Override
public void loescheAlle() {
studentDAO.loescheAlle();
}
}