查询统计查询Auditing history及应用说明

在本文中,我们主要分析查询统计的内容,自我感觉有个不错的建议和大家分享下

            在《FileNet Auditing简略置配及明说》中已分析了Auditing的作用及其够能统计的关相内容。可以说其对评估一个档文类产品的用利况情很有代价,对此早些买购FileNet产品的公司(如zhy)会直接在XT上行进制定开辟,使其备具档文报表统计功能。

             全部报表统计程过,其实就是对auditing history的查询程过,其映射的是对event log的查询。就像我们查询Document类型(或自定义Document类型)一样,我们应用的式方是同相的。在懂得好Query语法的基础上,便能轻易的行进关相作操了。代码示例如下所示。

public long getAuditingInfos(ObjectStore os,
												Date startDate,
												Date endDate,
												Id auditingType,
												Boolean 				needParentClassType,
												String topParentClass,
												
) throws Exception{
		
		
		long total = 0;
		
		AuditingInfoBean bean = null;
		RepositoryRowSet rrs = null;
		RepositoryRow rr = null;
		
		if(startDate != null && endDate != null && 
				(rrs = buildData(os,startDate,endDate,auditingType)) != null){
			
			PageIterator iter = rrs.pageIterator();
			while (iter.nextPage())
			{
			    Object[] currentPage = iter.getCurrentPage();
			    if(currentPage != null){
			    	for(int i=0;i<currentPage.length;i++){
			    		rr = (RepositoryRow)currentPage[i];
			    		
			    		if(null != rr && rr.getProperties().getInteger32Value(PropertyNames.EVENT_STATUS) == 0){
			    			
					    	try{
					    		rr.getProperties().getIdValue(PropertyNames.ID).toString();
					    		rr.getProperties().getObjectValue(PropertyNames.CREATOR);
					    		rr.getProperties().getIdValue(PropertyNames.SOURCE_OBJECT_ID);
					    		Id classId = rr.getProperties().getIdValue(PropertyNames.SOURCE_CLASS_ID);
					    		PropertyFilter filter = new PropertyFilter();
								FilterElement ele0 = new FilterElement(null, null, null, PropertyNames.SYMBOLIC_NAME, null);
								FilterElement ele1 = new FilterElement(null, null, null, PropertyNames.SUPERCLASS_DESCRIPTION, null);
								filter.addIncludeProperty(ele0);
								filter.addIncludeProperty(ele1);
								ClassDescription classDescription = Factory.ClassDescription.fetchInstance(os, classId, filter);
								String selfSymbolicName = classDescription.get_SymbolicName();
					    		
					    	}catch(Exception e){
					    		logger.error(e.toString());
					    		continue;
					    	}
			    		}
			    	}
			    }
			}
		}
		
		return total;
	}
	
	private RepositoryRowSet buildData(ObjectStore os,Date startDate,Date endDate,Id auditingType){

		RepositoryRowSet rrs  = null;
		
		if(AuditingUtil.CREATIONEVENT == auditingType 
				|| AuditingUtil.GETCONTENTEVENT == auditingType){
			
			String sqlString = "SELECT "  + PropertyNames.CREATOR + "," + 
											PropertyNames.ID + "," + 
											PropertyNames.DATE_CREATED + "," + 
											PropertyNames.EVENT_STATUS + "," + 
											PropertyNames.SOURCE_CLASS_ID + "," + 
											PropertyNames.SOURCE_OBJECT_ID;

			SearchSQL searchSql = new SearchSQL(sqlString + 
									" FROM " + auditingType + 
							        " WHERE " + 
							        	PropertyNames.DATE_CREATED + " >= " + dateFormat(startDate) + 
							        	" AND " + 
							        	PropertyNames.DATE_CREATED  + " < " + dateFormat(endDate) +
							        " ORDER BY " + PropertyNames.DATE_CREATED);
			
			SearchScope ss = new SearchScope(os);
			
			PropertyFilter filter = new PropertyFilter();
			FilterElement ele1 = new FilterElement(null, null, null, PropertyNames.EVENT_STATUS, null);
			FilterElement ele2 = new FilterElement(null, null, null, PropertyNames.CREATOR, null);
			FilterElement ele3 = new FilterElement(null, null, null, PropertyNames.DATE_CREATED, null);
			FilterElement ele4 = new FilterElement(null, null, null, PropertyNames.SOURCE_CLASS_ID, null);
			FilterElement ele5 = new FilterElement(null, null, null, PropertyNames.SOURCE_OBJECT_ID, null);
			filter.addIncludeProperty(ele1);
			filter.addIncludeProperty(ele2);
			filter.addIncludeProperty(ele3);
			filter.addIncludeProperty(ele4);
			filter.addIncludeProperty(ele5);
			
			rrs = ss.fetchRows(searchSql, 1000, filter, true);
		}

		return rrs;
	}
	
	private String dateFormat(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		String dateStr = sdf.format(date);
		sdf = new SimpleDateFormat("HHmmss");
		dateStr = dateStr + "T" + sdf.format(date) + "Z";
		return dateStr;
	}
    每日一道理
风,渐渐吹起,吹乱了我的发丝,也让我的长裙有些飘动。绿叶仿佛在风中起舞,离开了树,投向了大地,却不知这样会枯萎,我弯下腰,轻轻拾起一片树叶,那非常有序的茎脉,是一种美的点缀。我有些哀叹:绿叶啊,绿叶,你这般美丽地从树上轻轻飘下,随风起舞,却不知已被人称之为落叶!

             FileNet供给了对流程的报表析分工具(process Analyzer),却没有供给与Auditing相互配合的产品。这类直接制定性开辟的任务虽然功能上可以实现,但效率问题是已在XT上制定出来的功能随着zhy某分公司几十万附件的量也使得这个功能形同虚设。究其原因不是FileNet存储够不优化,而是auditing存储的是响应作操事件关相的内容,虽然也已存储着作操的档文实例,但要借此获取到档文关相息信(如称名、甚至是作操者在所部门)则会非常耗时。

             针对此类问题可以斟酌去直接理清FileNet数据库继而直接作操数据库,但这类险风较高,而且产品升级也可能有所便不;另外可以斟酌将务业关相数据在定时任务转中移到应用的务业库中,这类短间时的auditing查询,且是在应用闲空间时行进的,会较易接受,虽然这类式方会有必定延迟,但统计本身的间时量很大,这类一天甚至更短间时的延迟是可以接受的;当然,我们还可以全完不应用auditing,直接在务业中录记关相要统计的数据,但这样做除了要做更多的开辟任务,更要紧的是对已成型的产品(或应用)的修改会很大,可能会带来比这类开辟更大的任务量(如试测)。所以,可以根据是目项阶段在后两种中择选,如果是FileNet内部人员可能会更爱好第一种,但要斟酌升级险风。

文章结束给大家分享下程序员的一些笑话语录: 开发时间
  项目经理: 如果我再给你一个人,那可以什么时候可以完工?程序员: 3个月吧!项目经理: 那给两个呢?程序员: 1个月吧!
项目经理: 那100呢?程序员: 1年吧!
项目经理: 那10000呢?程序员: 那我将永远无法完成任务.

posted @ 2013-04-29 13:35  坚固66  阅读(203)  评论(0编辑  收藏  举报