⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testqueryimpl.java

📁 具备多表组合查询组件功能。通过将表字段与表间关系映射到对象关系及属性
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
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 + -