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.math.BigDecimal;
022 import java.util.ArrayList;
023 import java.util.HashMap;
024 import java.util.List;
025 import java.util.Map;
026
027 public class TimeSummary {
028 private List<String> summaryHeader = new ArrayList<String>();
029 private List<EarnGroupSection> sections = new ArrayList<EarnGroupSection>();
030 private List<LeaveSummaryRow> maxedLeaveRows = new ArrayList<LeaveSummaryRow>();
031 private List<BigDecimal> workedHours = new ArrayList<BigDecimal>();
032
033 public List<String> getSummaryHeader() {
034 return summaryHeader;
035 }
036 public void setSummaryHeader(List<String> summaryHeader) {
037 this.summaryHeader = summaryHeader;
038 }
039 public List<EarnGroupSection> getSections() {
040 return sections;
041 }
042 public void setSections(List<EarnGroupSection> sections) {
043 this.sections = sections;
044 }
045 public List<BigDecimal> getWorkedHours() {
046 return workedHours;
047 }
048 public void setWorkedHours(List<BigDecimal> workedHours) {
049 this.workedHours = workedHours;
050 }
051
052 public String toJsonString() {
053
054 List<Map<String, Object>> earnCodeSections = new ArrayList<Map<String, Object>>();
055
056 for (EarnGroupSection earnGroupSection : this.sections) {
057 for (EarnCodeSection earnCodeSection : earnGroupSection.getEarnCodeSections()) {
058 Map<String, Object> ecs = new HashMap<String, Object>();
059
060
061 ecs.put("earnCode", earnCodeSection.getEarnCode());
062 ecs.put("desc", earnCodeSection.getDescription());
063 ecs.put("totals", earnCodeSection.getTotals());
064 ecs.put("isAmountEarnCode", earnCodeSection.getIsAmountEarnCode());
065
066 List<Map<String, Object>> assignmentRows = new ArrayList<Map<String, Object>>();
067 for (AssignmentRow assignmentRow : earnCodeSection.getAssignmentsRows()) {
068
069 Map<String, Object> ar = new HashMap<String, Object>();
070
071 ar.put("assignmentKey", assignmentRow.getAssignmentKey());
072 ar.put("descr", assignmentRow.getDescr());
073 ar.put("cssClass", assignmentRow.getCssClass());
074 ar.put("amount", assignmentRow.getAmount());
075 ar.put("total", assignmentRow.getTotal());
076 ar.put("amount", assignmentRow.getAmount());
077
078 assignmentRows.add(ar);
079 }
080
081 ecs.put("assignmentRows", assignmentRows);
082 ecs.put("earnGroup", earnGroupSection.getEarnGroup());
083 ecs.put("totals", earnGroupSection.getTotals());
084
085 earnCodeSections.add(ecs);
086 }
087
088 }
089
090 return JSONValue.toJSONString(earnCodeSections);
091 }
092 public List<LeaveSummaryRow> getMaxedLeaveRows() {
093 return maxedLeaveRows;
094 }
095 public void setMaxedLeaveRows(List<LeaveSummaryRow> maxedLeaveRows) {
096 this.maxedLeaveRows = maxedLeaveRows;
097 }
098
099 }