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.timeblock.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.hr.time.timeblock.TimeBlock;
22  import org.kuali.hr.time.timeblock.TimeBlockHistory;
23  import org.kuali.hr.time.timeblock.TimeBlockHistoryDetail;
24  import org.kuali.hr.time.timeblock.TimeHourDetail;
25  import org.kuali.hr.time.timeblock.dao.TimeBlockHistoryDao;
26  
27  public class TimeBlockHistoryServiceImpl implements TimeBlockHistoryService {
28  
29      private TimeBlockHistoryDao timeBlockHistoryDao;
30  
31  	public void saveTimeBlockHistory(TimeBlockHistory tbh) {
32  		timeBlockHistoryDao.saveOrUpdate(tbh);
33  	}
34  
35  	public List<TimeBlockHistory> saveTimeBlockHistoryList(List<TimeBlockHistory> tbhs) {
36  		return tbhs;
37  	}
38  
39  	public void setTimeBlockHistoryDao(TimeBlockHistoryDao timeBlockHistoryDao) {
40  		this.timeBlockHistoryDao = timeBlockHistoryDao;
41  	}
42  
43      public TimeBlockHistory getTimeBlockHistoryByTkTimeBlockId(String tkTimeBlockId) {
44          return timeBlockHistoryDao.getTimeBlockHistoryByTkTimeBlockId(tkTimeBlockId);
45      }
46      
47      public void addTimeBlockHistoryDetails(TimeBlockHistory timeBlockHistory, TimeBlock timeBlock) {
48        List<TimeHourDetail> details = timeBlock.getTimeHourDetails();
49        if(!details.isEmpty()) {
50        	List<TimeBlockHistoryDetail> tbhds = new ArrayList<TimeBlockHistoryDetail>();
51        	for(TimeHourDetail thd : details) {
52        		TimeBlockHistoryDetail tbhd = new TimeBlockHistoryDetail(thd);
53        		tbhds.add(tbhd);
54        	}
55        	timeBlockHistory.setTimeBlockHistoryDetails(tbhds);
56        }
57      }
58  
59  }