1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leavedonation.service;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.hr.core.cache.CacheUtils;
22 import org.kuali.hr.lm.LMConstants;
23 import org.kuali.hr.lm.leaveblock.LeaveBlock;
24 import org.kuali.hr.lm.leavedonation.LeaveDonation;
25 import org.kuali.hr.time.HrBusinessObject;
26 import org.kuali.hr.time.service.base.TkServiceLocator;
27 import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
28
29 public class LeaveDonationMaintainableServiceImpl extends HrBusinessObjectMaintainableImpl {
30
31 private static final long serialVersionUID = -2969252116840795858L;
32
33 @Override
34 public HrBusinessObject getObjectById(String id) {
35 return TkServiceLocator.getLeaveDonationService().getLeaveDonation(id);
36 }
37
38 @Override
39 public void saveBusinessObject() {
40 super.saveBusinessObject();
41
42 CacheUtils.flushCache(LeaveDonation.CACHE_NAME);
43
44
45 LeaveDonation ld = (LeaveDonation) this.getBusinessObject();
46 List<LeaveBlock> lbList = new ArrayList<LeaveBlock>();
47
48 LeaveBlock aLeaveBlock = new LeaveBlock();
49 aLeaveBlock.setPrincipalId(ld.getDonorsPrincipalID());
50 aLeaveBlock.setLeaveDate(ld.getEffectiveDate());
51 aLeaveBlock.setEarnCode(ld.getDonatedEarnCode());
52 aLeaveBlock.setAccrualCategory(ld.getDonatedAccrualCategory());
53 aLeaveBlock.setDescription(ld.getDescription());
54 aLeaveBlock.setLeaveAmount(ld.getAmountDonated().negate());
55 aLeaveBlock.setAccrualGenerated(false);
56 aLeaveBlock.setLeaveBlockType(LMConstants.LEAVE_BLOCK_TYPE.DONATION_MAINT);
57 aLeaveBlock.setRequestStatus(LMConstants.REQUEST_STATUS.APPROVED);
58 aLeaveBlock.setBlockId(0L);
59 lbList.add(aLeaveBlock);
60
61
62 aLeaveBlock = new LeaveBlock();
63 aLeaveBlock.setPrincipalId(ld.getRecipientsPrincipalID());
64 aLeaveBlock.setLeaveDate(ld.getEffectiveDate());
65 aLeaveBlock.setEarnCode(ld.getRecipientsEarnCode());
66 aLeaveBlock.setAccrualCategory(ld.getRecipientsAccrualCategory());
67 aLeaveBlock.setDescription(ld.getDescription());
68 aLeaveBlock.setLeaveAmount(ld.getAmountReceived());
69 aLeaveBlock.setAccrualGenerated(false);
70 aLeaveBlock.setLeaveBlockType(LMConstants.LEAVE_BLOCK_TYPE.DONATION_MAINT);
71 aLeaveBlock.setRequestStatus(LMConstants.REQUEST_STATUS.APPROVED);
72 aLeaveBlock.setBlockId(0L);
73 lbList.add(aLeaveBlock);
74
75 TkServiceLocator.getLeaveBlockService().saveLeaveBlocks(lbList);
76 }
77 }