package com.abc.service; import com.abc.dao.DAO; import com.abc.dao.DeptDAO; import com.abc.entities.Dept; import com.abc.entities.DeptPK; import com.abc.exceptions.AppException; public class DeptServiceImpl implements DeptService { DeptDAO deptDAO; public DeptDAO getDeptDAO() { return deptDAO; } public void setDeptDAO(DeptDAO deptDAO) { this.deptDAO = deptDAO; } public Dept registerDept(String deptName, String projCode, String projType, String projStartDate) throws AppException { Dept dept = new Dept(); DeptPK pk = new DeptPK(); pk.setDeptName(deptName); pk.setProjCode(projCode); dept.setDeptPK(pk); dept.setStartDate(projStartDate); dept.setType(projType); Dept newDept = deptDAO.create(dept); DAO.close(); return newDept; } public Dept getDept(String deptName, String projCode) throws AppException { Dept dept = deptDAO.get(deptName, projCode); DAO.close(); return dept; } public void updateProjectDetails(String deptName, String projCode, String projType) throws AppException { Dept dept = deptDAO.get(deptName, projCode); dept.setType(projType); deptDAO.save(dept); DAO.close(); } public void removeProject(String deptName, String projCode) throws AppException { Dept dept = deptDAO.get(deptName, projCode); deptDAO.delete(dept); DAO.close(); } public Dept getDeptWithEmployees(String deptName, String projCode) throws AppException { Dept deptNew = deptDAO.getAll(deptName, projCode); DAO.close(); return deptNew; } }