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