package de.nak.notendb.service;
import java.util.List;
import de.nak.notendb.dao.ManipelDAO;
import de.nak.notendb.model.Manipel;
/**
* Implementation des ManipelService fuer die Verwaltung von Manipeln
*
* @author Julian Pusch
*
*/
public class ManipelServiceImpl implements ManipelService {
private ManipelDAO manipelDAO;
public void setManipelDAO(ManipelDAO manipelDAO) {
this.manipelDAO = manipelDAO;
}
@Override
public Manipel ladeManipel(long manipelId) throws ManipelNichtGefundenException {
Manipel manipel = manipelDAO.lade(manipelId);
if (manipel == null) {
throw new ManipelNichtGefundenException();
}
return manipel;
}
@Override
public void speichere(Manipel manipel) throws ManipelExistentException {
if (manipelDAO.ladeManipelPerJahrgangUndStudienrichtung
(manipel.getJahrgang(), manipel.getStudienrichtung()).isEmpty() == false) {
throw new ManipelExistentException();
} else {
manipelDAO.speichere(manipel);
}
}
@Override
public void loescheAlle() {
manipelDAO.loescheAlle();
}
@Override
public List<Manipel> ladeAlle() {
return manipelDAO.ladeAlle();
}
}