View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.tklm.time.timesummary;
17  
18  import java.io.Serializable;
19  import java.math.BigDecimal;
20  import java.util.ArrayList;
21  import java.util.HashMap;
22  import java.util.LinkedHashMap;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.kuali.kpme.core.util.HrConstants;
27  import org.kuali.kpme.tklm.api.time.timesummary.EarnGroupSectionContract;
28  
29  public class EarnGroupSection implements Serializable, EarnGroupSectionContract {
30  
31  	private static final long serialVersionUID = 2655916770367036144L;
32  	private String earnGroup;
33  	private Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap = new HashMap<String, EarnCodeSection>();
34  	private List<EarnCodeSection> earnCodeSections = new ArrayList<EarnCodeSection>();
35  	private Map<Integer, BigDecimal> totals = new LinkedHashMap<Integer, BigDecimal>();
36  	private BigDecimal earnGroupTotal = BigDecimal.ZERO;
37  	
38  	public String getEarnGroup() {
39  		return earnGroup;
40  	}
41  	public void setEarnGroup(String earnGroup) {
42  		this.earnGroup = earnGroup;
43  	}
44  
45  	public Map<Integer, BigDecimal> getTotals() {
46  		return totals;
47  	}
48  	
49  	public void addEarnCodeSection(EarnCodeSection earnCodeSection, List<Boolean> dayArrangements){
50  		for(AssignmentRow assignRow : earnCodeSection.getAssignmentsRows()) {
51  			for(Integer i : assignRow.getAssignmentColumns().keySet()) {
52  				AssignmentColumn assignmentColumn = assignRow.getAssignmentColumns().get(i);
53  				BigDecimal value = totals.get(i).add(assignmentColumn.getTotal(), HrConstants.MATH_CONTEXT);
54  				totals.put(i, value.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING));
55  				earnGroupTotal = earnGroupTotal.add(assignmentColumn.getTotal());
56  				earnGroupTotal.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING);
57  			}
58  			/**
59  			for (AssignmentColumn assignmentColumn : assignRow.getAssignmentColumns().values()) {
60  				BigDecimal value = totals.get(i).add(assignmentColumn.getTotal(), HrConstants.MATH_CONTEXT);
61  				totals.set(i, value.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING));
62  				System.out.println("Column total is "+assignmentColumn.getTotal());
63  				earnGroupTotal = earnGroupTotal.add(assignmentColumn.getTotal());
64  				earnGroupTotal.setScale(HrConstants.BIG_DECIMAL_SCALE, HrConstants.BIG_DECIMAL_SCALE_ROUNDING);
65  				i++;
66  			}**/
67  		}
68  		earnCodeToEarnCodeSectionMap.put(earnCodeSection.getEarnCode(), earnCodeSection);
69  		earnCodeSections.add(earnCodeSection);
70  		
71  		
72  	}
73  	public Map<String, EarnCodeSection> getEarnCodeToEarnCodeSectionMap() {
74  		return earnCodeToEarnCodeSectionMap;
75  	}
76  	public void setEarnCodeToEarnCodeSectionMap(
77  			Map<String, EarnCodeSection> earnCodeToEarnCodeSectionMap) {
78  		this.earnCodeToEarnCodeSectionMap = earnCodeToEarnCodeSectionMap;
79  	}
80  	
81  	public void addToTotal(int index, BigDecimal hrs){
82  		BigDecimal total = getTotals().get(index);
83  		total = total.add(hrs, HrConstants.MATH_CONTEXT);
84  		getTotals().put(index, total);
85  	}
86  	
87  	public List<EarnCodeSection> getEarnCodeSections() {
88  		return earnCodeSections;
89  	}
90  	
91  	public void setEarnCodeSections(List<EarnCodeSection> earnCodeSections) {
92  		this.earnCodeSections = earnCodeSections;
93  	}
94  	
95  	public BigDecimal getEarnGroupTotal() {
96  		return earnGroupTotal;
97  	}
98  	
99  	public void setEarnGroupTotal(BigDecimal earnGroupTotal) {
100 		this.earnGroupTotal = earnGroupTotal;
101 	}
102 	
103 	
104 }