001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.timesummary;
017
018 import org.json.simple.JSONValue;
019 import org.kuali.hr.lm.leaveSummary.LeaveSummaryRow;
020
021 import java.io.Serializable;
022 import java.math.BigDecimal;
023 import java.util.ArrayList;
024 import java.util.HashMap;
025 import java.util.List;
026 import java.util.Map;
027
028 public class TimeSummary implements Serializable {
029 private List<String> summaryHeader = new ArrayList<String>();
030 private List<EarnGroupSection> sections = new ArrayList<EarnGroupSection>();
031 private List<LeaveSummaryRow> maxedLeaveRows = new ArrayList<LeaveSummaryRow>();
032 private List<BigDecimal> workedHours = new ArrayList<BigDecimal>();
033
034 public List<String> getSummaryHeader() {
035 return summaryHeader;
036 }
037 public void setSummaryHeader(List<String> summaryHeader) {
038 this.summaryHeader = summaryHeader;
039 }
040 public List<EarnGroupSection> getSections() {
041 return sections;
042 }
043 public void setSections(List<EarnGroupSection> sections) {
044 this.sections = sections;
045 }
046 public List<BigDecimal> getWorkedHours() {
047 return workedHours;
048 }
049 public void setWorkedHours(List<BigDecimal> workedHours) {
050 this.workedHours = workedHours;
051 }
052
053 public String toJsonString() {
054
055 List<Map<String, Object>> earnCodeSections = new ArrayList<Map<String, Object>>();
056
057 for (EarnGroupSection earnGroupSection : this.sections) {
058 for (EarnCodeSection earnCodeSection : earnGroupSection.getEarnCodeSections()) {
059 Map<String, Object> ecs = new HashMap<String, Object>();
060
061
062 ecs.put("earnCode", earnCodeSection.getEarnCode());
063 ecs.put("desc", earnCodeSection.getDescription());
064 ecs.put("totals", earnCodeSection.getTotals());
065 ecs.put("isAmountEarnCode", earnCodeSection.getIsAmountEarnCode());
066
067 List<Map<String, Object>> assignmentRows = new ArrayList<Map<String, Object>>();
068 for (AssignmentRow assignmentRow : earnCodeSection.getAssignmentsRows()) {
069
070 Map<String, Object> ar = new HashMap<String, Object>();
071
072 ar.put("assignmentKey", assignmentRow.getAssignmentKey());
073 ar.put("descr", assignmentRow.getDescr());
074 ar.put("cssClass", assignmentRow.getCssClass());
075 ar.put("amount", assignmentRow.getAmount());
076 ar.put("total", assignmentRow.getTotal());
077 ar.put("amount", assignmentRow.getAmount());
078
079 assignmentRows.add(ar);
080 }
081
082 ecs.put("assignmentRows", assignmentRows);
083 ecs.put("earnGroup", earnGroupSection.getEarnGroup());
084 ecs.put("totals", earnGroupSection.getTotals());
085
086 earnCodeSections.add(ecs);
087 }
088
089 }
090
091 return JSONValue.toJSONString(earnCodeSections);
092 }
093 public List<LeaveSummaryRow> getMaxedLeaveRows() {
094 return maxedLeaveRows;
095 }
096 public void setMaxedLeaveRows(List<LeaveSummaryRow> maxedLeaveRows) {
097 this.maxedLeaveRows = maxedLeaveRows;
098 }
099
100 }