001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.department.service;
017
018 import org.kuali.hr.time.department.Department;
019 import org.kuali.hr.time.department.dao.DepartmentDao;
020 import org.kuali.hr.time.roles.TkRole;
021 import org.kuali.hr.time.service.base.TkServiceLocator;
022 import org.kuali.hr.time.util.TkConstants;
023
024 import java.sql.Date;
025 import java.util.List;
026
027 public class DepartmentServiceImpl implements DepartmentService {
028
029 private DepartmentDao departmentDao;
030
031 @Override
032 public List<Department> getDepartments(String chart, Date asOfDate) {
033 List<Department> ds = departmentDao.getDepartments(chart, asOfDate);
034
035 for (Department d : ds) {
036 populateDepartmentRoles(d);
037 }
038
039 return ds;
040 }
041
042 @Override
043 public Department getDepartment(String department, Date asOfDate) {
044 Department d = departmentDao.getDepartment(department, asOfDate);
045 populateDepartmentRoles(d);
046
047 return d;
048 }
049
050 public void setDepartmentDao(DepartmentDao departmentDao) {
051 this.departmentDao = departmentDao;
052 }
053
054 @Override
055 public void populateDepartmentRoles(Department department) {
056 if (department != null) {
057 department.getRoles().addAll(TkServiceLocator.getTkRoleService().getDepartmentRoles(department.getDept()));
058 department.getInactiveRoles().addAll(TkServiceLocator.getTkRoleService().getDepartmentInactiveRoles(department.getDept()));
059 }
060 }
061
062 @Override
063 public Department getDepartment(String hrDeptId) {
064 return departmentDao.getDepartment(hrDeptId);
065 }
066
067 @Override
068 public List<Department> getDepartmentByLocation(String location) {
069 return departmentDao.getDepartmentByLocation(location);
070 }
071
072 @Override
073 public int getDepartmentCount(String department) {
074 return departmentDao.getDepartmentCount(department);
075 }
076
077 @Override
078 public List<Department> getDepartments(String department, String location, String descr, String active, String showHistory) {
079 return departmentDao.getDepartments(department, location, descr, active, showHistory);
080 }
081 }