1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.leave.accrual;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.joda.time.DateTime;
23 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
24 import org.kuali.kpme.tklm.api.leave.accrual.RateRangeAggregateContract;
25
26 public class RateRangeAggregate implements RateRangeAggregateContract {
27 private List<RateRange> rateRanges = new ArrayList<RateRange>();
28 private RateRange currentRate;
29 private boolean rateRangeChanged;
30 private Map<String, List<CalendarEntry>> calEntryMap;
31
32 public RateRange getRate(DateTime date) {
33 rateRangeChanged = false;
34 if (currentRate == null) {
35 currentRate = rateRanges.get(0);
36 }
37
38 if (currentRate.getRange().contains(date)) {
39 for (RateRange rateRange : rateRanges) {
40 if (rateRange.getRange().contains(date)) {
41 rateRangeChanged = rateRange.getAccrualRatePercentageModifier() != currentRate.getAccrualRatePercentageModifier();
42 currentRate = rateRange;
43 break;
44 }
45 }
46 }
47 return currentRate;
48 }
49
50 public List<RateRange> getRateRanges() {
51 return rateRanges;
52 }
53 public void setRateRanges(List<RateRange> rateRanges) {
54 this.rateRanges = rateRanges;
55 }
56 public RateRange getCurrentRate() {
57 return currentRate;
58 }
59 public void setCurrentRate(RateRange currentRate) {
60 this.currentRate = currentRate;
61 }
62 public boolean isRateRangeChanged() {
63 return rateRangeChanged;
64 }
65 public void setRateRangeChanged(boolean rateRangeChanged) {
66 this.rateRangeChanged = rateRangeChanged;
67 }
68
69
70 public RateRange getRateOnDate(DateTime date) {
71 for (RateRange rateRange : rateRanges) {
72 if (rateRange.getRange().contains(date)) {
73 return rateRange;
74 }
75 }
76 return null;
77 }
78
79 public Map<String, List<CalendarEntry>> getCalEntryMap() {
80 return calEntryMap;
81 }
82
83 public void setCalEntryMap(Map<String, List<CalendarEntry>> calEntryMap) {
84 this.calEntryMap = calEntryMap;
85 }
86
87
88 }