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.console.base.context.SubMessageHolderConsolePageContext;
029: import org.jfolder.security.audit.SecurityAuditHelper;
030: import org.jfolder.services.workflow.WorkflowServiceCaller;
031: import org.jfolder.services.workflow.WorkflowServiceCallerFactory;
032:
033: //other classes
034:
035: public class AuditCreateContext extends ConsolePageContext {
036:
037: //
038: //
039: //private final static String DROP_BOX__DATE_RANGE_TYPE =
040: // "DROP_BOX__DATE_RANGE_TYPE";
041: //private final static String DROP_BOX__DATE_RANGE_MONTH =
042: // "DROP_BOX__DATE_RANGE_MONTH";
043: //private final static String DROP_BOX__DATE_RANGE_DAY =
044: // "DROP_BOX__DATE_RANGE_DAY";
045: //private final static String DROP_BOX__DATE_RANGE_YEAR =
046: // "DROP_BOX__DATE_RANGE_YEAR";
047: //private final static String DROP_BOX__DATE_RANGE_HOUR =
048: // "DROP_BOX__DATE_RANGE_HOUR";
049: //private final static String DROP_BOX__DATE_RANGE_MINUTE =
050: // "DROP_BOX__DATE_RANGE_MINUTE";
051: //private final static String DROP_BOX__DATE_RANGE_SECOND =
052: // "DROP_BOX__DATE_RANGE_SECOND";
053: private final static String DROP_BOX__SEVERITY_LEVEL = "DROP_BOX__SEVERITY_LEVEL";
054: //private final static String DROP_BOX__CATEGORY_TYPE =
055: // "DROP_BOX__CATEGORY_TYPE";
056: //private final static String DROP_BOX__SOURCE_TYPE =
057: // "DROP_BOX__SOURCE_TYPE";
058: private final static String DROP_BOX__STATUS = "DROP_BOX__STATUS";
059: //private final static String DROP_BOX__CUSTOM_CODE =
060: // "DROP_BOX__CUSTOM_CODE";
061: //private final static String DROP_BOX__CUSTOM_CATEGORY_TYPE =
062: // "DROP_BOX__CUSTOM_CATEGORY_TYPE";
063: //private final static String DROP_BOX__CUSTOM_SOURCE_TYPE =
064: // "DROP_BOX__CUSTOM_SOURCE_TYPE";
065:
066: //
067: //
068: //private final static String TEXT_BOX__CATEGORY_TYPE_PREFIX =
069: // "TEXT_BOX__CATEGORY_TYPE_";
070: //private final static String TEXT_BOX__SOURCE_TYPE_PREFIX =
071: // "TEXT_BOX__SOURCE_TYPE_";
072: private final static String TEXT_BOX__SEQUENCE_CODE = "TEXT_BOX__SEQUENCE_CODE";
073: private final static String TEXT_BOX__CUSTOM_CODE = "TEXT_BOX__CUSTOM_CODE";
074: private final static String TEXT_AREA__CUSTOM_MESSAGE = "TEXT_AREA__CUSTOM_MESSAGE";
075: //private final static String TEXT_BOX__CUSTOM_CATEGORY_TYPE_PREFIX =
076: // "TEXT_BOX__CUSTOM_CATEGORY_TYPE_";
077: //private final static String TEXT_BOX__CUSTOM_SOURCE_TYPE_PREFIX =
078: // "TEXT_BOX__CUSTOM_SOURCE_TYPE_";
079:
080: //
081: private final static String MULTI_SELECT_AREA_NAME__CATEGORY_TYPE = "MULTI_SELECT_AREA_NAME__CATEGORY_TYPE";
082: private final static String MULTI_SELECT_AREA_VALUE__CATEGORY_TYPE = "MULTI_SELECT_AREA_VALUE__CATEGORY_TYPE";
083: //
084: private final static String MULTI_SELECT_AREA_NAME__SOURCE_TYPE = "MULTI_SELECT_AREA_NAME__SOURCE_TYPE";
085: private final static String MULTI_SELECT_AREA_VALUE__SOURCE_TYPE = "MULTI_SELECT_AREA_VALUE__SOURCE_TYPE";
086: //
087: private final static String MULTI_SELECT_AREA_NAME__CUSTOM_CATEGORY_TYPE = "MULTI_SELECT_AREA_NAME__CUSTOM_CATEGORY_TYPE";
088: private final static String MULTI_SELECT_AREA_VALUE__CUSTOM_CATEGORY_TYPE = "MULTI_SELECT_AREA_VALUE__CUSTOM_CATEGORY_TYPE";
089: //
090: private final static String MULTI_SELECT_AREA_NAME__CUSTOM_SOURCE_TYPE = "MULTI_SELECT_AREA_NAME__CUSTOM_SOURCE_TYPE";
091: private final static String MULTI_SELECT_AREA_VALUE__CUSTOM_SOURCE_TYPE = "MULTI_SELECT_AREA_VALUE__CUSTOM_SOURCE_TYPE";
092:
093: //
094: //
095: private final static String BUTTON__EXECUTE = "BUTTON__EXECUTE";
096: private final static String BUTTON__GO_BACK = "BUTTON__GO_BACK";
097:
098: //
099: //
100: private final static String TOGGLE_LINK_PART__START_DATE = "START_DATE";
101: private final static String TOGGLE_LINK_PART__END_DATE = "END_DATE";
102:
103: //
104: //private String topDateRangeType = null;
105: //private String topFromDateRange = null;
106: //private String topToDateRange = null;
107: //private String topStatus = null;
108: //private String topSeverityLevel = null;
109: //private ArrayList topCategoryTypes = null;
110: //private ArrayList topSourceTypes = null;
111: //private ArrayList topCustomCodes = null;
112: //private ArrayList topCustomCategoryTypes = null;
113: //private ArrayList topCustomSourceTypes = null;
114: //
115: private String topStatusId = null;
116: private String topSequenceCodeId = null;
117: private String topSeverityLevelId = null;
118: private String topCategoryTypeIds = null;
119: private String topSourceTypeIds = null;
120: private String topCustomCodeId = null;
121: private String topCustomCategoryTypeIds = null;
122: private String topCustomSourceTypeIds = null;
123: private String topCustomMessageId = null;
124:
125: private AuditCreateContext(ConsolePageSession inCps) {
126: super (inCps);
127: }
128:
129: public final static AuditCreateContext newInstance(
130: ConsolePageSession inCps) {
131:
132: AuditCreateContext outValue = null;
133:
134: outValue = new AuditCreateContext(inCps);
135:
136: return outValue;
137: }
138:
139: public String getFromPage() {
140: //
141: //
142: return ConsolePageParameters.SERVLET_AUDIT_CREATE;
143: }
144:
145: public String getHandleExtension() {
146: return NULL_HANDLE;
147: }
148:
149: private void setQueryParameters(String inStatusId,
150: String inSequenceCodeId, String inSeverityLevelId,
151: String inCategoryTypeIds, String inSourceTypeIds,
152: String inCustomCodeId, String inCustomCategoryTypeIds,
153: String inCustomSourceTypeIds, String inCustomMessageId) {
154: //
155: this .topStatusId = inStatusId;
156: this .topSequenceCodeId = inSequenceCodeId;
157: this .topSeverityLevelId = inSeverityLevelId;
158: this .topCategoryTypeIds = inCategoryTypeIds;
159: this .topSourceTypeIds = inSourceTypeIds;
160: this .topCustomCodeId = inCustomCodeId;
161: this .topCustomCategoryTypeIds = inCustomCategoryTypeIds;
162: this .topCustomSourceTypeIds = inCustomSourceTypeIds;
163: this .topCustomMessageId = inCustomMessageId;
164: }
165:
166: private SubmitActionContext getExecuteSac() {
167:
168: SubmitActionContext outValue = null;
169:
170: outValue = SubmitActionContext.newInstance(this );
171: //
172: outValue.addAction(ConsoleParameterContext.FIRST_INPUT,
173: singleQuotes(SubmitActionParameters.EXECUTE));
174: //
175: if (!isMetaMode()) {
176: outValue.addParameter(ConsoleParameterContext.FIRST_INPUT,
177: singleQuotes(this .topStatusId));
178: outValue.addParameter(ConsoleParameterContext.SECOND_INPUT,
179: singleQuotes(this .topSequenceCodeId));
180: outValue.addParameter(ConsoleParameterContext.THIRD_INPUT,
181: singleQuotes(this .topSeverityLevelId));
182: outValue.addParameter(ConsoleParameterContext.FOURTH_INPUT,
183: singleQuotes(this .topCategoryTypeIds));
184: outValue.addParameter(ConsoleParameterContext.FIFTH_INPUT,
185: singleQuotes(this .topSourceTypeIds));
186: outValue.addParameter(ConsoleParameterContext.SIXTH_INPUT,
187: singleQuotes(this .topCustomCodeId));
188: outValue.addParameter(
189: ConsoleParameterContext.SEVENTH_INPUT,
190: singleQuotes(this .topCustomCategoryTypeIds));
191: outValue.addParameter(ConsoleParameterContext.EIGHTH_INPUT,
192: singleQuotes(this .topCustomSourceTypeIds));
193: outValue.addParameter(ConsoleParameterContext.NINTH_INPUT,
194: singleQuotes(this .topCustomMessageId));
195: }
196:
197: return outValue;
198: }
199:
200: //ConsoleScreenHelper
201: protected void renderConsolePage() throws IOException {
202:
203: startCommonPage();
204:
205: ConsolePageSession cps = getConsolePageSession();
206:
207: //
208: //String nextEntityRep[] = new String[1];
209: //String nextEntityId[] = new String[1];
210: //
211: //String fromDate[] = new String[1];
212: //String toDate[] = new String[1];
213:
214: //
215: startEnclosingTableAndRowAndCell(alignCenter(null));
216: startAndEndStretchTableAndRowAndCell("<hr/>");
217: //
218: startAndEndSimpleTableAndRowAndCell(2, "Query Audits",
219: getFontStyle(20, ARIAL, BLACK));
220:
221: SubMessageHolderConsolePageContext
222: .renderMessagesIfPresent(this );
223:
224: startAndEndStretchTableAndRowAndCell("<hr/>");
225:
226: //if (cps.isSecurityAuditSetPresent()) {
227: // //
228: // startTable(4);
229: // startRow();
230: // AuditQueryTableContext.newInstance(4, 300, "#333333", this);
231: // endRow();
232: // endTable();
233: // //
234: // startAndEndStretchTableAndRowAndCell("<hr/>");
235: //}
236:
237: //
238: SubmitActionContext sacGoBack = SubmitActionContext
239: .newInstance(this );
240: sacGoBack.addAction(ConsoleParameterContext.FIRST_INPUT,
241: singleQuotes(SubmitActionParameters.RETURN));
242: sacGoBack.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
243: //
244: SubmitActionContext sacExecute = getExecuteSac();
245: //sacExecute.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
246:
247: startTable(4);
248: startRow();
249: startAndEndCell(1, padNbsp(1));
250: startCell(1, alignCenter(null));
251: createButton(BUTTON__EXECUTE, "Execute", 150,
252: submitActionCall(sacExecute), null, null, null, null);
253: endCell();
254: startCell(1);
255: createButton(BUTTON__GO_BACK, "Go Back", 150,
256: submitActionCall(sacGoBack), null, null, null, null);
257: endCell();
258: startAndEndCell(1, padNbsp(1));
259: endRow();
260: endTable();
261:
262: startAndEndStretchTableAndRowAndCell("<hr/>");
263: //
264: //
265: //
266: //
267: /////////////////////////////////////////////////////////////
268: //
269: //getDateRangeTypeSelection(nextEntityRep, nextEntityId);
270: //
271: //startTable(4);
272: //startRow();
273: //
274: //startAndEndCell(1, "Date Range",
275: // addAttr(getFontStyle(12, ARIAL, BLACK), "valign", "top"));
276: //startAndEndCell(1, padNbsp(1));
277: //startAndEndCell(2, nextEntityRep[0], alignRight(null));
278: //
279: //endRow();
280: //endTable();
281: //
282: //createHorizontalRow(1);
283: //
284: //startTable(4);
285: //startRow();
286: //
287: //startAndEndCell(1, padNbsp(1));
288: //startAndEndCell(1, "From Date");
289: //startCell(3);
290: //renderDateSelector(fromDate, toDate, 3);
291: //endCell();
292: //
293: //endRow();
294: //endTable();
295: //
296: //
297: //startTable(4);
298: //startRow();
299: ////
300: //startAndEndCell(1, padNbsp(1));
301: //startAndEndCell(1, "To Date");
302: //startCell(2);
303: //String toDateValue = renderDateSelector(TOGGLE_LINK_PART__END_DATE);
304: //endCell();
305: ////
306: //endRow();
307: //endTable();
308: //
309: //
310: //createHorizontalRow(1);
311: //
312: /////////////////////////////////////////////////////////////
313: //
314: ArrayList statusLabels = new ArrayList();
315: ArrayList statusValues = new ArrayList();
316: //statusLabels.add("Those That Do And Do Not Need Attention");
317: //statusValues.add("");
318: statusLabels.add("Requires Attention");
319: statusValues.add(true + "");
320: statusLabels.add("Does Not Require Attention");
321: statusValues.add(false + "");
322: HashMap statusStyles = new HashMap();
323: HashMap statusAttrs = new HashMap();
324: String statusDropDown = createDropDownBox(DROP_BOX__STATUS,
325: statusLabels, statusValues, statusAttrs, statusStyles,
326: 1, null, null, null);
327: String statusId = cps.getPreviousToggleLink();
328: //
329: startTable(4);
330: startRow();
331: //
332: startAndEndCell(1, "Current Status", addAttr(getFontStyle(12,
333: ARIAL, BLACK), "valign", "top"));
334: startAndEndCell(1, padNbsp(1));
335: startAndEndCell(2, statusDropDown, alignRight(null));
336: //
337: endRow();
338: endTable();
339: //
340: //
341: //
342: createHorizontalRow(1);
343: //
344: String sequenceCodeTextBox = createTextBox(
345: TEXT_BOX__SEQUENCE_CODE, SecurityAuditHelper.INITIAL_ID
346: + "", new HashMap(), new HashMap(), null, null,
347: null);
348: String sequenceCodeId = cps.getPreviousToggleLink();
349: //
350: startTable(4);
351: startRow();
352: //
353: startAndEndCell(1, "Sequence Code", addAttr(getFontStyle(12,
354: ARIAL, BLACK), "valign", "top"));
355: startAndEndCell(1, padNbsp(1));
356: startAndEndCell(1, padNbsp(1));
357: startAndEndCell(1, sequenceCodeTextBox);
358: //
359: endRow();
360: endTable();
361: //
362: //
363: createHorizontalRow(1);
364: //
365: /////////////////////////////////////////////////////////////
366: //
367: ArrayList severityLevelLabels = SecurityAuditHelper
368: .getSeverityLevels();
369: ArrayList severityLevelValues = SecurityAuditHelper
370: .getSeverityLevels();
371: // SecurityAuditHelper.getSeverityCodesAsStrings();
372: HashMap severityLevelStyles = new HashMap();
373: HashMap severityLevelAttrs = new HashMap();
374: //severityLevelAttrs.put("multiple", "true");
375: String severityLevelDropDown = createDropDownBox(
376: DROP_BOX__SEVERITY_LEVEL,
377: severityLevelLabels,
378: severityLevelValues,
379: severityLevelAttrs,
380: severityLevelStyles,
381: severityLevelLabels
382: .indexOf(SecurityAuditHelper.SEVERITY_LEVEL__INFORMATION),
383: null, null, null);
384: String severityLevelId = cps.getPreviousToggleLink();
385: //
386: startTable(4);
387: startRow();
388: //
389: startAndEndCell(1, "Severity Level", addAttr(getFontStyle(12,
390: ARIAL, BLACK), "valign", "top"));
391: startAndEndCell(1, padNbsp(1));
392: startAndEndCell(1, padNbsp(1));
393: startAndEndCell(1, severityLevelDropDown);
394: //
395: endRow();
396: endTable();
397: //
398: //
399: createHorizontalRow(1);
400: //
401: /////////////////////////////////////////////////////////////
402: //
403: String categoryTypeIds = getEntryPairList(
404: MULTI_SELECT_AREA_NAME__CATEGORY_TYPE,
405: MULTI_SELECT_AREA_VALUE__CATEGORY_TYPE,
406: "Category Types", SecurityAuditHelper
407: .getCommonCategoryTypes(), 5);
408: //
409: //
410: createHorizontalRow(1);
411: //
412: /////////////////////////////////////////////////////////////
413: //
414: String sourceTypeIds = getEntryPairList(
415: MULTI_SELECT_AREA_NAME__SOURCE_TYPE,
416: MULTI_SELECT_AREA_VALUE__SOURCE_TYPE, "Source Types",
417: SecurityAuditHelper.getCommonSourceTypes(), 5);
418: //
419: //
420: createHorizontalRow(1);
421: //
422: //
423: String customCodeTextBox = createTextBox(TEXT_BOX__CUSTOM_CODE,
424: SecurityAuditHelper.STADARD_CUSTOM_CODE + "",
425: new HashMap(), new HashMap(), null, null, null);
426: String customCodeId = cps.getPreviousToggleLink();
427: //
428: startTable(4);
429: startRow();
430: //
431: startAndEndCell(1, "Custom Codes", addAttr(getFontStyle(12,
432: ARIAL, BLACK), "valign", "top"));
433: startAndEndCell(1, padNbsp(1));
434: startAndEndCell(1, padNbsp(1));
435: startAndEndCell(1, customCodeTextBox);
436: //
437: endRow();
438: endTable();
439: //
440: //ArrayList customCodeIds = listOptionBoxes(
441: // TEXT_BOX__CUSTOM_CODE_PREFIX, 5);
442: //
443: createHorizontalRow(1);
444: //
445: //
446: String customCategoryTypeIds = getEntryPairList(
447: MULTI_SELECT_AREA_NAME__CUSTOM_CATEGORY_TYPE,
448: MULTI_SELECT_AREA_VALUE__CUSTOM_CATEGORY_TYPE,
449: "Custom Category Types", new ArrayList(), 5);
450: //
451: createHorizontalRow(1);
452: //
453: //
454: String customSourceTypeIds = getEntryPairList(
455: MULTI_SELECT_AREA_NAME__CUSTOM_SOURCE_TYPE,
456: MULTI_SELECT_AREA_VALUE__CUSTOM_SOURCE_TYPE,
457: "Custom Source Types", new ArrayList(), 5);
458: //
459: //
460: //
461: createHorizontalRow(1);
462: //
463: //
464: String customMessageTextArea = createTextArea(
465: TEXT_AREA__CUSTOM_MESSAGE, "", new HashMap(),
466: new HashMap(), null, null, null);
467: String customMessageId = cps.getPreviousToggleLink();
468: //
469: startTable(4);
470: startRow();
471: //
472: startAndEndCell(1, "Custom Message", addAttr(getFontStyle(12,
473: ARIAL, BLACK), "valign", "top"));
474: startAndEndCell(1, padNbsp(1));
475: startAndEndCell(2, customMessageTextArea);
476: //
477: endRow();
478: endTable();
479: //
480: //
481: //
482: //
483: startAndEndStretchTableAndRowAndCell("<hr/>");
484: //
485: endEnclosingTableAndRowAndCell();
486:
487: endCommonPage();
488:
489: //
490: //
491: //
492: //
493: //
494: //if (isMetaMode()) {
495: // setQueryParameters(
496: // nextEntityId[0], fromDate[0], toDate[0], statusId,
497: // severityLevelId, categoryTypeIds, sourceTypeIds,
498: // customCodeIds,
499: // customCategoryTypeIds, customSourceTypeIds);
500: //}
501: if (isMetaMode()) {
502: setQueryParameters(statusId, sequenceCodeId,
503: severityLevelId, categoryTypeIds, sourceTypeIds,
504: customCodeId, customCategoryTypeIds,
505: customSourceTypeIds, customMessageId);
506: }
507: }
508:
509: private String getEntryPairList(String inNameIdPrefix,
510: String inValueIdPrefix, String inLabel,
511: ArrayList inCommonValues, int inExtraCount)
512: throws IOException {
513: //
514: String outValue = null;
515:
516: ArrayList idValues = new ArrayList();
517:
518: ConsolePageSession cps = getConsolePageSession();
519:
520: //protected String createTextBox(String inId, String inValue,
521: // HashMap inAttrs, HashMap inStyles, Integer inSize,
522: // Integer inMaxLength,
523: // String inOnChange) throws IOException {
524: //protected String createDropDownBox(String inId, ArrayList inLabels,
525: // ArrayList inValues, HashMap inAttrs, HashMap inStyles,
526: // int inSelected,
527: // Integer inSize, String inOnChange) throws IOException {
528:
529: startTable(4);
530: //
531: startRow();
532: startAndEndCell(1, inLabel);
533: startAndEndCell(1, padNbsp(1));
534: startAndEndCell(1, padNbsp(1));
535: startAndEndCell(1, padNbsp(1));
536: endRow();
537: //
538: for (int i = 0; i < inCommonValues.size(); i++) {
539:
540: //
541: //
542: //
543: ArrayList nextNameLabels = (ArrayList) inCommonValues
544: .clone();
545: ArrayList nextNameValues = (ArrayList) inCommonValues
546: .clone();
547: //
548: nextNameLabels.add(0, "(If You Wish, Select Below)");
549: nextNameValues.add(0, "");
550: //
551: String nextNameDropDown = createDropDownBox(
552: (inNameIdPrefix + i), nextNameLabels,
553: nextNameValues, new HashMap(), new HashMap(), 0,
554: null, null, null);
555: idValues.add(cps.getPreviousToggleLink());
556: //
557: String nextValueTextBox = createTextBox(
558: (inValueIdPrefix + i), "", new HashMap(),
559: new HashMap(), null, null, null);
560: idValues.add(cps.getPreviousToggleLink());
561:
562: //
563: //
564: //
565: startRow();
566: startAndEndCell(1, padNbsp(1));
567: startAndEndCell(1, padNbsp(1));
568: startAndEndCell(1, nextNameDropDown);
569: startAndEndCell(1, nextValueTextBox);
570: endRow();
571: }
572: //
573: int base = inCommonValues.size();
574: for (int i = base; i < (base + inExtraCount); i++) {
575:
576: //
577: //
578: //
579: String nextNameDropDown = createTextBox(
580: (inNameIdPrefix + i), "", new HashMap(),
581: new HashMap(), null, null, null);
582: idValues.add(cps.getPreviousToggleLink());
583: //
584: String nextValueTextBox = createTextBox(
585: (inValueIdPrefix + i), "", new HashMap(),
586: new HashMap(), null, null, null);
587: idValues.add(cps.getPreviousToggleLink());
588:
589: //
590: //
591: //
592: startRow();
593: startAndEndCell(1, padNbsp(1));
594: startAndEndCell(1, padNbsp(1));
595: startAndEndCell(1, nextNameDropDown);
596: startAndEndCell(1, nextValueTextBox);
597: endRow();
598: }
599: //
600: endTable();
601:
602: outValue = MiscHelper.reassembleHandle(idValues,
603: HANDLE_SEPARATOR);
604:
605: return outValue;
606: }
607: }
|