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