1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.common;
17
18 import java.util.ArrayList;
19 import java.util.Date;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.apache.commons.lang.StringUtils;
25 import org.joda.time.DateTime;
26 import org.joda.time.format.DateTimeFormat;
27 import org.joda.time.format.DateTimeFormatter;
28 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
29 import org.kuali.kpme.core.web.KPMEForm;
30
31 public abstract class CalendarForm extends KPMEForm {
32
33 private static final long serialVersionUID = 7437602046032470340L;
34
35 private static final DateTimeFormatter SDF_NO_TZ = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss yyyy");
36
37 private String prevDocumentId;
38 private String nextDocumentId;
39
40 private String hrCalendarEntryId;
41
42 private String prevHrCalendarEntryId;
43 private String nextHrCalendarEntryId;
44
45 private Date beginCalendarEntryDate;
46 private Date endCalendarEntryDate;
47
48 private CalendarEntry calendarEntry;
49
50 private List<String> calendarYears = new ArrayList<String>();
51 private Map<String,String> payPeriodsMap = new HashMap<String,String>();
52
53 private String selectedCalendarYear;
54 private String selectedPayPeriod;
55
56 private List<String> errorMessages = new ArrayList<String>();
57
58 private List<String> warningMessages = new ArrayList<String>();
59
60 private List<String> infoMessages = new ArrayList<String>();
61
62 private List<String> actionMessages = new ArrayList<String>();
63
64 public String getNextDocumentId() {
65 return nextDocumentId;
66 }
67
68 public void setNextDocumentId(String nextDocumentId) {
69 this.nextDocumentId = nextDocumentId;
70 }
71
72 public String getPrevDocumentId() {
73 return prevDocumentId;
74 }
75
76 public void setPrevDocumentId(String prevDocumentId) {
77 this.prevDocumentId = prevDocumentId;
78 }
79
80 public String getHrCalendarEntryId() {
81 return hrCalendarEntryId;
82 }
83
84 public void setHrCalendarEntryId(String hrCalendarEntryId) {
85 this.hrCalendarEntryId = hrCalendarEntryId;
86 }
87
88 public String getPrevHrCalendarEntryId() {
89 return prevHrCalendarEntryId;
90 }
91
92 public void setPrevHrCalendarEntryId(String prevHrCalendarEntryId) {
93 this.prevHrCalendarEntryId = prevHrCalendarEntryId;
94 }
95
96 public String getNextHrCalendarEntryId() {
97 return nextHrCalendarEntryId;
98 }
99
100 public void setNextHrCalendarEntryId(String nextHrCalendarEntryId) {
101 this.nextHrCalendarEntryId = nextHrCalendarEntryId;
102 }
103
104 public Date getBeginCalendarEntryDate() {
105 return beginCalendarEntryDate;
106 }
107
108 public void setBeginCalendarEntryDate(Date beginCalendarEntryDate) {
109 this.beginCalendarEntryDate = beginCalendarEntryDate;
110 }
111
112 public Date getEndCalendarEntryDate() {
113 return endCalendarEntryDate;
114 }
115
116 public void setEndCalendarEntryDate(Date endCalendarEntryDate) {
117 this.endCalendarEntryDate = endCalendarEntryDate;
118 }
119
120 public List<String> getCalendarYears() {
121 return calendarYears;
122 }
123
124 public void setCalendarYears(List<String> calendarYears) {
125 this.calendarYears = calendarYears;
126 }
127
128 public Map<String, String> getPayPeriodsMap() {
129 return payPeriodsMap;
130 }
131
132 public void setPayPeriodsMap(Map<String, String> payPeriodsMap) {
133 this.payPeriodsMap = payPeriodsMap;
134 }
135
136 public CalendarEntry getCalendarEntry() {
137 return calendarEntry;
138 }
139
140 public void setCalendarEntry(CalendarEntry calendarEntry) {
141 this.calendarEntry = calendarEntry;
142 }
143
144 public String getSelectedCalendarYear() {
145 return selectedCalendarYear;
146 }
147
148 public void setSelectedCalendarYear(String selectedCalendarYear) {
149 this.selectedCalendarYear = selectedCalendarYear;
150 }
151
152 public String getSelectedPayPeriod() {
153 return selectedPayPeriod;
154 }
155
156 public void setSelectedPayPeriod(String selectedPayPeriod) {
157 this.selectedPayPeriod = selectedPayPeriod;
158 }
159
160 public String getBeginPeriodDateTime() {
161 String beginPeriodDateTime = StringUtils.EMPTY;
162
163 if (getCalendarEntry() != null) {
164 beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime().toString(SDF_NO_TZ);
165 }
166
167 return beginPeriodDateTime;
168 }
169
170 public String getEndPeriodDateTime() {
171 String endPeriodDateTime = StringUtils.EMPTY;
172
173 if (getCalendarEntry() != null) {
174 endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime().toString(SDF_NO_TZ);
175 }
176
177 return endPeriodDateTime;
178 }
179
180 public boolean isOnCurrentPeriod() {
181 boolean isOnCurrentPeriod = false;
182
183 if (getCalendarEntry() != null) {
184 DateTime beginPeriodDateTime = getCalendarEntry().getBeginPeriodFullDateTime();
185 DateTime endPeriodDateTime = getCalendarEntry().getEndPeriodFullDateTime();
186 isOnCurrentPeriod = (beginPeriodDateTime.isEqualNow() || beginPeriodDateTime.isBeforeNow()) && endPeriodDateTime.isAfterNow();
187 }
188
189 return isOnCurrentPeriod;
190 }
191
192 public List<String> getErrorMessages() {
193 return errorMessages;
194 }
195
196 public void setErrorMessages(List<String> errorMessages) {
197 this.errorMessages = errorMessages;
198 }
199
200 public List<String> getWarningMessages() {
201 return warningMessages;
202 }
203
204 public void setWarningMessages(List<String> warningMessages) {
205 this.warningMessages = warningMessages;
206 }
207
208 public List<String> getInfoMessages() {
209 return infoMessages;
210 }
211
212 public void setInfoMessages(List<String> infoMessages) {
213 this.infoMessages = infoMessages;
214 }
215
216 public List<String> getActionMessages() {
217 return actionMessages;
218 }
219
220 public void setActionMessages(List<String> actionMessages) {
221 this.actionMessages = actionMessages;
222 }
223
224 }