1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leaveSummary;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.commons.lang3.StringUtils;
25 import org.json.simple.JSONValue;
26
27 public class LeaveSummary implements Serializable {
28 private List<LeaveSummaryRow> leaveSummaryRows = new ArrayList<LeaveSummaryRow>();
29 private String ytdDatesString;
30 private String pendingDatesString;
31 private String note;
32 private List<String> approvalHeaders = new ArrayList<String>();
33
34 public LeaveSummary(LeaveSummary leaveSummary) {
35 leaveSummaryRows = leaveSummary.leaveSummaryRows;
36 ytdDatesString = leaveSummary.ytdDatesString;
37 pendingDatesString = leaveSummary.pendingDatesString;
38 note = leaveSummary.note;
39 approvalHeaders = leaveSummary.approvalHeaders;
40 }
41
42 public LeaveSummary() {
43
44 }
45
46 public List<LeaveSummaryRow> getLeaveSummaryRows() {
47 return leaveSummaryRows;
48 }
49
50 public LeaveSummaryRow getLeaveSummaryRowForAccrualCtgy(String accrualCategory) {
51 for (LeaveSummaryRow row : getLeaveSummaryRows()) {
52 if (StringUtils.equals(row.getAccrualCategory(), accrualCategory)) {
53 return row;
54 }
55 }
56 return null;
57 }
58
59 public void setLeaveSummaryRows(List<LeaveSummaryRow> leaveSummaryRows) {
60 this.leaveSummaryRows = leaveSummaryRows;
61 }
62
63 public String getYtdDatesString() {
64 return ytdDatesString;
65 }
66
67 public void setYtdDatesString(String ytdDatesString) {
68 this.ytdDatesString = ytdDatesString;
69 }
70
71 public String getPendingDatesString() {
72 return pendingDatesString;
73 }
74
75 public void setPendingDatesString(String pendingDatesString) {
76 this.pendingDatesString = pendingDatesString;
77 }
78
79 public String toJsonString() {
80 List<Map<String, Object>> acSections = new ArrayList<Map<String, Object>>();
81 for(LeaveSummaryRow lsr : this.leaveSummaryRows) {
82 Map<String, Object> acs = new HashMap<String, Object>();
83
84 acs.put("accrualCategory", lsr.getAccrualCategory());
85 acs.put("periodUsage", lsr.getPendingLeaveRequests());
86 acs.put("available", lsr.getLeaveBalance());
87 acSections.add(acs);
88 }
89 return JSONValue.toJSONString(acSections);
90 }
91
92 public List<String> getApprovalHeaders() {
93 return approvalHeaders;
94 }
95
96 public void setApprovalHeaders(List<String> approvalHeaders) {
97 this.approvalHeaders = approvalHeaders;
98 }
99
100 public LeaveSummaryRow getLeaveSummaryRowForAccrualCategory(
101 String accrualCategoryId) {
102 for(LeaveSummaryRow lsr : leaveSummaryRows) {
103 if(StringUtils.equals(lsr.getAccrualCategoryId(),accrualCategoryId)) {
104 return lsr;
105 }
106 }
107 return null;
108 }
109
110 public String getNote() {
111 return note == null ? "" : note;
112 }
113
114 public void setNote(String note) {
115 this.note = note;
116 }
117
118
119
120 }