1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leaveadjustment.service;
17
18 import java.util.Date;
19 import java.util.Map;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.hr.lm.LMConstants;
23 import org.kuali.hr.lm.leaveadjustment.LeaveAdjustment;
24 import org.kuali.hr.lm.leaveblock.LeaveBlock;
25 import org.kuali.hr.time.HrBusinessObject;
26 import org.kuali.hr.time.principal.PrincipalHRAttributes;
27 import org.kuali.hr.time.service.base.TkServiceLocator;
28 import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
29 import org.kuali.hr.time.util.TKContext;
30 import org.kuali.rice.kns.document.MaintenanceDocument;
31
32 public class LeaveAdjustmentMaintainableServiceImpl extends HrBusinessObjectMaintainableImpl{
33
34 private static final long serialVersionUID = 2500485054776792764L;
35
36 @Override
37 public HrBusinessObject getObjectById(String id) {
38
39 return null;
40 }
41
42 @Override
43 public void saveBusinessObject() {
44 super.saveBusinessObject();
45
46
47 LeaveAdjustment la = (LeaveAdjustment) this.getBusinessObject();
48 LeaveBlock aLeaveBlock = new LeaveBlock();
49 aLeaveBlock.setPrincipalId(la.getPrincipalId());
50 aLeaveBlock.setLeaveDate(la.getEffectiveDate());
51 aLeaveBlock.setEarnCode(la.getEarnCode());
52 aLeaveBlock.setAccrualCategory(la.getAccrualCategory());
53 aLeaveBlock.setDescription("Leave Adjustment");
54 aLeaveBlock.setLeaveAmount(la.getAdjustmentAmount());
55 aLeaveBlock.setAccrualGenerated(false);
56 aLeaveBlock.setLeaveBlockType(LMConstants.LEAVE_BLOCK_TYPE.LEAVE_ADJUSTMENT_MAINT);
57 aLeaveBlock.setRequestStatus(LMConstants.REQUEST_STATUS.APPROVED);
58 aLeaveBlock.setBlockId(0L);
59
60 TkServiceLocator.getLeaveBlockService().saveLeaveBlock(aLeaveBlock, TKContext.getPrincipalId());
61 }
62
63 @SuppressWarnings("rawtypes")
64 @Override
65 public Map populateBusinessObject(Map<String, String> fieldValues,
66 MaintenanceDocument maintenanceDocument, String methodToCall) {
67 if (fieldValues.containsKey("principalId")
68 && StringUtils.isNotEmpty(fieldValues.get("principalId"))
69 && fieldValues.containsKey("effectiveDate")
70 && StringUtils.isNotEmpty(fieldValues.get("effectiveDate"))) {
71 Date effDate = new Date(fieldValues.get("effectiveDate"));
72 PrincipalHRAttributes principalHRAttrObj = TkServiceLocator.getPrincipalHRAttributeService()
73 .getPrincipalCalendar(fieldValues.get("principalId"), effDate);
74 String lpString = (principalHRAttrObj != null) ? principalHRAttrObj.getLeavePlan() : "";
75 fieldValues.put("leavePlan", lpString);
76 }
77 return super.populateBusinessObject(fieldValues, maintenanceDocument,
78 methodToCall);
79 }
80
81
82 }