001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.web.admin.audit;
009:
010: //base classes
011: import java.io.IOException;
012: import java.text.DecimalFormat;
013: import java.util.ArrayList;
014: import java.util.Calendar;
015: import java.util.GregorianCalendar;
016: import java.util.HashMap;
017:
018: //project specific classes
019: import org.jfolder.common.tagging.ConceptRollupTag;
020: import org.jfolder.common.utils.misc.MiscHelper;
021: import org.jfolder.common.utils.xml.XMLHelper;
022: import org.jfolder.common.web.template.ConsoleParameterContext;
023: import org.jfolder.common.web.template.SubmitActionContext;
024: import org.jfolder.common.web.template.SubmitActionParameters;
025: import org.jfolder.console.base.ConsolePageContext;
026: import org.jfolder.console.base.ConsolePageParameters;
027: import org.jfolder.console.base.ConsolePageSession;
028: import org.jfolder.security.audit.SecurityAuditHelper;
029: import org.jfolder.services.workflow.WorkflowServiceCaller;
030: import org.jfolder.services.workflow.WorkflowServiceCallerFactory;
031:
032: //other classes
033:
034: public class AuditQueryContext extends ConsolePageContext {
035:
036: //
037: //
038: private final static String DROP_BOX__DATE_RANGE_TYPE = "DROP_BOX__DATE_RANGE_TYPE";
039: private final static String DROP_BOX__DATE_RANGE_MONTH = "DROP_BOX__DATE_RANGE_MONTH";
040: private final static String DROP_BOX__DATE_RANGE_DAY = "DROP_BOX__DATE_RANGE_DAY";
041: private final static String DROP_BOX__DATE_RANGE_YEAR = "DROP_BOX__DATE_RANGE_YEAR";
042: private final static String DROP_BOX__DATE_RANGE_HOUR = "DROP_BOX__DATE_RANGE_HOUR";
043: private final static String DROP_BOX__DATE_RANGE_MINUTE = "DROP_BOX__DATE_RANGE_MINUTE";
044: private final static String DROP_BOX__DATE_RANGE_SECOND = "DROP_BOX__DATE_RANGE_SECOND";
045: private final static String DROP_BOX__SEVERITY_LEVEL = "DROP_BOX__SEVERITY_LEVEL";
046: private final static String DROP_BOX__CATEGORY_TYPE = "DROP_BOX__CATEGORY_TYPE";
047: private final static String DROP_BOX__SOURCE_TYPE = "DROP_BOX__SOURCE_TYPE";
048: private final static String DROP_BOX__STATUS = "DROP_BOX__STATUS";
049: //private final static String DROP_BOX__CUSTOM_CODE =
050: // "DROP_BOX__CUSTOM_CODE";
051: //private final static String DROP_BOX__CUSTOM_CATEGORY_TYPE =
052: // "DROP_BOX__CUSTOM_CATEGORY_TYPE";
053: //private final static String DROP_BOX__CUSTOM_SOURCE_TYPE =
054: // "DROP_BOX__CUSTOM_SOURCE_TYPE";
055:
056: //
057: //
058: private final static String TEXT_BOX__CATEGORY_TYPE_PREFIX = "TEXT_BOX__CATEGORY_TYPE_";
059: private final static String TEXT_BOX__SOURCE_TYPE_PREFIX = "TEXT_BOX__SOURCE_TYPE_";
060: private final static String TEXT_BOX__CUSTOM_CODE_PREFIX = "TEXT_BOX__CUSTOM_CODE_TYPE_";
061: private final static String TEXT_BOX__CUSTOM_CATEGORY_TYPE_PREFIX = "TEXT_BOX__CUSTOM_CATEGORY_TYPE_";
062: private final static String TEXT_BOX__CUSTOM_SOURCE_TYPE_PREFIX = "TEXT_BOX__CUSTOM_SOURCE_TYPE_";
063:
064: //
065: //
066: private final static String BUTTON__EXECUTE = "BUTTON__EXECUTE";
067: private final static String BUTTON__GO_BACK = "BUTTON__GO_BACK";
068:
069: //
070: //
071: private final static String TOGGLE_LINK_PART__START_DATE = "START_DATE";
072: private final static String TOGGLE_LINK_PART__END_DATE = "END_DATE";
073:
074: //
075: private String topDateRangeType = null;
076: private String topFromDateRange = null;
077: private String topToDateRange = null;
078: private String topStatus = null;
079: private String topSeverityLevel = null;
080: private ArrayList topCategoryTypes = null;
081: private ArrayList topSourceTypes = null;
082: private ArrayList topCustomCodes = null;
083: private ArrayList topCustomCategoryTypes = null;
084: private ArrayList topCustomSourceTypes = null;
085:
086: private AuditQueryContext(ConsolePageSession inCps) {
087: super (inCps);
088: }
089:
090: public final static AuditQueryContext newInstance(
091: ConsolePageSession inCps) {
092:
093: AuditQueryContext outValue = null;
094:
095: outValue = new AuditQueryContext(inCps);
096:
097: return outValue;
098: }
099:
100: public String getFromPage() {
101: //
102: //
103: return ConsolePageParameters.SERVLET_AUDIT_QUERY;
104: }
105:
106: public String getHandleExtension() {
107: return NULL_HANDLE;
108: }
109:
110: private void setQueryParameters(String inDateRangeType,
111: String inFromDateRange, String inToDateRange,
112: String inStatus, String inSeverityLevel,
113: ArrayList inCategoryTypes, ArrayList inSourceTypes,
114: ArrayList inCustomCodes, ArrayList inCustomCategoryTypes,
115: ArrayList inCustomSourceTypes) {
116: //
117: this .topDateRangeType = inDateRangeType;
118: this .topFromDateRange = inFromDateRange;
119: this .topToDateRange = inToDateRange;
120: this .topStatus = inStatus;
121: this .topSeverityLevel = inSeverityLevel;
122: this .topCategoryTypes = inCategoryTypes;
123: this .topSourceTypes = inSourceTypes;
124: this .topCustomCodes = inCustomCodes;
125: this .topCustomCategoryTypes = inCustomCategoryTypes;
126: this .topCustomSourceTypes = inCustomSourceTypes;
127: }
128:
129: private SubmitActionContext getExecuteSac() {
130:
131: SubmitActionContext outValue = null;
132:
133: outValue = SubmitActionContext.newInstance(this );
134: //
135: outValue.addAction(ConsoleParameterContext.FIRST_INPUT,
136: singleQuotes(SubmitActionParameters.EXECUTE));
137: //
138: if (!isMetaMode()) {
139: outValue.addParameter(ConsoleParameterContext.FIRST_INPUT,
140: singleQuotes(this .topDateRangeType));
141: outValue.addParameter(ConsoleParameterContext.SECOND_INPUT,
142: this .topFromDateRange);
143: outValue.addParameter(ConsoleParameterContext.THIRD_INPUT,
144: this .topToDateRange);
145: //
146: outValue.addParameter(ConsoleParameterContext.FOURTH_INPUT,
147: singleQuotes(this .topStatus));
148: //
149: outValue.addParameter(ConsoleParameterContext.FIFTH_INPUT,
150: singleQuotes(this .topSeverityLevel));
151: outValue.addParameter(ConsoleParameterContext.SIXTH_INPUT,
152: singleQuotes(MiscHelper.reassembleHandle(
153: this .topCategoryTypes, HANDLE_SEPARATOR)));
154: outValue.addParameter(
155: ConsoleParameterContext.SEVENTH_INPUT,
156: singleQuotes(MiscHelper.reassembleHandle(
157: this .topSourceTypes, HANDLE_SEPARATOR)));
158: outValue.addParameter(ConsoleParameterContext.EIGHTH_INPUT,
159: singleQuotes(MiscHelper.reassembleHandle(
160: this .topCustomCodes, HANDLE_SEPARATOR)));
161: outValue.addParameter(ConsoleParameterContext.NINTH_INPUT,
162: singleQuotes(MiscHelper.reassembleHandle(
163: this .topCustomCategoryTypes,
164: HANDLE_SEPARATOR)));
165: outValue.addParameter(ConsoleParameterContext.TENTH_INPUT,
166: singleQuotes(MiscHelper
167: .reassembleHandle(
168: this .topCustomSourceTypes,
169: HANDLE_SEPARATOR)));
170: }
171:
172: return outValue;
173: }
174:
175: //ConsoleScreenHelper
176: protected void renderConsolePage() throws IOException {
177:
178: startCommonPage();
179:
180: ConsolePageSession cps = getConsolePageSession();
181:
182: //
183: String nextEntityRep[] = new String[1];
184: String nextEntityId[] = new String[1];
185: //
186: String fromDate[] = new String[1];
187: String toDate[] = new String[1];
188:
189: //
190: startEnclosingTableAndRowAndCell(alignCenter(null));
191: startAndEndStretchTableAndRowAndCell("<hr/>");
192: //
193: startAndEndSimpleTableAndRowAndCell(2, "Query Audits",
194: getFontStyle(20, ARIAL, BLACK));
195:
196: startAndEndStretchTableAndRowAndCell("<hr/>");
197:
198: if (cps.isSecurityAuditSetPresent()) {
199: //
200: startTable(4);
201: startRow();
202: AuditQueryTableContext.newInstance(4, 300, "#333333", this );
203: endRow();
204: endTable();
205: //
206: startAndEndStretchTableAndRowAndCell("<hr/>");
207: }
208:
209: //
210: SubmitActionContext sacGoBack = SubmitActionContext
211: .newInstance(this );
212: sacGoBack.addAction(ConsoleParameterContext.FIRST_INPUT,
213: singleQuotes(SubmitActionParameters.RETURN));
214: sacGoBack.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
215: //
216: SubmitActionContext sacExecute = getExecuteSac();
217: //sacExecute.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
218:
219: startTable(4);
220: startRow();
221: startAndEndCell(1, padNbsp(1));
222: startCell(1, alignCenter(null));
223: createButton(BUTTON__EXECUTE, "Execute", 150,
224: submitActionCall(sacExecute), null, null, null, null);
225: endCell();
226: startCell(1);
227: createButton(BUTTON__GO_BACK, "Go Back", 150,
228: submitActionCall(sacGoBack), null, null, null, null);
229: endCell();
230: startAndEndCell(1, padNbsp(1));
231: endRow();
232: endTable();
233:
234: startAndEndStretchTableAndRowAndCell("<hr/>");
235: //
236: //
237: //
238: //
239: /////////////////////////////////////////////////////////////
240: //
241: getDateRangeTypeSelection(nextEntityRep, nextEntityId);
242: //
243: startTable(4);
244: startRow();
245: //
246: startAndEndCell(1, "Date Range", addAttr(getFontStyle(12,
247: ARIAL, BLACK), "valign", "top"));
248: startAndEndCell(1, padNbsp(1));
249: startAndEndCell(2, nextEntityRep[0], alignRight(null));
250: //
251: endRow();
252: endTable();
253: //
254: createHorizontalRow(1);
255: //
256: startTable(4);
257: startRow();
258: //
259: startAndEndCell(1, padNbsp(1));
260: //startAndEndCell(1, "From Date");
261: startCell(3);
262: renderDateSelector(fromDate, toDate, 3);
263: endCell();
264: //
265: endRow();
266: endTable();
267: //
268: //
269: //startTable(4);
270: //startRow();
271: ////
272: //startAndEndCell(1, padNbsp(1));
273: //startAndEndCell(1, "To Date");
274: //startCell(2);
275: //String toDateValue = renderDateSelector(TOGGLE_LINK_PART__END_DATE);
276: //endCell();
277: ////
278: //endRow();
279: //endTable();
280: //
281: //
282: createHorizontalRow(1);
283: //
284: /////////////////////////////////////////////////////////////
285: //
286: ArrayList statusLabels = new ArrayList();
287: ArrayList statusValues = new ArrayList();
288: statusLabels.add("Those That Do And Do Not Need Attention");
289: statusValues.add("");
290: statusLabels.add("Only Those That Need Attention");
291: statusValues.add(true + "");
292: statusLabels.add("Only Those That Do Not Need Attention");
293: statusValues.add(false + "");
294: HashMap statusStyles = new HashMap();
295: HashMap statusAttrs = new HashMap();
296: String statusDropDown = createDropDownBox(DROP_BOX__STATUS,
297: statusLabels, statusValues, statusAttrs, statusStyles,
298: 0, null, null, null);
299: String statusId = cps.getPreviousToggleLink();
300: //
301: startTable(4);
302: startRow();
303: //
304: startAndEndCell(1, "Current Status", addAttr(getFontStyle(12,
305: ARIAL, BLACK), "valign", "top"));
306: startAndEndCell(1, padNbsp(1));
307: startAndEndCell(2, statusDropDown, alignRight(null));
308: //
309: endRow();
310: endTable();
311: //
312: //
313: createHorizontalRow(1);
314: //
315: /////////////////////////////////////////////////////////////
316: //
317: ArrayList severityLevelLabels = SecurityAuditHelper
318: .getSeverityLevels();
319: ArrayList severityLevelValues = SecurityAuditHelper
320: .getSeverityCodesAsStrings();
321: HashMap severityLevelStyles = new HashMap();
322: HashMap severityLevelAttrs = new HashMap();
323: severityLevelAttrs.put("multiple", "true");
324: String severityLevelDropDown = createDropDownBox(
325: DROP_BOX__SEVERITY_LEVEL,
326: severityLevelLabels,
327: severityLevelValues,
328: severityLevelAttrs,
329: severityLevelStyles,
330: severityLevelLabels
331: .indexOf(SecurityAuditHelper.SEVERITY_LEVEL__ERROR),
332: null, null, null);
333: String severityLevelId = cps.getPreviousToggleLink();
334: //
335: startTable(4);
336: startRow();
337: //
338: startAndEndCell(1, "Severity Level", addAttr(getFontStyle(12,
339: ARIAL, BLACK), "valign", "top"));
340: startAndEndCell(1, padNbsp(1));
341: startAndEndCell(1, padNbsp(1));
342: startAndEndCell(1, severityLevelDropDown);
343: //
344: endRow();
345: endTable();
346: //
347: //
348: createHorizontalRow(1);
349: //
350: /////////////////////////////////////////////////////////////
351: //
352: ArrayList categoryTypeLabels = SecurityAuditHelper
353: .getCommonCategoryTypes();
354: ArrayList categoryTypeValues = (ArrayList) categoryTypeLabels
355: .clone();
356: HashMap categoryTypeStyles = new HashMap();
357: HashMap categoryTypeAttrs = new HashMap();
358: categoryTypeAttrs.put("multiple", "true");
359: String categoryTypeDropDown = createDropDownBox(
360: DROP_BOX__CATEGORY_TYPE, categoryTypeLabels,
361: categoryTypeValues, categoryTypeAttrs,
362: categoryTypeStyles, 0, null, null, null);
363: String categoryTypeId = cps.getPreviousToggleLink();
364: //
365: startTable(4);
366: startRow();
367: //
368: startAndEndCell(1, "Category Types", addAttr(getFontStyle(12,
369: ARIAL, BLACK), "valign", "top"));
370: startAndEndCell(1, padNbsp(1));
371: startAndEndCell(1, padNbsp(1));
372: startAndEndCell(1, categoryTypeDropDown);
373: //
374: endRow();
375: endTable();
376: //
377: createHorizontalRow(3);
378: //
379: ArrayList categoryTypeIds = listOptionBoxes(
380: TEXT_BOX__CATEGORY_TYPE_PREFIX, 5);
381: categoryTypeIds.add(0, categoryTypeId);
382: //
383: //
384: createHorizontalRow(1);
385: //
386: /////////////////////////////////////////////////////////////
387: //
388: ArrayList sourceTypeLabels = SecurityAuditHelper
389: .getCommonSourceTypes();
390: ArrayList sourceTypeValues = (ArrayList) sourceTypeLabels
391: .clone();
392: HashMap sourceTypeStyles = new HashMap();
393: HashMap sourceTypeAttrs = new HashMap();
394: sourceTypeAttrs.put("multiple", "true");
395: String sourceTypeDropDown = createDropDownBox(
396: DROP_BOX__SOURCE_TYPE, sourceTypeLabels,
397: sourceTypeValues, sourceTypeAttrs, sourceTypeStyles, 0,
398: null, null, null);
399: String sourceTypeId = cps.getPreviousToggleLink();
400: //
401: startTable(4);
402: startRow();
403: //
404: startAndEndCell(1, "Source Types", addAttr(getFontStyle(12,
405: ARIAL, BLACK), "valign", "top"));
406: startAndEndCell(1, padNbsp(1));
407: startAndEndCell(1, padNbsp(1));
408: startAndEndCell(1, sourceTypeDropDown);
409: //
410: endRow();
411: endTable();
412: //
413: createHorizontalRow(3);
414: //
415: ArrayList sourceTypeIds = listOptionBoxes(
416: TEXT_BOX__SOURCE_TYPE_PREFIX, 5);
417: sourceTypeIds.add(0, sourceTypeId);
418: //
419: //
420: createHorizontalRow(1);
421: //
422: //
423: startTable(4);
424: startRow();
425: //
426: startAndEndCell(1, "Custom Codes", addAttr(getFontStyle(12,
427: ARIAL, BLACK), "valign", "top"));
428: startAndEndCell(1, padNbsp(1));
429: startAndEndCell(1, padNbsp(1));
430: startAndEndCell(1, padNbsp(1));
431: //
432: endRow();
433: endTable();
434: //
435: ArrayList customCodeIds = listOptionBoxes(
436: TEXT_BOX__CUSTOM_CODE_PREFIX, 5);
437: //
438: createHorizontalRow(1);
439: //
440: //
441: startTable(4);
442: startRow();
443: //
444: startAndEndCell(1, "Custom Category Types", addAttr(
445: getFontStyle(10, ARIAL, BLACK), "valign", "top"));
446: startAndEndCell(1, padNbsp(1));
447: startAndEndCell(1, padNbsp(1));
448: startAndEndCell(1, padNbsp(1));
449: //
450: endRow();
451: endTable();
452: //
453: ArrayList customCategoryTypeIds = listOptionBoxes(
454: TEXT_BOX__CUSTOM_CATEGORY_TYPE_PREFIX, 5);
455: //
456: createHorizontalRow(1);
457: //
458: //
459: startTable(4);
460: startRow();
461: //
462: startAndEndCell(1, "Custom Source Types", addAttr(getFontStyle(
463: 10, ARIAL, BLACK), "valign", "top"));
464: startAndEndCell(1, padNbsp(1));
465: startAndEndCell(1, padNbsp(1));
466: startAndEndCell(1, padNbsp(1));
467: //
468: endRow();
469: endTable();
470: //
471: ArrayList customSourceTypeIds = listOptionBoxes(
472: TEXT_BOX__CUSTOM_SOURCE_TYPE_PREFIX, 5);
473: //
474: //
475: //
476: //
477: //
478: startAndEndStretchTableAndRowAndCell("<hr/>");
479: //
480: endEnclosingTableAndRowAndCell();
481:
482: endCommonPage();
483:
484: //
485: //
486: //
487: //
488: //
489: if (isMetaMode()) {
490: setQueryParameters(nextEntityId[0], fromDate[0], toDate[0],
491: statusId, severityLevelId, categoryTypeIds,
492: sourceTypeIds, customCodeIds,
493: customCategoryTypeIds, customSourceTypeIds);
494: }
495: }
496:
497: //
498: private ArrayList listOptionBoxes(String inPrefixId, int inCount)
499: throws IOException {
500: //
501: ArrayList outValue = new ArrayList();
502:
503: ConsolePageSession cps = getConsolePageSession();
504:
505: startTable(4);
506: for (int i = 1; i <= inCount; i++) {
507: HashMap nextAttrs = new HashMap();
508: HashMap nextStyles = new HashMap();
509:
510: String nextTextBox = createTextBox(inPrefixId + i, "",
511: nextAttrs, nextStyles, null, null, null);
512: outValue.add(cps.getPreviousToggleLink());
513:
514: startRow();
515: startAndEndCell(3, padNbsp(1));
516: startAndEndCell(1, nextTextBox);
517: endRow();
518: }
519: endTable();
520:
521: return outValue;
522: }
523:
524: //
525: private void getDateRangeTypeSelection(String inRep[],
526: String inId[]) throws IOException {
527:
528: ConsolePageSession cps = getConsolePageSession();
529:
530: //
531: GregorianCalendar currentTime = new GregorianCalendar();
532: //
533: GregorianCalendar withinHour = (GregorianCalendar) currentTime
534: .clone();
535: withinHour.add(Calendar.HOUR_OF_DAY, -1);
536: //
537: GregorianCalendar withinDay = (GregorianCalendar) currentTime
538: .clone();
539: withinDay.add(Calendar.DATE, -1);
540: //
541: GregorianCalendar withinWeek = (GregorianCalendar) currentTime
542: .clone();
543: withinWeek.add(Calendar.DATE, -7);
544: //
545: GregorianCalendar withinMonth = (GregorianCalendar) currentTime
546: .clone();
547: withinMonth.add(Calendar.MONTH, -1);
548: //
549: //GregorianCalendar currentHour =
550: // (GregorianCalendar)currentTime.clone();
551: //currentHour.set(Calendar.MINUTE, 0);
552: //currentHour.set(Calendar.SECOND, 0);
553: //currentHour.set(Calendar.MILLISECOND, 0);
554: //
555: //GregorianCalendar currentDay =
556: // (GregorianCalendar)currentHour.clone();
557: //currentDay.set(Calendar.HOUR_OF_DAY, 0);
558: //
559: //GregorianCalendar currentWeek =
560: // (GregorianCalendar)currentDay.clone();
561: //currentWeek.add(Calendar.DATE, -7);
562: //
563: //GregorianCalendar currentMonth =
564: // (GregorianCalendar)currentDay.clone();
565: //currentMonth.add(Calendar.MONTH, -1);
566:
567: //
568: HashMap styles = getFontStyle(14, ARIAL, BLACK);
569: HashMap attrs = new HashMap();
570: //
571: ArrayList labels = new ArrayList();
572: ArrayList values = new ArrayList();
573:
574: //
575: //
576: //
577: labels.add("Within Last Hour");
578: values.add(MiscHelper.fromLocalizedTimeToUTCTime(withinHour
579: .getTimeInMillis())
580: + "");
581: //
582: labels.add("Within Last Day");
583: values.add(MiscHelper.fromLocalizedTimeToUTCTime(withinDay
584: .getTimeInMillis())
585: + "");
586: //
587: labels.add("Within Last Week");
588: values.add(MiscHelper.fromLocalizedTimeToUTCTime(withinWeek
589: .getTimeInMillis())
590: + "");
591: //
592: labels.add("Within Last Month");
593: values.add(MiscHelper.fromLocalizedTimeToUTCTime(withinMonth
594: .getTimeInMillis())
595: + "");
596: //
597: //
598: //
599: //labels.add("This Calendar Hour");
600: //values.add("");
601: //
602: //labels.add("This Calendar Day");
603: //values.add("");
604: //
605: //labels.add("This Calendar Week");
606: //values.add("");
607: //
608: //labels.add("This Calendar Month");
609: //values.add("");
610: //
611: //
612: //
613: //labels.add("Last Calendar Hour");
614: //values.add("");
615: //
616: //labels.add("Last Calendar Day");
617: //values.add("");
618: //
619: //labels.add("Last Calendar Week");
620: //values.add("");
621: //
622: //labels.add("Last Calendar Month");
623: //values.add("");
624: //
625: //
626: //
627: labels.add("(Specify Below)");
628: values.add("");
629:
630: //
631: inRep[0] = createDropDownBox(DROP_BOX__DATE_RANGE_TYPE, labels,
632: values, attrs, styles, 0, null, null, null);
633: //
634: inId[0] = cps.getPreviousToggleLink();
635: }
636:
637: private void renderDateSelector(String inFromDateValue[],
638: String inToDateValue[], int inWidth) throws IOException {
639: //
640: //
641: //
642: printAndIndent("<table cellspacing=\"0\" cellpadding=\"0\" width=\""
643: + inWidth * getColumnWidth() + "\">");
644: printAndIndent("<tr>");
645: simpleAndPrint("<td>"
646: + formatText("Custom Range", getFontStyle(10, ARIAL,
647: BLACK)) + "</td>");
648: simpleAndPrint("<td>"
649: + formatText("Month", getFontStyle(10, ARIAL, BLACK))
650: + "</td>");
651: simpleAndPrint("<td>"
652: + formatText("Day", getFontStyle(10, ARIAL, BLACK))
653: + "</td>");
654: simpleAndPrint("<td>"
655: + formatText("Year", getFontStyle(10, ARIAL, BLACK))
656: + "</td>");
657: simpleAndPrint("<td>"
658: + formatText("Hour", getFontStyle(10, ARIAL, BLACK))
659: + "</td>");
660: simpleAndPrint("<td>"
661: + formatText("Minute", getFontStyle(10, ARIAL, BLACK))
662: + "</td>");
663: //simpleAndPrint("<td>Second</td>");
664: revertAndPrint("</tr>");
665: //
666: printAndIndent("<tr>");
667: simpleAndPrint("<td>" + padNbsp(1) + "</td>");
668: simpleAndPrint("<td colspan=\"5\"><hr/></td>");
669: revertAndPrint("</tr>");
670: //
671: inFromDateValue[0] = renderPartialDateSelector(formatText(
672: "From Date", getFontStyle(10, ARIAL, BLACK)),
673: TOGGLE_LINK_PART__START_DATE);
674: //
675: printAndIndent("<tr>");
676: simpleAndPrint("<td>" + padNbsp(1) + "</td>");
677: simpleAndPrint("<td colspan=\"5\"><hr/></td>");
678: revertAndPrint("</tr>");
679: //
680: inToDateValue[0] = renderPartialDateSelector(formatText(
681: "To Date", getFontStyle(10, ARIAL, BLACK)),
682: TOGGLE_LINK_PART__END_DATE);
683: //
684: revertAndPrint("</table>");
685: }
686:
687: private String renderPartialDateSelector(String inLabel,
688: String inPartId) throws IOException {
689:
690: String outValue = null;
691:
692: ConsolePageSession cps = getConsolePageSession();
693:
694: DecimalFormat yearDf = new DecimalFormat("0000");
695: DecimalFormat dayDf = new DecimalFormat("00");
696:
697: int currentYear = (new GregorianCalendar()).get(Calendar.YEAR);
698:
699: cps.pushToggleLink(inPartId);
700:
701: String yearId = null;
702: String monthId = null;
703: String dayId = null;
704: String hourId = null;
705: String minuteId = null;
706: //String secondId = null;
707:
708: //
709: //
710: //
711: printAndIndent("<tr>");
712: simpleAndPrint("<td>" + inLabel + "</td>");
713: //
714: //
715: //
716: //
717: //
718: ArrayList monthLabels = new ArrayList();
719: monthLabels.add("January");
720: monthLabels.add("February");
721: monthLabels.add("March");
722: monthLabels.add("April");
723: monthLabels.add("May");
724: monthLabels.add("June");
725: monthLabels.add("July");
726: monthLabels.add("August");
727: monthLabels.add("September");
728: monthLabels.add("October");
729: monthLabels.add("November");
730: monthLabels.add("December");
731: ArrayList monthValues = new ArrayList();
732: monthValues.add("01");
733: monthValues.add("02");
734: monthValues.add("03");
735: monthValues.add("04");
736: monthValues.add("05");
737: monthValues.add("06");
738: monthValues.add("07");
739: monthValues.add("08");
740: monthValues.add("09");
741: monthValues.add("10");
742: monthValues.add("11");
743: monthValues.add("12");
744: HashMap monthAttrs = new HashMap();
745: HashMap monthStyles = new HashMap();
746: //
747: String monthDropDown = createDropDownBox(
748: DROP_BOX__DATE_RANGE_MONTH, monthLabels, monthValues,
749: monthAttrs, monthStyles, 0, null, null, null);
750: monthId = cps.getPreviousToggleLink();
751: simpleAndPrint("<td>" + monthDropDown + "</td>");
752: //
753: //
754: //
755: //
756: //
757: ArrayList dayLabels = new ArrayList();
758: dayLabels.add("01");
759: dayLabels.add("02");
760: dayLabels.add("03");
761: dayLabels.add("04");
762: dayLabels.add("05");
763: dayLabels.add("06");
764: dayLabels.add("07");
765: dayLabels.add("08");
766: dayLabels.add("09");
767: dayLabels.add("10");
768: dayLabels.add("11");
769: dayLabels.add("12");
770: dayLabels.add("13");
771: dayLabels.add("14");
772: dayLabels.add("15");
773: dayLabels.add("16");
774: dayLabels.add("17");
775: dayLabels.add("18");
776: dayLabels.add("19");
777: dayLabels.add("20");
778: dayLabels.add("21");
779: dayLabels.add("22");
780: dayLabels.add("23");
781: dayLabels.add("24");
782: dayLabels.add("25");
783: dayLabels.add("26");
784: dayLabels.add("27");
785: dayLabels.add("28");
786: dayLabels.add("29");
787: dayLabels.add("30");
788: dayLabels.add("31");
789: ArrayList dayValues = (ArrayList) dayLabels.clone();
790: HashMap dayAttrs = new HashMap();
791: HashMap dayStyles = new HashMap();
792: //
793: String dayDropDown = createDropDownBox(
794: DROP_BOX__DATE_RANGE_DAY, dayLabels, dayValues,
795: dayAttrs, dayStyles, 0, null, null, null);
796: dayId = cps.getPreviousToggleLink();
797: simpleAndPrint("<td>" + dayDropDown + "</td>");
798: //
799: //
800: //
801: //
802: //
803: ArrayList yearLabels = new ArrayList();
804: ArrayList yearValues = new ArrayList();
805: int yearSelectedIndex = 0;
806: for (int i = 2005; i <= currentYear; i++) {
807: if (i == currentYear) {
808: yearSelectedIndex = yearLabels.size();
809: }
810: yearLabels.add(yearDf.format(i));
811: yearValues.add(yearDf.format(i));
812: }
813: HashMap yearAttrs = new HashMap();
814: HashMap yearStyles = new HashMap();
815: //
816: String yearDropDown = createDropDownBox(
817: DROP_BOX__DATE_RANGE_YEAR, yearLabels, yearValues,
818: yearAttrs, yearStyles, yearSelectedIndex, null, null,
819: null);
820: yearId = cps.getPreviousToggleLink();
821: simpleAndPrint("<td>" + yearDropDown + "</td>");
822: //
823: //
824: //
825: //
826: //
827: ArrayList hourLabels = new ArrayList();
828: ArrayList hourValues = new ArrayList();
829: for (int i = 0; i < 24; i++) {
830: hourLabels.add(dayDf.format(i));
831: hourValues.add(dayDf.format(i));
832: }
833: HashMap hourAttrs = new HashMap();
834: HashMap hourStyles = new HashMap();
835: //
836: String hourDropDown = createDropDownBox(
837: DROP_BOX__DATE_RANGE_HOUR, hourLabels, hourValues,
838: hourAttrs, hourStyles, 0, null, null, null);
839: hourId = cps.getPreviousToggleLink();
840: simpleAndPrint("<td>" + hourDropDown + "</td>");
841: //
842: //
843: //
844: //
845: //
846: ArrayList minuteLabels = new ArrayList();
847: ArrayList minuteValues = new ArrayList();
848: for (int i = 0; i < 60; i = i + 5) {
849: minuteLabels.add(dayDf.format(i));
850: minuteValues.add(dayDf.format(i));
851: }
852: HashMap minuteAttrs = new HashMap();
853: HashMap minuteStyles = new HashMap();
854: //
855: String minuteDropDown = createDropDownBox(
856: DROP_BOX__DATE_RANGE_MINUTE, minuteLabels,
857: minuteValues, minuteAttrs, minuteStyles, 0, null, null,
858: null);
859: minuteId = cps.getPreviousToggleLink();
860: simpleAndPrint("<td>" + minuteDropDown + "</td>");
861: //
862: //
863: //
864: //
865: //
866: //ArrayList secondLabels = new ArrayList();
867: //ArrayList secondValues = new ArrayList();
868: //HashMap secondAttrs = new HashMap();
869: //HashMap secondStyles = new HashMap();
870: ////
871: //String secondDropDown = createDropDownBox(
872: // DROP_BOX__DATE_RANGE_SECOND, secondLabels, secondValues,
873: // secondAttrs, secondStyles, 0, null, null);
874: //secondId = cps.getPreviousToggleLink();
875: //simpleAndPrint("<td>" + secondDropDown + "</td>");
876: //
877: //
878: revertAndPrint("</tr>");
879:
880: outValue = getPageComponentValue(yearId) + " + '-' + "
881: + getPageComponentValue(monthId) + " + '-' + "
882: + getPageComponentValue(dayId) + " + 'T' + "
883: + getPageComponentValue(hourId) + " + ':' + "
884: + getPageComponentValue(minuteId) + " + ':' + "
885: + "'00'";//getPageComponentValue(secondId);
886:
887: cps.popToggleLink();
888:
889: return outValue;
890: }
891: }
|