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.apache.commons.lang.StringUtils;
19 import org.json.simple.JSONValue;
20 import org.kuali.hr.lm.leaveSummary.LeaveSummaryRow;
21
22 import java.io.Serializable;
23 import java.math.BigDecimal;
24 import java.util.*;
25
26 public class TimeSummary implements Serializable {
27 private List<String> summaryHeader = new ArrayList<String>();
28 private List<EarnGroupSection> sections = new ArrayList<EarnGroupSection>();
29 private List<LeaveSummaryRow> maxedLeaveRows = new ArrayList<LeaveSummaryRow>();
30 private List<BigDecimal> workedHours = new ArrayList<BigDecimal>();
31
32 public List<String> getSummaryHeader() {
33 return summaryHeader;
34 }
35 public void setSummaryHeader(List<String> summaryHeader) {
36 this.summaryHeader = summaryHeader;
37 }
38 public List<EarnGroupSection> getSections() {
39 return sections;
40 }
41 public void setSections(List<EarnGroupSection> sections) {
42 this.sections = sections;
43 }
44 public List<BigDecimal> getWorkedHours() {
45 return workedHours;
46 }
47 public void setWorkedHours(List<BigDecimal> workedHours) {
48 this.workedHours = workedHours;
49 }
50
51 public String toJsonString() {
52 List<Map<String, Object>> earnGroupSections = new ArrayList<Map<String, Object>>();
53
54
55 Map<String, Object> workedHours = new HashMap<String, Object>();
56 workedHours.put("totals", getWorkedHours());
57 workedHours.put("earnGroup", "Worked Hours");
58 workedHours.put("earnCodeSections", new HashMap<String, Object>());
59
60
61
62
63
64
65
66 for (EarnGroupSection earnGroupSection : this.sections) {
67 List<Map<String, Object>> earnCodeSections = new ArrayList<Map<String, Object>>();
68 Map<String, Object> egs = new TreeMap<String, Object>();
69 egs.put("earnGroup", earnGroupSection.getEarnGroup());
70 egs.put("totals", earnGroupSection.getTotals());
71
72 for (EarnCodeSection earnCodeSection : earnGroupSection.getEarnCodeSections()) {
73 Map<String, Object> ecs = new TreeMap<String, Object>();
74
75 ecs.put("earnCode", earnCodeSection.getEarnCode());
76 ecs.put("desc", earnCodeSection.getDescription());
77 ecs.put("totals", earnCodeSection.getTotals());
78 ecs.put("isAmountEarnCode", earnCodeSection.getIsAmountEarnCode());
79
80 List<Map<String, Object>> assignmentRows = new ArrayList<Map<String, Object>>();
81 for (AssignmentRow assignmentRow : earnCodeSection.getAssignmentsRows()) {
82 Map<String, Object> ar = new TreeMap<String, Object>();
83
84 ar.put("descr", assignmentRow.getDescr());
85 ar.put("assignmentKey", assignmentRow.getAssignmentKey());
86 ar.put("cssClass", assignmentRow.getCssClass());
87 ar.put("earnCode", earnCodeSection.getEarnCode());
88 ecs.put("earnGroup", earnGroupSection.getEarnGroup());
89 ecs.put("totals", earnGroupSection.getTotals());
90
91 List<Map<String, Object>> assignmentColumns = new ArrayList<Map<String, Object>>();
92 for (AssignmentColumn assignmentColumn : assignmentRow.getAssignmentColumns()) {
93 Map<String, Object> ac = new TreeMap<String, Object>();
94
95 ac.put("cssClass", assignmentColumn.getCssClass());
96 ac.put("amount", assignmentColumn.getAmount());
97 ac.put("total", assignmentColumn.getTotal());
98 ac.put("isWeeklyTotal", assignmentColumn.isWeeklyTotal());
99
100 assignmentColumns.add(ac);
101 }
102 ar.put("assignmentColumns", assignmentColumns);
103
104 assignmentRows.add(ar);
105 }
106 ecs.put("assignmentRows", assignmentRows);
107
108 earnCodeSections.add(ecs);
109 }
110 egs.put("earnCodeSections", earnCodeSections);
111 earnGroupSections.add(egs);
112 }
113 earnGroupSections.add(workedHours);
114
115 return JSONValue.toJSONString(earnGroupSections);
116 }
117 public List<LeaveSummaryRow> getMaxedLeaveRows() {
118 return maxedLeaveRows;
119 }
120 public void setMaxedLeaveRows(List<LeaveSummaryRow> maxedLeaveRows) {
121 this.maxedLeaveRows = maxedLeaveRows;
122 }
123
124 }