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