1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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 }