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