1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leave.web;
17
18 import java.math.BigDecimal;
19 import java.sql.Timestamp;
20 import java.util.Collection;
21 import java.util.Date;
22 import java.util.SortedMap;
23 import java.util.TreeMap;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.kuali.hr.lm.LMConstants;
27 import org.kuali.hr.lm.leaveblock.LeaveBlock;
28 import org.kuali.hr.lm.workflow.LeaveCalendarDocumentHeader;
29 import org.kuali.hr.time.service.base.TkServiceLocator;
30 import org.kuali.rice.kew.api.KewApiConstants;
31
32 public class LeaveBlockDisplay {
33
34 private LeaveBlock leaveBlock;
35 private SortedMap<String, BigDecimal> accrualBalances = new TreeMap<String, BigDecimal>();
36
37 public LeaveBlockDisplay(LeaveBlock leaveBlock) {
38 this.leaveBlock = leaveBlock;
39 }
40
41 public Date getLeaveDate() {
42 return leaveBlock.getLeaveDate();
43 }
44
45 public String getDocumentId() {
46 return leaveBlock.getDocumentId();
47 }
48
49 public String getCalendarId() {
50 return leaveBlock.getCalendarId();
51 }
52
53 public String getEarnCode() {
54 return leaveBlock.getEarnCode();
55 }
56
57 public String getDescription() {
58 if(leaveBlock.getDescription() == null || leaveBlock.getDescription().trim().isEmpty()) {
59 return retrieveDescriptionAccordingToLeaveType(leaveBlock.getLeaveBlockType());
60 }
61 return leaveBlock.getDescription();
62 }
63
64 public String getRequestStatus() {
65 String requestStatus = null;
66
67 if (StringUtils.isNotBlank(leaveBlock.getRequestStatus())) {
68 requestStatus = LMConstants.REQUEST_STATUS_STRINGS.get(leaveBlock.getRequestStatus());
69 }
70
71 return requestStatus;
72 }
73
74 public String getDocumentStatus() {
75 String documentStatus = null;
76
77 if (StringUtils.isNotBlank(leaveBlock.getDocumentId())) {
78 LeaveCalendarDocumentHeader lcdh = TkServiceLocator.getLeaveCalendarDocumentHeaderService().getDocumentHeader(leaveBlock.getDocumentId());
79 if (lcdh != null ) {
80 documentStatus = KewApiConstants.DOCUMENT_STATUSES.get(lcdh.getDocumentStatus());
81 }
82 }
83
84 return documentStatus;
85 }
86
87 public BigDecimal getLeaveAmount() {
88 return leaveBlock.getLeaveAmount();
89 }
90
91 public Timestamp getTimestamp() {
92 return leaveBlock.getTimestamp();
93 }
94
95 public String getAssignmentTitle() {
96 return leaveBlock.getAssignmentTitle();
97 }
98
99 public String getAccrualCategory() {
100 return leaveBlock.getAccrualCategory();
101 }
102
103 public Collection<BigDecimal> getAccrualBalances() {
104 return accrualBalances.values();
105 }
106
107 public BigDecimal getAccrualBalance(String accrualCategory) {
108 return accrualBalances.get(accrualCategory);
109 }
110
111 public void setAccrualBalance(String accrualCategory, BigDecimal accrualBalance) {
112 this.accrualBalances.put(accrualCategory, accrualBalance);
113 }
114
115 private String retrieveDescriptionAccordingToLeaveType(String leaveType) {
116 String description = null;
117 description = LMConstants.LEAVE_BLOCK_TYPE_MAP.get(leaveType);
118 return description;
119 }
120
121 }