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.lm.accrual.service;
17  
18  import org.kuali.hr.lm.accrual.PrincipalAccrualRan;
19  import org.kuali.hr.lm.accrual.dao.PrincipalAccrualRanDao;
20  import org.kuali.hr.time.util.TKUtils;
21  import org.kuali.rice.krad.service.KRADServiceLocator;
22  
23  public class PrincipalAccrualRanServiceImpl implements PrincipalAccrualRanService{
24  
25  	private PrincipalAccrualRanDao principalAccrualRanDao;
26  	
27  	@Override
28  	public PrincipalAccrualRan getLastPrincipalAccrualRan(String principalId) {
29  		return principalAccrualRanDao.getLastPrincipalAccrualRan(principalId);
30  	}
31  	
32  	@Override
33  	public void updatePrincipalAccrualRanInfo(String principalId) {
34  		PrincipalAccrualRan par = this.getLastPrincipalAccrualRan(principalId);
35  		if(par == null) { // no data for last ran
36  			par = new PrincipalAccrualRan();
37  			par.setPrincipalId(principalId);
38  			par.setLastRanTs(TKUtils.getCurrentTimestamp());
39  		} else {
40  			par.setLastRanTs(TKUtils.getCurrentTimestamp());
41  		}
42  		
43  		KRADServiceLocator.getBusinessObjectService().save(par);
44  	}
45  
46  	public PrincipalAccrualRanDao getPrincipalAccrualRanDao() {
47  		return principalAccrualRanDao;
48  	}
49  
50  	public void setPrincipalAccrualRanDao(
51  			PrincipalAccrualRanDao principalAccrualRanDao) {
52  		this.principalAccrualRanDao = principalAccrualRanDao;
53  	}
54  }