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.task.service;
17  
18  import java.sql.Date;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.hr.time.task.Task;
23  import org.kuali.hr.time.task.dao.TaskDao;
24  import org.kuali.hr.time.util.TkConstants;
25  import org.kuali.hr.time.workarea.WorkArea;
26  
27  public class TaskServiceImpl implements TaskService {
28  
29      private TaskDao taskDao;
30      
31  	@Override
32  	public Task getTask(String tkTaskId) {
33  		return taskDao.getTask(tkTaskId);
34  	}
35  
36      @Override
37      public Task getTask(Long task, Date asOfDate) {
38          Task taskObj =  taskDao.getTask(task, asOfDate);
39          if(taskObj == null){
40          	taskObj = new Task();
41          	taskObj.setActive(true);
42          	taskObj.setEffectiveDate(asOfDate);
43          	taskObj.setTask(task);
44          	taskObj.setDescription(TkConstants.TASK_DEFAULT_DESP);
45          	taskObj.setTkTaskId("0");
46          }
47          return taskObj;
48      }
49  
50      @Override
51      public void saveTask(Task task) {
52          taskDao.saveOrUpdate(task);
53      }
54  
55      @Override
56      public void saveTasks(List<Task> tasks) {
57          taskDao.saveOrUpdate(tasks);
58      }
59  
60      public void setTaskDao(TaskDao taskDao) {
61          this.taskDao = taskDao;
62      } 
63  
64  	@Override
65  	public Task getMaxTask(){
66  		return taskDao.getMaxTask();
67  	}
68  
69      @Override
70      public List<Task> getTasks(String task, String description, String workArea, Date fromEffdt, Date toEffdt) {
71          Long taskNumber = StringUtils.isEmpty(task) ? null : Long.parseLong(task);
72          Long workAreaNumber = StringUtils.isEmpty(workArea) ? null : Long.parseLong(workArea);
73          
74          return taskDao.getTasks(taskNumber, description, workAreaNumber, fromEffdt, toEffdt);
75      }
76      
77      @Override
78      public int getTaskCount(Long task) {
79      	return taskDao.getTaskCount(task);
80      }
81  }