📄 logexportimpl.java
字号:
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");
}
/**
* 设置要导出的属性队列
* @param pojoName
* @param pojoCol
*/
public void assignExportQueue(String pojoName,String pojoCol)
{
this.logQueryImpl.assignSelectCol(pojoName, pojoCol);
this.logQueryImpl.assignShowQueue(pojoName, pojoCol);
}
/**
* 查出原始数据
* @return
* @throws Exception
*/
private List getInitData() throws Exception
{
List dataList = null;
this.mBeanPage = this.logQueryImpl.assignPage();
this.mBeanPage.setDBConnection(this.dbCon);
this.mBeanPage.initPage();
this.mBeanPage.setCurPate(1);
this.mBeanPage.setRowsPerPage(this.mBeanPage.getMaxRowCount());//应用特例:一页信息包括多有数据
this.mBeanPage = this.mBeanPage.queryPageData();
dataList = this.mBeanPage.getData();
return dataList;
}
/**
* 得到一条导出的记录内容
* @param initObj
* @return
*/
private Object[] getOneItem(Object[] initObj,int sqlIndex)
{
Object[] outPut = null;
outPut = this.logQueryImpl.getDataByShowQueue(initObj, (ResultFormat)this.logQueryImpl.getMBeanPage().getFormatList().get(sqlIndex));
return outPut;
}
/**
* 根据exportQueue的设置,按显示顺序生成数据
* @param data
* @param sqlIndex:MBeanPage中,sqlList集合sql语句的索引号
* @return
*/
public List rebuildData(List data,int sqlIndex)
{
List reData = new ArrayList();
Object[] initObj = null;
Object[] reObj = null;
Iterator iterData = data.iterator();
while (iterData.hasNext())
{
initObj = (Object[])iterData.next();
reObj = this.getOneItem(initObj, sqlIndex);
reData.add(reObj);
}
return reData;
}
/**
* 显示ViewQueue中的信息
* @param viewQueue
*/
public void showExQueueInfo(List viewQueue)
{
Iterator iter = null;
ResultFormat.ColBean colBean = null;
iter = viewQueue.iterator();
while (iter.hasNext())
{
colBean = (ResultFormat.ColBean)iter.next();
if (colBean != null)
{
System.out.println("\n In ViewQueue!!");
System.out.print("pojoName : "+colBean.getPojoName()+"\t");
System.out.print("pojoCol : "+colBean.getPojoCol()+"\t");
//System.out.print("title : "+colBean.getTitle()+"\t");
}
}
}
/**
* @throws Exception
*
*
*/
public void selectWinLog() throws Exception
{
this.initTree();
this.assignExportQueue("auditInfo", "id");
this.assignExportQueue("auditInfo", "auditDate");
this.assignExportQueue("auditInfo", "eventId");
this.assignExportQueue("auditInfo", "eventType");
this.assignExportQueue("auditInfo", "auditType");
this.assignExportQueue("auditInfo", "ipAddr");
this.assignExportQueue("auditInfo", "hostName");
this.assignExportQueue("auditInfo", "markTime");
this.assignExportQueue("winLog", "id");
this.assignExportQueue("winLog", "auditId");
this.assignExportQueue("winLog", "oneSource");
this.assignExportQueue("winLog", "secondSource");
this.assignExportQueue("winLog", "category");
this.assignExportQueue("winLog", "usr");
this.assignExportQueue("winLog", "description");
this.logQueryImpl.setQueryValue("auditInfo", "auditType", "=", 1);
//生成Sql语句
StringBuffer sql = this.logQueryImpl.createSql();
System.out.println("SQL is :"+sql.toString());
List data =this.rebuildData(this.getInitData(), 0);
//显示查询结果
//this.showSelectResult(data);
this.showExQueueInfo((List)this.mBeanPage.getViewQueueList().get(0));
this.mBeanPage.resetPage();//完成一次查询操作后,需重置设置mBeanPage参数
}
/**
* 显示MBeanPage中的信息
* @param page
* @throws Exception
*/
public void showSelectResult(List data) throws Exception
{
int dataNum = 0;
DateFormat dateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM,java.text.DateFormat.DEFAULT);
Iterator dataIter = data.iterator();
while(dataIter.hasNext())
{
Object[] obj = (Object[])dataIter.next();
System.out.print("\n");
for(dataNum=0;dataNum < obj.length;dataNum++)
{
if(obj[dataNum] != null)
{
if(obj[dataNum] instanceof java.util.Date)
{
System.out.print("test 1 "+dateFormatter.format((java.util.Date)obj[dataNum])+"\t");
}
else
{
System.out.print(obj[dataNum].toString()+"\t");
}
}
else
{
System.out.print("null\t");
}
}
}
}
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
//TestLogTreeImpl logTreeImpl = new TestLogTreeImpl("select");//日志查询用后序遍历LogTree
LogExportImpl logExportImpl = new LogExportImpl(new OracleConnection());
logExportImpl.selectWinLog();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -