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.hr.lm.accrual;
17  
18  import java.util.ArrayList;
19  import java.util.Date;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.kuali.hr.time.calendar.CalendarEntries;
24  
25  public class RateRangeAggregate {
26  	private List<RateRange> rateRanges = new ArrayList<RateRange>();
27  	private RateRange currentRate;
28  	private boolean rateRangeChanged;
29  	private Map<String, List<CalendarEntries>> calEntryMap;
30  	
31  	public RateRange getRate(Date date) {		
32  		rateRangeChanged = false;
33  		if (currentRate == null) {
34  			currentRate = rateRanges.get(0);
35  		}
36  		
37  		if (currentRate.getRange().contains(date.getTime())) {
38  			for (RateRange rateRange : rateRanges) {
39  				if (rateRange.getRange().contains(date.getTime())) {
40  					rateRangeChanged = rateRange.getAccrualRatePercentageModifier() != currentRate.getAccrualRatePercentageModifier();
41  					currentRate = rateRange;
42  					break;
43  				}
44  			}
45  		}
46  		return currentRate;
47  	}
48  	
49  	public List<RateRange> getRateRanges() {
50  		return rateRanges;
51  	}
52  	public void setRateRanges(List<RateRange> rateRanges) {
53  		this.rateRanges = rateRanges;
54  	}
55  	public RateRange getCurrentRate() {
56  		return currentRate;
57  	}
58  	public void setCurrentRate(RateRange currentRate) {
59  		this.currentRate = currentRate;
60  	}
61  	public boolean isRateRangeChanged() {
62  		return rateRangeChanged;
63  	}
64  	public void setRateRangeChanged(boolean rateRangeChanged) {
65  		this.rateRangeChanged = rateRangeChanged;
66  	}
67  	
68  	// return the rateRange on the given day
69  	public RateRange getRateOnDate(Date date) {
70  		for (RateRange rateRange : rateRanges) {
71  			if (rateRange.getRange().contains(date.getTime())) {
72  				return rateRange;
73  			}
74  		}
75  		return null;
76  	}
77  
78  	public Map<String, List<CalendarEntries>> getCalEntryMap() {
79  		return calEntryMap;
80  	}
81  
82  	public void setCalEntryMap(Map<String, List<CalendarEntries>> calEntryMap) {
83  		this.calEntryMap = calEntryMap;
84  	}
85  	
86  
87  }