<%
/*	Name			:	EgAckHistotyTable.jsp
	@author			:	Balamurugan J
	@created		:	01/21/2008
	Purpose			:	To show acknowledgement and deleted alarms
	Design			:	Jaiwin
						20/12/2011  Sri Devi G User - VM Changes
*/
%>
<%@ include file="EgLoginTracker.jsp" %>
<%@ page errorPage = "EgProbsM.jsp" %>
<%@ page import = "com.eg.EgDateInfo"%>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.eg.EgDiscInfo"%>
<%@ page import = "com.eg.EgDiscInfoHelper"%>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.eg.EgDbAdapterTypeUI" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import = "com.eg.EgMemInfo" %>
<%@ page import = "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.EgSpecsInfo"%>
<%@ page import = "com.eg.EgInstallInfo"%>
<%@ page import = "com.eg.EgAgentInfo"%>
<%@ page import = "com.eg.LangInfo" %>
<%@ page import = "com.egurkha.*" %>
<%@ page import = "com.egurkha.ini.*" %>
<%@ page import = "com.egurkha.util.*" %>
<%@ page import = "com.egurkha.monitor.alarms.*" %>
<%@ page import = "com.egurkha.monitor.EgAlarmsBean"%>
<%@ page import = "egurkha.EgDbAdapterUI" %>
<%@ page import = "egurkha.EgSettingsTimeStamp" %>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "egurkha.TestBean" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*"  %>
<%@ page import = "com.eg.IniFile"%>
<%@ taglib uri="/WEB-INF/indexer-taglib.tld" prefix="id" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "com.eg.EgTestInfo"%>
<%@ page import = "com.egurkha.pdfmaker.*"%>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.eg.EgURLDecoder" %>
<%@ page import = "com.eg.EgLastMeasureThread" %>
<%@ page import = "com.eg.EgSmConfigInfo" %>
<%@ page import = "egurkha.TransactionBean"%>
<!Doctype html>
<head>
<title>eG Manager</title>
<egui:skin ui="monitor"/>
<meta name="Author" content="" />
<%
	currentSessionId = session.getId();
%>
<%!
int compNameLength=32;
int displayLength=12;
String currentSessionId = null;
%>
<script language="javascript">
var ddwin=null;
var gwin=null;

function getDateObj(date, hour)
{
	var index = date.indexOf("/");
	var lastIndex = date.lastIndexOf("/");

	var day = date.substr(0, index);
	var month = date.substr(index+1, lastIndex-index-1);
	var year = date.substr(lastIndex+1);

	var dateObj = new Date(year, month, day, hour, 0, 0);
	return dateObj;
}

function findPagerOffset(page)
{
	var url = window.location.href;
	var index = url.indexOf("indexeroffset");

	if (index != -1)
	{
		var beforeStr = url.substr(0, index);
		var afterStr = url.substr(index);
		index = afterStr.indexOf("&");
		if (index == -1)
		{
			url = beforeStr + "indexeroffset=" + page;
		}
		else
		{
			afterStr = afterStr.substr(index);
			url = beforeStr + "indexeroffset=" + page + afterStr;
		}
	}
	else
	{
		url += "&indexeroffset="+page;
	}
	return url;
}

function onGoToPage(maxEntriesPerPage, totalEntries)
{
	var page = document.Event.pageno.value;
	
	if (!isNaN(page))
	{
		var offset = (page-1) * maxEntriesPerPage;
		if ((offset > totalEntries) || (page < 1))
		{
			alert('<egui:intnl text="monitor.history.Page"/> ' +page+' <egui:intnl text="monitor.history.does not exist"/>');
			document.Event.pageno.value = "";
		}
		else
		{
			window.location.href = findPagerOffset(offset);
		}
	}
	else
	{
		alert('<egui:intnl text="monitor.history.Page"/> '+page+' <egui:intnl text="monitor.history.is invalid"/>');
		document.Event.pageno.value = "";
	}
}

function popupValue(thisQuery,type)
{
	var newWindow = false;
	newWindow = document.Event.popup_selection.checked;
	parent.popup(encodeURI(thisQuery),type,newWindow);
}

function closeWin ()
{
	if(window.gwin!=null)
	gwin.close();
	if(window.ddwin!=null)
	ddwin.close();
}

/*------------------------Div Resize--------------------*/
window.onresize = myResize;
function myResize() 
{
	var myWidth = 900, myHeight = 500;

	if( typeof( window.innerWidth ) == 'number' ) 
	{
	//Non-IE
		document.getElementById("my_div").style.width=(window.innerWidth-15)+"px";
		document.getElementById("my_div").style.height=(window.innerHeight-14)+"px";
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight )) 
	{
	//IE 6+ in 'standards compliant mode'
		document.getElementById("my_div").style.width=(document.documentElement.clientWidth-14)+"px";
		document.getElementById("my_div").style.height=(document.documentElement.clientHeight-14)+"px";
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		document.getElementById("my_div").style.width=(document.body.clientWidth-14)+"px";
		document.getElementById("my_div").style.height=(document.body.clientHeight-14)+"px";
	}
}

/*-----------------------Div Resize---------------------*/ 
</script>

<%
	String printPage1=request.getParameter("printPage");
	if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
	{
%>

<link rel="stylesheet" type="text/css" href="../../final/monitor/eg_styles/printPageStyles.css" />

<!--<style>
<link rel="stylesheet" type="text/css" href="../../final/reporter/styles/printpagestyle.css" />
@media print {body {-webkit-print-color-adjust: exact;}}
body{font-size:11px;line-height:1.5em;color:#000;}
header{font-size:15px;}
.formLabel {font-size:12px;line-height:14px;}
.formValue {font-size:12px;line-height:14px;}
b{font-size:11px;}
table tr td{font-size:11px;padding:4px;}
.printTable{border: 1px solid #c3c3c3; border-collapse: collapse;}
.printTable tr td{border: 1px solid #c3c3c3;}
.printTableHeader{border: 1px solid #c3c3c3;text-align:center;background-color:#cdcdcd;padding:4px;}
.printTableHeader2{border: 1px solid #c3c3c3;text-align:center;background-color:#dcdcdc;padding:4px;}
</style>-->
<style type="text/css" media="print">
#printbt{ display:none}
</style>
<style>
</style>-->
<!-- <LINK href="/final/monitor/eg_styles/monstyle_<%//=monitor_Skin%>.css" type="text/css" rel="stylesheet">  -->
<%
	}
%>
</head>

<body  style="padding:10px;background-color:#ffffff">
<script type="text/javascript" src="/final/monitor/eg_scripts/wz_tooltip.js"></script>
<table align="left" cellspacing="0" cellpadding="0" width="100%" border="0" valign="top" height="100%" id="data_border">
	<tr>
		<td width="100%" valign="top">
<%!
	String licenseCheck = "me";
	String thisLanguage="";
	public Vector syncVector = new Vector();
	
	Hashtable ht = new Hashtable();
%>

<%
	String selectedCompName="";
	String selectedCompType="";
try
{
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);

	boolean isAllComp=false;
	boolean onlyVMAssigned=false;
	boolean vmAssigned=false;
	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());
	String userTimeZone = user.getUserTimeZone();
	//dummy conversion for getting the timezone shortname.....
	String conDate = DateUtil.changeDateFormat("01/01/2014","dd/MM/yyyy",user.getUserDateFormat());
	String timeShort = new EgTimeZoneConverter(conDate+" 00:00:00",user).getDateTimeWithShortTimeZone();
	EgTimeZoneConverter timeZoneConvertert =new EgTimeZoneConverter(conDate+" 00:00:00",user);
	TimeZone user_tz = (TimeZone)timeZoneConvertert.getTimeZone();
	java.util.Date loginUserDate = (java.util.Date)timeZoneConvertert.getDate(true);
	String shortTZ = user_tz.getDisplayName(user_tz.inDaylightTime(loginUserDate), TimeZone.SHORT);
	//	
	IniUI ui = (IniUI)com.egurkha.ini.IniUI.getInstance();

	EgUserRole userRole = EgUserRole.getRoleObject(user.getLoginType());
	isAllComp = userRole.hasAllComponentAccess();
	String loginid = user.getLoginID();
	LangInfo langinfo = new LangInfo(loginid);
	EgDbInfo dbInfo = new EgDbInfo(EgConstants.MANAGER);
	String fontStyle = "";
	if ((dbInfo.doubleByteEnabled || !thisLanguage.equals("en_US")))
	{
		//fontStyle = "multi_font";
	}
	boolean hasVMs = false;
	List a_userVMs = new LinkedList();	
	String vmType = "";
	String LABELS = "LABELS";
	thisLanguage = ui.getDefaultLanguage();
	boolean dispHeader = true;
	if (user!=null)
	{
		vmType = user.getVMType();
		String userLang = user.getLanguage();
		if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
		{
			thisLanguage=userLang;
		}
		
		if(!isAllComp)
		{
			onlyVMAssigned = user.isOnlyVMAssigned();
			vmAssigned = user.isVMAssigned();
			a_userVMs = user.getOnlyVMs();
			if(a_userVMs!=null && a_userVMs.size() > 0)
			{
				hasVMs = true;
			}
		}
	}
	//starts custom problem description 
	TransactionBean configMsgBean = null;
	String CustomAlertMessages = "No";
	boolean isCustomAlertMessages = false;
	
	configMsgBean = new TransactionBean();
	configMsgBean.createFile("eg_services.ini");
	CustomAlertMessages = configMsgBean.getStrValue("MISC_ARGS", "EnableCustomAlertMessages");
	if(CustomAlertMessages != null && CustomAlertMessages.equalsIgnoreCase("Yes")) {
		isCustomAlertMessages = true;
	}
	//ends custom problem description 

	EgDiscInfo discInfo = new EgDiscInfo(EgConstants.MANAGER);
	EgDiscInfoHelper discInfoHelper = new EgDiscInfoHelper();
	EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	boolean hasAllComponentAccess=userRole.hasAllComponentAccess();
	//Added by chandrasekhar to get real component type for host system
	List userCompList=new LinkedList();
	List vmUserCompList = new LinkedList();
	if(!hasAllComponentAccess)
	{
		userCompList=user.getServers(false);
		vmUserCompList=getHostSystemServers(userCompList);
		if(userCompList!=null && userCompList.size()>0)
		{
			List userCompList_host=new LinkedList();
			for(int r=0; r<userCompList.size(); r++)
			{
				String s = (String) userCompList.get(r);
				if(s!=null && !s.endsWith(":NULL"))
				{
					StringTokenizer st=new StringTokenizer(s,":");
					String ctype=st.nextToken();
					String cname=st.nextToken();
					if(ctype!=null && cname!=null && ctype.trim().length()>0 && cname.trim().length()>0)
						userCompList_host.add(ctype+":"+cname+":NULL");
				}
			}
			if(userCompList_host!=null && userCompList_host.size()>0)
				userCompList.addAll(userCompList_host);
		}
	}//Ended here..
	String uiFile = "eg_ui.ini";
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	String currDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	String currentDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	currentDateFormat = currentDateFormat + " HH:mm:ss";
	String showManagerID = egUI.getValue("ALARM_HISTORY","ShowManagerID");
	boolean showMgrId = false;
	if(EgInstallInfo.isSuperManager && showManagerID != null && (showManagerID.equalsIgnoreCase("yes") || showManagerID.equalsIgnoreCase("true")))
	{
		showMgrId=true;
	}

	EgSpecsInfo specsInfo = new EgSpecsInfo(EgConstants.MANAGER);
	EgAgentInfo agentInfo = new EgAgentInfo(EgConstants.MANAGER);
	
	Vector vpdfData=new Vector();
	List lst=new LinkedList();//to store into the session object
	List data_list=new LinkedList();//to store the data for CSV format
	Vector heads=new Vector();//to store table heading to CSV format
	Vector date=new Vector();
	
	String ackorDelete = request.getParameter("ackorDeleteComp");
	ackorDelete = EgURLDecoder.decode(ackorDelete,"UTF-8");
	if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Acknowledgement"))
	{
		lst.add(mappingInfo.getTextDescription("monitor.Ack.Acknowledgement History"));
	}
	else if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Uncknowledgement"))
	{
		lst.add(mappingInfo.getTextDescription("monitor.Ack.Unacknowledgement History"));
	}
	else if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Deletion"))
	{
		lst.add(mappingInfo.getTextDescription("monitor.Ack.DeletedAlarm History"));

	}
	String pdfHeading="";

	Vector all=new Vector();
	List history = null;//Same as all, but contains data as is from database. all undergoes modifications for display.
	int size = 0;		//The size of the Vector all

	//---For indexer-taglib.jar
	String index = "center";
	
	String count = request.getParameter("eventsCount");
	String alarmOption = request.getParameter("alarmOption");
	String eventsPerPage = request.getParameter("eventsPerPage");
	if(eventsPerPage == null)
	{
		eventsPerPage = egUI.getValue("ALARMS","Row_Multiplier");
	}
	if("ALL".equalsIgnoreCase(eventsPerPage))
	{
		eventsPerPage = count;
	}
	int eventsperPage_int = 15;
	if(eventsPerPage != null && !eventsPerPage.equalsIgnoreCase("null") && !eventsPerPage.equalsIgnoreCase(""))
	{
		eventsperPage_int = Integer.parseInt(eventsPerPage);
	}

	String eventHistFlag = egUI.getValue("ALARM_HISTORY","ShowEventHistory");
	boolean showEventHistory = true;
	if(eventHistFlag != null && eventHistFlag.trim().length() > 0 && (eventHistFlag.equalsIgnoreCase("yes") || eventHistFlag.equalsIgnoreCase("true") || eventHistFlag.equalsIgnoreCase("y") ))
		showEventHistory = true;
	else
		showEventHistory = false;

	int maxPageItems = eventsperPage_int;//ui.getMaxPageItems();
	int maxIndexPages = 10;
	int thisPageNumber = 1;
	int maxWidth = 0;
	int eventCount = 0;
	int offsetCount = 0;
	
	String realUser = "";
	String ackuserId = request.getParameter("ackUser");
	ackuserId = EgURLDecoder.decode(ackuserId,"UTF-8");
	String startTime = request.getParameter("startDate");
	String endTime = request.getParameter("endDate");
	selectedCompName = request.getParameter("compName");
	if(selectedCompName!=null && selectedCompName.length() > 0)
	{
		selectedCompName=com.egurkha.util.StringUtils.replace(selectedCompName,"|hash|","#");
		selectedCompName=com.egurkha.util.StringUtils.replace(selectedCompName,"|amp|","&");
	}
	if(selectedCompName!=null)
		selectedCompName=EgURLDecoder.decode(selectedCompName,"UTF-8");
	if(selectedCompName.equals("-1")) selectedCompName="Component Name (Optional)";
	selectedCompType = request.getParameter("compType");
	if(selectedCompType!=null)
		selectedCompType=EgURLDecoder.decode(selectedCompType,"UTF-8");
	if(selectedCompType.equals("-1")) selectedCompType="Component Type (Optional)";
	if(selectedCompType.length() == 0) selectedCompType="Component Type (Optional)";
	if(selectedCompName.length() == 0) selectedCompName="Component Name (Optional)";
	int selection=0;
	String str = "";
	if((selectedCompName.length()==0 || selectedCompName.equalsIgnoreCase("Component Name (Optional)")) && (selectedCompType.length()==0 || selectedCompType.equalsIgnoreCase("Component Type (Optional)")))
	{
		if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Acknowledgement"))
		{
			str=mappingInfo.getTextDescription("monitor.Ack.Acknowledgement Details");
			pdfHeading=mappingInfo.getTextDescription("monitor.Ack.Acknowledgement Details");
		}
		if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Unacknowledgement"))
		{
			str=mappingInfo.getTextDescription("monitor.Ack.Unacknowledgement Details");
			pdfHeading=mappingInfo.getTextDescription("monitor.Ack.Unacknowledgement Details");
		}
		if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Deletion"))
		{
			str=mappingInfo.getTextDescription("monitor.Ack.DeletedAlarm Details");
			pdfHeading=mappingInfo.getTextDescription("monitor.Ack.DeletedAlarm Details");
		}
		Vector v=new Vector();
		v.add(str);
		lst.add(v);
		selection=0;
	}
	else
	selection=1;

	if(selectedCompName.length()==0 && (selectedCompType.length()!=0 && !selectedCompType.equals("Component Type (Optional)") && !selectedCompType.equals("-1")))
	{
		str=mappingInfo.getTextDescription("monitor.history.Component Type")+" : "+mappingInfo.getComponentTypeDescription(selectedCompType);
		pdfHeading=str;
		
		Vector v=new Vector();
		v.add(str);
		lst.add(v);
		selection=0;
	}

	if((selectedCompName.length() !=0 && !selectedCompName.equals("Component Name (Optional)") && !selectedCompName.equals("-1"))  && selectedCompType.length() == 0)
	{
		str=mappingInfo.getTextDescription("monitor.history.Component Name")+" : "+selectedCompName;
		pdfHeading=str;
		Vector v=new Vector();
		v.add(str);
		lst.add(v);
		selection=0;
	}

	if((selectedCompName.length() !=0 && !selectedCompName.equals("-1")) && (selectedCompType.length()!=0 && !selectedCompType.equals("-1")))
	{
		 str = "";
		if(selectedCompType.equalsIgnoreCase("Component Type (Optional)"))
		{
			str=mappingInfo.getTextDescription("monitor.history.Component Name")+" : " +selectedCompName;
		}
		else if(selectedCompName.equalsIgnoreCase("Component Name (Optional)"))
		{
			str=mappingInfo.getTextDescription("monitor.history.Component Type")+" : " + mappingInfo.getComponentTypeDescription(selectedCompType);
		}
		else if(!selectedCompType.equalsIgnoreCase("Component Type (Optional)") && !selectedCompName.equalsIgnoreCase("Component Name (Optional)"))
		{
			str="Component Type : " + mappingInfo.getComponentTypeDescription(selectedCompType)+" , Component Name : "+selectedCompName;
		}

		pdfHeading=str;
		Vector v=new Vector();
		v.add(str);
		lst.add(v);
		selection=0;
	}
	StringBuffer sbuf=new StringBuffer(pdfHeading);	
	for(int i=sbuf.length();i<=100;i++)
	{
		sbuf.append(" ");
	}
	
	pdfHeading=sbuf.toString();

	if(startTime != null && !startTime.equals(""))
	{
		String dispStartDate = DateUtil.changeDateFormat(startTime,"MM/dd/yyyy HH:mm",currentDateFormat);
		EgTimeZoneConverter converterStart = new EgTimeZoneConverter(dispStartDate , u_ser);
		date.add("\""+mappingInfo.getTextDescription("monitor.history.Start Date") + ":" +converterStart.getDateTime()+"\"");
	}
	if(endTime != null && !endTime.equals(""))
	{
		String dispEndDate = DateUtil.changeDateFormat(endTime,"MM/dd/yyyy HH:mm",currentDateFormat);
		EgTimeZoneConverter converterEnd = new EgTimeZoneConverter(dispEndDate , u_ser);
		date.add("\""+mappingInfo.getTextDescription("monitor.history.End Date")+ ":" +converterEnd.getDateTime()+"\"");
	}
	lst.add(date);

	if(startTime != null && startTime.indexOf(":") >-1 && startTime.indexOf(":") == startTime.lastIndexOf(":"))
	{
		startTime+=":00";
	}
	if(endTime != null && endTime.indexOf(":")>-1 && endTime.indexOf(":") == endTime.lastIndexOf(":"))
	{
		endTime+=":00";
	}
	if(ackorDelete!=null && ackorDelete.length()>0 && (ackorDelete.equalsIgnoreCase("Acknowledgement") || ackorDelete.equalsIgnoreCase("Unacknowledgement")))
	{
		Vector almType=new Vector();
		if(alarmOption!=null && alarmOption.length()>0)
		{
			str= mappingInfo.getTextDescription("monitor.Ack.Alarm Type")+" : "+alarmOption;
			almType.add(str);
			lst.add(almType);
		}
	}
	String offsetStr = request.getParameter("indexeroffset");
	if (offsetStr != null)
	{
		offsetCount = Integer.parseInt(offsetStr);
	}
	if (StringUtils.isNull(count))
	{
		count = EgConstants.BLANK_STRING;
	}
	else
	{
		eventCount = Integer.parseInt(count);
	}

	logToTmpFile("INFO"," ","User = " + user.getLoginID()+"  HasAllCompAccess = " + isAllComp);
	List servers = new LinkedList();
	servers = user.getServers(false);
	List newServers = new LinkedList();
	List vmNames = new LinkedList();
	List vmServerTypes = new LinkedList();
	boolean showAll = false;
	boolean showAllTypes = false;
	boolean showAllComps = false;
	logToTmpFile("INFO","","Servers ... "+ servers);
	List serverNames = new LinkedList();
	List serverTypes = new LinkedList();

	boolean dispAll = false;
	if (servers.size() > 0 || hasVMs)
	{
		String nameList = null;
		String typeList = null;
		boolean allEvents = StringUtils.isNull(selectedCompName) && StringUtils.isNull(selectedCompType);
		if(selectedCompName!=null && selectedCompName.equalsIgnoreCase("Component Name (Optional)") && selectedCompType!=null && selectedCompType.equalsIgnoreCase("Component Type (Optional)"))
		{
			showAll = true;
		}
		if(selectedCompName !=null && selectedCompName.equalsIgnoreCase("Component Name (Optional)"))
		{
			showAllComps = true;
		}
		if(selectedCompType!=null && selectedCompType.equalsIgnoreCase("Component Type (Optional)"))
		{
			showAllTypes = true;
		}
		if(showAllTypes && showAllComps)
		{
			showAll = true;
		}
		if(selectedCompName!=null && selectedCompName.length() == 0 && selectedCompType!=null && selectedCompType.length() ==0)
		{
			showAll = true;
		}
		logToTmpFile("INFO","","All Events is " + allEvents);
		
		if (allEvents || showAll)
		{
			dispAll = true;
			if (isAllComp)
			{
				servers = new LinkedList();
			}
			else 
			{
				List ls = new LinkedList();
				ls = user.getServerTypes();
				for (int i=0;i<ls.size();i++)
					serverTypes.add((String)ls.get(i));
				if(servers.size() > 0)
				{
				serverTypes.add(Server.HOST_SYSTEM);
				List HostSysServers = new LinkedList();
				List xx = Server.getHostSystems(servers, true);
				if(xx!=null && xx.size()>0)
					{
						for (int r=0; r<xx.size(); r++)
						{
							String s = (String) xx.get(r);
							s =Server.HOST_SYSTEM+":"+s;
							if (!HostSysServers.contains(s))
							{
								HostSysServers.add(s);
							}
						}
					}
					HostSysServers.addAll(servers);
					servers = HostSysServers;
				}
				if(hasVMs)
				{
						vmServerTypes = user.getOnlyVMTypes();
						vmNames.addAll(user.getOnlyVMs());
						Hashtable vmHostMap = EgLastMeasureThread.vmMapDbForHistory;
						if(vmNames!=null)
						{
							for(int v =0; v< vmNames.size(); v++)
							{
								String vm = (String)vmNames.get(v);
								if(vmHostMap!=null)
								{
									ArrayList hosts = (ArrayList)vmHostMap.get(vm);
									String user_vm_host = user.getVMHost(vm);
									if(user_vm_host != null && user_vm_host.trim().length() > 0)
									{
										String host = user_vm_host;
										String comp = host.substring(0,host.lastIndexOf(":"));
										String type = host.substring(host.lastIndexOf(":")+1);
										String forServer = type+":"+comp;
										if(!newServers.contains(forServer))
											newServers.add(forServer);
									}
									else if(hosts!=null && hosts.size()  > 0)
									{
										for(int h =0; h < hosts.size(); h++)
										{
											String host = (String)hosts.get(h);
											String comp = host.substring(0,host.lastIndexOf(":"));
											String type = host.substring(host.lastIndexOf(":")+1);
											String forServer = type+":"+comp;
											if(!newServers.contains(forServer))
												newServers.add(forServer);
										}
									}
									else
									{
										newServers.addAll(user.getOnlyVMServers());
									}
								}
							}
						}
					
						if(servers.size() > 0)
							newServers.addAll(servers);
					
					servers = new LinkedList();
					
					servers.addAll(newServers);
					vmServerTypes = user.getOnlyVMTypes();
					if(vmServerTypes!=null) 
					{
						for(int v=0;v<vmServerTypes.size();v++)
						{
								String s_vmType = (String)vmServerTypes.get(v);
								if(!serverTypes.contains(s_vmType))
								{
									serverTypes.add(s_vmType);
								}
						}
					}
				}
			}
			logToTmpFile("INFO","","Servers for this User = "+servers);
		}
		else
		{
			if(showAllTypes && !showAllComps)
			{
				List xx = new LinkedList();
				List ls = new LinkedList();
				ls = user.getServerTypes();
				for (int i=0;i<ls.size();i++)
					serverTypes.add((String)ls.get(i));
				if(servers.size() > 0)
				{
					serverTypes.add(Server.HOST_SYSTEM);
				}
				
				if(!hasAllComponentAccess)
				{
					if(hasVMs)
					{
						if(onlyVMAssigned)
						{
							Hashtable vmHostMap = EgLastMeasureThread.vmMapDbForHistory;
							if(vmHostMap!=null && vmHostMap.containsKey(selectedCompName))
							{
								ArrayList hosts = (ArrayList)vmHostMap.get(selectedCompName);
								String user_vm_host = user.getVMHost(selectedCompName);
								if(user_vm_host != null && user_vm_host.trim().length() > 0)
								{
									String host = user_vm_host;
									String comp = host.substring(0,host.lastIndexOf(":"));
									String type = host.substring(host.lastIndexOf(":")+1);
									serverNames.add(comp);
									serverTypes.add(type);
									xx.add(type+":"+comp);
								}
								else if(hosts!=null)
								{
									for(int h=0; h < hosts.size();h++)
									{
										String host = (String)hosts.get(h);
										String comp = host.substring(0,host.lastIndexOf(":"));
										String type = host.substring(host.lastIndexOf(":")+1);
										serverNames.add(comp);
										serverTypes.add(type);
										xx.add(type+":"+comp);
									}
								}
								else
								{
									newServers.addAll(user.getOnlyVMServers());
									if(newServers!=null && newServers.size() >0)
									{
										for(int n=0; n < newServers.size();n++)
										{
											String host = (String)newServers.get(n);
											String type = host.substring(0,host.indexOf(":"));
											String comp = host.substring(host.indexOf(":")+1);
											serverNames.add(comp);
											serverTypes.add(type);
											xx.add(host);
										}
									}

								}

							}
						}
						else
						{
							if(userCompList!=null && userCompList.size() > 0)
							{
								for(int u =0 ; u < userCompList.size() ; u++)
								{

									String userComp = (String)userCompList.get(u);
									if(userComp.indexOf(selectedCompName) <0)
									{
										//Get the server for the vm
										Hashtable vmHostMap = EgLastMeasureThread.vmMapDbForHistory;
										if(vmHostMap!=null && vmHostMap.containsKey(selectedCompName))
										{
											ArrayList hosts = (ArrayList)vmHostMap.get(selectedCompName);
											String user_vm_host = user.getVMHost(selectedCompName);
											if(user_vm_host != null && user_vm_host.trim().length() > 0)
											{
												String host = user_vm_host;
												String comp = host.substring(0,host.lastIndexOf(":"));
												String type = host.substring(host.lastIndexOf(":")+1);
												serverNames.add(comp);
												serverTypes.add(type);
												xx.add(type+":"+comp);
											}
											else if(hosts!=null)
											{
												for(int h=0; h < hosts.size();h++)
												{
													String host = (String)hosts.get(h);
													String comp = host.substring(0,host.lastIndexOf(":"));
													String type = host.substring(host.lastIndexOf(":")+1);
													serverNames.add(comp);
													serverTypes.add(type);
													xx.add(type+":"+comp);
												}
											}
											else
											{
												newServers.addAll(user.getOnlyVMServers());
												if(newServers!=null && newServers.size() >0)
												{
													for(int n=0; n < newServers.size();n++)
													{
														String host = (String)newServers.get(n);
														String type = host.substring(0,host.indexOf(":"));
														String comp = host.substring(host.indexOf(":")+1);
														serverNames.add(comp);
														serverTypes.add(type);
														xx.add(host);
													}
												}

											}

										}
									}
								}
							}
						}
					}
					
				}
			
			
			if(servers!=null && servers.size() > 0)
			{
				//List xx_host_ser = Server.getHostSystems(servers, true);
				for(int u =0 ; u < servers.size() ; u++)
				{

						String userComp = (String)servers.get(u);
						if(userComp.indexOf(selectedCompName) >-1)
						{
							int ind = selectedCompName.indexOf(":");
							if (ind >= 0)
							{
								String s = selectedCompName.substring(0,ind);
								serverNames.add(s+":NULL");
							}
							else
							{
								selectedCompName = selectedCompName + ":NULL";
								
							}
							serverNames.add(selectedCompName);
				
							// get only servers of the name we want
							
							String search = ":"+selectedCompName;
							List HostSysServers = new LinkedList();
							// In this following method, when used parameter as true , its make problem in IC comp. so now used false.
							//List xx_host_ser = Server.getHostSystems(servers, true);
							//List xx_host_ser = Server.getHostSystems(servers, false);
							/*if(xx_host_ser!=null && xx_host_ser.size()>0)
							{
								for (int r=0; r<xx_host_ser.size(); r++)
								{
									String ss = (String) servers.get(r);
									if (ss.endsWith(search))
									{
											xx.add(ss);
									}

									ss = (String) xx_host_ser.get(r);
									if (ss.endsWith(search))
									{
										xx.add(ss);
									}
								}
							}*/
							int ind_comma = userComp.indexOf(":");
							if (ind_comma >= 0)
							{
								if(!selectedCompType.equals("Host_system"))
								{
									String t_ss=userComp;
									String typ = userComp.substring(0,ind_comma);
									userComp = userComp.substring(userComp.indexOf(":")+1,userComp.length());
									if (!serverTypes.contains(typ))
										continue;
									xx.add(t_ss);
									// for host system
									if(userComp.indexOf(":") > 0)
									{
										userComp = userComp.substring(0,userComp.indexOf(":"));
									}
									xx.add("Host_system:" + userComp + ":NULL");
								}
							}
						}
					}
				}
				servers = xx;
			}
			if(!showAllTypes && showAllComps)
			{
				List xx = new LinkedList();
				if(selectedCompType.equals(vmType))
				{
					//To bring the new and old servers after vmotion.
					Hashtable vmHostMap = EgLastMeasureThread.vmMapDbForHistory;

					String[] comp_name_arr=discInfo.getAllServersOfType(selectedCompType);
					for(int a =0; a < a_userVMs.size();a++)
					{
						String vm = (String)a_userVMs.get(a);
						if(vmHostMap!=null)
						{
							ArrayList hosts = (ArrayList)vmHostMap.get(vm);
							String user_vm_host = user.getVMHost(vm);
							if(user_vm_host != null && user_vm_host.trim().length() > 0)
							{
								String host = user_vm_host;
								String comp = host.substring(0,host.lastIndexOf(":"));
								String type = host.substring(host.lastIndexOf(":")+1);
								String forServer = type+":"+comp;
								serverNames.add(comp);
								serverTypes.add(type);
								xx.add(forServer);
							}
							else if(hosts!=null)
							{
								for(int h=0; h < hosts.size();h++)
								{
									String host = (String)hosts.get(h);
									String comp = host.substring(0,host.lastIndexOf(":"));
									String type = host.substring(host.lastIndexOf(":")+1);
									String forServer = type+":"+comp;
									serverNames.add(comp);
									serverTypes.add(type);
									xx.add(forServer);
								}
							}
							else
							{
								newServers.addAll(user.getOnlyVMServers());
								if(newServers!=null && newServers.size() >0)
								{
									for(int n=0; n < newServers.size();n++)
									{
										String host = (String)newServers.get(n);
										String type = host.substring(0,host.indexOf(":"));
										String comp = host.substring(host.indexOf(":")+1);
										serverNames.add(comp);
										serverTypes.add(type);
										xx.add(host);
									}
								}
							}
						}
					}
				
				}
				else
				{
					serverTypes.add(selectedCompType);
					serverTypes.add(Server.HOST_SYSTEM);
				}

				
				if(!selectedCompType.equals(vmType))
				{
					String[] comp_name_arr=discInfo.getAllServersOfType(selectedCompType);
					List comp_name_list=new ArrayList();
					List comp_name_host_list = new LinkedList();
					if(comp_name_arr!=null && comp_name_arr.length>0)
					{
						comp_name_list=Arrays.asList(comp_name_arr);
						comp_name_host_list = Server.getHostSystems(comp_name_list, true);
					}

					// get only servers of the type we want
					

					for (int r=0; r<servers.size(); r++)
					{
						String ss = (String) servers.get(r);
						int ind = ss.indexOf(":");
						if (ind >= 0)
						{
							//added by chandrasekhar to add Hostsystem to servers.
							String t_ss = "";
							String typ = ss.substring(0,ind);
							if(!selectedCompType.equals("Host_system"))
							{
								t_ss=ss;
								ss = ss.substring(ss.indexOf(":")+1,ss.length());
								if (!serverTypes.contains(typ))
									continue;
								xx.add(t_ss);
								// for host system
								if(ss.indexOf(":") > 0)
								{
									ss = ss.substring(0,ss.indexOf(":"));
								}
								xx.add("Host_system:" + ss + ":NULL");
							}
							else
							{
								t_ss = ss;

								ss = ss.substring(ss.indexOf(":")+1,ss.length());
								if(selectedCompType.equals("Host_system"))
								{
									if(ss.indexOf(":") > 0)
									{
										ss = ss.substring(0,ss.indexOf(":"));
									}
								}
								if(serverNames.contains(ss + ":NULL"))
								{
									xx.add("Host_system:" + ss + ":NULL");
								}
							}
						}
					}
				}
				servers = xx;
				logToTmpFile("INFO","","Servers for this User for compType " +selectedCompType+ " = "+servers);
			}

			if(!showAllComps && !showAllTypes)
			{
				List xx = new LinkedList();
				if(selectedCompType.equals(Server.HOST_SYSTEM))
				{
					serverTypes.add(Server.HOST_SYSTEM);
				}
				else
				{
					if(!selectedCompType.equals(vmType))
					{
					serverTypes.add(selectedCompType);
					serverTypes.add(Server.HOST_SYSTEM);
					}
					else
					{
						//Populate serverTypes and serverNames for vm
						//Type - VM , SelComp -> a VM
						//It may contain not only the current reporting host all other hosts
						//too which were initially assigned.
						Hashtable vmHostMap = EgLastMeasureThread.vmMapDbForHistory;
						if(vmHostMap!=null && vmHostMap.containsKey(selectedCompName))
						{
							ArrayList hosts = (ArrayList)vmHostMap.get(selectedCompName);
								String user_vm_host = user.getVMHost(selectedCompName);
								if(user_vm_host != null && user_vm_host.trim().length() > 0)
								{
									String host = user_vm_host;
									String comp = host.substring(0,host.lastIndexOf(":"));
									String type = host.substring(host.lastIndexOf(":")+1);
									String forServer = type + ":" + comp;
									serverNames.add(comp);
									serverTypes.add(type);
									xx.add(forServer);
								}
								else if(hosts!=null)
								{
										for(int h=0; h < hosts.size();h++)
										{
											String host = (String)hosts.get(h);
											String comp = host.substring(0,host.lastIndexOf(":"));
											String type = host.substring(host.lastIndexOf(":")+1);
											String forServer = type + ":" + comp;
											serverNames.add(comp);
											serverTypes.add(type);
											xx.add(forServer);
										}
									}
									else
									{
										newServers.addAll(user.getOnlyVMServers());
										if(newServers!=null && newServers.size() >0)
										{
											for(int n=0; n < newServers.size();n++)
											{
												String host = (String)newServers.get(n);
												String type = host.substring(0,host.indexOf(":"));
												String comp = host.substring(host.indexOf(":")+1);
												serverNames.add(comp);
												serverTypes.add(type);
												xx.add(host);
											}
										}
									}
						}

					}
				}

				String search = ":" + selectedCompName;
				if(!selectedCompType.equals(vmType))
				{
					int ind = selectedCompName.indexOf(":");
					if (ind >= 0)
					{
						//String s = selectedCompName.substring(0,ind);
						//serverNames.add(s+":NULL");
						serverNames.add(selectedCompName);
					}
					else
					{
				
						selectedCompName = selectedCompName + ":NULL";
						serverNames.add(selectedCompName);
					}
					
					for (int r=0; r<servers.size(); r++)
					{
						String ss = (String) servers.get(r);
						ind = ss.indexOf(":");
						
						if (ind >= 0)
						{
							String t_ss = "";
							String typ = ss.substring(0,ind);
							if(selectedCompType!=null && !selectedCompType.equals("Host_system"))
							{
								t_ss = ss;
								ss = ss.substring(ss.indexOf(":")+1,ss.length());
								if (!serverTypes.contains(typ))
									continue;
								if(serverNames.contains(ss.trim()))
								{
									xx.add(t_ss);
									// for host system
									if(ss.indexOf(":") > 0)
									{
										ss = ss.substring(0,ss.indexOf(":"));
									}
									xx.add("Host_system:" + ss + ":NULL");
									//---end---
								}
							}
							else
							{
								t_ss = ss;

								ss = ss.substring(ss.indexOf(":")+1,ss.length());
								if(selectedCompType.equals("Host_system"))
								{
									if(ss.indexOf(":") > 0)
									{
										ss = ss.substring(0,ss.indexOf(":"));
									}
								}
								if(serverNames.contains(ss + ":NULL"))
								{
									xx.add("Host_system:" + ss + ":NULL");
								}
							}
						}
					}
				}
				servers = xx;
			}
			if(selectedCompType.equalsIgnoreCase("Host_system") || selectedCompType.equalsIgnoreCase("Component Type (Optional)"))
			{
				List HostSysServers = new LinkedList();
				if(hasAllComponentAccess || vmAssigned)
				{
					List xx = Server.getHostSystems(servers, true);
					for (int r=0; r<xx.size(); r++)
					{
					String s = (String) xx.get(r);
					s =Server.HOST_SYSTEM+":"+s;
					if (!HostSysServers.contains(s))
					HostSysServers.add(s);
				}
				HostSysServers.addAll(servers);
				logToTmpFile("INFO","","Host_System servers  = "+HostSysServers);
				servers = HostSysServers;
				}
			}
		}
		String ctypes = "";
		if (serverTypes.size() > 0)
			ctypes = StringUtils.getArrayAsString(serverTypes.toArray(), '\'');
		String cnames = "";
		if (serverNames.size() > 0)
			cnames = StringUtils.getArrayAsString(serverNames.toArray(), '\'');

		
		List serversWithHost = null;
		if (selectedCompName!=null || selectedCompType.equals(Server.HOST_SYSTEM) || selectedCompType.equalsIgnoreCase("Component Type (Optional)"))
		{
			/*
			 * When a component name is selected, the component type will not be known
			 */
			serversWithHost = Server.getServersWithHostIp(serverNames, false);
		}
		else
		{
			serversWithHost = Server.getServersWithHostIp(serverNames, true);
		}
		
		nameList = StringUtils.getArrayAsString(serversWithHost.toArray(), '\'');
		typeList = StringUtils.getArrayAsString(serverTypes.toArray(), '\'');
		
		//Added by Chnadrasekhar to add Host system type comps.
		String selCompName=com.egurkha.util.StringUtils.replace(cnames,"'","");
		if(selCompName!=null && selCompName.indexOf(":")!=-1)
		{
			String temp_compname=selCompName.substring(0,selCompName.indexOf(":"));
			cnames+=",'"+temp_compname+":NULL'";
		}//ended here..
		boolean reverseList = false;

		EgDbAdapterUI egDb = EgDbAdapterTypeUI.getObject();
		String status = egDb.setConnection();
		try
		{
			//if (eventCount == 0)
			{
				//If selected Type is VM - > send vm list
				//If selected Name is a VM - > send only that vm.
				//If show All Types - > send vm list.

				//eventCount has been calculated along with data retrieval
				//eventCount = getAckCount(servers, cnames, ctypes, ackuserId, ackorDelete, startTime, endTime, alarmOption, egDb,vmUserCompList,dispAll,hasVMs,user,selectedCompType,selectedCompName,showAllTypes,showAllComps);
				//getting data and eventCount
				if(showEventHistory)
					history = getAckHistory(servers, cnames, ctypes, ackuserId, ackorDelete, startTime, endTime, null,offsetCount, alarmOption, !reverseList, egDb,vmUserCompList,dispAll,hasVMs,user,selectedCompType,selectedCompName, showAllTypes, showAllComps);
				else
					history = getAckHistoryofAlarms(servers, cnames, ctypes, ackuserId, ackorDelete, startTime, endTime, null,offsetCount, alarmOption, !reverseList, egDb,vmUserCompList,dispAll,hasVMs,user,selectedCompType,selectedCompName, showAllTypes, showAllComps);
				EgTablesInfo tablesInfo = new EgTablesInfo(EgConstants.MANAGER);
				EgTestInfo tokInfo = new EgTestInfo(EgConstants.MANAGER);
				ArrayList aList=new ArrayList();
				int count_noduplicates=0;
				List history2 = new LinkedList();
				//calculating eventCount
				if(history!=null && history.size()>0)
				{
					Hashtable alertParams = new Hashtable();
					if(EgInstallInfo.isSuperManager)
					{
						for (Iterator i=history.iterator(); i.hasNext();)
						{
							String[] row = (String[])i.next();
							for(int p=0;p<row.length;p=p+13)
							{
								String info = "";
								boolean rowDisp = true;
								String
								comp_info=discInfoHelper.getCompTypeForHostSystem(row[5],row[6],row[8],hasAllComponentAccess,mappingInfo,userCompList);
								info = row[7];
								StringBuffer temp_dec_key = new StringBuffer();
								temp_dec_key.append(row[8]);
								temp_dec_key.append(EgConstants.COLON);
								temp_dec_key.append(row[9]);
								alertParams = new Hashtable();
								alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(row[5]));
								alertParams.put("$componentName",Server.getServerNameWithoutPort(row[6], false));
								if(row[7]!=null && row[7].trim().length()>1){
									if(row[7].startsWith("+"))
										alertParams.put("$info",row[7].substring(1));
									else
										alertParams.put("$info",row[7]);
								}
								alertParams.put("appendTag",new Boolean(false));
								String temp_description = tablesInfo.getMeasureAlert(temp_dec_key.toString(),row[7],thisLanguage,alertParams);
								if(temp_description != null && temp_description.indexOf("~!~") != -1){
									temp_description = temp_description.substring(0,temp_description.indexOf("~!~"));
								}
								String temp_compName=Server.getServerNameWithoutPort((String)row[6], false);
								String comp_str=row[1]+":"+row[2]+":"+row[3]+":"+row[4]+":"+comp_info+":"+temp_compName+":"+temp_description+":"+row[8];
								if(aList!=null && !aList.contains(comp_str))
								{
									aList.add(comp_str);
									count_noduplicates++;
									history2.add((String[])row);
								}
								else
								{
									continue;
								}
							}
						}
					}
					else
					{
						for (Iterator i=history.iterator(); i.hasNext();)
						{
							String[] row = (String[])i.next();
							//added by Chandrasekhar to get real component type for hostsystem
							for(int p=0;p<row.length;p=p+13)
							{
								/*boolean isVM = false;
								String hostForVM = row[4]+":"+row[5];
								List thisUser_servers = new LinkedList();
								List thisUser_hservers = new LinkedList();
								String s_user = row[p+1];
								ErUserData userData = new ErUserData(s_user,false);
								User selectedUser = null;
								List thisUser_a_userVMs = new LinkedList();

								if(userData!=null)
								{
									selectedUser=userData.usr;
									if(selectedUser==null)
									{
										selectedUser = userData.getUser(s_user);
									}
									thisUser_servers = selectedUser.getServers(false);
									thisUser_hservers = getHostSystemServers(thisUser_servers);
								}*/
								String info = "";
								boolean rowDisp = true;
								String
								comp_info=discInfoHelper.getCompTypeForHostSystem(row[4],row[5],row[7],hasAllComponentAccess,mappingInfo,userCompList);
								info = row[6];
								//Added by chandrasekhar.p to remove duplicate deletion alarms in deletion page
								StringBuffer temp_dec_key = new StringBuffer();
								temp_dec_key.append(row[7]);
								temp_dec_key.append(EgConstants.COLON);
								temp_dec_key.append(row[8]);
								alertParams = new Hashtable();
								alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(row[4]));
								alertParams.put("$componentName",Server.getServerNameWithoutPort(row[5], false));
								if(row[6]!=null && row[6].trim().length()>1){
									if(row[6].startsWith("+"))
										alertParams.put("$info",row[6].substring(1));
									else
										alertParams.put("$info",row[6]);
								}
								alertParams.put("appendTag",new Boolean(false));
								String temp_description = tablesInfo.getMeasureAlert(temp_dec_key.toString(),row[6],thisLanguage,alertParams);
								if(temp_description != null && temp_description.indexOf("~!~") != -1){
									temp_description = temp_description.substring(0,temp_description.indexOf("~!~"));
								}
								String temp_compName=Server.getServerNameWithoutPort((String)row[5], false);
								String comp_str=row[0]+":"+row[1]+":"+row[2]+":"+row[3]+":"+comp_info+":"+temp_compName+":"+info+":"+temp_description+":"+row[7];
								
								if(aList!=null && !aList.contains(comp_str))
								{
									aList.add(comp_str);
									count_noduplicates++;
									history2.add((String[])row);
								}
								else
								{
									continue;
								}
							}
						}
					}
				}

				if(history2!=null)
				{
					history=new LinkedList();
					history=history2;
				}
				eventCount=count_noduplicates;
				//If has VMs get eventCount according to the selection
				if("ALL".equalsIgnoreCase(request.getParameter("eventsPerPage")))
				{
					maxPageItems = eventCount;
				}
				printPage1=request.getParameter("printPage");
				if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
				{
					maxPageItems = eventCount;
				}
				logToTmpFile("INFO","","Event Count for the selection is " + eventCount);
			}
			
			if (eventCount > 0)
			{
				/*if (offsetCount > eventCount/2)
				{
					reverseList = true;
					offsetCount = eventCount - offsetCount;
				}
				else
				{
					reverseList = false;
					offsetCount += maxPageItems;
				}*/
				
				if (offsetCount > eventCount/2)
				{
					reverseList = true;
					offsetCount = eventCount - offsetCount;
					Collections.reverse(history);
					if (history.size() > offsetCount)
					{
						history.subList(offsetCount , history.size()).clear();
					}
					
				}
				else
				{
					reverseList = false;
					offsetCount += maxPageItems;
					if (history.size() > offsetCount)
					{
						history.subList(offsetCount , history.size()).clear();
					}
				}
				String fromLink  =request.getParameter("fromLink");

					//history = getAckHistory(servers, cnames, ctypes, ackuserId, ackorDelete, startTime, endTime, null,offsetCount, alarmOption, !reverseList, egDb,vmUserCompList,dispAll,hasVMs,user,selectedCompType,selectedCompName, showAllTypes, showAllComps);

				// session objects created here which is used to store the request parameters needed for pdf and csv format

				String offset = Integer.toString(offsetCount);
				String ev_count = Integer.toString(eventCount);
								
				HashMap eventHist = new HashMap();
				
				eventHist.put("pdfheading",pdfHeading);
				eventHist.put("lst", lst);
				eventHist.put("servers",servers);
				eventHist.put("cnames", cnames);
				eventHist.put("ctypes", ctypes);
				eventHist.put("ackuserId",ackuserId);
				eventHist.put("ackorDelete",ackorDelete);
				eventHist.put("startTime", startTime);
				eventHist.put("endTime", endTime);
				eventHist.put("offsetCount", offset);
				eventHist.put("alarmOption", alarmOption);
				eventHist.put("user", (User)user);
				eventHist.put("showAll", new Boolean(showAll));
				eventHist.put("hasVMs", new Boolean(hasVMs));
				eventHist.put("selectedCompType", selectedCompType);
				eventHist.put("selectedCompName", selectedCompName);
				eventHist.put("showAllTypes", new Boolean(showAllTypes));
				eventHist.put("showAllComps", new Boolean(showAllComps));
				eventHist.put("vmUserCompList", vmUserCompList);
				eventHist.put("showEventHistory",new Boolean(showEventHistory));
				HashMap eventHistDB = new HashMap();

				eventHistDB.put("nameList",nameList);
				eventHistDB.put("typeList", typeList);
				eventHistDB.put("ackuserId",ackuserId);
				eventHistDB.put("ackorDelete",ackorDelete);
				eventHistDB.put("startTime", startTime);
				eventHistDB.put("endTime", endTime);
				eventHistDB.put("eventCount", ev_count);
				eventHistDB.put("alarmOption", alarmOption);
				
				session.setAttribute("eventdata", eventHist); //session object for all component access
				session.setAttribute("eventdatadb", eventHistDB); //session object for selected components
				session.setAttribute("eventCount", ev_count);

				int recordCount = history.size();
				if (recordCount > maxPageItems)
				{
					if (reverseList)
					{
						history.subList(0 , recordCount-maxPageItems).clear();
						Collections.reverse(history);
					}
					else 
					{
						
						history.subList(Math.min(offsetCount, recordCount), recordCount).clear();
						history.subList(0, offsetCount-maxPageItems).clear();
					}
				}
				else
				{
					 // If the user directly goes to the last page
					if (reverseList)
					{
						Collections.reverse(history);
					}
				}
				
				maxWidth = 20;
				if (allEvents)
				{
					maxWidth = 15;
				}
				all.add(history);
			}
			egDb.releaseConnection(false);
		}
		catch(Exception se)
		{
			egDb.releaseConnection(true);
		}
		finally
		{
			EgDbAdapterTypeUI.releaseObject(egDb);
		}
	}

if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
{
	String acknowledge1=request.getParameter("acknowledge");
	String Title="";
	if(acknowledge1!=null)
	{
		if(acknowledge1.equalsIgnoreCase("Acknowledgement") || acknowledge1=="Acknowledgement")
		{
			Title="HISTORY OF ACKNOWLEDGEMENT";
		}
		else if(acknowledge1.equalsIgnoreCase("Deletion") || acknowledge1=="Deletion")
		{
			Title="HISTORY OF DELETION";
		}
	}
	String compTypeList2="";
	String compNameList2="";
	String compTypeList=request.getParameter("compTypeList");
	String compNameList=request.getParameter("compNameList");
	String ackUser1=request.getParameter("ackUser");
	String timeline1=request.getParameter("timeline");
	String alarmOption1=request.getParameter("alarmOption");
	//block starts for pdf
	Hashtable pdf_values=new Hashtable();
	List pdf_list=new LinkedList();
	
	if(compTypeList!=null && (compTypeList=="-1" || compTypeList.equals("-1")))
	{
		compTypeList2="Component type(Optional)";
	}
	else
	{
		compTypeList2=mappingInfo.getComponentTypeDescription(compTypeList);
		
	}
	if(compNameList!=null && (compNameList=="-1" || compNameList.equals("-1")))
	{
		compNameList2="Component Name(Optional)";
	}
	else
	{
		compNameList2=compNameList;
	}
	
	pdf_values.put("Type",compTypeList2);
	pdf_list.add("Type");
	pdf_values.put("Name",compNameList2);
	pdf_list.add("Name");
	if(ackUser1=="-1" || ackUser1.equals("-1"))
	{
		ackUser1="User Id(Optional)";
	}
	else
	{
		String displayUser = ackUser1;
		if (displayUser != null && displayUser.indexOf("/Grp/") != -1)
		{
			String temp_Usr = egUI.getValue("DBUSER_USER_MAP",displayUser);
			if (temp_Usr != null && temp_Usr.length() > 0)
			{
				displayUser = temp_Usr;
			}
			String grpDelimiter = "/Grp/";
			int idx = displayUser.indexOf(grpDelimiter);
			String str_uname_A = displayUser.substring(0,idx);
			int nextIdx = idx + grpDelimiter.length();
			String str_uname_B = displayUser.substring(nextIdx);
			displayUser = str_uname_A + "/" + str_uname_B + " (Group)";
		}
		else if (displayUser.startsWith("samlsso/"))
		{
			String tmpUser = displayUser;
			int slshIdx = tmpUser.indexOf("/");
			displayUser = tmpUser.substring(slshIdx+1);
			displayUser = displayUser + " (SAML)";
		}
		ackUser1 = displayUser;
	}
	pdf_values.put("User",ackUser1);
	pdf_list.add("User");
	pdf_values.put("Timeline",timeline1);
	pdf_list.add("Timeline");
	
	//change to user format....
	
	String sTime = DateUtil.changeDateFormat(startTime,"MM/dd/yyyy HH:mm",currentDateFormat);
	String eTime = DateUtil.changeDateFormat(endTime,"MM/dd/yyyy HH:mm",currentDateFormat);
	EgTimeZoneConverter converterStart = new EgTimeZoneConverter(sTime , u_ser);
	sTime = converterStart.getDate(false)+" "+converterStart.getHour()+":"+converterStart.getMinute();
	EgTimeZoneConverter converterEnd = new EgTimeZoneConverter(eTime , u_ser);
	eTime = converterEnd.getDate(false)+" "+converterEnd.getHour()+":"+converterEnd.getMinute();
	

	pdf_values.put("StartTime",sTime+" "+shortTZ);
	pdf_values.put("EndTime",eTime+" "+shortTZ);
	pdf_list.add("StartTime");
	pdf_list.add("EndTime");
	if(acknowledge1.equalsIgnoreCase("Acknowledgement") || acknowledge1=="Acknowledgement")
	{
		pdf_values.put("Alarm type",alarmOption1);
		pdf_list.add("Alarm type");
	}
	String mainTitle =(String)session.getAttribute("REPORT_NAME");
	if(mainTitle!=null && mainTitle.trim().length()>0)
	{
		mainTitle=mainTitle.replaceAll("_"," ");
		mainTitle=mappingInfo.getTextDescription("monitor.history."+mainTitle);
	}
	IniUI img1=IniUI.getInstance();
	String logo=img1.getMonitorHomeLogo();
	if(img1.isHKTThemeEnabled())
	{
		logo = img1.getHKTReporterLogo();
	}
	if(logo!=null && logo.trim().length()>0)
	{
%>
<table border="0" cellspacing="0" cellpadding="2" width="93%" style="table-layout:fixed">
	<tr>
		<td width="100%" align="center" height="100%" valign="top">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			
			<td align="left" width="30%"><img src="<%=logo%>" border="0"></td>

			<td width="70%" align="right" valign="bottom">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			
			<tr>
			<td align="center"><b font size="24"><%//=mainTitle%></b></td>
			</tr>
			<tr>
			<td><img src="/final/config/images/spacer.gif" border="0"></td>
			</tr>
			<tr>
			<td><img src="/final/config/images/spacer.gif" border="0"></td>
			</tr>
			<tr>
			<td><img src="/final/config/images/spacer.gif" border="0"></td>
			</tr>
			</table>
			</td>
			</tr>
			</table>
		</td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="border-bottom:1px solid #ccc;">
	<tr>
		<th nowrap class="data_headbg"  id="inner_subhead" align="left" height="24"> &nbsp;
		<%=Title%> </th>
		<td align="right" class="data_headbg" id="inner_subhead"><a href="javascript:void(0);"></a>
		</td>
	</tr>
	</table>
		<table cellspacing="0" cellpadding="0" align="center" border="0" width="100%" class ="data_border"  id="eg_cellbglight">
				
				<!--<tr>
					<td align="center" class="<%=fontStyle%>" id="eg_bodybg" height="5" colspan="12" nowrap> <font style="font-size: 17px; font-family: Arial,Verdana; letter-spacing: 1px;">&nbsp;<b><%=Title%></b>
					</td>
				</tr>-->
			<%
	}
			int temp=0,temp1=0;
			Iterator itera=pdf_list.iterator();
			while(itera.hasNext())
			{
					String key=(String)itera.next();
					String value=(String)pdf_values.get(key);
					temp++;
					temp1++;
					if(temp==4 || temp==1)
					{
						temp=1;
			%>
				<tr>
					<td id="eg_innerbg" nowrap   align="left"><b></b></td>
					<td id="eg_innerbg" class="formLabel" nowrap  height="22"><b><%=key%></b> </td>
					<td id="eg_innerbg" class="formLabel" nowrap   align="left"><b>:</b></td>
					<td id="eg_innerbg" class="formValue" nowrap 
					width="150" align="left"><%=value%>&nbsp;
					</td>
					
				<%
					}
					else
					{
						%>
					<td id="eg_innerbg" nowrap   align="left"><b></b></td>
					<td id="eg_innerbg" class="formLabel" nowrap  height="22"><b><%=key%></b> </td>
					<td id="eg_innerbg" class="formLabel" nowrap   align="left"><b>:</b></td>
					<td id="eg_innerbg" class="formValue" nowrap 
					width="150" align="left"><%=value%>&nbsp;
					</td>
					
					<%
						if(temp==3 || temp1==pdf_values.size())
						{
					%>
							</tr>
					<%
						}
					}
			}
		%>
				<tr>
					<td id="eg_blankspace" height="5" colspan="7" nowrap>&nbsp;</td>
				</tr>
			</table>
			<br></br>
			
<%
}
%>

		<div id="my_div" class="div_scroll" style="width:100%;">
			<table align="left" cellspacing="0" cellpadding="0" width="100%" border="0">
				<tr>
					<td width="100%"  align="center">
<%
	if (eventCount > 0 && all!=null) 
	{
		size = all.size();
		//---Configure DateTimeTokenizer for results
		DateTimeTokenizer dtt = new DateTimeTokenizer();
		dtt.setDateFormat(DateTimeTokenizer._YMD);
		dtt.setDateSeparator(DateTimeTokenizer.HYPHEN_SEPARATOR);
		dtt.setTimeFormat(DateTimeTokenizer.HMS);
		dtt.setYearAsYY(false);
		String selectedType = null;
		String selectedName = null;
		if (!StringUtils.isNull(selectedCompType))
		{
			selectedType = "type";
		}
		else if (!StringUtils.isNull(selectedCompName))
		{
			selectedName = "name";
		}
%>
		<!-- Indexer taglib begins here -->
		<id:indexer
		isOffset = "<%= true %>"
		index = "<%= index %>"
		items = "<%= eventCount%>"
		maxPageItems = "<%= maxPageItems %>"
		maxIndexPages = "<%= maxIndexPages %>"
		export = "offset,currentPageNumber=pageNumber"
		scope = "request">

		<!-- Parameters for the request query string -->
		<id:param name="eventsCount" value="<%=String.valueOf(eventCount)%>" />
		<id:param name="compName" value='<%=EgURLEncoder.encode((selectedCompName==null?"":selectedCompName),"UTF-8")%>' />
		<id:param name="compType" value='<%=EgURLEncoder.encode((selectedCompType==null?"":selectedCompType),"UTF-8")%>' />
		<id:param name="ackUser" value='<%=EgURLEncoder.encode((ackuserId==null?"":ackuserId),"UTF-8")%>' /> 
		<id:param name="ackorDeleteComp" value='<%=EgURLEncoder.encode((ackorDelete==null?"":ackorDelete),"UTF-8")%>' /> 
		<id:param name="startDate" value="<%=startTime %>" /> 
		<id:param name="endDate" value="<%=endTime %>" /> 
		<id:param name="alarmOption" value="<%=alarmOption%>" />
		<id:param name="eventsPerPage" value="<%=eventsPerPage%>" />
		<!-- save Indexer offset during form changes -->
						<table width="100%" align="center" cellspacing="0" cellpadding="0" border="0" height="100%">
						<tbody>
							<tr>
								<td  width="100%">
								<!--<form method="POST" name="Event" style="margin:0px">-->
									<table width="100%" cellspacing="0" cellpadding="4" align="center" border="0">
										<tbody><tr>
<%
		int start = offset.intValue();
%>
											<th id="eg_cellbglight" class="eg_8bold" align="left"  width="95%" nowrap>&nbsp;&nbsp;<%=start+1%>&nbsp;<egui:intnl text="monitor.history.to"/>&nbsp;<%=Math.min(start+maxPageItems,eventCount)%> &nbsp;<egui:intnl text="monitor.history.of"/>&nbsp;<%=eventCount%>&nbsp;<egui:intnl text="monitor.Ack.records found"/>&nbsp; </th>
										</tbody></tr>
									</table>
								</td>
							</tr>
							<tr>
							<td  align="center" width="100%" id="white_bg">
								<div id="div_scroll" style="width:100%;overflow:auto;overflow-x:auto;overflow-y:auto;" align="center">
									<table align="center" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-left-width:0px; border-right-width:0px">
										<tbody><tr>
											<td width="100%" align="center" rowspan="2"><input type="hidden" name="indexeroffset" value="<%=offset%>">
											<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
													<tbody><tr>
														<td align="center" >
															<table align="center" cellspacing="0" cellpadding="0" border="0" style="table-layout:auto" width="100%" class="printTable">
															<col width="20px"><col width="50px"><col width="25%"><col width="100px"><col width="80px"><col width="80px"><col width="30%"><col width="100px">
																<thead>
																<tr>
																	<th id="eg_cellbglightdark" class="printTableHeader">
																	<img src="/final/monitor/eg_images/spacer.gif" width="18" height="21"></th>
																	<th  nowrap="nowrap" id="eg_cellbglightdark" style="border-top-width:0px;border-left-width:0px" align="center">&nbsp;<egui:intnl text="monitor.Ack.User"/>&nbsp;</th>
<%
																	if(ackorDelete!=null && (ackorDelete.equalsIgnoreCase("Acknowledgement") || ackorDelete.equalsIgnoreCase("Unacknowledgement")))
																	{
%>
																		<th nowrap id="eg_cellbglightdark" style="border-top-width:0px;border-left-width:0px;" align="center"><egui:intnl text="monitor.Ack.Acknowledgement"/></th>
<%
																	}
																	else
																	{
%>
																		<th  nowrap id="eg_cellbglightdark"style="border-top-width:0px;border-left-width:0px;" align="center"><egui:intnl text="monitor.Ack.Reason for Deletion"/></th>
<%
																	}
																	if(ackorDelete!=null && (ackorDelete.equalsIgnoreCase("Acknowledgement") || ackorDelete.equalsIgnoreCase("Unacknowledgement")))
																	{
%>
																		<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.Ack.Ack Time"/></th>
<%
																	}
																	else
																	{
%>
																		<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.Ack.Deleted Time"/></th>
<%
																	}
%>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.common.Component Type"/></th>
<%																		if(hasVMs)
																		{
																			if(onlyVMAssigned && !vmAssigned)
																			{
%>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.common.VM Name"/></th>
<%
																			}
																			else
																			{
%>
																					<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.common.Component Name/VM Name"/></th>
<%																			}
																		}
																		else
																		{
																			if(hasAllComponentAccess)
																			{
%>
																					<th  id="eg_cellbglightdark" class="printTableHeader" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Component Name/VM Name"/></th>

<%																			}
																			else
																			{
%>
																		
																		<th  id="eg_cellbglightdark"  nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Comp Name"/></th>

<%	
																			}
																		}
%>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Description"/></th>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Test"/></th>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Start Time"/></th>
																	<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Duration"/></th>
<%
																	if(showMgrId)
																	{
%>
																		<th  nowrap id="eg_cellbglightdark" nowrap="nowrap"  style="border-top-width:0px;border-left-width:0px" align="center"><egui:intnl text="monitor.history.Manager ID"/></th>
<%
																	}
%>

																	
																</tr>
																</thead><tbody>
<%
		int historyCount = 0;
		EgTablesInfo tablesInfo = new EgTablesInfo(EgConstants.MANAGER);
		EgTestInfo tokInfo = new EgTestInfo(EgConstants.MANAGER);
		ArrayList aList=new ArrayList();
		Hashtable userObjHash=new Hashtable();
		if(history!=null && history.size()>0)
		{
			for (Iterator i=history.iterator(); i.hasNext();)
			{
				String[] row = (String[])i.next();
				String manager_id=null;
				if(EgInstallInfo.isSuperManager)
				{
					manager_id=row[0];
					String[] dummyRow = new String[row.length-1];
					System.arraycopy(row, 1, dummyRow, 0, dummyRow.length);
					row=dummyRow;
				}
				//added by Chandrasekhar to get real component type for hostsystem
				for(int p=0;p<row.length;p=p+13)
				{
						boolean isVM = false;
						String hostForVM = row[4]+":"+row[5];
						List thisUser_servers = new LinkedList();
						List thisUser_hservers = new LinkedList();
						String s_user = row[p+1];
						
						User selectedUser = null;
						List thisUser_a_userVMs = new LinkedList();
						if(userObjHash!=null && userObjHash.containsKey(s_user))
						{
							selectedUser = (User)userObjHash.get(s_user);
							thisUser_hservers = (List)userObjHash.get(s_user+"_Servers");
						}
						else
						{
							ErUserData userData = new ErUserData(s_user,false);
							if(userData!=null)
							{
								selectedUser=userData.usr;
								if(selectedUser==null)
								{
									selectedUser = userData.getUser(s_user);
								}
								if(selectedUser!=null)
								{
									userObjHash.put(s_user,(User)selectedUser);
									thisUser_servers = selectedUser.getServers(false);
									thisUser_hservers = getHostSystemServers(thisUser_servers);

									userObjHash.put(s_user+"_Servers",(List)thisUser_hservers);
								}
							}
						}

						String info = "";
						boolean rowDisp = true;
						String
						comp_info=discInfoHelper.getCompTypeForHostSystem(row[4],row[5],row[7],hasAllComponentAccess,mappingInfo,userCompList);
						info = row[6];
						//Added by chandrasekhar.p to remove duplicate deletion alarms in deletion page
						StringBuffer temp_dec_key = new StringBuffer();
						temp_dec_key.append(row[7]);
						temp_dec_key.append(EgConstants.COLON);
						temp_dec_key.append(row[8]);
			
						//custom problem alert description
						String temp_description = "";
						int len = 0;
						String tmpInfo = com.egurkha.util.StringUtils.replace(row[6], "+", "").trim();
						if(isCustomAlertMessages)
						{
							/**
							* row[4]-compType
							* row[7]-testName 
							* row[8]-measure
							**/
							String layer = tablesInfo.getRelevantLayer(row[4], row[7], row[8]);
							temp_description = tablesInfo.getCustomMeasureAlert(temp_dec_key.toString(), row[6], thisLanguage);
							len = temp_description.trim().length();
							if(temp_description != null && len > 0){
								temp_description = replaceMsg (temp_description, Server.getServerNameWithoutPort(row[5], false), mappingInfo.getComponentTypeDescription(row[4]), "-", mappingInfo.getLabelDescription(row[0]), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(row[7]), tmpInfo, mappingInfo.getMeasureDescription(row[7], row[8]), "");
							}
						} 
						if(temp_description == null || len == 0 || temp_description.startsWith(row[8])) {
							Hashtable alertParams = new Hashtable();
							alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(row[4]));
							alertParams.put("$componentName",Server.getServerNameWithoutPort(row[5], false));
							if(row[6]!=null && row[6].trim().length()>1){
								if(row[6].startsWith("+"))
									alertParams.put("$info",row[6].substring(1));
								else
									alertParams.put("$info",row[6]);
							}
							alertParams.put("appendTag",new Boolean(false));
							 temp_description = tablesInfo.getMeasureAlert(temp_dec_key.toString(), row[6], thisLanguage,alertParams);
							 if(temp_description != null && temp_description.indexOf("~!~") != -1){
								temp_description = temp_description.substring(0,temp_description.indexOf("~!~"));
							}
						}

						String temp_compName=Server.getServerNameWithoutPort((String)row[5], false);
						String comp_str=row[0]+":"+row[1]+":"+row[2]+":"+row[3]+":"+comp_info+":"+temp_compName+":"+info+":"+temp_description+":"+row[7];
						if(aList!=null && !aList.contains(comp_str))
						{
							aList.add(comp_str);
						}
						else
						{
							continue;
						}
						//ended here
						//It is a vm so check if it is assigned to the user.<!--  -->			
						if(info!=null && info.startsWith("+"))
						{
							info=info.substring(1);
						}
						if(info.indexOf(":") > -1)
						{
							info = info.substring(0,info.indexOf(":"));
						}
						if(!hasAllComponentAccess)
						{
							if(vmUserCompList!=null && (vmUserCompList.size() > 0 && !vmUserCompList.contains(hostForVM)) || (onlyVMAssigned && !vmAssigned))// || onlyVMAssigned)
							{
								
								if(!vmUserCompList.contains(hostForVM))
								{
									isVM = true;
									if(a_userVMs!=null && a_userVMs.size() > 0)
									{
										if(showAllTypes && showAllComps)
										{
											if(!hostForVM.startsWith("Host_system"))
											{
												if(!a_userVMs.contains(info))
												{
													rowDisp = false;
												}
											}
											else
											{
												rowDisp = false;
											}
										}
										else if(showAllTypes && !showAllComps)
										{
												
											if(selectedCompName!=null && selectedCompName.equals(info))
											{
												if(!a_userVMs.contains(info))
												{
													rowDisp = false;
												}
												else
												{
													rowDisp = true;
													isVM = true;
												}
											}
											else
											{
												rowDisp = false;
											}
										}
										else if(!showAllTypes && showAllComps)
										{
											if(selectedCompType!=null && selectedCompType.equals(vmType))
											{
												
												if(!a_userVMs.contains(info))
												{
													rowDisp = false;
												}
											}
										}
										else if(!showAllTypes && !showAllComps)
										{
											if(selectedCompType!=null && selectedCompType.equals(vmType))
											{
												
												if(selectedCompName!=null && selectedCompName.equals(info))
												{
													
													if(!a_userVMs.contains(info))
													{
														rowDisp = false;
													}
												}
												else
												{
													rowDisp = false;
												}
											}
										}
									}
									else
									{
										isVM = false;
										rowDisp = true;
									}
								}
							}
							else
							{
								//what if it is a virtual server & vm combination.
								//the vs will have the vm as well as it will be assigned separately.

								
								if(showAll)
								{
									if(vmUserCompList!=null && vmUserCompList.size() > 0)
									{
										if(vmUserCompList.contains(hostForVM))
										{
											rowDisp = true;
											isVM = false;
										}
									}
								}
								else if(showAllTypes && !showAllComps)
								{
									if(vmUserCompList!=null && vmUserCompList.size() > 0)
									{
										for(int u = 0; u < vmUserCompList.size(); u++)
										{
											String server = (String)vmUserCompList.get(u);
											if(server!=null && server.indexOf(selectedCompName) >-1)
											{
												rowDisp = true;
												isVM = false;
												break;
											}
											else
											{
												if(selectedCompName!=null && selectedCompName.equals(info))
												{
													if(!a_userVMs.contains(info))
													{
														rowDisp = false;
													}
													else
													{
														isVM = true;
													}
												}
			
												
											}
											
										}
									}
								}
								else if(!showAllTypes && !showAllComps)
								{
									if(selectedCompType!=null && selectedCompType.equals(vmType))
									{
										if(thisUser_hservers!=null && thisUser_hservers.size() > 0 && thisUser_hservers.contains(hostForVM))
										{
											rowDisp = false;
										}
										else
										{
											if(selectedCompName!=null && selectedCompName.equals(info))
											{
												
												if(!a_userVMs.contains(info))
												{
													rowDisp = false;
												}
											}
											else
											{
												rowDisp = false;
											}
											isVM=true;
										}
										
									}
									else
									{
										if(vmUserCompList.contains(hostForVM))
										{
											//Choose the user - comp type.
											if(thisUser_hservers!=null && thisUser_hservers.size() > 0 && thisUser_hservers.contains(hostForVM))
											{
												rowDisp = true;
												isVM = false;
											}
											else
											{
												rowDisp = false;
											}
											
										}
									}
								}
								else if(!showAllTypes && showAllComps)
								{
									if(selectedCompType!=null && selectedCompType.equals(vmType))
									{
										
										if(thisUser_hservers!=null && thisUser_hservers.size() > 0 && thisUser_hservers.contains(hostForVM))
										{

											rowDisp = false;
										}
										else
										{
											if(!a_userVMs.contains(info))
											{
												rowDisp = false;
												
											}
											isVM = true;
										}
										
										
									}
									else
									{
										if(vmUserCompList.contains(hostForVM))
										{
											if(thisUser_hservers!=null && thisUser_hservers.size() > 0 && thisUser_hservers.contains(hostForVM))
											{
												rowDisp = true;
												isVM = false;
											}
											else
											{
												rowDisp = false;
											}
										}
									}
								}

							}
						}
						if(!rowDisp)
						{
							continue;
						}
%>
															<id:item>
																<tr>
																	<td TITLE='<%=mappingInfo.getLabelDescription(row[0])%>'>
<%
																	if(row[9].equals("Deletion"))
																	{
%>
																		<img src="/final/images/Light/state20_<%=row[0]%>.png" border="0" height="20" width="20" >
<%																		
																	}
																	else if(row[9].equals("Acknowledgement"))
																	{
%>
																		<img src="/final/images/Light/alarmAck_<%=row[0]%>.png" border="0">
<%
																	}
																	else if(row[9].equals("Unacknowledgement"))
																	{
%>
																		<img src = "/final/monitor/eg_images/unAckImage.gif" border="0" />
<%
																	}
																	else
																	{
%>
																		&nbsp;
<%
																	}
					String displayUser = "";
					String ruser = row[p+1];
					realUser = row[10];
					if (realUser != null && !realUser.equalsIgnoreCase("null") && !ruser.equalsIgnoreCase(realUser))
					{
						if (ruser != null && ruser.indexOf("/Grp/") != -1)
						{
							String temp_Usr = egUI.getValue("DBUSER_USER_MAP",ruser);
							if (temp_Usr != null && temp_Usr.length() > 0)
							{
								ruser = temp_Usr;
							}
							String grpDelimiter = "/Grp/";
							int idx = ruser.indexOf(grpDelimiter);
							String str_uname_A = ruser.substring(0,idx);
							int nextIdx = idx + grpDelimiter.length();
							String str_uname_B = ruser.substring(nextIdx);
							ruser = str_uname_A + "/" + str_uname_B + " (Group)";
						}
						displayUser = realUser + " of " +ruser;
					}
					else
					{
						String temp_Usr = egUI.getValue("DBUSER_USER_MAP",ruser);
						if (temp_Usr != null && temp_Usr.length() > 0)
						{
							ruser = temp_Usr;
						}
						displayUser = ruser;
					}

					if (displayUser.startsWith("samlsso/"))
					{
						String tmpUser = displayUser;
						int slshIdx = tmpUser.indexOf("/");
						displayUser = tmpUser.substring(slshIdx+1);
						displayUser = displayUser + " (SAML)";
					}

					String tempDisplayUser = StringUtils.replace(displayUser,"<","&lt;");
					tempDisplayUser = StringUtils.replace(tempDisplayUser,">","&gt;");
%>
																	</td>
																	<td> <%=tempDisplayUser%></td>
																	<td> <%=row[p+2]%></td>
<%
					String displayDate="";
					if(row[3]!= null && !row[3].equals(""))
					{
						displayDate = DateUtil.changeDateFormat(row[3],"yyyy-MM-dd HH:mm:ss",currentDateFormat);
					}
					try
					{
						EgTimeZoneConverter converter = new EgTimeZoneConverter(displayDate , u_ser);
						displayDate = converter.getDateTime();
					}
					catch (Exception e) {}

%>

																	<td><%=displayDate%></td>

<%
						if ((selectedType == null) || (selectedType.equals("type")) && (selectedName == null) || selectedName.equals("name"))
						{
							//row[4]= mappingInfo.getComponentTypeDescription(row[4]);
							if (((String)row[5]).endsWith(EgConstants.NULL_PORT))
							{
								if(!isVM)
								{
								row[5] = Server.getServerNameWithoutPort((String)row[5], false);
								}
							}
							if(comp_info!=null)
							{
								if(comp_info.length()<15)
								{
									if(selectedUser!=null)
									{
										thisUser_a_userVMs = selectedUser.getOnlyVMs();
										if(thisUser_a_userVMs!=null)
										{
											if(thisUser_a_userVMs.size() > 0)
											{
												if(thisUser_a_userVMs.contains(info))
												{
													//This is a vm.
														comp_info=mappingInfo.getComponentTypeDescription("VM");
												}
												else
												{
													if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
													{
														//This is a vm.
														if(showAll)
															comp_info=mappingInfo.getComponentTypeDescription("VM");
													}
												}
											}
											
										}
									}
%>
										<td><%=comp_info%></td>
<%
								}
								else
								{
									int start_var=0;
									int end_var=0;
									String display_component="";
									String display_comp="";
									do
									{
										String display=comp_info.substring(0,14);
										int disp_length=display.length();

										if((comp_info.length() - end_var) > disp_length)
										{
											end_var=end_var+disp_length;
										}
										else
										{
											end_var=end_var + (comp_info.length() - end_var);
										}
										display_comp=comp_info.substring(start_var,end_var);
										if(display_comp!=null && display_comp.indexOf(" ")<0)
											display_component=display_component+display_comp + " ";
										else
											display_component=display_component+display_comp;
										start_var=end_var;
									}while(end_var<comp_info.length());
									
										if(selectedUser!=null)
										{
											thisUser_a_userVMs = selectedUser.getOnlyVMs();
											if(thisUser_a_userVMs!=null)
											{
												if(thisUser_a_userVMs.size() > 0)
												{
													 if(thisUser_a_userVMs.contains(info))
													{
														//This is a vm.
															display_component=mappingInfo.getComponentTypeDescription("VM");
													}
													else
													{
														if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
														{
															//This is a vm.
															if(showAll)
																display_component=mappingInfo.getComponentTypeDescription("VM");
														}
													}
												}
												
											}
										}
%>
										<td><%=display_component%></td>
<%
								}
							}
							if(row[5]!=null)
							{
								if(row[5].length()<15)
								{
									if(selectedUser!=null)
										{
											thisUser_a_userVMs = selectedUser.getOnlyVMs();
											if(thisUser_a_userVMs!=null)
											{
												if(thisUser_a_userVMs.size() > 0)
												{
													if(thisUser_a_userVMs.contains(info))
													{
														//This is a vm.
														row[5]=info;
													}
													else
													{
														if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
														{
															//This is a vm.
															if(showAll)
																row[5]=info;
														}
													}
													
												}
												
											}
										}
										if(isVM)
										{
									%>	
											<td><%=row[5]%></td>
									<%
										}
										else
										{
%>
								<td><%=row[5]%></td>

<%
										}
								}
								else
								{
									int start_var=0;
									int end_var=0;
									String display_component="";
									String display_comp="";
									do
									{
										String display=row[5].substring(0,14);
										int disp_length=display.length();
										if((row[5].length() - end_var) > disp_length)
										{
											end_var=end_var+disp_length;
										}
										else
										{
											end_var=end_var + (row[5].length() - end_var);
										}
										display_comp=row[5].substring(start_var,end_var);
										if(display_comp!=null && display_comp.indexOf(" ")<0)
											display_component=display_component+display_comp + " ";
										else
											display_component=display_component+display_comp;
										start_var=end_var;
									}while(end_var<row[5].length());
									if(selectedUser!=null)
									{
										thisUser_a_userVMs = selectedUser.getOnlyVMs();
										if(thisUser_a_userVMs!=null)
										{
											if(thisUser_a_userVMs.size() > 0 )
											{
												if(thisUser_a_userVMs.contains(info))
												{
													//This is a vm.
													display_component=info;
												}
												else
												{
													if(thisUser_hservers!=null && (thisUser_hservers.size() ==0 || !thisUser_hservers.contains(hostForVM)))
													{
														if(showAll)
															display_component=info;
													}
												}
											}
											
										}
									}
									
%>
										<td><%=display_component%></td>
<%
								}
							}
						}
						StringBuffer dec_key = new StringBuffer();
						dec_key.append(row[7]);
						dec_key.append(EgConstants.COLON);
						dec_key.append(row[8]);

						//custom problem alert description
						String description = "";
						String tmpInfo2 = com.egurkha.util.StringUtils.replace(row[6], "+", "").trim();
						int len1 = 0;
						if(isCustomAlertMessages)
						{
							/**
							* row[4] - compType
							* row[7] - testName 
							* row[8] - measure
							**/
							String layer = tablesInfo.getRelevantLayer(row[4], row[7], row[8]);
							description = tablesInfo.getCustomMeasureAlert(dec_key.toString(), row[6], thisLanguage);
							len1 = description.trim().length();
							if(description != null && len1 > 0){
								description = replaceMsg (description, Server.getServerNameWithoutPort(row[5], false), mappingInfo.getComponentTypeDescription(row[4]), "-", mappingInfo.getLabelDescription(row[0]), mappingInfo.getLayerDescription(layer), mappingInfo.getTestDescription(row[7]), tmpInfo2, mappingInfo.getMeasureDescription(row[7], row[8]), "");
							}
						} 
						if(description == null || len1 == 0 || description.startsWith(row[8])) {
							Hashtable alertParams = new Hashtable();
							alertParams.put("$componentType",mappingInfo.getComponentTypeDescription(row[4]));
							alertParams.put("$componentName",Server.getServerNameWithoutPort(row[5], false));
							if(row[6]!=null && row[6].trim().length()>1){
								if(row[6].startsWith("+"))
									alertParams.put("$info",row[6].substring(1));
								else
									alertParams.put("$info",row[6]);
							}
							alertParams.put("appendTag",new Boolean(false));
							 description = tablesInfo.getMeasureAlert(dec_key.toString(), row[6], thisLanguage,alertParams)+"$info$"+row[6];
						}

						row[6] = description;
						
						String test_name_value=row[7];
						String testLabel_for_display=row[6];
						String testMeasureAlert=null;
						boolean ifInside=false;
						boolean infoAdded = false;
						if(testLabel_for_display!=null && testLabel_for_display.lastIndexOf("{")>-1 && testLabel_for_display.lastIndexOf("}")>-1)
						{
							testMeasureAlert=testLabel_for_display.substring(0,testLabel_for_display.lastIndexOf("{"));
							testLabel_for_display=testLabel_for_display.substring(testLabel_for_display.lastIndexOf("{")+1,testLabel_for_display.lastIndexOf("}"));
							
							ifInside=true;
							if(testMeasureAlert != null && testMeasureAlert.indexOf("~!~") != -1){
								infoAdded = Boolean.parseBoolean(testMeasureAlert.substring(testMeasureAlert.indexOf("~!~")+3));
								testMeasureAlert = testMeasureAlert.substring(0,testMeasureAlert.indexOf("~!~"));
								ifInside = !infoAdded;
							}
							if(testLabel_for_display!=null && testLabel_for_display.startsWith("+"))
							{
								testLabel_for_display=testLabel_for_display.substring(1);
							}
						}
						else if(testLabel_for_display.indexOf("$info$") > 0){
							testMeasureAlert = testLabel_for_display.substring(0,testLabel_for_display.indexOf("$info$"));
							if(testMeasureAlert != null && testMeasureAlert.indexOf("~!~") != -1){
								infoAdded = Boolean.parseBoolean(testMeasureAlert.substring(testMeasureAlert.indexOf("~!~")+3));
								testMeasureAlert = testMeasureAlert.substring(0,testMeasureAlert.indexOf("~!~"));
							}
							testLabel_for_display = testLabel_for_display.substring(testLabel_for_display.indexOf("$info$")+6);
							testLabel_for_display = testLabel_for_display.startsWith("+")?testLabel_for_display.substring(1):testLabel_for_display;
							if(testLabel_for_display!=null && testLabel_for_display.trim().length()>0)
								ifInside = !infoAdded;
							info = testLabel_for_display;
						}
						
						String isSymbol=(String)egUI.getValue("Tests_For_LayerModel_Images",test_name_value);
						String skipInfos=(String)egUI.getValue("MISC_ARGS","FINAL_INFO");
									
						boolean symbolBlock=true;
						ArrayList exclude_info_list = new ArrayList();
						if(skipInfos!=null && skipInfos.trim().length()>0)
							exclude_info_list = tokInfo.egTokenizer(skipInfos, ",");
						
						if(exclude_info_list!=null && testLabel_for_display!=null && exclude_info_list.contains(testLabel_for_display.trim()))
							symbolBlock=false;

						if(symbolBlock && isSymbol!=null && isSymbol.trim().equalsIgnoreCase("::") && testLabel_for_display!=null && testLabel_for_display.trim().length()>0)
						{
							String temp_testLabel="";
							ArrayList token_list = tokInfo.egTokenizer(testLabel_for_display, "::");
							
							if(token_list!=null && token_list.size()>0)
							{
								String end_image_name_value="";
								String tooltip_value="";
								for(int ind_no=0;ind_no<token_list.size();ind_no++)
								{
									String path=(String)token_list.get(ind_no);

									if(ind_no==0)
									{
										if(test_name_value!=null && test_name_value.equals("RHEVMDataCenTest") || test_name_value.equals("RHEVMStorageTest") || test_name_value.equals("RHEVMClusterTest"))
										{
											end_image_name_value="rhev_datacenter";
											tooltip_value="monitor.layermodel.Datacenter";
										}
										else
										{
											end_image_name_value="vsphere_datacenter_11";
											tooltip_value="monitor.layermodel.Datacenter";
										}
									}
									else if(ind_no==1)
									{
										if(test_name_value!=null && test_name_value.equals("RHEVMStorageTest"))
										{
											end_image_name_value="rhev_datastore";
											tooltip_value="monitor.layermodel.Data&nbsp;Storage";
										}
										else if(test_name_value!=null && test_name_value.equals("RHEVMClusterTest"))
										{
											end_image_name_value="rhev_cluster";
											tooltip_value="monitor.layermodel.Cluster";
										}
										else
										{
											end_image_name_value="vsphere_cluster_11";
											tooltip_value="monitor.layermodel.Cluster";
										}
									}
									else if(ind_no==2)
									{
										end_image_name_value="vsphere_resourcepool_11";
										tooltip_value="monitor.layermodel.monitor.layermodel.Resource&nbsp;pool";
									}

									if(path!=null && path.trim().length()>0)
									{
										ArrayList path_list = tokInfo.egTokenizer(path, "->");
										if(path_list!=null && path_list.size()==2)
										{
											String folder_part=(String)path_list.get(0);
											if(folder_part!=null && folder_part.trim().length()>0)
											{
												ArrayList folder_list = tokInfo.egTokenizer(folder_part, "\\");
												if(folder_list!=null && folder_list.size()>0)
												{
													for(int w=0;w<folder_list.size();w++)
													{
														String folder_name=(String)folder_list.get(w);
														if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
														{
															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
														}
														else
														{

															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
														}
													}
												}
											}

											String dc_or_cl_rp_path=(String)path_list.get(1);
											if(dc_or_cl_rp_path!=null && dc_or_cl_rp_path.trim().length()>0)
											{
												ArrayList dc_or_cl_rp_list = tokInfo.egTokenizer(dc_or_cl_rp_path,"/");
									
												if(dc_or_cl_rp_list!=null && dc_or_cl_rp_list.size()>0)
												{
													for(int w=0;w<dc_or_cl_rp_list.size();w++)
													{
														String dc_or_cl_rp_name=(String)dc_or_cl_rp_list.get(w);
														if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
														{
															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+dc_or_cl_rp_name.trim();
														}
														else
														{
															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+dc_or_cl_rp_name.trim();
														}
													}
												}
											}
										}
										else if(path_list!=null && path_list.size()==1)
										{
											String dc_or_cl_rp_path=(String)path_list.get(0);
											if(dc_or_cl_rp_path!=null && dc_or_cl_rp_path.trim().length()>0)
											{
												ArrayList dc_or_cl_rp_list = tokInfo.egTokenizer(dc_or_cl_rp_path,"/");
									
												if(dc_or_cl_rp_list!=null && dc_or_cl_rp_list.size()>0)
												{
													for(int w=0;w<dc_or_cl_rp_list.size();w++)
													{
														String dc_or_cl_rp_name=(String)dc_or_cl_rp_list.get(w);
														if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
														{
															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+dc_or_cl_rp_name.trim();
														}
														else
														{
															temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+dc_or_cl_rp_name.trim();
														}
													}
												}
											}
										}
									}
								}
								if(temp_testLabel!=null && temp_testLabel.trim().length()>0)
									testLabel_for_display=temp_testLabel;
							}
						}
						else if(symbolBlock && isSymbol!=null && isSymbol.trim().equalsIgnoreCase("/") && testLabel_for_display!=null && testLabel_for_display.trim().length()>0)
						{
							String temp_testLabel="";
							ArrayList resourcepool_list = tokInfo.egTokenizer(testLabel_for_display,"/");
							if(resourcepool_list!=null && resourcepool_list.size()>0)
							{
								for(int w=0;w<resourcepool_list.size();w++)
								{
									String resourcepool_name=(String)resourcepool_list.get(w);
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_resourcepool_11.png'  border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Resource&nbsp;pool")+"'/> "+resourcepool_name.trim();
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_resourcepool_11.png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Resource&nbsp;pool")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Resource&nbsp;pool")+"'/> "+resourcepool_name.trim();
									}
								}
							}
							if(temp_testLabel!=null && temp_testLabel.trim().length()>0)
								testLabel_for_display=temp_testLabel;
						}
						//code added
						else if(symbolBlock && isSymbol!=null && isSymbol.trim().equalsIgnoreCase("$eg^") && testLabel_for_display!=null && testLabel_for_display.trim().length()>0)
						{
							String temp_testLabel="";
							if(test_name_value.equals("MsSqlDatabaseTest") || test_name_value.equals("MsSqlDBStatusTest") || test_name_value.equals("MsSqlLongRunQryTest") || test_name_value.equals("MsSqlMissingIdxTest") || test_name_value.equals("MsSqlNetTest") || test_name_value.equals("MsSqlSpaceTest") || test_name_value.equals("MsSqlTabSizeTest") || test_name_value.equals("MsSqlTransSpaceTest") || test_name_value.equals("MsSqlUnusedIdxTest"))
							{
								if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/db_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.DB")+"'/> "+testLabel_for_display.trim();
								}
								else
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/db_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.DB&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.DB")+"'/> "+testLabel_for_display.trim();
								}
							}
							else if(test_name_value.equals("MsSqlAppsTest") || test_name_value.equals("MsSqlSessionStTest"))
							{
								if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+testLabel_for_display.trim();
								}
								else
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Application&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+testLabel_for_display.trim();
								}
							}
							else if(test_name_value.equals("CtxAppTest")|| test_name_value.equals("CtxXcXAAppTest"))
							{
								String testLabel_for_display_name=testLabel_for_display.trim();
								if(testLabel_for_display_name.indexOf(':') != -1)
								{
									StringTokenizer strToken = new StringTokenizer(testLabel_for_display_name,":");
									String firstString=strToken.nextToken();
									String secondString=strToken.nextToken();
									StringTokenizer strTokenOne = new StringTokenizer(firstString,"\\");
									{
										String folderName=firstString.substring(0,firstString.lastIndexOf('\\'));
										StringTokenizer stringToken = new StringTokenizer(folderName,"\\");
										{
											while (stringToken.hasMoreElements())
											{
												if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+stringToken.nextElement();
												}
												else
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+stringToken.nextElement();
												}
											}
										}
										String workGroup=firstString.substring(firstString.lastIndexOf('\\')+1);
										if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
										{
											temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/workerGroup_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.WorkerGroup")+"'/> "+workGroup;
										}
										else
										{
											temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/workerGroup_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.WorkerGroup&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.WorkerGroup")+"'/> "+workGroup;
										}
									}
									StringTokenizer strTokenTwo = new StringTokenizer(secondString,"\\");
									{
										String folderName=strTokenTwo.nextToken();
										if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
										{
											temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
										}
										else
										{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
										}
										String applicationName=strTokenTwo.nextToken();
										if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
										{
											temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
										}
										else
										{
											temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Application&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
										}
									}
								}//end if :
								else if(testLabel_for_display_name.indexOf('\\') != -1)
								{
									StringTokenizer stringToken = new StringTokenizer(testLabel_for_display_name,"\\");
									String folderName=stringToken.nextToken();
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
									}
									
									String applicationName=stringToken.nextToken();
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Application&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
									}
								}
								else if(testLabel_for_display_name.indexOf('/') != -1)
								{
									StringTokenizer stringToken = new StringTokenizer(testLabel_for_display_name,"/");
									String folderName=stringToken.nextToken();
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folderName;
									}
									String applicationName=stringToken.nextToken();
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Application&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+applicationName;
									}
								}
								else
								{
									if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+testLabel_for_display.trim();
									}
									else
									{
										temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/application_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Application&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Application")+"'/> "+testLabel_for_display.trim();
									}
								}
							} //end if for citrix
							else
							{
								if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/user_small12.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/> "+testLabel_for_display.trim();
								}
								else
								{
									temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/user_small12.png' border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.User&nbsp;")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/> "+testLabel_for_display.trim();
								}
							}
							if(temp_testLabel!=null && temp_testLabel.trim().length()>0)
							testLabel_for_display=temp_testLabel;
						}
						//code ended
						else if(symbolBlock && isSymbol!=null && isSymbol.trim().equalsIgnoreCase(":") && testLabel_for_display!=null && testLabel_for_display.trim().length()>0)
						{
							String temp_testLabel="";
							ArrayList token_list = tokInfo.egTokenizer(testLabel_for_display, ":");
							if(token_list!=null && token_list.size()>0)
							{
								String end_image_name_value="";
								String image_name_value2="";
								String tooltip_value="";
								String tooltip_value2="";
								for(int ind_no=0;ind_no<token_list.size();ind_no++)
								{
									String path=(String)token_list.get(ind_no);

									if(ind_no==0)
									{
										end_image_name_value="xen_small_desktopcontroller";
										tooltip_value="monitor.layermodel.Controller";

										image_name_value2="xen_small_desktopgroup";
										tooltip_value2="monitor.layermodel.Desktop&nbsp;Groups";
									}
									else if(ind_no==1)
									{
										end_image_name_value="xen_small_desktop";
										tooltip_value="monitor.layermodel.Desktop";
									}

									if(path!=null && path.trim().length()>0)
									{
										if(ind_no==0)
										{
											ArrayList path_list = tokInfo.egTokenizer(path, "->");
											if(path_list!=null && path_list.size()==2)
											{
												String controller=(String)path_list.get(0);
												if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+controller.trim();
												}
												else
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+controller.trim();
												}
												
												String folder_and_groupName=(String)path_list.get(1);

												if(folder_and_groupName!=null && folder_and_groupName.trim().length()>0)
												{
													ArrayList f_and_g_list = tokInfo.egTokenizer(folder_and_groupName, "\\");

													if(f_and_g_list!=null && f_and_g_list.size()>0)
													{
														if(f_and_g_list.size()==2)
														{
															String  folder_name=(String)f_and_g_list.get(0);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
															}

															String group_name=(String)f_and_g_list.get(1);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+group_name.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value2)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+group_name.trim();
															}
														}
														else if(f_and_g_list.size()==1)
														{
															String groupName=(String)f_and_g_list.get(0);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+groupName.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value2)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+groupName.trim();
															}
														}
													}
												}
											}
											else if(path_list!=null && path_list.size()==1)
											{
												String folder_and_groupName=(String)path_list.get(0);

												if(folder_and_groupName!=null && folder_and_groupName.trim().length()>0)
												{
													ArrayList f_and_g_list = tokInfo.egTokenizer(folder_and_groupName, "\\");

													if(f_and_g_list!=null && f_and_g_list.size()>0)
													{
														if(f_and_g_list.size()==2)
														{
															String  folder_name=(String)f_and_g_list.get(0);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/vsphere_folder_11.png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Folder")+"'/> "+folder_name.trim();
															}
															
															String group_name=(String)f_and_g_list.get(1);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+group_name.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value2)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+group_name.trim();
															}
														}
														else if(f_and_g_list.size()==1)
														{
															String groupName=(String)f_and_g_list.get(0);
															if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+groupName.trim();
															}
															else
															{
																temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+image_name_value2+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value2)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value2)+"'/> "+groupName.trim();
															}
														}
													}
												}
											}
										}
										else if(ind_no==1)
										{
											ArrayList path_list = tokInfo.egTokenizer(path, "\\");
											if(path_list!=null && path_list.size()==2)
											{
												String  domain_name=(String)path_list.get(0);
												if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/domain_name.png'  border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Domain")+"'/> "+domain_name.trim();
												}
												else
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/domain_name.png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription("monitor.layermodel.Domain")+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription("monitor.layermodel.Domain")+"'/> "+domain_name.trim();
												}
												
												String deskTopName=(String)path_list.get(1);
												if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+deskTopName.trim();
												}
												else
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+deskTopName.trim();
												}
											}
											else if(path_list!=null && path_list.size()==1)
											{
												String deskTopName=(String)path_list.get(0);
												if(printPage1!=null && printPage1.equalsIgnoreCase("toprint"))
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+deskTopName.trim();
												}
												else
												{
													temp_testLabel=temp_testLabel+" <img src ='/final/monitor/eg_images/"+end_image_name_value+".png'  border = '0' onmouseover=Tip('"+mappingInfo.getTextDescription(tooltip_value)+"',FONTWEIGHT,\'bold\',FONTSIZE,\'8pt\',BGCOLOR,\'#FFFFE1\') onmouseout='UnTip()' title='"+mappingInfo.getTextDescription(tooltip_value)+"'/> "+deskTopName.trim();
												}
											
											}
										}
									}
								}
							}
							if(temp_testLabel!=null && temp_testLabel.trim().length()>0)
									testLabel_for_display=temp_testLabel;
						}


						String vmDesc = "";
						if(testLabel_for_display!=null && testMeasureAlert!=null && testMeasureAlert.trim().length()>0)
						{
							if(thisUser_a_userVMs!=null)
							{
								if(thisUser_a_userVMs.size() > 0)
								{
									 if(thisUser_a_userVMs.contains(info))
										vmDesc = testLabel_for_display;
									else
									{
										if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
										{
											if(showAll)
												vmDesc = testLabel_for_display;
										}
										else
											testLabel_for_display=ifInside?testMeasureAlert+" {"+testLabel_for_display+"}":testMeasureAlert;
									}
								}
								else
									testLabel_for_display=ifInside?testMeasureAlert+" {"+testLabel_for_display+"}":testMeasureAlert;
							}
							else
								testLabel_for_display=ifInside?testMeasureAlert+" {"+testLabel_for_display+"}":testMeasureAlert;
						}
						String vmInfo = "";
						if(thisUser_a_userVMs!=null)
						{
							if(thisUser_a_userVMs.size() > 0 )
							{
								if(thisUser_a_userVMs.contains(info))
								{
									vmInfo = testMeasureAlert;
									if(vmDesc!=null && vmDesc.length() > 0)
									{
										if(vmDesc.indexOf(":")>-1)
										{
											vmDesc = vmDesc.substring(vmDesc.indexOf(":")+1);
											vmInfo = vmInfo +"{" + vmDesc +"}";
										}
										
									}
								}
								else
								{
									if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
									{
										vmInfo = testMeasureAlert;
										if(vmDesc!=null && vmDesc.length() > 0)
										{
											if(vmDesc.indexOf(":")>-1)
											{
												vmDesc = vmDesc.substring(vmDesc.indexOf(":")+1);
												vmInfo = vmInfo +"{" + vmDesc +"}";
											}
											
										}
									}
								}
							}
							

						}
%>
																	<td>
																	<%
																	if(thisUser_a_userVMs!=null)
																	{
																		if(thisUser_a_userVMs.size() > 0)
																		{
																			if(thisUser_a_userVMs.contains(info))
																			{
																				out.println(vmInfo);
																			}
																			else
																			{
																				if(thisUser_hservers!=null && (thisUser_hservers.size() == 0 || !thisUser_hservers.contains(hostForVM)))
																				{
																					out.println(vmInfo);
																				}
																				else
																				{
																					out.println(testLabel_for_display);
																				}
																			}
																		}
																		else
																		{
																			out.println(testLabel_for_display);
																		}
																	}
																	else
																	{
																		out.println(testLabel_for_display);
																	}
																	%>
																	</td>
<%
						if(row[7]!=null)
						{
							if(row[7].length()<15)
							{
%>
																	<td> <%=mappingInfo.getTestDescription(row[7])%></td>
<%
							}
							else
							{
								int start_var=0;
								int end_var=0;
								String display_component="";
								String display_comp="";
								do
								{
									String display=row[7].substring(0,14);
									int disp_length=display.length();
									if((row[7].length() - end_var) > disp_length)
									{
										end_var=end_var+disp_length;
									}
									else
									{
										end_var=end_var + (row[7].length() - end_var);
									}
									display_comp=row[7].substring(start_var,end_var);
									display_component=display_component+display_comp;
									start_var=end_var;
								}while(end_var<row[7].length());
%>
										<td class="alarm_td" ><%=mappingInfo.getTestDescription(display_component)%></td>
<%
							}
						}
						String s_displayDate="";
						if(row[11] != null && !row[7].equals(""))
						{
							s_displayDate = DateUtil.changeDateFormat(row[11],"yyyy-MM-dd HH:mm:ss",currentDateFormat);
							EgMonTimeZoneConverter timeZoneConverter = new EgMonTimeZoneConverter(s_displayDate,user); 
							s_displayDate = timeZoneConverter.getDateTime();
%>
							<td> <%=s_displayDate%></td>
<%
						}
						if(row[12].startsWith("1900-01")){
%>
							<td> <%=mappingInfo.getTextDescription("monitor.history.Current")%></td>
<%
						}
						else{
							long diff = getDuration(row[11], row[12]);
%>
							<td> <%=DateTimeTokenizer.getTimeDifference(diff)%></td>
<%
						}
						if(showMgrId)
						{
%>
										<td class="alarm_td" ><%=manager_id%></td>
<%
						}

%>
																</tr>
															</id:item>
<%
				}
			}
		}
%>
																
															</tbody></table>
														</td>
													</tr>
												</tbody></table>
<%
		int fCount =0;
		if (eventCount > maxPageItems)
		{
%>
												<table align="center" cellspacing="0" cellpadding="2"  width="100%" border="0" id="eg_cellbglight" class="linebottom">
													<tbody><tr>
														<td align="center" width="100%" valign="bottom">
															<table cellspacing="0" cellpadding="0" align="center" border="0" style="table-layout:collapse" width="100%">
																<tbody><tr>
																	<td align="right" nowrap> &nbsp; &nbsp; <egui:intnl text="monitor.history.Go to page"/> # :&nbsp;</td>
																	<td nowrap><input type="text" name="pageno" width="6" size="3" style="width: 35px; text-align: center;" > &nbsp;</td>
																	<td nowrap> <img src="/final/monitor/eg_images/arrow_1.gif" name="gotopage" onClick="onGoToPage(<%=maxPageItems%>, <%=eventCount%>)" alt="<egui:intnl text='monitor.common.Go'/>" id="eg_input" class="mouse"> </td>
																	<td width="20%">&nbsp;</td>
																	<id:index><id:pages>
<%
			if(!(String.valueOf(currentPageNumber)).equals("1") && fCount == 0)
			{
				fCount++;
%>
																	<td align="left" nowrap width="70">&nbsp; <id:first export="firstPageUrl=pageUrl"> <a href="#"  id="eg_monlink" onClick='window.location.href = "<%=firstPageUrl%>"'/> <img src="/final/monitor/eg_images/back-arrow.gif" border="0"> <img src="/final/monitor/eg_images/back-arrow.gif" border="0">&nbsp;<b><egui:intnl text="monitor.history.FIRST"/></b></a>
																	</id:first>
																	</td>
<%
			}
%>
																	</id:pages>
																	<id:prev export="prevPageUrl=pageUrl">
																	<td align="left" nowrap> <a href="#"  id="eg_monlink" onClick='window.location.href = "<%=prevPageUrl%>"'/><img src="/final/monitor/eg_images/back-arrow.gif" border="0">&nbsp;<b><egui:intnl text="monitor.history.PREV"/></b></a>
																	</td>
																	</id:prev>
																	<td align="right"  width="40%">
																	<id:pages>
<%
			if (pageNumber.equals(currentPageNumber))
			{
%>
																	<span id="page_no"><%=pageNumber %></span>
<%
			}
			else
			{
%>
																	&nbsp;<a href="<%=pageUrl%>&fromLink=true" id="eg_alarmlink"><%= pageNumber%></a>
<%
			}
%>
																	</id:pages>&nbsp; &nbsp;</td>
																	<id:next export="nextPageUrl=pageUrl">
																	<td align="center" nowrap width="50">
																	<a href="#"  id="eg_monlink" onClick='window.location.href = "<%=nextPageUrl%>"'/><b><egui:intnl text="monitor.history.NEXT"/></b>&nbsp;<img src="/final/monitor/eg_images/forward-arrow.gif" border="0"></a>
																	</td>
																	</id:next>
															
<%
			if(Math.min(start+maxPageItems,eventCount) < eventCount)
			{
%>
																	<td align="right" nowrap width="70">
																	<id:last export="lastPageUrl=pageUrl">
																	<a href="#"  id="eg_monlink" onClick='window.location.href = "<%=lastPageUrl%>"'/><b><egui:intnl text="monitor.history.LAST"/></b>&nbsp;<img src="/final/monitor/eg_images/forward-arrow.gif" border="0"><img src="/final/monitor/eg_images/forward-arrow.gif" border="0"></a>
																	</id:last>
																	</td>

<%
			}
%>
																	</id:index>
																	<td width="25%">&nbsp;</td>
																</tr>
															</tbody></table>
														</td>
													</tr>
												</tbody></table>
											<!--</form>-->
<%
		}
%>
											</id:indexer>
											</td>
										</tr>
									</tbody></table>
								</div>
								</td>
							</tr>
						</tbody></table>
					</td>
				</tr>
				<tr>
					<td>
<%
	}
	else if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Acknowledgement"))
	{
%>
						<table align="center" cellspacing="0" cellpadding="2" border="0" valign="middle" height="100%" width="100%">
							<tbody><tr>
								<td height="170">&nbsp;</td>
							</tr>
							<tr>
								<th id="eg_alarmth" align="center" valign="middle" height="100%">
									<table align="center" cellspacing="0" cellpadding="10" border="0">
										<tbody><tr>
											<td align="center"><img src="../monitor/eg_images/<%=monitor_Skin%>/exclamation-icon.gif" align="center" border="0" /><br><egui:intnl text="monitor.Ack.No acknowledgements found"/></td>
										</tr>
									</tbody></table>
								</th>
							</tr>
						</tbody></table>
<%
	}
	else if(ackorDelete!=null && ackorDelete.length()>0 && ackorDelete.equalsIgnoreCase("Unacknowledgement"))
	{
%>
						<table align="center" cellspacing="0" cellpadding="2" border="0" valign="middle" height="100%" width="100%">
							<tbody><tr>
								<td height="170">&nbsp;</td>
							</tr>
							<tr>
								<th id="eg_alarmth" align="center" valign="middle" height="100%">
									<table align="center" cellspacing="0" cellpadding="10" border="0">
										<tbody><tr>
											<td align="center" id="eg_errorsmall"><img src="../monitor/eg_images/<%=monitor_Skin%>/exclamation-icon.gif" align="center" border="0" /><br><egui:intnl text="monitor.Ack.No unacknowledgements found"/></td>
										</tr>
									</tbody></table>
								</th>
							</tr>
						</tbody></table>
<%
	}
	else
	{
%>
						<table align="center" cellspacing="0" cellpadding="2" border="0" valign="middle" height="100%" width="100%">
							<tbody><tr>
								<td height="170">&nbsp;</td>
							</tr>
							<tr>
								<th id="eg_alarmth" align="center" valign="middle" height="100%">
									<tbody><table align="center" cellspacing="0" cellpadding="10" border="0">
										<tr>
											<td align="center"><img src="../monitor/eg_images/<%=monitor_Skin%>/exclamation-icon.gif" align="center" border="0" /><br><egui:intnl text="monitor.Ack.No alarms deleted"/></td>
										</tr>
									</tbody></table>
								</th>
							</tr>
						</tbody></table>
<%
	}
%>
					</div>
					</td>
				</tr>
			</table>

<%!
	String blank = "&nbsp;";
	private String tmpFile = EgInstallInfo.getInstallDir()+"/manager/logs/tmp.log";
	private boolean tmpLog = false;

	public int getAckCount(
		List servers,
		String compNames,
		String compTypes,
		String ackUserId,
		String ackorDeleteComp,
		String fromDate,
		String toDate,
		String alarmOption,
		EgDbAdapterUI egDb,
		List userCompList,boolean showAll,boolean hasVMs,User user,String selectedCompType,String selectedCompName,boolean showAllTypes,boolean showAllComps)
	{
		if(EgInstallInfo.isSuperManager)
		{
			SmSessionData smsData = new SmSessionData(currentSessionId);
			EgThreadLocal egtl = new EgThreadLocal();
			egtl.set(smsData);
			new SMDateTimeConverter("MM/dd/yyyy HH:mm",fromDate,toDate,"yyyy-MM-dd HH:mm:ss",new int[]{3});

		}
		EgDateInfo dateInfo = new EgDateInfo();
		EgUserRole forUserRole = EgUserRole.getRoleObject(user.getLoginType());
		boolean allCompAccess = forUserRole.hasAllComponentAccess();
		int count = 0;
		StringBuffer sb = new StringBuffer();
		String real_user = "";
		if (ackUserId != null && !ackUserId.equals("-1") && ackUserId.indexOf("/RealUser/") != -1)
		{
			String grpDelimiter = "/RealUser/";
			int id = ackUserId.indexOf(grpDelimiter);
			String str_uname_A = ackUserId.substring(0,id);
			int nextIdx = id + grpDelimiter.length();
			String str_uname_B = ackUserId.substring(nextIdx);
			ackUserId = str_uname_A;
			real_user = str_uname_B;
		}
		if (servers.isEmpty())
		{
			if (EgDbInfo.isOraAdapter)
			{
				sb.append("SELECT AH.USER_ID,AHS.COMP_TYPE||':'||AHS.COMP_NAME,AH.REAL_USER FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					sb.append(" AH.ACK_TIME BETWEEN to_date('");
					sb.append(fromDate);
					sb.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					sb.append(toDate);
					sb.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						sb.append(" AND AH.options='");
						sb.append(ackorDeleteComp);
					}
					else
					{
						sb.append(" AND AH.options!='Deletion");
					}
					sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					sb.append(" AND AH.ACK_DESCRIPTION>' '");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
				}
				else
				{
					sb.append(" AH.USER_ID='");
					sb.append(ackUserId);
					sb.append("' AND AH.ACK_TIME BETWEEN to_date('");
					sb.append(fromDate);
					sb.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					sb.append(toDate);
					sb.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						sb.append(" AND AH.options='");
						sb.append(ackorDeleteComp);
					}
					else
					{
						sb.append(" AND AH.options!='Deletion");
					}
					sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID AND AH.ACK_DESCRIPTION>' '");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					if (!real_user.equals("") && real_user.length() > 0)
					{
						sb.append(" AND AH.REAL_USER='");
						sb.append(real_user);
						sb.append("'");
					}
				}
			}
			else
			{
				sb.append("SELECT AH.USER_ID,AHS.COMP_TYPE+':'+AHS.COMP_NAME,AH.REAL_USER FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					sb.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
					sb.append(fromDate);
					sb.append("', 101) AND convert(datetime,'");
					sb.append(toDate);
					sb.append("', 101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						sb.append(" AND AH.options='");
						sb.append(ackorDeleteComp);
					}
					else
					{
						sb.append(" AND AH.options!='Deletion");
					}
					sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					sb.append(" AND AH.ACK_DESCRIPTION>' ' ");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
				}
				else
				{
					sb.append(" AH.USER_ID='");
					sb.append(ackUserId);
					sb.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
					sb.append(fromDate);
					sb.append("', 101) AND convert(datetime,'");
					sb.append(toDate);
					sb.append("', 101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						sb.append(" AND AH.options='");
						sb.append(ackorDeleteComp);
					}
					else
					{
						sb.append(" AND AH.options!='Deletion");
					}
					sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					sb.append(" AND AH.ACK_DESCRIPTION>' ' ");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					
					if (!real_user.equals("") && real_user.length() > 0)
					{
						sb.append(" AND AH.REAL_USER='");
						sb.append(real_user);
						sb.append("'");
					}
				}
			}

			logToTmpFile("INFO","","Query for events count 1 "+sb.toString());
			ResultSet rs = egDb.dbselect(sb.toString());
			try
			{
				if (rs != null)
				{
					count = 0;
					while(rs.next())
					{
						//count = rs.getInt(1);
						/*String s_user = rs.getString(1);
						String host = rs.getString(2);
						ErUserData userData = new ErUserData(s_user,false);
						User selectedUser = null;
						List thisUser_servers= new LinkedList();
						List thisUser_hservers = new LinkedList();
						EgUserRole userRole = null;
						if(userData!=null)
						{
							selectedUser=userData.usr;
							if(selectedUser==null)
							{
								selectedUser = userData.getUser(s_user);
							}
							thisUser_servers = selectedUser.getServers(false);
							thisUser_hservers = getHostSystemServers(thisUser_servers);
							userRole = selectedUser.getUserRole();
						}
						if(allCompAccess)
						{
							if(thisUser_hservers!=null && thisUser_hservers.size() > 0)
							{
								if(!thisUser_hservers.contains(host))
								{
									
									continue;
								}
								else
								{
									count=count+1;
								}
							}
							
						}
						else
						{
							if(!userRole.hasAllComponentAccess())
							{
								if(thisUser_hservers!=null && thisUser_hservers.size() > 0)
								{
									if(!thisUser_hservers.contains(host))
									{
										
										continue;
									}
									else
									{
										count=count+1;
									}
								}
								else
								{
									continue;
								}
							}
							else
							{
								count = count+1;
							}
						}*/
						count = count+1;
					}
					try 
					{
						rs.close();
						rs = null;
					} catch (Exception grrr)
					{
					}
				}
			}
			catch (SQLException e)
			{
			}
			return count;
		} 
		else // all component access (!USER)
		{
			// restricted access or using specific comp-name and type 
			if (EgDbInfo.isOraAdapter)
			{
				sb.append("SELECT AH.EVENT_ID,AHS.COMP_TYPE||':'||AHS.COMP_NAME,AH.OPTIONS");
						sb.append(",AHS.INFO,AH.USER_ID,AH.REAL_USER ");
				sb.append("FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
			}
			else
			{
				sb.append("SELECT AH.EVENT_ID,AHS.COMP_TYPE+':'+AHS.COMP_NAME,AH.OPTIONS"); 
						sb.append(",AHS.INFO,AH.USER_ID,AH.REAL_USER ");

				sb.append(" FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
			}
			if (compNames.length()==0)
			{
				if (EgDbInfo.isOraAdapter)                      //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN to_date('");
						sb.append(fromDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						sb.append(toDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}

						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
					else
					{
						sb.append(" AH.ACK_TIME BETWEEN to_date('");
						sb.append(fromDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						sb.append(toDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						
					}
				}
				else                                                    //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						sb.append(fromDate);
						sb.append("', 101) AND convert(datetime,'");
						sb.append(toDate);
						sb.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sb.append(" AND AHS.END_TIME >'1900-01-01 00:00:00.0'");

						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
					else
					{
						sb.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						sb.append(fromDate);
						sb.append("', 101) AND convert(datetime,'");
						sb.append(toDate);
						sb.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			else 
			{ // filter based on comp_name 
				if (EgDbInfo.isOraAdapter)                                // oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN to_date('");
						sb.append(fromDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						sb.append(toDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_NAME IN (");
						sb.append(compNames);
						sb.append(") AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
					else
					{
						sb.append(" AH.ACK_TIME BETWEEN to_date('");
						sb.append(fromDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						sb.append(toDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss')");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_NAME IN (");
						sb.append(compNames);
						sb.append(") AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
							
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							sb.append(" AND (AHS.END_TIME IS  NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
				}
				else                                                          // sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						sb.append(fromDate);
						sb.append("', 101) AND convert(datetime,'");
						sb.append(toDate);
						sb.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_NAME IN (");
						sb.append(compNames);
						sb.append(") AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
					else
					{
						sb.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						sb.append(fromDate);
						sb.append("', 101) AND convert(datetime,'");
						sb.append(toDate);
						sb.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						sb.append(" AND AHS.COMP_NAME IN (");
						sb.append(compNames);
						sb.append(") AND AHS.COMP_TYPE IN (");
						sb.append(compTypes);
						sb.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			if(compNames.length()==0 && compTypes.length()==0 && ackUserId!=null && !ackUserId.equals("-1"))
			{
				if (EgDbInfo.isOraAdapter)                      //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN to_date('");
						sb.append(fromDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						sb.append(toDate);
						sb.append("','mm/dd/yyyy hh24:mi:ss')");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							sb.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							sb.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}

						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
				}
				else                                             //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						sb.append(" AH.USER_ID='");
						sb.append(ackUserId);
						sb.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						sb.append(fromDate);
						sb.append("', 101) and convert(datetime,'");
						sb.append(toDate);
						sb.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sb.append(" AND AH.options='");
							sb.append(ackorDeleteComp);
						}
						else
						{
							sb.append(" AND AH.options!='Deletion");
						}
						sb.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sb.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sb.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals("") && real_user.length() > 0)
						{
							sb.append(" AND AH.REAL_USER='");
							sb.append(real_user);
							sb.append("'");
						}
					}
				}
			}
			logToTmpFile("INFO","","Query for events count "+sb.toString());
			ResultSet rs = egDb.dbselect(sb.toString());
			count = 0;
			Hashtable user_obj=new Hashtable();
			try
			{
				List a_userVMs = new LinkedList();
				List userServ  = new LinkedList();
				if(hasVMs)
				{
					a_userVMs = user.getOnlyVMs();
				}
				userServ  = userCompList;
				if(rs!=null)
				{
					while(rs.next())
					{
						String s = rs.getString(2);
						String s_user = rs.getString(5);
						User selectedUser = null;
						List thisUser_a_userVMs = new LinkedList();
						List thisUser_servers = new LinkedList();
						List thisUser_hservers = new LinkedList();
						EgUserRole userRole = null;
						boolean rowUserHasVM = false;

						if(user_obj!=null && user_obj.containsKey(s_user))
						{
							selectedUser = (User)user_obj.get(s_user);
							thisUser_hservers = (List)user_obj.get(s_user+"_Servers");
						}
						else
						{
							ErUserData userData = new ErUserData(s_user,false);
							if(userData!=null)
							{
								selectedUser=userData.usr;
								if(selectedUser==null)
								{
									selectedUser = userData.getUser(s_user);
								}

								if(selectedUser!=null)
								{
									user_obj.put(s_user,(User)selectedUser);
									thisUser_servers = selectedUser.getServers(false);
									thisUser_hservers = getHostSystemServers(thisUser_servers);
									user_obj.put(s_user+"_Servers",(List)thisUser_hservers);
								}
							}
						}

						if(selectedUser!=null)
						{
							thisUser_a_userVMs = selectedUser.getOnlyVMs();
							userRole = selectedUser.getUserRole();
							if(thisUser_a_userVMs.size() > 0)
								rowUserHasVM = true;
						}
						if(hasVMs)
						{
							
							if(showAll)
							{	
								
								if(allCompAccess)
								{
									count++;
								}
								else
								{
									if(userServ.contains(s))
									{
										count++;
									}
									else
									{
										if(rowUserHasVM)
										{
											String vm = rs.getString(4);
											vm = vm.substring(1);
											if(a_userVMs!=null && a_userVMs.size() > 0)
											{
												//Count only the vm alarms with the particular descriptor
												if(vm.indexOf(":") > -1)
												{
													vm = vm.substring(0,vm.indexOf(":"));
												}
												if(a_userVMs.contains(vm))
												{
													count++;
												}
											}
										}
										else
										{
											continue;
										}
									}
								}
							}
							else
							{
								if(!showAllTypes && showAllComps)
								{
									//If selected type is VM and if ackUserId(admin) has All Component Access dont show 
									//the virtual servers.
										if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))								
										{
											if(rowUserHasVM)
											{
												String vm = rs.getString(4);
												vm = vm.substring(1);
												if(a_userVMs!=null && a_userVMs.size() > 0)
												{
													//Count only the vm alarms with the particular descriptor
													if(vm.indexOf(":") > -1)
													{
														vm = vm.substring(0,vm.indexOf(":"));
													}
													if(a_userVMs.contains(vm))
													{

														
																count++;
														
													}
												}
											}
										}
										else
										{
											if(thisUser_hservers.contains(s))
											{
												//It comes here when all types and only vm is selected.
												if(allCompAccess)
												{
													count++;
												}
												else
												{
													if(userServ.contains(s))
													{
														count++;
													}
												}
											}
										}
								}
								else if(!showAllTypes && !showAllComps)
								{
										if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))
										{
											if(rowUserHasVM)
											{
												String vm = rs.getString(4);
												vm = vm.substring(1);
												if(a_userVMs!=null && a_userVMs.size() > 0)
												{
													//Count only the vm alarms with the particular descriptor
													if(vm.indexOf(":") > -1)
													{
														vm = vm.substring(0,vm.indexOf(":"));
													}
													if(a_userVMs.contains(vm))
													{

														
														if(selectedCompName.equals(vm))
															count++;
														
													}
													else
													{
														continue;
													}
													
												}
											}
										}
										else
										{
											if(!allCompAccess)
											{
												if(thisUser_hservers.contains(s))
												{
													if (userServ.contains(s))
													{
														count ++;
													}
												}
											}
											else
											{
												count++;
											}
										}
								}
								else if(showAllTypes && !showAllComps)
								{
										int countVM = 0;
										for(int u =0 ; u  < userServ.size() ; u++)
										{
											String host = (String)userServ.get(u);
											String type = host.substring(0,host.indexOf(":"));
											String comp = host.substring(host.indexOf(":")+1);
											if(selectedCompName.indexOf(":") <0)
											{
												if(comp.indexOf(selectedCompName) < 0)
												{
													//it is a vm
													countVM++;
												}
											}
											else
											{
												if(comp.indexOf(selectedCompName) < 0)
												{
													continue;
												}
											}


										}
										if(countVM == userServ.size())
										{
											String vm = rs.getString(4);
											vm = vm.substring(1);
											if(a_userVMs!=null && a_userVMs.size() > 0)
											{
												//Count only the vm alarms with the particular descriptor
												if(vm.indexOf(":") > -1)
												{
													vm = vm.substring(0,vm.indexOf(":"));
												}
												if(a_userVMs.contains(vm))
												{
														if(selectedCompName.equals(vm))
															count++;
													
												}
												
											}
										}
										else
										{
											if(s.indexOf(selectedCompName)>-1)
											{
												if (!userServ.contains(s))
												{
													continue;
												}
												else
												{
													count++;
												}
											}
											else
											{
												continue;
											}
										}

								}
							}
						}
						else
						{
							if(!allCompAccess)
							{
								if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(s))
								{
									if (servers.contains(s))
									{
										count++;
									}
								}
								else
								{
									continue;
								}
							}
							else
							{
								if(showAll)
								{
									count++;
								}
								if(!showAllTypes || !showAllComps)
								{
									if(selectedUser.isOnlyVMAssigned() && !selectedUser.isVMAssigned())
									{
										continue;
									}
									else
									{
										if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(s))
										{
											if (servers.contains(s))
											{
												count++;
											}
										}
										else
										{
											continue;
										}
									}
									
								}
							}
						}
					}
					try 
					{
						rs.close();
						rs = null;
					} catch (Exception grrr)
					{
						grrr.printStackTrace();
					}
				}
			}
			catch(SQLException e)
			{
				e.printStackTrace();
				System.out.println(e);
			}
			return count;
		}
	}
	
		public List getAckHistory(
		List servers,
		String serverNames,
		String serverTypes,
		String ackUserId,
		String ackorDeleteComp,
		String fromTime,
		String toTime,
		String eventID,
		int offsetCount,
		String alarmOption,
		boolean reverseList, EgDbAdapterUI egDb,List userCompList,boolean showAll,boolean hasVMs,User user,String selectedCompType,String selectedCompName,boolean showAllTypes,boolean showAllComps)
	{
		EgDateInfo dateInfo = new EgDateInfo();
		StringBuffer query = new StringBuffer();
		EgUserRole forUserRole = EgUserRole.getRoleObject(user.getLoginType());
		boolean allCompAccess = forUserRole.hasAllComponentAccess();
		String real_user = "";
		if (ackUserId != null && !ackUserId.equals("-1") && ackUserId.indexOf("/RealUser/") != -1)
		{
			String grpDelimiter = "/RealUser/";
			int id = ackUserId.indexOf(grpDelimiter);
			String str_uname_A = ackUserId.substring(0,id);
			int nextIdx = id + grpDelimiter.length();
			String str_uname_B = ackUserId.substring(nextIdx);
			ackUserId = str_uname_A;
			real_user = str_uname_B;
		}
		if (servers.isEmpty())
		{
			StringBuffer oracleQuery = null;
			StringBuffer sqlQuery = null;
			if(EgInstallInfo.isSuperManager)
			{
				oracleQuery = new StringBuffer(256);
				sqlQuery = new StringBuffer(256);
				//Building oracle query for super manager
				{
					oracleQuery.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
					if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
					{
						oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
						oracleQuery.append(fromTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						oracleQuery.append(toTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							oracleQuery.append(" AND AH.options='");
							oracleQuery.append(ackorDeleteComp);
						}
						else
						{
							oracleQuery.append(" AND AH.options!='Deletion");
						}
						oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
					else
					{
						oracleQuery.append(" AH.USER_ID='");
						oracleQuery.append(ackUserId);
						oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
						oracleQuery.append(fromTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						oracleQuery.append(toTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							oracleQuery.append(" AND AH.options='");
							oracleQuery.append(ackorDeleteComp);
						}
						else
						{
							oracleQuery.append(" AND AH.options!='Deletion");
						}
						oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							oracleQuery.append(" AND AH.REAL_USER='");
							oracleQuery.append(real_user);
							oracleQuery.append("'");
						}
					}
				}
				//Building sqlserver query for super manager
				{
					sqlQuery.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
					if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
					{
						sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						sqlQuery.append(fromTime);
						sqlQuery.append("', 101) AND convert(datetime,'");
						sqlQuery.append(toTime);
						sqlQuery.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sqlQuery.append(" AND AH.options='");
							sqlQuery.append(ackorDeleteComp);
						}
						else
						{
							sqlQuery.append(" AND AH.options!='Deletion");
						}
						sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sqlQuery.append(" AND AHS.END_TIME ='1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
					else
					{
						sqlQuery.append(" AH.USER_ID='");
						sqlQuery.append(ackUserId);
						sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						sqlQuery.append(fromTime);
						sqlQuery.append("', 101) AND convert(datetime,'");
						sqlQuery.append(toTime);
						sqlQuery.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sqlQuery.append(" AND AH.options='");
							sqlQuery.append(ackorDeleteComp);
						}
						else
						{
							sqlQuery.append(" AND AH.options!='Deletion");
						}
						sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						if (!real_user.equals(""))
						{
							sqlQuery.append(" AND AH.REAL_USER='");
							sqlQuery.append(real_user);
							sqlQuery.append("'");
						}
					}
				}
			}
			else if (EgDbInfo.isOraAdapter)                                          //oracle
			{
				query.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					query.append(" AH.ACK_TIME BETWEEN to_date('");
					query.append(fromTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					query.append(toTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
				}
				else
				{
					query.append(" AH.USER_ID='");
					query.append(ackUserId);
					query.append("' AND AH.ACK_TIME BETWEEN to_date('");
					query.append(fromTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					query.append(toTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					if (!real_user.equals("") && real_user.length() > 0)
					{
						query.append(" AND AH.REAL_USER='");
						query.append(real_user);
						query.append("'");
					}
				}
			}
			else                                                                  //sql
			{
				query.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
					query.append(fromTime);
					query.append("', 101) AND convert(datetime,'");
					query.append(toTime);
					query.append("',101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						query.append(" AND AHS.END_TIME ='1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
				}
				else
				{
					query.append(" AH.USER_ID='");
					query.append(ackUserId);
					query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
					query.append(fromTime);
					query.append("', 101) AND convert(datetime,'");
					query.append(toTime);
					query.append("',101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					if (!real_user.equals(""))
					{
						query.append(" AND AH.REAL_USER='");
						query.append(real_user);
						query.append("'");
					}
				}
			}
			/*if (eventID != null)
			{
				if (reverseList)
				{
					query.append(" AND AH.EVENT_ID < ");
					query.append(eventID);
				}
				else
				{
					query.append(" AND AH.EVENT_ID > ");
					query.append(eventID);
				}
			}*/
			query.append(" ORDER BY AH.ACK_TIME ");
			if (reverseList)
			{
				query.append(" DESC");
			}
			logToTmpFile("INFO","","Query for event history is "+query.toString());
			ResultSet rs = null;
			try
			{
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery.append(" ORDER BY AH.ACK_TIME ");
					sqlQuery.append(" ORDER BY AH.ACK_TIME ");
					if (reverseList)
					{
						oracleQuery.append(" DESC");
						sqlQuery.append(" DESC");
					}
					System.out.println("ack 1");
					Hashtable ht = new Hashtable();
					ht.put("OracleQuery",oracleQuery.toString());
					ht.put("SqlQuery",sqlQuery.toString());
					ht.put("AddMgrIdToRs","yes");
					if(fromTime != null && toTime != null)
					{
						ht.put("startDate",fromTime);
						ht.put("endDate",toTime);
						if(fromTime.indexOf(":") == fromTime.lastIndexOf(":"))
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm");
						}
						else
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm:ss");
						}
					}
					rs=new EgSMDBHelper().getResultSet(ht);
					oracleQuery.setLength(0);
					sqlQuery.setLength(0);
				}
				else
				{
					rs = egDb.dbselect(query.toString());
				}
				List result = new LinkedList();
				result = (List)egDb.getResultSetAsList(rs);
				List copyResult = new LinkedList();
				if(result!=null && result.size() > 0)
				{
					for(int r =0 ; r < result.size();r++)
					{
						String[] row = (String[])result.get(r);
						if(row!=null && row.length > 0)
						{
							/*String s_user = row[1];
							String host = row[4]+":"+row[5];
							ErUserData userData = new ErUserData(s_user,false);
							User selectedUser = null;
							List thisUser_servers = new LinkedList();
							List thisUser_hservers = new LinkedList();
							List a_userVMs = new LinkedList();
							boolean hasVM = false;
							if(userData!=null)
							{
								selectedUser=userData.usr;
								if(selectedUser==null)
								{
									selectedUser = userData.getUser(s_user);
								}
								a_userVMs = selectedUser.getOnlyVMs();
								if(a_userVMs!=null && a_userVMs.size() > 0)
								{
									hasVM = true;
									
								}
							}
							if(hasVM)
							{
								copyResult.add(row);
							}
							else
							{
								copyResult.add(row);
							}*/

							copyResult.add(row);
						}
					}
				}

				try
				{
					rs.close();
					rs = null;
				}
				catch (Exception hh)
				{
					rs = null;
				}
				if (copyResult != null)
				{
					int recordCount = copyResult.size();
					//if (recordCount > offsetCount)
					//copyResult.subList(offsetCount , recordCount).clear();
				}
				return copyResult;
			}
			catch (Exception jpm)
			{
				logToTmpFile("INFO","","Error "+jpm.toString());
				jpm.printStackTrace();
				try
				{
					if (rs != null)
					{
						rs.close();
					}
				}
				catch (Exception grr)
				{
					//System.out.println("grr================>"+grr);
					grr.printStackTrace();
				}
				return null;
			}
		}
		else 
		{
			StringBuffer oracleQuery = null;
			StringBuffer sqlQuery = null;

			query.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
			if (serverNames.length()==0)
			{// filter based on comp_type
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery = new StringBuffer(256);
					sqlQuery = new StringBuffer(256);
					oracleQuery.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
					sqlQuery.append("SELECT AHS.EVENT_SEVERITY,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.INFO,AHS.TEST_NAME,AHS.MEASURE,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HISTORY_SUMMARY AHS WHERE");
					
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							oracleQuery.append(" AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}

							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
						else
						{
							oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							oracleQuery.append(" AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) AND convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							sqlQuery.append(" AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

							if (!real_user.equals(""))
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
						else
						{
							sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) AND convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							sqlQuery.append(" AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                                 //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}

						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
				}
				else                                                   //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) AND convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals(""))
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) AND convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			else 
			{ // filter based on comp_name
				if(EgInstallInfo.isSuperManager)
				{
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							oracleQuery.append(" AND AHS.COMP_NAME IN (");
							oracleQuery.append(serverNames);
							oracleQuery.append(") AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
						else
						{
							oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							oracleQuery.append(" AND AHS.COMP_NAME IN (");
							oracleQuery.append(serverNames);
							oracleQuery.append(") AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							sqlQuery.append(" AND AHS.COMP_NAME IN (");
							sqlQuery.append(serverNames);
							sqlQuery.append(") AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
							
							if (!real_user.equals("") && real_user.length() > 0)
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
						else
						{
							sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							sqlQuery.append(" AND AHS.COMP_NAME IN (");
							sqlQuery.append(serverNames);
							sqlQuery.append(") AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                                 //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
				}
				else
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) and convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) and convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			if(serverNames.length()==0 && serverTypes.length()==0 && ackUserId!=null && !ackUserId.equals("-1"))
			{
				if(EgInstallInfo.isSuperManager)
				{
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("', 101) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("', 101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

							if (!real_user.equals("") && real_user.length() > 0)
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                      //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
				}
				else                                             //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("', 101) and convert(datetime,'");
						query.append(toTime);
						query.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.EVENT_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
				}
			}
/*
			if (eventID != null)
			{
				if (reverseList)
				{
					query.append(" and AH.EVENT_ID < ");
					query.append(eventID);
				}
				else
				{
					query.append(" and AH.EVENT_ID > ");
					query.append(eventID);
				}
			}
*/
			query.append(" ORDER BY AH.ACK_TIME");
			if (reverseList)
			{
				query.append(" DESC");
			}
			logToTmpFile("INFO","","Query for event history2 is "+query.toString());

			ResultSet rs = null;
			//List result=new LinkedList();
			
			try
			{
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery.append(" ORDER BY AH.ACK_TIME");
					sqlQuery.append(" ORDER BY AH.ACK_TIME");
					if (reverseList)
					{
						oracleQuery.append(" DESC");
						sqlQuery.append(" DESC");
					}
					Hashtable ht = new Hashtable();
					ht.put("OracleQuery",oracleQuery.toString());
					ht.put("SqlQuery",sqlQuery.toString());
					ht.put("AddMgrIdToRs","yes");
					if(fromTime != null && toTime != null)
					{
						ht.put("startDate",fromTime);
						ht.put("endDate",toTime);
						if(fromTime.indexOf(":") == fromTime.lastIndexOf(":"))
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm");
						}
						else
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm:ss");
						}
					}
					rs=new EgSMDBHelper().getResultSet(ht);
					oracleQuery.setLength(0);
					sqlQuery.setLength(0);
				}
				else
				{
					rs = egDb.dbselect(query.toString());
				}
				List result = (List)getEventHistAsList(rs, servers,showAll,hasVMs,user,selectedCompType,selectedCompName,showAllTypes,showAllComps,userCompList);
				try
				{
					rs.close();
					rs = null;
				}
				catch (Exception hh)
				{
					rs = null;
				}
				if (result != null)
				{
					int recordCount = result.size();
					//if (offsetCount < recordCount)
					//result.subList(offsetCount , recordCount).clear();
				}
				return result;
			}
			catch (Exception chasegrrr)
			{
				try
				{
					if (rs != null)
					{
						rs.close();
					}
				}
				catch (Exception grr)
				{
				}
				return null;
			}
		}
	}
	public List getAckHistoryofAlarms(
		List servers,
		String serverNames,
		String serverTypes,
		String ackUserId,
		String ackorDeleteComp,
		String fromTime,
		String toTime,
		String eventID,
		int offsetCount,
		String alarmOption,
		boolean reverseList, EgDbAdapterUI egDb,List userCompList,boolean showAll,boolean hasVMs,User user,String selectedCompType,String selectedCompName,boolean showAllTypes,boolean showAllComps)
	{
		EgDateInfo dateInfo = new EgDateInfo();
		StringBuffer query = new StringBuffer();
		EgUserRole forUserRole = EgUserRole.getRoleObject(user.getLoginType());
		boolean allCompAccess = forUserRole.hasAllComponentAccess();
		String real_user = "";
		if (ackUserId != null && !ackUserId.equals("-1") && ackUserId.indexOf("/RealUser/") != -1)
		{
			String grpDelimiter = "/RealUser/";
			int id = ackUserId.indexOf(grpDelimiter);
			String str_uname_A = ackUserId.substring(0,id);
			int nextIdx = id + grpDelimiter.length();
			String str_uname_B = ackUserId.substring(nextIdx);
			ackUserId = str_uname_A;
			real_user = str_uname_B;
		}
		if (servers.isEmpty())
		{
			StringBuffer oracleQuery = null;
			StringBuffer sqlQuery = null;
			if(EgInstallInfo.isSuperManager)
			{
				oracleQuery = new StringBuffer(256);
				sqlQuery = new StringBuffer(256);
				//Building oracle query for super manager
				{
					oracleQuery.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
					if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
					{
						oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
						oracleQuery.append(fromTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						oracleQuery.append(toTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							oracleQuery.append(" AND AH.options='");
							oracleQuery.append(ackorDeleteComp);
						}
						else
						{
							oracleQuery.append(" AND AH.options!='Deletion");
						}
						oracleQuery.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
					else
					{
						oracleQuery.append(" AH.USER_ID='");
						oracleQuery.append(ackUserId);
						oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
						oracleQuery.append(fromTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						oracleQuery.append(toTime);
						oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							oracleQuery.append(" AND AH.options='");
							oracleQuery.append(ackorDeleteComp);
						}
						else
						{
							oracleQuery.append(" AND AH.options!='Deletion");
						}
						oracleQuery.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							oracleQuery.append(" AND AH.REAL_USER='");
							oracleQuery.append(real_user);
							oracleQuery.append("'");
						}
					}
				}
				//Building sqlserver query for super manager
				{
					sqlQuery.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
					if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
					{
						sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						sqlQuery.append(fromTime);
						sqlQuery.append("', 101) AND convert(datetime,'");
						sqlQuery.append(toTime);
						sqlQuery.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sqlQuery.append(" AND AH.options='");
							sqlQuery.append(ackorDeleteComp);
						}
						else
						{
							sqlQuery.append(" AND AH.options!='Deletion");
						}
						sqlQuery.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sqlQuery.append(" AND AHS.END_TIME ='1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
					else
					{
						sqlQuery.append(" AH.USER_ID='");
						sqlQuery.append(ackUserId);
						sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						sqlQuery.append(fromTime);
						sqlQuery.append("', 101) AND convert(datetime,'");
						sqlQuery.append(toTime);
						sqlQuery.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							sqlQuery.append(" AND AH.options='");
							sqlQuery.append(ackorDeleteComp);
						}
						else
						{
							sqlQuery.append(" AND AH.options!='Deletion");
						}
						sqlQuery.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						if (!real_user.equals(""))
						{
							sqlQuery.append(" AND AH.REAL_USER='");
							sqlQuery.append(real_user);
							sqlQuery.append("'");
						}
					}
				}
			}
			else if (EgDbInfo.isOraAdapter)                                          //oracle
			{
				query.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					query.append(" AH.ACK_TIME BETWEEN to_date('");
					query.append(fromTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					query.append(toTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
				}
				else
				{
					query.append(" AH.USER_ID='");
					query.append(ackUserId);
					query.append("' AND AH.ACK_TIME BETWEEN to_date('");
					query.append(fromTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
					query.append(toTime);
					query.append("','mm/dd/yyyy hh24:mi:ss') ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.Alarm_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
					{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
					{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
					}
					if (!real_user.equals("") && real_user.length() > 0)
					{
						query.append(" AND AH.REAL_USER='");
						query.append(real_user);
						query.append("'");
					}
				}
			}
			else                                                                  //sql
			{
				query.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER,AHS.START_TIME,AHS.END_TIME FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
				if(ackUserId == null || ackUserId.equals("-1") || ackUserId.equalsIgnoreCase("null") || ackUserId.equals(""))
				{
					query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
					query.append(fromTime);
					query.append("', 101) AND convert(datetime,'");
					query.append(toTime);
					query.append("',101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						query.append(" AND AHS.END_TIME ='1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
				}
				else
				{
					query.append(" AH.USER_ID='");
					query.append(ackUserId);
					query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
					query.append(fromTime);
					query.append("', 101) AND convert(datetime,'");
					query.append(toTime);
					query.append("',101) ");
					if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
					{
						query.append(" AND AH.options='");
						query.append(ackorDeleteComp);
					}
					else
					{
						query.append(" AND AH.options!='Deletion");
					}
					query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
					if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
					else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					if (!real_user.equals(""))
					{
						query.append(" AND AH.REAL_USER='");
						query.append(real_user);
						query.append("'");
					}
				}
			}
			/*if (eventID != null)
			{
				if (reverseList)
				{
					query.append(" AND AH.EVENT_ID < ");
					query.append(eventID);
				}
				else
				{
					query.append(" AND AH.EVENT_ID > ");
					query.append(eventID);
				}
			}*/
			query.append(" ORDER BY AH.ACK_TIME ");
			if (reverseList)
			{
				query.append(" DESC");
			}
			logToTmpFile("INFO","","Query for event history is "+query.toString());
			//System.out.println("PDF---------getAckHistoryofAlarms----->"+query);
			ResultSet rs = null;
			try
			{
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery.append(" ORDER BY AH.ACK_TIME ");
					sqlQuery.append(" ORDER BY AH.ACK_TIME ");
					if (reverseList)
					{
						oracleQuery.append(" DESC");
						sqlQuery.append(" DESC");
					}
					Hashtable ht = new Hashtable();
					ht.put("OracleQuery",oracleQuery.toString());
					ht.put("SqlQuery",sqlQuery.toString());
					//ht.put("AddMgrIdToRs","yes");
					if(fromTime != null && toTime != null)
					{
						ht.put("startDate",fromTime);
						ht.put("endDate",toTime);
						if(fromTime.indexOf(":") == fromTime.lastIndexOf(":"))
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm");
						}
						else
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm:ss");
						}
					}
					rs=new EgSMDBHelper().getResultSet(ht);
					oracleQuery.setLength(0);
					sqlQuery.setLength(0);
				}
				else
				{
					rs = egDb.dbselect(query.toString());
				}
				List result = new LinkedList();
				result = (List)egDb.getAckResultSetAsList(rs);
				List copyResult = new LinkedList();
				if(result!=null && result.size() > 0)
				{
					for(int r =0 ; r < result.size();r++)
					{
						String[] row = (String[])result.get(r);
						if(row!=null && row.length > 0)
						{
							/*String s_user = row[1];
							String host = row[4]+":"+row[5];
							ErUserData userData = new ErUserData(s_user,false);
							User selectedUser = null;
							List thisUser_servers = new LinkedList();
							List thisUser_hservers = new LinkedList();
							List a_userVMs = new LinkedList();
							boolean hasVM = false;
							if(userData!=null)
							{
								selectedUser=userData.usr;
								if(selectedUser==null)
								{
									selectedUser = userData.getUser(s_user);
								}
								a_userVMs = selectedUser.getOnlyVMs();
								if(a_userVMs!=null && a_userVMs.size() > 0)
								{
									hasVM = true;
									
								}
							}
							if(hasVM)
							{
								copyResult.add(row);
								
							}
							else
							{
								copyResult.add(row);
							}*/
							copyResult.add(row);
						}
					}
				}

				try
				{
					rs.close();
					rs = null;
				}
				catch (Exception hh)
				{
					rs = null;
				}
				if (copyResult != null)
				{
					int recordCount = copyResult.size();
					//if (recordCount > offsetCount)
					//copyResult.subList(offsetCount , recordCount).clear();
				}
				return copyResult;
			}
			catch (Exception jpm)
			{
				logToTmpFile("INFO","","Error "+jpm.toString());
				jpm.printStackTrace();
				try
				{
					if (rs != null)
					{
						rs.close();
					}
				}
				catch (Exception grr)
				{
					//System.out.println("grr================>"+grr);
					grr.printStackTrace();
				}
				return null;
			}
		}
		else 
		{
			StringBuffer oracleQuery = null;
			StringBuffer sqlQuery = null;

			query.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
			if (serverNames.length()==0)
			{// filter based on comp_type
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery = new StringBuffer(256);
					sqlQuery = new StringBuffer(256);
					oracleQuery.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
					sqlQuery.append("SELECT AHS.Priority,AH.USER_ID,AH.ACK_DESCRIPTION,AH.ACK_TIME,AHS.COMP_TYPE,AHS.COMP_NAME,AHS.PROBLEM_DESC,AH.OPTIONS,AH.REAL_USER FROM ACKNOWLEDGEMENT_HISTORY AH,ALARM_HIST_SUMMARY AHS WHERE");
					
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							oracleQuery.append(" AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}

							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
						else
						{
							oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							oracleQuery.append(" AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) AND convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							sqlQuery.append(" AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

							if (!real_user.equals(""))
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
						else
						{
							sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) AND convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							sqlQuery.append(" AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                                 //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}

						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') AND to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
				}
				else                                                   //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) AND convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals(""))
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) AND convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			else 
			{ // filter based on comp_name
				if(EgInstallInfo.isSuperManager)
				{
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							oracleQuery.append(" AND AHS.COMP_NAME IN (");
							oracleQuery.append(serverNames);
							oracleQuery.append(") AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
						else
						{
							oracleQuery.append(" AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							oracleQuery.append(" AND AHS.COMP_NAME IN (");
							oracleQuery.append(serverNames);
							oracleQuery.append(") AND AHS.COMP_TYPE IN (");
							oracleQuery.append(serverTypes);
							oracleQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							sqlQuery.append(" AND AHS.COMP_NAME IN (");
							sqlQuery.append(serverNames);
							sqlQuery.append(") AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
							
							if (!real_user.equals("") && real_user.length() > 0)
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
						else
						{
							sqlQuery.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("',101 ) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("',101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							sqlQuery.append(" AND AHS.COMP_NAME IN (");
							sqlQuery.append(serverNames);
							sqlQuery.append(") AND AHS.COMP_TYPE IN (");
							sqlQuery.append(serverTypes);
							sqlQuery.append(")");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                                 //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
					}
				}
				else
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) and convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
						
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
					else
					{
						query.append(" AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("',101 ) and convert(datetime,'");
						query.append(toTime);
						query.append("',101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						query.append(" AND AHS.COMP_NAME IN (");
						query.append(serverNames);
						query.append(") AND AHS.COMP_TYPE IN (");
						query.append(serverTypes);
						query.append(")");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");
					}
				}
			}
			if(serverNames.length()==0 && serverTypes.length()==0 && ackUserId!=null && !ackUserId.equals("-1"))
			{
				if(EgInstallInfo.isSuperManager)
				{
					//Building oracle query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							oracleQuery.append(" AH.USER_ID='");
							oracleQuery.append(ackUserId);
							oracleQuery.append("' AND AH.ACK_TIME BETWEEN to_date('");
							oracleQuery.append(fromTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
							oracleQuery.append(toTime);
							oracleQuery.append("','mm/dd/yyyy hh24:mi:ss') ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								oracleQuery.append(" AND AH.options='");
								oracleQuery.append(ackorDeleteComp);
							}
							else
							{
								oracleQuery.append(" AND AH.options!='Deletion");
							}
							oracleQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							{
								oracleQuery.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
							}
							if (!real_user.equals("") && real_user.length() > 0)
							{
								oracleQuery.append(" AND AH.REAL_USER='");
								oracleQuery.append(real_user);
								oracleQuery.append("'");
							}
						}
					}
					//Building sqlserver query for super manager
					{
						if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
						{
							sqlQuery.append(" AH.USER_ID='");
							sqlQuery.append(ackUserId);
							sqlQuery.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
							sqlQuery.append(fromTime);
							sqlQuery.append("', 101) and convert(datetime,'");
							sqlQuery.append(toTime);
							sqlQuery.append("', 101) ");
							if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
							{
								sqlQuery.append(" AND AH.options='");
								sqlQuery.append(ackorDeleteComp);
							}
							else
							{
								sqlQuery.append(" AND AH.options!='Deletion");
							}
							sqlQuery.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
							if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
								sqlQuery.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
							else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
								sqlQuery.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

							if (!real_user.equals("") && real_user.length() > 0)
							{
								sqlQuery.append(" AND AH.REAL_USER='");
								sqlQuery.append(real_user);
								sqlQuery.append("'");
							}
						}
					}
				}
				else if (EgDbInfo.isOraAdapter)                      //oracle
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN to_date('");
						query.append(fromTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') and to_date('");
						query.append(toTime);
						query.append("','mm/dd/yyyy hh24:mi:ss') ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
						{
							query.append(" AND (AHS.END_TIME IS NULL or AHS.END_TIME =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
						{
							query.append(" AND (AHS.END_TIME IS NOT NULL AND AHS.END_TIME! =to_date('01/01/1900 00:00:00','mm/dd/yyyy hh24:mi:ss'))");
						}
						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
				}
				else                                             //sql
				{
					if(ackUserId!=null && ackUserId.length()>0 && !ackUserId.equals("-1"))
					{
						query.append(" AH.USER_ID='");
						query.append(ackUserId);
						query.append("' AND AH.ACK_TIME BETWEEN convert(datetime,'");
						query.append(fromTime);
						query.append("', 101) and convert(datetime,'");
						query.append(toTime);
						query.append("', 101) ");
						if(ackorDeleteComp!=null && ackorDeleteComp.equalsIgnoreCase("Deletion"))
						{
							query.append(" AND AH.options='");
							query.append(ackorDeleteComp);
						}
						else
						{
							query.append(" AND AH.options!='Deletion");
						}
						query.append("' AND AH.EVENT_ID = AHS.ALARM_ID");
						if(alarmOption!= null && alarmOption.equalsIgnoreCase("Open"))
							query.append(" AND AHS.END_TIME = '1900-01-01 00:00:00.0'");
						else if(alarmOption!= null && alarmOption.equalsIgnoreCase("Closed"))
							query.append(" AND AHS.END_TIME > '1900-01-01 00:00:00.0'");

						if (!real_user.equals("") && real_user.length() > 0)
						{
							query.append(" AND AH.REAL_USER='");
							query.append(real_user);
							query.append("'");
						}
					}
				}
			}
/*
			if (eventID != null)
			{
				if (reverseList)
				{
					query.append(" and AH.EVENT_ID < ");
					query.append(eventID);
				}
				else
				{
					query.append(" and AH.EVENT_ID > ");
					query.append(eventID);
				}
			}
*/
			query.append(" ORDER BY AH.ACK_TIME");
			if (reverseList)
			{
				query.append(" DESC");
			}
			logToTmpFile("INFO","","Query for event history2 is "+query.toString());

			ResultSet rs = null;
			//List result=new LinkedList();
			
			try
			{
				if(EgInstallInfo.isSuperManager)
				{
					oracleQuery.append(" ORDER BY AH.ACK_TIME");
					sqlQuery.append(" ORDER BY AH.ACK_TIME");
					if (reverseList)
					{
						oracleQuery.append(" DESC");
						sqlQuery.append(" DESC");
					}
					Hashtable ht = new Hashtable();
					ht.put("OracleQuery",oracleQuery.toString());
					ht.put("SqlQuery",sqlQuery.toString());
					//ht.put("AddMgrIdToRs","yes");
					if(fromTime != null && toTime != null)
					{
						ht.put("startDate",fromTime);
						ht.put("endDate",toTime);
						if(fromTime.indexOf(":") == fromTime.lastIndexOf(":"))
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm");
						}
						else
						{
							ht.put("sourceDateFormat","MM/dd/yyyy HH:mm:ss");
						}
					}
					rs=new EgSMDBHelper().getResultSet(ht);
					oracleQuery.setLength(0);
					sqlQuery.setLength(0);
				}
				else
				{
					rs = egDb.dbselect(query.toString());
				}
				List result = new LinkedList();
				List result_temp = (List)egDb.getAckResultSetAsList(rs);

				if(result_temp != null && result_temp.size() > 0)
				{
					result = (List)getAlarmHistAsList(result_temp, servers,showAll,hasVMs,user,selectedCompType,selectedCompName,showAllTypes,showAllComps,userCompList);
				}
				try
				{
					rs.close();
					rs = null;
				}
				catch (Exception hh)
				{
					rs = null;
				}
				if (result != null)
				{
					int recordCount = result.size();
					//if (offsetCount < recordCount)
					//result.subList(offsetCount , recordCount).clear();
				}
				return result;
			}
			catch (Exception chasegrrr)
			{
				try
				{
					if (rs != null)
					{
						rs.close();
					}
				}
				catch (Exception grr)
				{
				}
				return null;
			}
		}
	}
	public final List getEventHistAsList(ResultSet rs, List servers,boolean showAll,boolean hasVMs,User user,String selectedCompType,String selectedCompName,boolean showAllTypes,boolean showAllComps,List userCompList) throws SQLException
	{
		List list = new LinkedList();
		ResultSetMetaData rsmd = rs.getMetaData();
		int count = rsmd.getColumnCount();
		List userServ = userCompList;
		List a_userVMs = new LinkedList();
		EgUserRole userRole = EgUserRole.getRoleObject(user.getLoginType());
		boolean allCompAccess = userRole.hasAllComponentAccess();
		String vm ="";
		Hashtable user_obj=new Hashtable();
		while (rs.next())
		{
			//if (count > 1)
			//{
				
				String[] row = new String[count];
				for (int a = 0; a < count; a++)
				{
					row[a] = rs.getString(a + 1);
				}
				String ctypeName = row[4]+":"+row[5];
				boolean rowUserHasVM = false;
				String s_user = rs.getString(2);
				User selectedUser = null;
				List thisUser_a_userVMs = new LinkedList();
				List thisUser_servers = new LinkedList();
				List thisUser_hservers = new LinkedList();

				if(user_obj!=null && user_obj.containsKey(s_user))
				{
					selectedUser = (User)user_obj.get(s_user);
					thisUser_hservers = (List)user_obj.get(s_user+"_Servers");
				}
				else
				{
					ErUserData userData = new ErUserData(s_user,false);
					if(userData!=null)
					{
						selectedUser=userData.usr;
						if(selectedUser==null)
						{
							selectedUser = userData.getUser(s_user);
						}
						if(selectedUser!=null)
						{
							user_obj.put(s_user,(User)selectedUser);
							thisUser_servers = selectedUser.getServers(false);
							thisUser_hservers = getHostSystemServers(thisUser_servers);
							user_obj.put(s_user+"_Servers",(List)thisUser_hservers);
						}
					}
				}

				if(selectedUser!=null)
				{
					thisUser_a_userVMs = selectedUser.getOnlyVMs();
					if(thisUser_a_userVMs.size() > 0)
					{
						rowUserHasVM = true;
					}
				}

				if(hasVMs)
				{
					a_userVMs = user.getOnlyVMs();
					//what if selected vm is chosen.
					if(showAll)
					{	
						if(!allCompAccess)
						{
							if(!userServ.contains(ctypeName))
							{
								if(rowUserHasVM)
								{
									vm = rs.getString(7);
									vm = vm.substring(1);
									if(a_userVMs!=null && a_userVMs.size() > 0)
									{
										if(vm.indexOf(":") > -1)
										{
											vm = vm.substring(0,vm.indexOf(":"));
										}
										if(!a_userVMs.contains(vm))
										{
											continue;
										}
									}
								}
								else
								{
									continue;
								}
							}
						}
					}
					else
					{
						if(!showAllTypes && showAllComps)
						{
							if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))
							{
								//If all component access user in resultset dont iterate.
								if(rowUserHasVM)
								{
									vm = rs.getString(7);
									vm = vm.substring(1);
									
									if(a_userVMs!=null && a_userVMs.size() > 0)
									{
										if(vm.indexOf(":") > -1)
										{
											vm = vm.substring(0,vm.indexOf(":"));
										}
										
										if(!a_userVMs.contains(vm))
										{
											continue;
										}
									}
								}
								else
								{
									continue;
								}
							}
							else
							{
								if(thisUser_hservers.contains(ctypeName))
								{
									
									if(!allCompAccess)
									{
										if(!userServ.contains(ctypeName))
											continue;
									}
								}
								else
								{
									continue;
								}
							}
						}
						else if(showAllTypes && !showAllComps)
						{
									if(userServ!=null && userServ.size() >0)
									{
										int countVM = 0;
										for(int u =0 ; u  < userServ.size() ; u++)
										{
											String host = (String)userServ.get(u);
											String type = host.substring(0,host.indexOf(":"));
											String comp = host.substring(host.indexOf(":")+1);
											if(selectedCompName.indexOf(":") <0)
											{
												if(comp.indexOf(selectedCompName) < 0)
												{
													//it is a vm
													countVM++;
												}
											}
											else
											{
												if(comp.indexOf(selectedCompName) < 0)
												{
													continue;
												}
											}

										}
										if(countVM == userServ.size())
										{
											vm = rs.getString(7);
											vm = vm.substring(1);
											if(a_userVMs!=null && a_userVMs.size() > 0)
											{
												//Count only the vm alarms with the particular descriptor
												if(vm.indexOf(":") > -1)
												{
													vm = vm.substring(0,vm.indexOf(":"));
												}
												if(a_userVMs.contains(vm))
												{

													
														if(!selectedCompName.equals(vm))
														{
															continue;
														}
													
												}
												else
												{
													continue;
												}
											}
										}
										else
										{
											if(!allCompAccess)
											{
												if(ctypeName.indexOf(selectedCompName)>-1)
												{
													if (!userServ.contains(ctypeName))
													{
														continue;
													}
												}
												else
												{
													continue;
												}
											}
										}
									}
						}
						else if(!showAllTypes && !showAllComps)
						{
							if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))
							{
								if(rowUserHasVM)
								{
									vm = rs.getString(7);
									vm = vm.substring(1);
									
									if(a_userVMs!=null && a_userVMs.size() > 0)
									{
										if(vm.indexOf(":") > -1)
										{
											vm = vm.substring(0,vm.indexOf(":"));
										}
										
										if(a_userVMs.contains(vm))
										{
											if(!selectedCompName.equals(vm))
											{
												continue;		
											}
										}
										else
										{
											continue;
										}
									}
								}
								else
								{
									continue;
								}
							}
							else
							{
								if(thisUser_hservers.contains(ctypeName))
								{
									if(!allCompAccess)
									{
											if(ctypeName.indexOf(selectedCompName)>-1)
											{
												if (!userServ.contains(ctypeName))
												{
													continue;
												}
											}
											else
											{
												continue;
											}
									}
								}

							}

						}
					}
					list.add(row);

				}
				else
				{
					if(allCompAccess)
					{
						if(showAll)
						{
							list.add(row);
						}
						if(!showAllTypes || !showAllComps)
						{
							if(selectedUser.isOnlyVMAssigned() && !selectedUser.isVMAssigned())
							{
								continue;
							}
							else
							{
								if(!showAllTypes && showAllComps)
								{
									
									if(rowUserHasVM && thisUser_hservers.size() == 0)
									{
										continue;
									}
									else
									{
										if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(ctypeName))
										{
											if (!servers.contains(ctypeName))
												continue;
											if(ctypeName.indexOf(selectedCompType) <0 && ctypeName.indexOf(Server.HOST_SYSTEM)< 0)
												continue;
											list.add(row);
										}

									}
								}
								if(!showAllComps && showAllTypes)
								{
									if(thisUser_hservers.contains(ctypeName))
									{
										if (!servers.contains(ctypeName))
											continue;
										if(ctypeName.indexOf(selectedCompName) < 0 && ctypeName.indexOf(Server.HOST_SYSTEM)< 0 )						
											continue;
										list.add(row);
									}
									else
										continue;
									
								}
								if(!showAllComps && !showAllTypes)
								{
									if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(ctypeName))
									{
										if(!servers.contains(ctypeName))
											continue;
										
										if((ctypeName.indexOf(selectedCompType) <0 && ctypeName.indexOf(Server.HOST_SYSTEM)<0) ||(ctypeName.indexOf(selectedCompName) < 0 && ctypeName.indexOf(Server.HOST_SYSTEM) < 0 ))
											continue;

										else
											list.add(row);
										
									}
								}
							}
						}
					}
					else
					{
						if(thisUser_hservers.contains(ctypeName))
						{
							if (!servers.contains(ctypeName))
							{
								continue; 
							}
						}
						else
						{
							continue;
						}
						list.add(row);
					}
				}
			//}
			//else
			//{
				//list.add(rs.getString(1));
			//}
		}
		return list;
	}

	public final List getAlarmHistAsList(List result, List servers,boolean showAll,boolean hasVMs,User user,String selectedCompType,String selectedCompName,boolean showAllTypes,boolean showAllComps,List userCompList) throws SQLException
	{
		List list = new LinkedList();
		int count = result.size();
		List userServ = userCompList;
		List a_userVMs = new LinkedList();
		EgUserRole userRole = EgUserRole.getRoleObject(user.getLoginType());
		boolean allCompAccess = userRole.hasAllComponentAccess();
		String vm ="";
		Hashtable user_obj=new Hashtable();
		if(result != null && result.size() > 0)
		{
			for(int kk=0;kk<count;kk++)
			{
				String[] row = (String[])result.get(kk);
				if(row != null && row.length > 0)
				{
					String ctypeName = row[4]+":"+row[5];
					boolean rowUserHasVM = false;
					String s_user = row[1];
					
					User selectedUser = null;
					List thisUser_a_userVMs = new LinkedList();
					List thisUser_servers = new LinkedList();
					List thisUser_hservers = new LinkedList();

					if(user_obj!=null && user_obj.containsKey(s_user))
					{
						selectedUser = (User)user_obj.get(s_user);
						thisUser_hservers = (List)user_obj.get(s_user+"_Servers");
					}
					else
					{
						ErUserData userData = new ErUserData(s_user,false);
						if(userData!=null)
						{
							selectedUser=userData.usr;
							if(selectedUser==null)
							{
								selectedUser = userData.getUser(s_user);
							}

							if(selectedUser!=null)
							{
								user_obj.put(s_user,(User)selectedUser);
								thisUser_servers = selectedUser.getServers(false);
								thisUser_hservers = getHostSystemServers(thisUser_servers);
								user_obj.put(s_user+"_Servers",(List)thisUser_hservers);
							}
						}
					}

					if(selectedUser!=null)
					{
						thisUser_a_userVMs = selectedUser.getOnlyVMs();
						if(thisUser_a_userVMs.size() > 0)
						{
							rowUserHasVM = true;
						}
					}

					if(hasVMs)
					{
						a_userVMs = user.getOnlyVMs();
						//what if selected vm is chosen.
						if(showAll)
						{	
							if(!allCompAccess)
							{
								if(!userServ.contains(ctypeName))
								{
									if(rowUserHasVM)
									{
										vm = row[6];
										vm = vm.substring(1);
										if(a_userVMs!=null && a_userVMs.size() > 0)
										{
											if(vm.indexOf(":") > -1)
											{
												vm = vm.substring(0,vm.indexOf(":"));
											}
											if(!a_userVMs.contains(vm))
											{
												continue;
											}
										}
									}
									else
									{
										continue;
									}
								}
							}
						}
						else
						{
							if(!showAllTypes && showAllComps)
							{
								if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))
								{
									//If all component access user in resultset dont iterate.
									if(rowUserHasVM)
									{
										vm = row[6];
										vm = vm.substring(1);
										
										if(a_userVMs!=null && a_userVMs.size() > 0)
										{
											if(vm.indexOf(":") > -1)
											{
												vm = vm.substring(0,vm.indexOf(":"));
											}
											
											if(!a_userVMs.contains(vm))
											{
												continue;
											}
										}
									}
									else
									{
										continue;
									}
								}
								else
								{
									if(thisUser_hservers.contains(ctypeName))
									{
										
										if(!allCompAccess)
										{
											if(!userServ.contains(ctypeName))
												continue;
										}
									}
									else
									{
										continue;
									}
								}
							}
							else if(showAllTypes && !showAllComps)
							{
										if(userServ!=null && userServ.size() >0)
										{
											int countVM = 0;
											for(int u =0 ; u  < userServ.size() ; u++)
											{
												String host = (String)userServ.get(u);
												String type = host.substring(0,host.indexOf(":"));
												String comp = host.substring(host.indexOf(":")+1);
												if(selectedCompName.indexOf(":") <0)
												{
													if(comp.indexOf(selectedCompName) < 0)
													{
														//it is a vm
														countVM++;
													}
												}
												else
												{
													if(comp.indexOf(selectedCompName) < 0)
													{
														continue;
													}
												}

											}
											if(countVM == userServ.size())
											{
												vm = row[6];
												vm = vm.substring(1);
												if(a_userVMs!=null && a_userVMs.size() > 0)
												{
													//Count only the vm alarms with the particular descriptor
													if(vm.indexOf(":") > -1)
													{
														vm = vm.substring(0,vm.indexOf(":"));
													}
													if(a_userVMs.contains(vm))
													{

														
															if(!selectedCompName.equals(vm))
															{
																continue;
															}
														
													}
													else
													{
														continue;
													}
												}
											}
											else
											{
												if(!allCompAccess)
												{
													if(ctypeName.indexOf(selectedCompName)>-1)
													{
														if (!userServ.contains(ctypeName))
														{
															continue;
														}
													}
													else
													{
														continue;
													}
												}
											}
										}
							}
							else if(!showAllTypes && !showAllComps)
							{
								if(selectedCompType!=null && selectedCompType.equals(user.getVMType()))
								{
									if(rowUserHasVM)
									{
										vm = row[6];
										vm = vm.substring(1);
										
										if(a_userVMs!=null && a_userVMs.size() > 0)
										{
											if(vm.indexOf(":") > -1)
											{
												vm = vm.substring(0,vm.indexOf(":"));
											}
											
											if(a_userVMs.contains(vm))
											{
												if(!selectedCompName.equals(vm))
												{
													continue;		
												}
											}
											else
											{
												continue;
											}
										}
									}
									else
									{
										continue;
									}
								}
								else
								{
									if(thisUser_hservers.contains(ctypeName))
									{
										if(!allCompAccess)
										{
												if(ctypeName.indexOf(selectedCompName)>-1)
												{
													if (!userServ.contains(ctypeName))
													{
														continue;
													}
												}
												else
												{
													continue;
												}
										}
									}
								}
							}
						}
						list.add(row);
					}
					else
					{
						if(allCompAccess)
						{
							if(showAll)
							{
								list.add(row);
							}
							if(!showAllTypes || !showAllComps)
							{
								if(selectedUser.isOnlyVMAssigned() && !selectedUser.isVMAssigned())
								{
									continue;
								}
								else
								{
									if(!showAllTypes && showAllComps)
									{
										
										if(rowUserHasVM && thisUser_hservers.size() == 0)
										{
											continue;
										}
										else
										{
											if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(ctypeName))
											{
												if (!servers.contains(ctypeName))
													continue;
												if(ctypeName.indexOf(selectedCompType) <0 && ctypeName.indexOf(Server.HOST_SYSTEM)< 0)
													continue;
												list.add(row);
											}

										}
									}
									if(!showAllComps && showAllTypes)
									{
										if(thisUser_hservers.contains(ctypeName))
										{
											if (!servers.contains(ctypeName))
												continue;
											if(ctypeName.indexOf(selectedCompName) < 0 && ctypeName.indexOf(Server.HOST_SYSTEM)< 0 )						
												continue;
											list.add(row);
										}
										else
											continue;
										
									}
									if(!showAllComps && !showAllTypes)
									{
										if(thisUser_hservers.size() > 0 && thisUser_hservers.contains(ctypeName))
										{
											if(!servers.contains(ctypeName))
												continue;
											
											if((ctypeName.indexOf(selectedCompType) <0 && ctypeName.indexOf(Server.HOST_SYSTEM)<0) ||(ctypeName.indexOf(selectedCompName) < 0 && ctypeName.indexOf(Server.HOST_SYSTEM) < 0 ))
												continue;

											else
												list.add(row);
											
										}
									}
								}
							}
						}
						else
						{
							if(thisUser_hservers.contains(ctypeName))
							{
								if (!servers.contains(ctypeName))
								{
									continue; 
								}
							}
							else
							{
								continue;
							}
							list.add(row);
						}
					}
				}
			}
		}
		return list;
	}
	public void logToTmpFile(String type, String entity,String msg)
	{
		PrintWriter logWriter;
		if (!tmpLog)
		return;
		synchronized(syncVector)
		{
			EgDateInfo dateInfo = new EgDateInfo();
			String logDateAndTime = dateInfo.egetDate(false);
			try
			{
				logWriter = new PrintWriter(new FileWriter(tmpFile, true));
			}
			catch(Exception e)
			{
				System.err.println("Cannot open tmp log file ");
				return;
			}
			String log=new String(logDateAndTime+" "+type + " "+ entity + " "+ msg);
			logWriter.println(log);
			logWriter.flush();
			logWriter.close();
		}
	}
	private List getHostSystemServers(List listServers)
	{
		List returnServer = new LinkedList();
		if(listServers!=null && listServers.size() > 0)
		{
			for(int t=0; t < listServers.size() ;t++)
			{
				String s_host = (String)listServers.get(t);
				StringTokenizer tokens = new StringTokenizer(s_host,":");

				String type = tokens.nextToken();
				String comp = tokens.nextToken();
				String host_sys = Server.getHostSystem(s_host,true);
				returnServer.add(s_host);
				returnServer.add(host_sys);
			}
		}
		return returnServer;
	}

		/**
		* This method is used to get custom problem alert description. 
		* @param message -Problem alert description
		* @param Compname -Component name
		* @param CompType -Component type
		* @param Service -Service name
		* @param Priority -Priority critical|major|minor
		* @param Layer - Layer name
		* @param Test -Test name 
		* @param info -Descriptor details 
		* @param Measure -Measure name 
		* @param LastMeasurevalue - Last measure value
		* @return String This returns the custom problem alert description.
		*/
		
		private String replaceMsg (String message,String Compname,String CompType,String Service,String Priority,String Layer,String Test,String info,String Measure,String LastMeasurevalue)
		{
			message = replace(message,"$Compname",Compname);
			message = replace(message,"$CompType",CompType);
			message = replace(message,"$Service",Service);
			message = replace(message,"$Priority",Priority);
			message = replace(message,"$Layer",Layer);
			message = replace(message,"$Test",Test);
			String tempInfoStr="";
			if(info!=null && !info.trim().equals("+"))
			{
				tempInfoStr=info;
			}
			message = replace(message,"$info",tempInfoStr);
			message = replace(message,"$Measure",Measure);
			message = replace(message,"$LastMeasurevalue",LastMeasurevalue);
			return message.toString();
		}
		private String replace (String s,String s_search,String s_replace)
		{
			StringBuffer sb_tmp = new StringBuffer();
			while(s.indexOf(s_search) > -1)
			{
			   sb_tmp.append(s.substring(0,s.indexOf(s_search)) + s_replace);
				s = s.substring(s.indexOf(s_search) + s_search.length(),s.length());
			}
			if(s.length() > 0)
			sb_tmp.append(s);
			return sb_tmp.toString();
		}

	private long getDuration(String s, String s1)
    {
        long l = 0L;
        try
        {
            SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            java.util.Date date = simpledateformat.parse(s);
            java.util.Date date1 = simpledateformat.parse(s1);
            l = (date1.getTime() - date.getTime()) / 1000L;
        }
        catch(Exception exception)
        {
            System.out.println("Exception in EgAckHistoryTableBean:getDuration()");
            exception.printStackTrace();
        }
        return l;
    }


%>

<%
	if(history!=null && history.size()>0)
	{
%>
			<script>

				if(window.parent.document.getElementById("hidVpdfData")!=null)
				{
					window.parent.document.getElementById("hidVpdfData").value="true";
				}

			</script>
<%
	}
	else
	{
%>
			<script>

				if(window.parent.document.getElementById("hidVpdfData")!=null)
				{
					window.parent.document.getElementById("hidVpdfData").value="false";
				}

			</script>
<%
	}
}
catch(Exception e)
{
	e.printStackTrace();
}
%>
</body>
</html>

