package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDAO; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.EmployeeValidator; import java.util.Set; import org.springframework.stereotype.Service; @Service public class EmployeeServiceImpl implements EmployeeService { private final EmployeeDAO employeePersistence; public EmployeeServiceImpl(EmployeeDAO employeePersistence) { this.employeePersistence = employeePersistence; } @Override public long add(Employee employee) throws InvalidEmployeeException, ServiceException { EmployeeValidator.validate(employee); try { return employeePersistence.add(employee); } catch (PersistenceException e) { throw new ServiceException(e); } } @Override public Employee update(Employee employee) throws InvalidEmployeeException, ServiceException { EmployeeValidator.validate(employee); try { employeePersistence.update(employee); return employee; } catch (ElementNotFoundException | PersistenceException e) { throw new ServiceException(e); } } @Override public Set list() throws ServiceException { try { return employeePersistence.list(); } catch (PersistenceException e) { throw new ServiceException(e); } } @Override public void remove(long id) throws InvalidEmployeeException, ServiceException { throw new UnsupportedOperationException(); } }