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