View Javadoc
1   /**
2    * Copyright 2004-2014 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.timeoff.web;
17  
18  import java.util.Map;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.joda.time.LocalDate;
22  import org.kuali.kpme.core.api.earncode.EarnCodeContract;
23  import org.kuali.kpme.core.bo.HrBusinessObject;
24  import org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl;
25  import org.kuali.kpme.core.service.HrServiceLocator;
26  import org.kuali.kpme.core.util.TKUtils;
27  import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
28  import org.kuali.kpme.tklm.leave.timeoff.SystemScheduledTimeOff;
29  import org.kuali.rice.kns.document.MaintenanceDocument;
30  
31  public class SystemScheduledTimeOffMaintainableServiceImpl extends HrBusinessObjectMaintainableImpl {
32  
33  	/**
34  	 * 
35  	 */
36  	private static final long serialVersionUID = 1L;
37  
38  	@Override
39  	public HrBusinessObject getObjectById(String id) {
40  		return (SystemScheduledTimeOff)LmServiceLocator.getSysSchTimeOffService().getSystemScheduledTimeOff(id);
41  	}
42  	
43  	// KPME-2763/2787
44  	@Override
45  	public Map populateBusinessObject(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, String methodToCall) {
46  		if (fieldValues.containsKey("earnCode")
47  			&& StringUtils.isNotEmpty(fieldValues.get("earnCode"))
48  			&& fieldValues.containsKey("effectiveDate")
49  			&& StringUtils.isNotEmpty(fieldValues.get("effectiveDate"))) {
50  			
51  			LocalDate effDate = TKUtils.formatDateString(fieldValues.get("effectiveDate"));
52  			EarnCodeContract ec =  HrServiceLocator.getEarnCodeService().getEarnCode(fieldValues.get("earnCode"), effDate);
53  			if (ec != null) {
54  				fieldValues.put("accrualCategory", ec.getAccrualCategory());
55  				fieldValues.put("leavePlan", ec.getLeavePlan());
56  			} else {
57  				fieldValues.put("accrualCategory", "");
58  				fieldValues.put("leavePlan", "");
59  			}
60  		}
61  
62  		return super.populateBusinessObject(fieldValues, maintenanceDocument,
63  				methodToCall);
64  	}
65  }