?? testqueryimpl.java
字號:
package cn.edu.buaa.ieguam.logmanage.query;
import java.text.DateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import cn.edu.buaa.ieguam.logmanage.LogQueryImpl;
import cn.edu.buaa.ieguam.logmanage.MBean;
import cn.edu.buaa.ieguam.logmanage.MBeanPage;
import cn.edu.buaa.ieguam.logmanage.OracleConnection;
import cn.edu.buaa.ieguam.logmanage.ResultFormat;
import cn.edu.buaa.ieguam.logmanage.SqlDefForOracle;
import cn.edu.buaa.ieguam.logmanage.pojos.AppLog;
import cn.edu.buaa.ieguam.logmanage.pojos.AuditInfo;
import cn.edu.buaa.ieguam.logmanage.pojos.AuditType;
import cn.edu.buaa.ieguam.logmanage.pojos.EventId;
import cn.edu.buaa.ieguam.logmanage.pojos.EventType;
import cn.edu.buaa.ieguam.logmanage.pojos.LinuxLog;
import cn.edu.buaa.ieguam.logmanage.pojos.MySqlLog;
import cn.edu.buaa.ieguam.logmanage.pojos.Operation;
import cn.edu.buaa.ieguam.logmanage.pojos.OracleLog;
import cn.edu.buaa.ieguam.logmanage.pojos.SqlServerLog;
import cn.edu.buaa.ieguam.logmanage.pojos.TomcatLog;
import cn.edu.buaa.ieguam.logmanage.pojos.WinLog;
public class TestQueryImpl
{
private LogQueryImpl logQueryImpl = new LogQueryImpl(new SqlDefForOracle());
private AuditInfo auditInfo = new AuditInfo();
private AuditType auditType = new AuditType();
private EventId eventId = new EventId();
private EventType eventType = new EventType();
private WinLog winLog = new WinLog();
private LinuxLog linuxLog = new LinuxLog();
private TomcatLog tomcatLog = new TomcatLog();
private MySqlLog mySqlLog = new MySqlLog();
private OracleLog oracleLog = new OracleLog();
private SqlServerLog sqlServerLog = new SqlServerLog();
private AppLog appLog = new AppLog();
private Operation operation = new Operation();
public void initTree()
{
//設置MBean
this.logQueryImpl.assignMBean("auditInfo", "AUDITINFO", this.auditInfo);
this.logQueryImpl.assignMBean("auditType", "AUDITTYPE", this.auditType);
this.logQueryImpl.assignMBean("eventId", "EVENTID", this.eventId);
this.logQueryImpl.assignMBean("eventType", "EVENTTYPE", this.eventType);
this.logQueryImpl.assignMBean("winLog", "WINLOG", this.winLog);
this.logQueryImpl.assignMBean("linuxLog", "LINUXLOG", this.linuxLog);
this.logQueryImpl.assignMBean("tomcatLog", "TOMCATLOG", this.tomcatLog);
this.logQueryImpl.assignMBean("mySqlLog", "MYSQLLOG", this.mySqlLog);
this.logQueryImpl.assignMBean("oracleLog", "ORACLELOG", this.oracleLog);
this.logQueryImpl.assignMBean("sqlServerLog", "SQLSERVERLOG", this.sqlServerLog);
this.logQueryImpl.assignMBean("appLog", "APPLOG", this.appLog);
this.logQueryImpl.assignMBean("operation", "OPERATION", this.operation);
//設置主鍵屬性
this.logQueryImpl.createPkm("auditInfo", "id");
this.logQueryImpl.createPkm("auditType", "id");
this.logQueryImpl.createPkm("eventId", "id");
this.logQueryImpl.createPkm("eventType", "id");
this.logQueryImpl.createPkm("winLog", "id");
this.logQueryImpl.createPkm("linuxLog", "id");
this.logQueryImpl.createPkm("tomcatLog", "id");
this.logQueryImpl.createPkm("mySqlLog", "id");
this.logQueryImpl.createPkm("oracleLog", "id");
this.logQueryImpl.createPkm("sqlServerLog", "id");
this.logQueryImpl.createPkm("appLog", "id");
this.logQueryImpl.createPkm("operation", "id");
//設置對象-關系映射
this.logQueryImpl.createOrmMap("auditInfo", "id", "AUDITINFO.ID");
this.logQueryImpl.createOrmMap("auditInfo", "auditDate", "AUDITINFO.AUDITDATE");
this.logQueryImpl.createOrmMap("auditInfo", "eventId", "AUDITINFO.EVENTID");
this.logQueryImpl.createOrmMap("auditInfo", "eventType", "AUDITINFO.EVENTTYPE");
this.logQueryImpl.createOrmMap("auditInfo", "ipAddr", "AUDITINFO.IPADDR");
this.logQueryImpl.createOrmMap("auditInfo", "hostName", "AUDITINFO.HOSTNAME");
this.logQueryImpl.createOrmMap("auditInfo", "auditType", "AUDITINFO.AUDITTYPE");
this.logQueryImpl.createOrmMap("auditInfo", "markTime", "AUDITINFO.MARKTIME");
this.logQueryImpl.createOrmMap("auditType", "id", "AUDITTYPE.ID");
this.logQueryImpl.createOrmMap("auditType", "tableIndex", "AUDITTYPE.TABLEINDEX");
this.logQueryImpl.createOrmMap("auditType", "typeName", "AUDITTYPE.TYPENAME");
this.logQueryImpl.createOrmMap("auditType", "description", "AUDITTYPE.DESCRIPTION");
this.logQueryImpl.createOrmMap("eventId", "id", "EVENTID.ID");
this.logQueryImpl.createOrmMap("eventId", "eventName", "EVENTID.EVENTNAME");
this.logQueryImpl.createOrmMap("eventId", "eventShort", "EVENTID.EVENTSHORT");
this.logQueryImpl.createOrmMap("eventId", "description", "EVENTID.DESCRIPTION");
this.logQueryImpl.createOrmMap("eventType", "id", "EVENTTYPE.ID");
this.logQueryImpl.createOrmMap("eventType", "eTypeName", "EVENTTYPE.ETYPENAME");
this.logQueryImpl.createOrmMap("eventType", "description", "EVENTTYPE.DESCRIPTION");
this.logQueryImpl.createOrmMap("winLog", "id", "WINLOG.ID");
this.logQueryImpl.createOrmMap("winLog", "auditId", "WINLOG.AUDITID");
this.logQueryImpl.createOrmMap("winLog", "oneSource", "WINLOG.ONESOURCE");
this.logQueryImpl.createOrmMap("winLog", "secondSource", "WINLOG.SECONDSOURCE");
this.logQueryImpl.createOrmMap("winLog", "category", "WINLOG.CATEGORY");
this.logQueryImpl.createOrmMap("winLog", "usr", "WINLOG.USR");
this.logQueryImpl.createOrmMap("winLog", "description", "WINLOG.DESCRIPTION");
this.logQueryImpl.createOrmMap("linuxLog", "id", "LINUXLOG.ID");
this.logQueryImpl.createOrmMap("linuxLog", "auditId", "LINUXLOG.AUDITID");
this.logQueryImpl.createOrmMap("linuxLog", "description", "LINUXLOG.DESCRIPTION");
this.logQueryImpl.createOrmMap("tomcatLog", "id", "TOMCATLOG.ID");
this.logQueryImpl.createOrmMap("tomcatLog", "auditId", "TOMCATLOG.AUDITID");
this.logQueryImpl.createOrmMap("tomcatLog", "remoteIp", "TOMCATLOG.REMOTEIP");
this.logQueryImpl.createOrmMap("tomcatLog", "locIp", "TOMCATLOG.LOCIP");
this.logQueryImpl.createOrmMap("tomcatLog", "byteSent", "TOMCATLOG.BYTESENT");
this.logQueryImpl.createOrmMap("tomcatLog", "ReHostName", "TOMCATLOG.REHOSTNAME");
this.logQueryImpl.createOrmMap("tomcatLog", "reqMethod", "TOMCATLOG.REQMETHOD");
this.logQueryImpl.createOrmMap("tomcatLog", "locPort", "TOMCATLOG.LOCPORT");
this.logQueryImpl.createOrmMap("tomcatLog", "queryStr", "TOMCATLOG.QUERYSTR");
this.logQueryImpl.createOrmMap("tomcatLog", "firstLineReq", "TOMCATLOG.FIRSTLINEREQ");
this.logQueryImpl.createOrmMap("tomcatLog", "httpStatus", "TOMCATLOG.HTTPSTATUS");
this.logQueryImpl.createOrmMap("tomcatLog", "usrSessId", "TOMCATLOG.USRSESSID");
this.logQueryImpl.createOrmMap("tomcatLog", "autherReUsr", "TOMCATLOG.AUTHERREUSR");
this.logQueryImpl.createOrmMap("tomcatLog", "reqUrl", "TOMCATLOG.REQURL");
this.logQueryImpl.createOrmMap("tomcatLog", "locSerName", "TOMCATLOG.LOCSERNAME");
this.logQueryImpl.createOrmMap("tomcatLog", "proTime", "TOMCATLOG.PROTIME");
this.logQueryImpl.createOrmMap("tomcatLog", "reQuProtocol", "TOMCATLOG.REQUPROTOCOL");
this.logQueryImpl.createOrmMap("tomcatLog", "reUsrName", "TOMCATLOG.REUSRNAME");
this.logQueryImpl.createOrmMap("sqlServerLog", "id", "SQLSERVERLOG.ID");
this.logQueryImpl.createOrmMap("sqlServerLog", "auditId", "SQLSERVERLOG.AUDITID");
this.logQueryImpl.createOrmMap("sqlServerLog", "process", "SQLSERVERLOG.PROCESS");
this.logQueryImpl.createOrmMap("sqlServerLog", "description", "SQLSERVERLOG.DESCRIPTION");
this.logQueryImpl.createOrmMap("mySqlLog", "id", "MYSQLLOG.ID");
this.logQueryImpl.createOrmMap("mySqlLog", "auditId", "MYSQLLOG.AUDITID");
this.logQueryImpl.createOrmMap("mySqlLog", "process", "MYSQLLOG.PROCESS");
this.logQueryImpl.createOrmMap("mySqlLog", "description", "MYSQLLOG.DESCRIPTION");
this.logQueryImpl.createOrmMap("oracleLog", "id", "ORACLELOG.ID");
this.logQueryImpl.createOrmMap("oracleLog", "auditId", "ORACLELOG.AUDITID");
this.logQueryImpl.createOrmMap("oracleLog", "process", "ORACLELOG.PROCESS");
this.logQueryImpl.createOrmMap("oracleLog", "description", "ORACLELOG.DESCRIPTION");
this.logQueryImpl.createOrmMap("appLog", "id", "APPLOG.ID");
this.logQueryImpl.createOrmMap("appLog", "auditId", "APPLOG.AUDITID");
this.logQueryImpl.createOrmMap("appLog", "sql", "APPLOG.SQL");
this.logQueryImpl.createOrmMap("appLog", "tableName", "APPLOG.TABLENAME");
this.logQueryImpl.createOrmMap("appLog", "opType", "APPLOG.OPTYPE");
this.logQueryImpl.createOrmMap("appLog", "operatorId", "APPLOG.OPERATORID");
this.logQueryImpl.createOrmMap("appLog", "beOperatedId", "APPLOG.BEOPERATEDID");
this.logQueryImpl.createOrmMap("operation", "id", "OPERATION.ID");
this.logQueryImpl.createOrmMap("operation", "appId", "OPERATION.APPID");
this.logQueryImpl.createOrmMap("operation", "columnName", "OPERATION.COLUMNNAME");
this.logQueryImpl.createOrmMap("operation", "newValue", "OPERATION.NEWVALUE");
this.logQueryImpl.createOrmMap("operation", "oldValue", "OPERATION.OLDVALUE");
//設置外鍵映射
this.logQueryImpl.createFkmMap("auditInfo", "eventType", "eventType", "id");
//this.logQueryImpl.createFkmMap("auditInfo", "eventId", "eventId", "id");
this.logQueryImpl.createFkmMap("auditInfo", "auditType", "auditType", "id");
this.logQueryImpl.createFkmMap("winLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("linuxLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("tomcatLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("sqlServerLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("mySqlLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("oracleLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("appLog", "auditId", "auditInfo", "id");
this.logQueryImpl.createFkmMap("operation", "appId", "appLog", "id");
//設置顯示字段標題
this.logQueryImpl.addColTitle("auditInfo", "auditDate", "日期/時間");
this.logQueryImpl.addColTitle("auditInfo", "ipAddr", "IP地址");
this.logQueryImpl.addColTitle("auditInfo", "hostName", "主機名");
this.logQueryImpl.addColTitle("eventId", "eventName", "事件名稱");
this.logQueryImpl.addColTitle("eventId", "eventShort", "簡要事件描述");
this.logQueryImpl.addColTitle("eventId", "description", "詳細事件描述");
this.logQueryImpl.addColTitle("eventType", "eTypeName", "事件類型");
this.logQueryImpl.addColTitle("auditType", "typeName", "子表名稱");
this.logQueryImpl.addColTitle("winLog", "oneSource", "一級來源");
this.logQueryImpl.addColTitle("winLog", "secondSource", "二級來源");
this.logQueryImpl.addColTitle("winLog", "category", "分類");
this.logQueryImpl.addColTitle("winLog", "usr", "用戶");
this.logQueryImpl.addColTitle("winLog", "description", "描述");
this.logQueryImpl.addColTitle("sqlServerLog", "process", "進程名");
this.logQueryImpl.addColTitle("sqlServerLog", "description", "描述");
this.logQueryImpl.addColTitle("tomcatLog", "id", "TOMCATLOG.ID");
this.logQueryImpl.addColTitle("tomcatLog", "auditId", "TOMCATLOG.AUDITID");
this.logQueryImpl.addColTitle("tomcatLog", "remoteIp", "遠程IP");
this.logQueryImpl.addColTitle("tomcatLog", "locIp", "本地IP");
this.logQueryImpl.addColTitle("tomcatLog", "byteSent", "發送字節數");
this.logQueryImpl.addColTitle("tomcatLog", "ReHostName", "遠程主機名");
this.logQueryImpl.addColTitle("tomcatLog", "reqMethod", "請求方法");
this.logQueryImpl.addColTitle("tomcatLog", "locPort", "本地端口");
this.logQueryImpl.addColTitle("tomcatLog", "queryStr", "請求字符串");
this.logQueryImpl.addColTitle("tomcatLog", "firstLineReq", "首行請求");
this.logQueryImpl.addColTitle("tomcatLog", "httpStatus", "HTTP狀態");
this.logQueryImpl.addColTitle("tomcatLog", "usrSessId", "用戶會話ID");
this.logQueryImpl.addColTitle("tomcatLog", "autherReUsr", "驗證遠程用戶名");
this.logQueryImpl.addColTitle("tomcatLog", "reqUrl", "請求URL");
this.logQueryImpl.addColTitle("tomcatLog", "locSerName", "本地服務器名");
this.logQueryImpl.addColTitle("tomcatLog", "proTime", "響應時間");
this.logQueryImpl.addColTitle("tomcatLog", "reQuProtocol", "客戶請求協議");
this.logQueryImpl.addColTitle("tomcatLog", "reUsrName", "遠程邏輯用戶名");
//定義樹中節點的父子關系
this.logQueryImpl.setMBeanRelation("auditInfo", "left", "auditType");
this.logQueryImpl.setMBeanRelation("auditInfo", "left", "eventType");
//this.logQueryImpl.setMBeanRelation("auditInfo", "left", "eventId");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "winLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "linuxLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "tomcatLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "sqlServerLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "mySqlLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "oracleLog");
this.logQueryImpl.setMBeanRelation("auditInfo", "right", "appLog");
this.logQueryImpl.setMBeanRelation("appLog", "right", "operation");
//建立節點樹
this.logQueryImpl.initTree("auditInfo");
}
public void oneQuery()
{
//設置頁面中需要查詢(Select)的屬性字段
/*
this.logQueryImpl.assignSelectCol("eventId", "id");
this.logQueryImpl.assignSelectCol("eventId", "eventName");
this.logQueryImpl.assignSelectCol("eventId", "eventShort");
this.logQueryImpl.assignSelectCol("eventId", "description");
*/
this.logQueryImpl.assignSelectCol("eventType", "id");
this.logQueryImpl.assignSelectCol("eventType", "eTypeName");
this.logQueryImpl.assignSelectCol("eventType", "description");
this.logQueryImpl.assignSelectCol("auditType", "id");
this.logQueryImpl.assignSelectCol("auditType", "tableIndex");
this.logQueryImpl.assignSelectCol("auditType", "typeName");
this.logQueryImpl.assignSelectCol("auditType", "description");
this.logQueryImpl.assignSelectCol("auditInfo", "id");
this.logQueryImpl.assignSelectCol("auditInfo", "auditDate");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -