1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.department.service;
17
18 import org.kuali.hr.time.department.Department;
19 import org.kuali.hr.time.department.dao.DepartmentDao;
20 import org.kuali.hr.time.roles.TkRole;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.hr.time.util.TkConstants;
23
24 import java.sql.Date;
25 import java.util.List;
26
27 public class DepartmentServiceImpl implements DepartmentService {
28
29 private DepartmentDao departmentDao;
30
31 @Override
32 public List<Department> getDepartments(String chart, Date asOfDate) {
33 List<Department> ds = departmentDao.getDepartments(chart, asOfDate);
34
35 for (Department d : ds) {
36 populateDepartmentRoles(d);
37 }
38
39 return ds;
40 }
41
42 @Override
43 public Department getDepartment(String department, Date asOfDate) {
44 Department d = departmentDao.getDepartment(department, asOfDate);
45 populateDepartmentRoles(d);
46
47 return d;
48 }
49
50 public void setDepartmentDao(DepartmentDao departmentDao) {
51 this.departmentDao = departmentDao;
52 }
53
54 @Override
55 public void populateDepartmentRoles(Department department) {
56 if (department != null) {
57 department.getRoles().addAll(TkServiceLocator.getTkRoleService().getDepartmentRoles(department.getDept()));
58 department.getInactiveRoles().addAll(TkServiceLocator.getTkRoleService().getDepartmentInactiveRoles(department.getDept()));
59 }
60 }
61
62 @Override
63 public Department getDepartment(String hrDeptId) {
64 return departmentDao.getDepartment(hrDeptId);
65 }
66
67 @Override
68 public List<Department> getDepartmentByLocation(String location) {
69 return departmentDao.getDepartmentByLocation(location);
70 }
71
72 @Override
73 public int getDepartmentCount(String department) {
74 return departmentDao.getDepartmentCount(department);
75 }
76
77 @Override
78 public List<Department> getDepartments(String department, String location, String descr, String active) {
79 return departmentDao.getDepartments(department, location, descr, active);
80 }
81 }