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

📄 testqueryimpl.java

📁 具备多表组合查询组件功能。通过将表字段与表间关系映射到对象关系及属性
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		this.logQueryImpl.assignSelectCol("auditInfo", "eventId");
		this.logQueryImpl.assignSelectCol("auditInfo", "eventType");
		this.logQueryImpl.assignSelectCol("auditInfo", "auditType");
		this.logQueryImpl.assignSelectCol("auditInfo", "ipAddr");
		this.logQueryImpl.assignSelectCol("auditInfo", "hostName");
		this.logQueryImpl.assignSelectCol("auditInfo", "markTime");
		
		this.logQueryImpl.assignSelectCol("winLog", "id");
		this.logQueryImpl.assignSelectCol("winLog", "auditId");
		this.logQueryImpl.assignSelectCol("winLog", "oneSource");
		this.logQueryImpl.assignSelectCol("winLog", "secondSource");
		this.logQueryImpl.assignSelectCol("winLog", "category");
		this.logQueryImpl.assignSelectCol("winLog", "usr");
		this.logQueryImpl.assignSelectCol("winLog", "description");
/*	
		this.logQueryImpl.assignSelectCol("linuxLog", "id");
		this.logQueryImpl.assignSelectCol("linuxLog", "auditId");
		this.logQueryImpl.assignSelectCol("linuxLog", "description");
		
		this.logQueryImpl.assignSelectCol("tomcatLog", "id");
		this.logQueryImpl.assignSelectCol("tomcatLog", "auditId");
		this.logQueryImpl.assignSelectCol("tomcatLog", "remoteIp");
				
		this.logQueryImpl.assignSelectCol("tomcatLog", "locIp");
		this.logQueryImpl.assignSelectCol("tomcatLog", "byteSent");
		this.logQueryImpl.assignSelectCol("tomcatLog", "ReHostName");
		this.logQueryImpl.assignSelectCol("tomcatLog", "reqMethod");
		this.logQueryImpl.assignSelectCol("tomcatLog", "locPort");
		this.logQueryImpl.assignSelectCol("tomcatLog", "queryStr");
		this.logQueryImpl.assignSelectCol("tomcatLog", "firstLineReq");
		this.logQueryImpl.assignSelectCol("tomcatLog", "httpStatus");
		this.logQueryImpl.assignSelectCol("tomcatLog", "usrSessId");
		this.logQueryImpl.assignSelectCol("tomcatLog", "autherReUsr");
		this.logQueryImpl.assignSelectCol("tomcatLog", "reqUrl");
		this.logQueryImpl.assignSelectCol("tomcatLog", "locSerName");
		this.logQueryImpl.assignSelectCol("tomcatLog", "proTime");
		this.logQueryImpl.assignSelectCol("tomcatLog", "reQuProtocol");
		this.logQueryImpl.assignSelectCol("tomcatLog", "reUsrName");
		
		this.logQueryImpl.assignSelectCol("sqlServerLog", "id");	
		this.logQueryImpl.assignSelectCol("sqlServerLog", "auditId");
		this.logQueryImpl.assignSelectCol("sqlServerLog", "process");
		this.logQueryImpl.assignSelectCol("sqlServerLog", "description");
		
		this.logQueryImpl.assignSelectCol("oracleLog", "id");	
		this.logQueryImpl.assignSelectCol("oracleLog", "auditId");
		this.logQueryImpl.assignSelectCol("oracleLog", "process");
		this.logQueryImpl.assignSelectCol("oracleLog", "description");
		
		
		this.logQueryImpl.assignSelectCol("mySqlLog", "id");
		this.logQueryImpl.assignSelectCol("mySqlLog", "auditId");
		this.logQueryImpl.assignSelectCol("mySqlLog", "process");
		this.logQueryImpl.assignSelectCol("mySqlLog", "description");
		
		
		this.logQueryImpl.assignSelectCol("appLog", "id");
		this.logQueryImpl.assignSelectCol("appLog", "auditId");
		this.logQueryImpl.assignSelectCol("appLog", "sql");
		this.logQueryImpl.assignSelectCol("appLog", "tableName");
		this.logQueryImpl.assignSelectCol("appLog", "opType");
		this.logQueryImpl.assignSelectCol("appLog", "operatorId");
		this.logQueryImpl.assignSelectCol("appLog", "beOperatedId");
				
		this.logQueryImpl.assignSelectCol("operation", "id");
		this.logQueryImpl.assignSelectCol("operation", "appId");
		this.logQueryImpl.assignSelectCol("operation", "columnName");
		this.logQueryImpl.assignSelectCol("operation", "newValue");
		this.logQueryImpl.assignSelectCol("operation", "oldValue");
	*/
		
		//设置页面中需要显示的字段
	/*
		this.logQueryImpl.assignShowQueue("auditInfo", "ipAddr");
		
		this.logQueryImpl.assignShowQueue("auditInfo", "auditDate");
		this.logQueryImpl.assignShowQueue("auditInfo", "ipAddr");
		this.logQueryImpl.assignShowQueue("auditInfo", "hostName");
		
		this.logQueryImpl.assignShowQueue("eventId", "eventName");
		this.logQueryImpl.assignShowQueue("eventId", "eventShort");
		this.logQueryImpl.assignShowQueue("eventId", "description");
		
		this.logQueryImpl.assignShowQueue("eventType", "eTypeName");
		
		this.logQueryImpl.assignShowQueue("auditType", "typeName");
		
		this.logQueryImpl.assignShowQueue("winLog", "oneSource");
		this.logQueryImpl.assignShowQueue("winLog", "secondSource");
		this.logQueryImpl.assignShowQueue("winLog", "category");
		this.logQueryImpl.assignShowQueue("winLog", "usr");
		this.logQueryImpl.assignShowQueue("winLog", "description");
		
		this.logQueryImpl.assignShowQueue("sqlServerLog", "process");
		this.logQueryImpl.assignShowQueue("sqlServerLog", "description");
		
		
		this.logQueryImpl.assignShowQueue("tomcatLog", "id");
		this.logQueryImpl.assignShowQueue("tomcatLog", "auditId");
		this.logQueryImpl.assignShowQueue("tomcatLog", "remoteIp");
		this.logQueryImpl.assignShowQueue("tomcatLog", "locIp");
		this.logQueryImpl.assignShowQueue("tomcatLog", "byteSent");
		this.logQueryImpl.assignShowQueue("tomcatLog", "ReHostName");
		this.logQueryImpl.assignShowQueue("tomcatLog", "reqMethod");
		this.logQueryImpl.assignShowQueue("tomcatLog", "locPort");
		this.logQueryImpl.assignShowQueue("tomcatLog", "queryStr");
		this.logQueryImpl.assignShowQueue("tomcatLog", "firstLineReq");
		this.logQueryImpl.assignShowQueue("tomcatLog", "httpStatus");
		this.logQueryImpl.assignShowQueue("tomcatLog", "usrSessId");
		this.logQueryImpl.assignShowQueue("tomcatLog", "autherReUsr");
		this.logQueryImpl.assignShowQueue("tomcatLog", "reqUrl");
		this.logQueryImpl.assignShowQueue("tomcatLog", "locSerName");
		this.logQueryImpl.assignShowQueue("tomcatLog", "proTime");
		this.logQueryImpl.assignShowQueue("tomcatLog", "reQuProtocol");
		this.logQueryImpl.assignShowQueue("tomcatLog", "reUsrName");
	*/	
		
		//设置查询条件
		Date auditDate = new Date();
		//this.logQueryImpl.setQueryValue("auditInfo", "id", "=", 25);
		this.logQueryImpl.setQueryValue("auditInfo", "auditType", "=", 1);
		//this.logQueryImpl.setQueryValue("auditInfo", "auditDate", "=", auditDate);
		//this.logQueryImpl.setQueryRelation("eventType", "descr", "=", "Application");
		
		//生成Sql语句
		StringBuffer sql = this.logQueryImpl.createSql();
		
		System.out.println("SQL is :"+sql.toString());
		
		//建立MBeanPage
		MBeanPage page = this.logQueryImpl.assignPage();
		
		
	}
	
	/**
	 * 显示ResultFormat中的信息
	 * @param format
	 */
	public void showFormatInfo(ResultFormat format,int colIndex)
	{
		ResultFormat.ColBean colBean = null;
		
		colBean = (ResultFormat.ColBean)format.getColList().get(colIndex);
		System.out.println("\n   In format !!");
		System.out.print("pojoName : "+colBean.getPojoName()+"\t");
		System.out.print("pojoCol  : "+colBean.getPojoCol()+"\t");
		System.out.print("tableCol : "+colBean.getTableCol()+"\t");
		
		
	}
	
	/**
	 * 显示ViewQueue中的信息
	 * @param viewQueue
	 */
	public void showViewQueueInfo(Map viewQueue,int key)
	{
		ResultFormat.ColBean colBean = null;
		
		colBean = (ResultFormat.ColBean)viewQueue.get(key);
		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");
			
		}
		
	}
	
	/**
	 * 显示MBeanPage中的参数信息
	 * @param page
	 */
	public void showPageInfo(MBeanPage page)
	{
		int sqlCount = page.getQuerySqlList().size();
		int i1 = 0;
		int i2 = 0;
		StringBuffer sql = null;
		Map viewQueue = null;
		ResultFormat format = null;
		System.out.println("Show page information!");
		for (i1=0;i1<sqlCount;i1++)
		{
			System.out.println("Sql Number is : "+i1);
			sql = (StringBuffer)page.getQuerySqlList().get(i1);
			System.out.println("Sql : "+sql);
			
			format = (ResultFormat)page.getFormatList().get(i1);
			viewQueue = (Map)page.getViewQueueList().get(i1);
			for (i2=0;i2<format.getColList().size();i2++)
			{
				this.showFormatInfo(format, i2);
				this.showViewQueueInfo(viewQueue, i2);		
			}
			
			
		}
		
	}
	
	/**
	 * 显示MBeanPage中的数据
	 * @param page
	 * @throws Exception
	 */
	public void showSelectResult(MBeanPage page) throws Exception
	{
		page.setDBConnection(new OracleConnection());
		page.initPage();
		page = page.queryPageData();
		List dataList = page.getData();
		int dataNum = 0;
	      
	    
	    DateFormat dateFormatter = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.MEDIUM,java.text.DateFormat.DEFAULT);
	    Iterator dataIter = dataList.iterator();  
	    while(dataIter.hasNext())
	      { 
	         Object[] obj = (Object[])dataIter.next();
	        
	         System.out.print("\n");
	         for(dataNum=0;dataNum < obj.length-1;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");
			   }	   	  
		     }   
	      }
		
	}
	
	public static void main(String[] args) throws Exception
	{
		TestQueryImpl test = new TestQueryImpl();
		//MBeanPage page = new MBeanPage();
		test.initTree();
		test.oneQuery();
		//test.showPageInfo(test.logQueryImpl.createPage());
		test.showSelectResult(test.logQueryImpl.assignPage());
		test.logQueryImpl.getMBeanPage().resetPage();
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -