1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package edu.sampleu.kew.krad.form; |
18 | |
|
19 | |
import java.text.ParseException; |
20 | |
import java.text.SimpleDateFormat; |
21 | |
import java.util.Date; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.Map; |
24 | |
|
25 | |
import org.kuali.rice.kew.stats.Stats; |
26 | |
import org.kuali.rice.kew.stats.web.StatsAction; |
27 | |
import org.kuali.rice.kew.util.KEWConstants; |
28 | |
import org.kuali.rice.krad.util.GlobalVariables; |
29 | |
import org.kuali.rice.krad.web.form.UifFormBase; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class StatsForm extends UifFormBase { |
39 | |
|
40 | |
private static final long serialVersionUID = 4587377779133823858L; |
41 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(StatsForm.class); |
42 | |
private static final String BEGIN_DATE = "begDate"; |
43 | |
private static final String END_DATE = "endDate"; |
44 | |
|
45 | |
public static final String DAY_TIME_UNIT = "DDD"; |
46 | |
public static final String WEEK_TIME_UNIT = "WW"; |
47 | |
public static final String MONTH_TIME_UNIT = "MM"; |
48 | |
public static final String YEAR_TIME_UNIT = "YYYY"; |
49 | |
|
50 | |
public static final String DEFAULT_BEGIN_DATE = "01/01/1900"; |
51 | |
public static final String DEFAULT_END_DATE = "01/01/2400"; |
52 | |
public static final String BEG_DAY_TIME = " 00:00"; |
53 | |
public static final String END_DAY_TIME = " 23:59"; |
54 | |
public static final String DATE_FORMAT = "MM/dd/yyyy"; |
55 | |
public static final String TIME_FORMAT = " HH:mm"; |
56 | |
|
57 | |
private Stats stats; |
58 | 0 | private String methodToCall = ""; |
59 | 0 | private String avgActionsPerTimeUnit = DAY_TIME_UNIT; |
60 | |
|
61 | |
private String begDate; |
62 | |
private String endDate; |
63 | |
|
64 | |
private Date beginningDate; |
65 | |
private Date endingDate; |
66 | |
|
67 | |
|
68 | |
private String backLocation; |
69 | |
|
70 | 0 | public StatsForm() { |
71 | 0 | stats = new Stats(); |
72 | 0 | } |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
public void determineBeginDate() { |
89 | 0 | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT + TIME_FORMAT); |
90 | |
|
91 | 0 | beginningDate = null; |
92 | |
try { |
93 | 0 | if (getBegDate() == null || getBegDate().trim().equals("")) { |
94 | 0 | beginningDate = dateFormat.parse(DEFAULT_BEGIN_DATE + BEG_DAY_TIME); |
95 | |
} else { |
96 | 0 | beginningDate = dateFormat.parse(getBegDate() + BEG_DAY_TIME); |
97 | |
} |
98 | |
|
99 | 0 | dateFormat = new SimpleDateFormat(DATE_FORMAT); |
100 | 0 | begDate = dateFormat.format(beginningDate); |
101 | 0 | } catch (ParseException e) { |
102 | |
|
103 | |
} finally { |
104 | 0 | if (beginningDate == null) { |
105 | |
try { |
106 | 0 | beginningDate = dateFormat.parse(DEFAULT_BEGIN_DATE + BEG_DAY_TIME); |
107 | 0 | } catch (ParseException e) { |
108 | 0 | throw new RuntimeException("Default Begin Date format incorrect"); |
109 | 0 | } |
110 | |
} |
111 | |
} |
112 | 0 | } |
113 | |
|
114 | |
public void determineEndDate() { |
115 | 0 | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT + TIME_FORMAT); |
116 | |
|
117 | 0 | endingDate = null; |
118 | |
try { |
119 | 0 | if (getEndDate() == null || getEndDate().trim().equals("")) { |
120 | 0 | endingDate = dateFormat.parse(DEFAULT_END_DATE + END_DAY_TIME); |
121 | |
} else { |
122 | 0 | endingDate = dateFormat.parse(getEndDate() + END_DAY_TIME); |
123 | |
} |
124 | |
|
125 | 0 | dateFormat = new SimpleDateFormat(DATE_FORMAT); |
126 | 0 | endDate = dateFormat.format(endingDate); |
127 | 0 | } catch (ParseException e) { |
128 | |
|
129 | |
} finally { |
130 | 0 | if (endingDate == null) { |
131 | |
try { |
132 | 0 | endingDate = dateFormat.parse(DEFAULT_END_DATE + END_DAY_TIME); |
133 | 0 | } catch (ParseException e) { |
134 | 0 | throw new RuntimeException("Default End Date format incorrect"); |
135 | 0 | } |
136 | |
} |
137 | |
} |
138 | 0 | } |
139 | |
|
140 | |
public Map makePerUnitOfTimeDropDownMap() { |
141 | |
|
142 | 0 | Map dropDownMap = new HashMap(); |
143 | 0 | dropDownMap.put(DAY_TIME_UNIT, KEWConstants.DAILY_UNIT); |
144 | 0 | dropDownMap.put(WEEK_TIME_UNIT, KEWConstants.WEEKLY_UNIT); |
145 | 0 | dropDownMap.put(MONTH_TIME_UNIT, KEWConstants.MONTHLY_UNIT); |
146 | 0 | dropDownMap.put(YEAR_TIME_UNIT, KEWConstants.YEARLY_UNIT); |
147 | 0 | return dropDownMap; |
148 | |
|
149 | |
} |
150 | |
|
151 | |
public void validateDates() { |
152 | 0 | LOG.debug("validate()"); |
153 | |
|
154 | |
|
155 | |
|
156 | 0 | if (getBegDate() != null && getBegDate().length() != 0) { |
157 | |
try { |
158 | 0 | new SimpleDateFormat(DATE_FORMAT + TIME_FORMAT).parse(getBegDate().trim() + END_DAY_TIME); |
159 | 0 | } catch (ParseException e) { |
160 | 0 | GlobalVariables.getMessageMap().putError(BEGIN_DATE, "general.error.fieldinvalid", "Begin Date"); |
161 | 0 | } |
162 | |
} |
163 | 0 | if (getEndDate() != null && getEndDate().length() != 0) { |
164 | |
try { |
165 | 0 | new SimpleDateFormat(DATE_FORMAT + TIME_FORMAT).parse(getEndDate().trim() + END_DAY_TIME); |
166 | 0 | } catch (ParseException e) { |
167 | 0 | GlobalVariables.getMessageMap().putError(END_DATE, "general.error.fieldinvalid", "End Date"); |
168 | 0 | } |
169 | |
} |
170 | 0 | } |
171 | |
|
172 | |
public Stats getStats() { |
173 | 0 | return stats; |
174 | |
} |
175 | |
|
176 | |
public void setStats(Stats stats) { |
177 | 0 | this.stats = stats; |
178 | 0 | } |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
public String getCanceledLabel() { |
185 | 0 | return KEWConstants.ROUTE_HEADER_CANCEL_LABEL; |
186 | |
} |
187 | |
|
188 | |
public String getDisapprovedLabel() { |
189 | 0 | return KEWConstants.ROUTE_HEADER_DISAPPROVED_LABEL; |
190 | |
} |
191 | |
|
192 | |
public String getEnrouteLabel() { |
193 | 0 | return KEWConstants.ROUTE_HEADER_ENROUTE_LABEL; |
194 | |
} |
195 | |
|
196 | |
public String getExceptionLabel() { |
197 | 0 | return KEWConstants.ROUTE_HEADER_EXCEPTION_LABEL; |
198 | |
} |
199 | |
|
200 | |
public String getFinalLabel() { |
201 | 0 | return KEWConstants.ROUTE_HEADER_FINAL_LABEL; |
202 | |
} |
203 | |
|
204 | |
public String getInitiatedLabel() { |
205 | 0 | return KEWConstants.ROUTE_HEADER_INITIATED_LABEL; |
206 | |
} |
207 | |
|
208 | |
public String getProcessedLabel() { |
209 | 0 | return KEWConstants.ROUTE_HEADER_PROCESSED_LABEL; |
210 | |
} |
211 | |
|
212 | |
public String getSavedLabel() { |
213 | 0 | return KEWConstants.ROUTE_HEADER_SAVED_LABEL; |
214 | |
} |
215 | |
|
216 | |
public String getAvgActionsPerTimeUnit() { |
217 | 0 | return avgActionsPerTimeUnit; |
218 | |
} |
219 | |
|
220 | |
public void setAvgActionsPerTimeUnit(String string) { |
221 | 0 | avgActionsPerTimeUnit = string; |
222 | 0 | } |
223 | |
|
224 | |
public String getBegDate() { |
225 | 0 | return begDate; |
226 | |
} |
227 | |
|
228 | |
public void setBegDate(String begDate) { |
229 | 0 | this.begDate = begDate; |
230 | 0 | } |
231 | |
|
232 | |
public String getEndDate() { |
233 | 0 | return endDate; |
234 | |
} |
235 | |
|
236 | |
public void setEndDate(String endDate) { |
237 | 0 | this.endDate = endDate; |
238 | 0 | } |
239 | |
|
240 | |
public String getMethodToCall() { |
241 | 0 | return methodToCall; |
242 | |
} |
243 | |
|
244 | |
public void setMethodToCall(String methodToCall) { |
245 | 0 | this.methodToCall = methodToCall; |
246 | 0 | } |
247 | |
|
248 | |
public Date getBeginningDate() { |
249 | 0 | return beginningDate; |
250 | |
} |
251 | |
|
252 | |
public void setBeginningDate(Date beginningDate) { |
253 | 0 | this.beginningDate = beginningDate; |
254 | 0 | } |
255 | |
|
256 | |
public Date getEndingDate() { |
257 | 0 | return endingDate; |
258 | |
} |
259 | |
|
260 | |
public void setEndingDate(Date endingDate) { |
261 | 0 | this.endingDate = endingDate; |
262 | 0 | } |
263 | |
|
264 | |
public String getDayTimeUnit() { |
265 | 0 | return DAY_TIME_UNIT; |
266 | |
} |
267 | |
|
268 | |
public String getMonthTimeUnit() { |
269 | 0 | return MONTH_TIME_UNIT; |
270 | |
} |
271 | |
|
272 | |
public String getWeekTimeUnit() { |
273 | 0 | return WEEK_TIME_UNIT; |
274 | |
} |
275 | |
|
276 | |
public String getYearTimeUnit() { |
277 | 0 | return YEAR_TIME_UNIT; |
278 | |
} |
279 | |
|
280 | |
public String getBackLocation() { |
281 | 0 | return this.backLocation; |
282 | |
} |
283 | |
|
284 | |
public void setBackLocation(String backLocation) { |
285 | 0 | this.backLocation = backLocation; |
286 | 0 | } |
287 | |
|
288 | |
} |