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.util.HashMap;
013:
014: //project specific classes
015: import org.jfolder.common.utils.misc.MiscHelper;
016: import org.jfolder.common.utils.xml.XMLHelper;
017: import org.jfolder.common.web.template.ConsoleParameterContext;
018: import org.jfolder.common.web.template.CreationParameterContext;
019: import org.jfolder.common.web.template.SubmitActionContext;
020: import org.jfolder.common.web.template.SubmitActionParameters;
021: import org.jfolder.console.base.BaseSubConsolePageContext;
022: import org.jfolder.console.base.ConsolePageContext;
023: import org.jfolder.console.base.ConsolePageParameters;
024: import org.jfolder.console.base.ConsolePageSession;
025: import org.jfolder.console.base.NamesForSubCpc;
026: import org.jfolder.console.base.context.BaseSubBoxConsolePageContext;
027: import org.jfolder.project.model.ProjectSystem;
028: import org.jfolder.security.audit.SecurityAudit;
029: import org.jfolder.security.audit.SecurityAuditSet;
030:
031: //other classes
032:
033: public class AuditQueryTableContext extends
034: BaseSubBoxConsolePageContext {
035:
036: //private final static String BUTTON__CREATE = "BUTTON__CREATE";
037: //private final static String BUTTON__UPDATE = "BUTTON__UPDATE";
038: //private final static String BUTTON__DELETE = "BUTTON__DELETE";
039:
040: private AuditQueryTableContext(String inName, int inColumnWidth,
041: int inHeight, String inSideColor, ConsolePageContext inCpc) {
042:
043: super (inName, inColumnWidth, inHeight, inSideColor, inCpc);
044: //
045:
046: }
047:
048: public final static AuditQueryTableContext newInstance(
049: int inColumnWidth, int inHeight, String inSideColor,
050: ConsolePageContext inCpc) throws IOException {
051:
052: AuditQueryTableContext outValue = null;
053:
054: String subCpcName = NamesForSubCpc
055: .getSecurityAuditSetTableCpcName();
056:
057: if (inCpc.isSubConsolePageContextPresent(subCpcName)) {
058: Object o = inCpc.getSubConsolePageContext(subCpcName);
059: outValue = (AuditQueryTableContext) o;
060: } else {
061: outValue = new AuditQueryTableContext(subCpcName,
062: inColumnWidth, inHeight, inSideColor, inCpc);
063: //inCpc.registerSubConsolePageContext(inName, outValue);
064: }
065:
066: outValue.copyFromParent(inCpc);
067: outValue.createConsolePage(inCpc.getWriter(), inCpc
068: .getPageSetupContext());
069:
070: return outValue;
071: }
072:
073: //
074: //
075: protected void renderContent() throws IOException {
076:
077: ConsolePageSession cps = getConsolePageSession();
078:
079: SecurityAuditSet sas = cps.getSecurityAuditSet();
080:
081: //simpleAndPrint("Greetings Earthling!<br/>");
082: //simpleAndPrint(
083: // "Total Entries = " + sas.getSecurityAuditCount() + "<br/>");
084: printAndIndent("<table border=\"1\">");
085: printAndIndent("<tr>");
086: simpleAndPrint("<td>Date and Time</td>");
087: simpleAndPrint("<td>Opened?</td>");
088: simpleAndPrint("<td>Severity Level</td>");
089: simpleAndPrint("<td>Custom Code</td>");
090: simpleAndPrint("<td>Sequence Number</td>");
091: simpleAndPrint("<td>View Audit</td>");
092: simpleAndPrint("<td>Update Audit</td>");
093: revertAndPrint("</tr>");
094: for (int i = (sas.getSecurityAuditCount() - 1); i >= 0; i--) {
095: //
096: SecurityAudit nextSa = sas.getSecurityAudit(i);
097: //simpleAndPrint(nextSa.getAuditDateTime() + "<br/>");
098: //
099: String utcDateTime = nextSa.getAuditDateTime();
100: long utcMillis = MiscHelper.fromStringToTime(utcDateTime);
101: long localMillis = MiscHelper
102: .fromUTCTimeToLocalizedTime(utcMillis);
103: String localDateTime = MiscHelper
104: .fromTimeToString(localMillis);
105: //
106: //
107: //
108: SubmitActionContext updateSac = SubmitActionContext
109: .newInstance(this );
110: updateSac.addAction(ConsoleParameterContext.FIRST_INPUT,
111: singleQuotes(SubmitActionParameters.UPDATE));
112: CreationParameterContext updateCpc = CreationParameterContext
113: .newInstance("Update Audit", updateSac, false,
114: false);
115: updateCpc.addInputAsExclusive(
116: ConsoleParameterContext.FIRST_INPUT, "New Status",
117: new String[] { "", true + "", false + "" },
118: new String[] { "Do Not Change", "Attention Needed",
119: "No Attention Needed" });
120: updateCpc.addInputAsTextArea(
121: ConsoleParameterContext.SECOND_INPUT, "Annotation",
122: "(Comment Here)");
123: updateCpc.addInputAsHiddenBox(
124: ConsoleParameterContext.THIRD_INPUT,
125: (sas.getId(i) + ""));
126: //updateCpc.addInputAsTextArea(
127: // updateCpc.SECOND_INPUT, "Gary101", "Gary102");
128: //testCpc.addInputAsExclusive(
129: // testCpc.THIRD_INPUT, "Gary301",
130: // new String[]{"A"}, new String[]{"a"});
131: //testCpc.addInputAsInclusive(
132: // testCpc.FOURTH_INPUT, "Gary401",
133: // new String[]{"B"}, new String[]{"b"}, "Gary402");
134: //testCpc.addInputAsHiddenBox(
135: // testCpc.FIFTH_INPUT, "GaryHidden501");
136: //testCpc.addInputAsFileUpload(
137: // testCpc.SIXTH_INPUT, "GaryFile601");
138: //startTable(4, alignCenter(null));
139: //startRow();
140: //startCell(4, alignCenter(null));
141: //createButton("{-REMOVE-}", "Remove Text", null,
142: // testCpc.createParameterCall(), null, null, null, null);
143: //
144: //
145: //
146: printAndIndent("<tr>");
147: simpleAndPrint("<td>" + localDateTime + "</td>");
148: if (nextSa.isAuditOpened()) {
149: simpleAndPrint("<td>" + "Yes" + "</td>");
150: } else {
151: simpleAndPrint("<td>" + "No" + "</td>");
152: }
153: simpleAndPrint("<td>" + nextSa.getAuditSeverityLevel()
154: + "</td>");
155: simpleAndPrint("<td>"
156: + nextSa.getAuditCustomCode().longValue() + "</td>");
157: simpleAndPrint("<td>"
158: + nextSa.getAuditSequenceNumber().longValue()
159: + "</td>");
160: simpleAndPrint("<td>View Audit</td>");
161: simpleAndPrint("<td><a href=\"javascript:"
162: + updateCpc.createParameterCall()
163: + "\">Edit Audit</a></td>");
164: revertAndPrint("</tr>");
165: }
166: revertAndPrint("</table>");
167: }
168: }
|