View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }