View Javadoc

1   /**
2    * Copyright 2004-2012 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.workarea.service;
17  
18  import org.apache.log4j.Logger;
19  import org.kuali.hr.time.service.base.TkServiceLocator;
20  import org.kuali.hr.time.util.TkConstants;
21  import org.kuali.hr.time.workarea.WorkArea;
22  import org.kuali.hr.time.workarea.dao.WorkAreaDao;
23  
24  import java.sql.Date;
25  import java.util.List;
26  
27  public class WorkAreaServiceImpl implements WorkAreaService {
28  
29  	@SuppressWarnings("unused")
30  	private static final Logger LOG = Logger.getLogger(WorkAreaServiceImpl.class);
31  
32  	private WorkAreaDao workAreaDao;
33  
34  	public WorkAreaServiceImpl() {
35  	}
36  
37      @Override
38      public List<WorkArea> getWorkAreas(String department, Date asOfDate) {
39          List<WorkArea> wa = workAreaDao.getWorkArea(department, asOfDate);
40  
41          // Load Roles
42          // TODO: We may not need to do this, as this method is currently only grabbing WorkArea objects to build role structures for users.
43          //for (WorkArea w : wa) {
44             // populateWorkAreaRoles(w);
45        //  }
46  
47          return wa;
48      }
49  
50      @Override
51  	public WorkArea getWorkArea(Long workArea, Date asOfDate) {
52          WorkArea w = workAreaDao.getWorkArea(workArea, asOfDate);
53          populateWorkAreaRoles(w);
54  		return w;
55  	}
56  
57  	@Override
58  	public void saveOrUpdate(WorkArea workArea) {
59  		workAreaDao.saveOrUpdate(workArea);
60  	}
61  
62  	public WorkAreaDao getWorkAreaDao() {
63  		return workAreaDao;
64  	}
65  
66  	public void setWorkAreaDao(WorkAreaDao workAreaDao) {
67  		this.workAreaDao = workAreaDao;
68  	}
69  
70      @Override
71      public void populateWorkAreaRoles(WorkArea workArea) {
72          if (workArea != null) {
73              workArea.setRoles(
74                      TkServiceLocator.getTkRoleService().getWorkAreaRoles(
75                              workArea.getWorkArea(),
76                              workArea.getEffectiveDate()
77                      )
78              );
79              workArea.setInactiveRoles(
80              		TkServiceLocator.getTkRoleService().getInActiveWorkAreaRoles(
81              				workArea.getWorkArea(),
82              				workArea.getEffectiveDate()
83              		)
84              );
85          }
86      }
87  
88  	@Override
89  	public WorkArea getWorkArea(String tkWorkAreaId) {
90  		return workAreaDao.getWorkArea(tkWorkAreaId);
91  	}
92  
93  	@Override
94  	public Long getNextWorkAreaKey() {
95  		return workAreaDao.getNextWorkAreaKey();
96  	}
97  
98  	@Override
99  	public List<WorkArea> getWorkAreas(String dept, String workArea,
100 			String workAreaDescr, Date fromEffdt, Date toEffdt, String active,
101 			String showHistory) {
102 		return workAreaDao.getWorkAreas(dept, workArea, workAreaDescr, fromEffdt, toEffdt, active, showHistory);
103 	}
104 	
105 	@Override
106     public int getWorkAreaCount(String dept, Long workArea) {
107 		return workAreaDao.getWorkAreaCount(dept, workArea);
108     }
109 }