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.task.service;
017
018 import java.sql.Date;
019 import java.util.List;
020
021 import org.apache.commons.lang.StringUtils;
022 import org.kuali.hr.time.task.Task;
023 import org.kuali.hr.time.task.dao.TaskDao;
024 import org.kuali.hr.time.util.TkConstants;
025 import org.kuali.hr.time.workarea.WorkArea;
026
027 public class TaskServiceImpl implements TaskService {
028
029 private TaskDao taskDao;
030
031 @Override
032 public Task getTask(String tkTaskId) {
033 return taskDao.getTask(tkTaskId);
034 }
035
036 @Override
037 public Task getTask(Long task, Date asOfDate) {
038 Task taskObj = taskDao.getTask(task, asOfDate);
039 if(taskObj == null){
040 taskObj = new Task();
041 taskObj.setActive(true);
042 taskObj.setEffectiveDate(asOfDate);
043 taskObj.setTask(task);
044 taskObj.setDescription(TkConstants.TASK_DEFAULT_DESP);
045 taskObj.setTkTaskId("0");
046 }
047 return taskObj;
048 }
049
050 @Override
051 public void saveTask(Task task) {
052 taskDao.saveOrUpdate(task);
053 }
054
055 @Override
056 public void saveTasks(List<Task> tasks) {
057 taskDao.saveOrUpdate(tasks);
058 }
059
060 public void setTaskDao(TaskDao taskDao) {
061 this.taskDao = taskDao;
062 }
063
064 @Override
065 public Task getMaxTask(){
066 return taskDao.getMaxTask();
067 }
068
069 @Override
070 public List<Task> getTasks(String task, String description, String workArea, Date fromEffdt, Date toEffdt) {
071 Long taskNumber = StringUtils.isEmpty(task) ? null : Long.parseLong(task);
072 Long workAreaNumber = StringUtils.isEmpty(workArea) ? null : Long.parseLong(workArea);
073
074 return taskDao.getTasks(taskNumber, description, workAreaNumber, fromEffdt, toEffdt);
075 }
076
077 @Override
078 public int getTaskCount(Long task) {
079 return taskDao.getTaskCount(task);
080 }
081 }