1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timesummary;
17
18 import org.json.simple.JSONValue;
19 import org.kuali.hr.lm.leaveSummary.LeaveSummaryRow;
20
21 import java.io.Serializable;
22 import java.math.BigDecimal;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27
28 public class TimeSummary implements Serializable {
29 private List<String> summaryHeader = new ArrayList<String>();
30 private List<EarnGroupSection> sections = new ArrayList<EarnGroupSection>();
31 private List<LeaveSummaryRow> maxedLeaveRows = new ArrayList<LeaveSummaryRow>();
32 private List<BigDecimal> workedHours = new ArrayList<BigDecimal>();
33
34 public List<String> getSummaryHeader() {
35 return summaryHeader;
36 }
37 public void setSummaryHeader(List<String> summaryHeader) {
38 this.summaryHeader = summaryHeader;
39 }
40 public List<EarnGroupSection> getSections() {
41 return sections;
42 }
43 public void setSections(List<EarnGroupSection> sections) {
44 this.sections = sections;
45 }
46 public List<BigDecimal> getWorkedHours() {
47 return workedHours;
48 }
49 public void setWorkedHours(List<BigDecimal> workedHours) {
50 this.workedHours = workedHours;
51 }
52
53 public String toJsonString() {
54
55 List<Map<String, Object>> earnCodeSections = new ArrayList<Map<String, Object>>();
56
57 for (EarnGroupSection earnGroupSection : this.sections) {
58 for (EarnCodeSection earnCodeSection : earnGroupSection.getEarnCodeSections()) {
59 Map<String, Object> ecs = new HashMap<String, Object>();
60
61
62 ecs.put("earnCode", earnCodeSection.getEarnCode());
63 ecs.put("desc", earnCodeSection.getDescription());
64 ecs.put("totals", earnCodeSection.getTotals());
65 ecs.put("isAmountEarnCode", earnCodeSection.getIsAmountEarnCode());
66
67 List<Map<String, Object>> assignmentRows = new ArrayList<Map<String, Object>>();
68 for (AssignmentRow assignmentRow : earnCodeSection.getAssignmentsRows()) {
69
70 Map<String, Object> ar = new HashMap<String, Object>();
71
72 ar.put("assignmentKey", assignmentRow.getAssignmentKey());
73 ar.put("descr", assignmentRow.getDescr());
74 ar.put("cssClass", assignmentRow.getCssClass());
75 ar.put("amount", assignmentRow.getAmount());
76 ar.put("total", assignmentRow.getTotal());
77 ar.put("amount", assignmentRow.getAmount());
78
79 assignmentRows.add(ar);
80 }
81
82 ecs.put("assignmentRows", assignmentRows);
83 ecs.put("earnGroup", earnGroupSection.getEarnGroup());
84 ecs.put("totals", earnGroupSection.getTotals());
85
86 earnCodeSections.add(ecs);
87 }
88
89 }
90
91 return JSONValue.toJSONString(earnCodeSections);
92 }
93 public List<LeaveSummaryRow> getMaxedLeaveRows() {
94 return maxedLeaveRows;
95 }
96 public void setMaxedLeaveRows(List<LeaveSummaryRow> maxedLeaveRows) {
97 this.maxedLeaveRows = maxedLeaveRows;
98 }
99
100 }