<!DOCTYPE html>

<%@ include file = "EgTrackerA.jsp" %>
<%@ page import="com.eg.*" %>
<%@ page import ="java.util.ArrayList"%>
<%@ page import="com.egurkha.ini.IniUI" %>
<%@ page import = "java.util.TimeZone"%>
<%@ page import = "java.util.Calendar"%>
<%@ page import = "java.text.SimpleDateFormat"%>
<%@ page import = "java.text.DateFormat"%>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ page import = "com.egurkha.util.EgSorter"%>
<%@ taglib prefix = "egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%
	String print = (String) request.getParameter("print");
%>

<html>
<head>

<%
	if (print!=null && print.equalsIgnoreCase("printpage"))
	{
%>
<link rel="stylesheet" type="text/css" href="/final/styles/eGLightTheme.css" />
<link rel="stylesheet" type="text/css" href="/final/styles/eGLightThemeIcons.css" />
<%
	}
%>

<style>

@media print {body {-webkit-print-color-adjust: exact;}}

/*
@font-face{font-family:'LucidaGrandeRegular';src:url('/final/fonts/6216/6216.woff') format('woff')}
@font-face{font-family:'LucidaGrandeBold';src:url('/final/fonts/6215/6215.woff') format('woff')}
*/

body{font-size:12px;line-height:1.5em;color:#2a292a;}
header{font-size:15px;}
.formLabel {font-size:12px;}
.formValue {font-weight:500;font-size:12px;}
b{font-weight:500;font-size:12px;}
table tr td{font-size:12px;padding:4px;}
.printTable{border: 1px solid #c3c3c3; border-collapse: collapse;}
.printTable tr td{border: 1px solid #c3c3c3;}
.printTableHeader{font-weight:500;border: 1px solid #c3c3c3;text-align:center;background-color:#cdcdcd;padding:4px;}
</style>
<script language="JavaScript">
	function printData()
	{
		window.print();
	}
</script>
</head>
<!--<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
	String from = (String)session.getAttribute("from");
	String	choosenCompType = (String)session.getAttribute("choosenCompType");
	String	totalDiscCount = (String)session.getAttribute("totalDiscCount");
	String	value = (String)session.getAttribute("value");
	String	searchType = (String)session.getAttribute("searchType");
	String	fromDateSearch = (String)session.getAttribute("fromdateSearch");
	String	todateSearch = (String)session.getAttribute("todateSearch");
	String	timelineVal = (String)session.getAttribute("timelineVal");
	String	searchVal = (String)session.getAttribute("searchVal");
	if (searchVal == null || searchVal.equals(""))
	{
		searchVal = (String)session.getAttribute("nickSearch");
	}
	EgDiscInfo discInfo = new EgDiscInfo("manager");
	Hashtable allNickIpMap = discInfo.getNickIpMap(true,"");
	IniUI iniUI = IniUI.getInstance();
	String userLanguage = iniUI.getDefaultLanguage();
	if (_user != null)
	{
		userLanguage = _user.getLanguage();
	}
	String logo=iniUI.getMonitorHomeLogo();
	if(iniUI.isHKTThemeEnabled())
	{
		logo = iniUI.getHKTReporterLogo();
	}
	IniFile egAutoDelete = new IniFile(EgConfigInfo.egMgrConfigDir + "eg_autodelete.ini");
	String[] firstDiscoveryDetails = egAutoDelete.getVariables("Components_Firsttime_Discovery_Details");
	String[] reDiscoveryDetails = egAutoDelete.getVariables("Components_Discovery_Details");
	ArrayList firstDiscoverdCompArrList = new ArrayList();
	ArrayList reDiscoveryArr = new ArrayList();
	for(int j=0; j<reDiscoveryDetails.length; j++)
	{
		String reDiscDetail = reDiscoveryDetails[j];
		reDiscoveryArr.add(reDiscDetail);
	}
	
	String userDateFormat = _user.getUserDateFormat();
	String userTimeFormat = _user.getUserTimeZone();
	if(userTimeFormat!=null && (userTimeFormat.equalsIgnoreCase("default") || com.egurkha.util.StringUtils.isNull(userTimeFormat)))
	{
		EgDateInfo egDate = new EgDateInfo();
		TimeZone tmz = egDate.getRealTimeZone();
		userTimeFormat = tmz.getID();
	}
	String userDateTimeFormat = userDateFormat+" HH:mm:ss";
	TimeZone timeZone = TimeZone.getTimeZone(userTimeFormat);
	MappingNameSorter sorter = new MappingNameSorter(userLanguage);
	ArrayList firstDiscArr = new ArrayList(Arrays.asList(firstDiscoveryDetails));
	ArrayList sortedComponents = sorter.getSortedCompTypesWithNick(firstDiscArr);
	ArrayList totalComponents = new ArrayList();
	ArrayList choosenCompArr = new ArrayList();
	ArrayList serachCompList = new ArrayList();
	String firstDiscoveredDate = "";
	String lastDisoveredDate = "";
	String duration = "";
	if(searchType!=null && searchType.equalsIgnoreCase("Last discovered time") && timelineVal != null && !timelineVal.equalsIgnoreCase("Any"))
	{
		String timeLines[] = setStartAndEndDateTime(timelineVal,userDateFormat);
		firstDiscoveredDate = timeLines[0];
		lastDisoveredDate = timeLines[1];
		if(timelineVal.indexOf("hour") > -1)
		{
			//duration =  "Timeline :"+timelineVal;
		}
		else
		{
			//duration =  "Timeline: "+timelineVal+"   From : "+firstDiscoveredDate+"   To : "+lastDisoveredDate;
		}
	}
	else if(searchType!=null && searchType.equalsIgnoreCase("Last discovered time") && fromDateSearch != null && !fromDateSearch.equals("null") && todateSearch != null && !todateSearch.equals("null"))
	{
	//	DateFormat formatDate = new SimpleDateFormat("E MM dd yyyy HH:mm:ss 'GMT'z");
	//	SimpleDateFormat sdf = new SimpleDateFormat(userDateFormat);
	//	Date fromDatePick = formatDate.parse(fromDateSearch);
	//	Date toDatePick = formatDate.parse(todateSearch);
	//	firstDiscoveredDate = sdf.format(fromDatePick); 	
	//	lastDisoveredDate = sdf.format(toDatePick);

		SimpleDateFormat sdf = new SimpleDateFormat(userDateTimeFormat);
		Date date1=new SimpleDateFormat("MM/dd/yyyy").parse(fromDateSearch);
		Date date2=new SimpleDateFormat("MM/dd/yyyy").parse(todateSearch);
		firstDiscoveredDate = sdf.format(date1);
		lastDisoveredDate = sdf.format(date2);
		
		//duration = "Timeline: "+timelineVal+"  From : "+fromVal+","+"  To : "+toVal;
	}
	
	ArrayList totalGridArr = new ArrayList();
	
	for(int h=0; h<sortedComponents.size(); h++)
	{
		String startdate="";
		String date="";
		String firstdiscDetail = (String)sortedComponents.get(h);
		String firstDiscTime = egAutoDelete.getValue("Components_Firsttime_Discovery_Details",firstdiscDetail);
		totalGridArr.add(firstDiscTime);

	//	startdate = getDateValue(firstDiscTime,userDateFormat,userTimeFormat); 
		if(reDiscoveryArr.contains(firstdiscDetail))
		{
			String reDiscTime = egAutoDelete.getValue("Components_Discovery_Details",firstdiscDetail);
			totalGridArr.add(reDiscTime);
			date = getDateValue(reDiscTime,userDateFormat,userTimeFormat); 
		}
		else
		{
			totalGridArr.add(firstDiscTime);
	//		date=startdate;
		}
		StringTokenizer strTok = new StringTokenizer(firstdiscDetail,":");
		//while(strTok.hasMoreTokens())
		if(strTok.countTokens() > 2)
		{
			String compType = strTok.nextToken();
			String compRawType = compType;
			if(!firstDiscoverdCompArrList.contains(compType))
			{
				firstDiscoverdCompArrList.add(compType);
			}
			compType = _mapping.getComponentTypeDescription(compType);
			String nick = strTok.nextToken();
			String portVal = strTok.nextToken();
			String tempPortVal = portVal;
			totalGridArr.add(compType);
			totalGridArr.add(nick);
			String SID = "-";
		//	String actualPortVal = portVal;
		//	if(portVal == "NULL" || portVal.equalsIgnoreCase("null") || portVal == "" || portVal.equals(""))
		//	{
		//		portVal = "-";
		//	}
			if (strTok.hasMoreTokens())
			{
				SID = strTok.nextToken();
				tempPortVal+="^"+SID;
			}
			totalGridArr.add(tempPortVal); 

			String discFrom = "-";
			String discFromHostIp="-";
			String discByNick = "-";
			String AgentUser = "-";
			String discFromDetail = egAutoDelete.getValue("Components_Discovered_From_Details",firstdiscDetail);
			if(discFromDetail!=null && discFromDetail.length() > 0)
			{
				int ind =discFromDetail.indexOf("#:#");
				discFrom = discFromDetail.substring(0,ind);
				totalGridArr.add(discFrom);  //Agent or Manager
				discFromDetail= discFromDetail.substring(ind+3);
				int secind = discFromDetail.indexOf("#:#");
				discFromHostIp = discFromDetail.substring(0,secind);
				totalGridArr.add(discFromHostIp);
				discFromDetail= discFromDetail.substring(secind+3);
				int thridx = discFromDetail.lastIndexOf("#:#");
				discByNick = discFromDetail.substring(0,thridx);
				discByNick=discByNick.replace(",","#:#");
				totalGridArr.add(discByNick);
				AgentUser = discFromDetail.substring(thridx+3);
				totalGridArr.add(AgentUser);
			}
			else
			{
				totalGridArr.add("-");  //Agent or Manager
				totalGridArr.add("-");
				totalGridArr.add("-");
				totalGridArr.add("-");
			}

			String compNameWithoutType = (compRawType.equalsIgnoreCase("oracle_server")) ? nick+":"+portVal+":"+SID : nick+":"+portVal;
			boolean isExistInDiscoverIni = discInfo.isCompAlreadyExist(compRawType,compNameWithoutType);
			if (isExistInDiscoverIni)
			{
			//	totalGridArr.add(compType);
			//	totalGridArr.add(nick);
			//	totalGridArr.add(portVal);
			//	String components = //compType+"#"+nick+"#"+portVal+"#"+SID+"#"+startdate+"#"+date+"#"+discFrom+"#"+discFromHostIp+"#"+discByNick+"#"+AgentUser;
			//	totalComponents.add(components);
			if(!firstDiscoverdCompArrList.contains(compType))
				{
					firstDiscoverdCompArrList.add(compType);
				}
			}
		}
	}
	/*	if(searchType!=null && searchType.equalsIgnoreCase("Last discovered time"))
	{
		int colNumberVal = 5;
		EgSorter egsort = new EgSorter(totalGridArr,colNumberVal);
		List sortedlist = egsort.sort(2,"long","DESC");
		totalComponents.clear();
		for(int b=0; b<sortedlist.size(); b++)
		{
			String start = (String)sortedlist.get(b);
			String end = (String)sortedlist.get(b+1);
			String comp = (String)sortedlist.get(b+2);
			String nick = (String)sortedlist.get(b+3);
			String portSort = (String)sortedlist.get(b+4);
			String sid = "-";
			if (_mapping.getReverseComponentTypeDescription(comp).toLowerCase().equalsIgnoreCase("oracle_server"))
			{
				sid = (String)sortedlist.get(b+5);
				b = b+5;
			}
			else
			{
				b = b+4;
			}
			String firstDate = getDateValue(start,userDateFormat,userTimeFormat); 
			String lastDate = getDateValue(end,userDateFormat,userTimeFormat); 
			String totComp = comp+"#"+nick+"#"+portSort+"#"+sid+"#"+firstDate+"#"+lastDate;
			totalComponents.add(totComp);
		}
	}*/

	if(totalGridArr.size() >0 )
	{
		int colNumberVal = 9;
		EgSorter egsort = new EgSorter(totalGridArr,colNumberVal);
		List sortedlist = egsort.sort(1,"long","DESC"); //1 - sort according to the First Discovery Time
		totalComponents.clear();
		int sortedListSize=sortedlist.size();
		for(int b=0; b<sortedListSize; b=b+9)
		{
			String start = (String)sortedlist.get(b);
			String end = (String)sortedlist.get(b+1);
			String comp = (String)sortedlist.get(b+2);
			String nick = (String)sortedlist.get(b+3);
			String portSort = (String)sortedlist.get(b+4);
			String discoverBy = (String)sortedlist.get(b+5);
			String discoverByIp = (String)sortedlist.get(b+6);
			String discoverybynick = (String)sortedlist.get(b+7);
			discoverybynick=discoverybynick.replace("#:#",", ");
			String discoverybyUser = (String)sortedlist.get(b+8);
			String sid = "-";
			int portSortIndex=portSort.indexOf("^");
			//if (_mapping.getReverseComponentTypeDescription(comp).toLowerCase().equalsIgnoreCase("oracle_server"))
			if(portSortIndex!=-1)
			{
				sid=portSort.substring(portSortIndex+1);
				portSort=portSort.substring(0,portSortIndex);
			}
			String firstDate = getDateValue(start,userDateFormat,userTimeFormat); 
			String lastDate = getDateValue(end,userDateFormat,userTimeFormat); 
			//String totComp = comp+"#"+nick+"#"+portSort+"#"+sid+"#"+firstDate+"#"+lastDate+"#"+discoverBy+"#"+discoverByIp+"#"+discoverybynick+"#"+discoverybyUser;
			String totComp = comp+"#::#"+nick+"#::#"+portSort+"#::#"+sid+"#::#"+firstDate+"#::#"+lastDate+"#::#"+discoverBy+"#::#"+discoverByIp+"#::#"+discoverybynick+"#::#"+discoverybyUser;
			totalComponents.add(totComp);
		}
	}
	if(from!= null && from.equalsIgnoreCase("combo"))
	{
		String nick="";
		String portVal="";
		String sid="";
		String components="";
		String startdate="";
		String endDateTime="";
		String disBy = "";
		String disByIp = "";
		String disByNick = "";
		String disByuser = "";
		// String ipVal = "-";
		for(int l=0; l<totalComponents.size(); l++)
		{
			String comp = (String)totalComponents.get(l);
			ArrayList tokList = StringUtils.egTokenizer(comp,"#::#");
			Iterator tok = tokList.iterator();
			while(tok.hasNext())
			{
				String compType =(String) tok.next();
			//	Enumeration nickEnum = allNickIpMap.keys();
			//	while(nickEnum.hasMoreElements())
			//	{
			//		String nickKey=(String) nickEnum.nextElement();
			//		if(nick.equalsIgnoreCase(nickKey))
			//		{
			//			ipVal =(String)allNickIpMap.get(nickKey);
			//		}
			//	}
				choosenCompType = _mapping.getComponentTypeDescription(choosenCompType);
				if(choosenCompType.equalsIgnoreCase(compType))
				{
					nick =(String) tok.next();
					portVal =(String) tok.next();
					sid = (String) tok.next();
					startdate =(String) tok.next();
					endDateTime =(String) tok.next();
					disBy =(String) tok.next();
					disByIp =(String) tok.next();
					disByNick =(String) tok.next();
					disByuser =(String) tok.next();
					components = compType+"#::#"+nick+"#::#"+portVal+"#::#"+sid+"#::#"+startdate+"#::#"+endDateTime+"#::#"+disBy+"#::#"+disByIp+"#::#"+disByNick+"#::#"+disByuser;
					choosenCompArr.add(components);
				}
				else if(choosenCompType.equalsIgnoreCase("All"))
				{
					nick =(String) tok.next();
					portVal =(String) tok.next();
					sid = (String) tok.next();
					startdate =(String) tok.next();
					endDateTime =(String) tok.next();
					disBy =(String) tok.next();
					disByIp =(String) tok.next();
					disByNick =(String) tok.next();
					disByuser =(String) tok.next();
					components = compType+"#::#"+nick+"#::#"+portVal+"#::#"+sid+"#::#"+startdate+"#::#"+endDateTime+"#::#"+disBy+"#::#"+disByIp+"#::#"+disByNick+"#::#"+disByuser;
					choosenCompArr.add(components);
				}
				else
				{
					nick =(String) tok.next();
					portVal =(String) tok.next();
					sid =(String) tok.next();
					startdate =(String) tok.next();
					endDateTime =(String) tok.next();
					disBy =(String) tok.next();
					disByIp =(String) tok.next();
					disByNick =(String) tok.next();
					disByuser =(String) tok.next();
				}
			}
		}
		totalComponents.clear();
		totalComponents.addAll(choosenCompArr);

		if(value!=null && value.equalsIgnoreCase("searchbox") && (searchVal!=null && !searchVal.equals("") || (fromDateSearch != null && !fromDateSearch.equals("null") && todateSearch != null && !todateSearch.equals("null"))))
		{
			boolean isSearchResult =(searchVal!=null);
			ArrayList searchList = new ArrayList();
			if (isSearchResult)
			{
				StringTokenizer st = new StringTokenizer(searchVal);
				while (st.hasMoreTokens())
				{
					String thisToken = st.nextToken().trim();
					if (thisToken.equals(""))
						continue;
					searchList.add(thisToken);
				}
			}
			for(int k=0; k<totalComponents.size(); k++)
			{
				String comp = (String)totalComponents.get(k);
				ArrayList tokList = StringUtils.egTokenizer(comp,"#::#");
				Iterator tok = tokList.iterator();
				while(tok.hasNext())
				{
					String compType =(String) tok.next();
					nick =(String) tok.next();
					Enumeration nickEnum = allNickIpMap.keys();
					String ipVal = "-";
					while(nickEnum.hasMoreElements())
					{
						String nickKey=(String) nickEnum.nextElement();
						if(nick.equalsIgnoreCase(nickKey))
						{
							ipVal =(String)allNickIpMap.get(nickKey);
						}
					}
					portVal =(String) tok.next();
					sid =(String) tok.next();
					startdate = (String) tok.next();
					endDateTime = (String) tok.next();
					disBy = (String) tok.next();
					disByIp = (String) tok.next();
					disByNick = (String) tok.next();
					disByuser =(String) tok.next();
					boolean exist = false;
					if(searchType!=null && searchType.equalsIgnoreCase("Nick name"))
					{
						exist = doesExist(nick,searchList);
					}
					else if(searchType!=null && searchType.equalsIgnoreCase("HOST IP/NAME"))
					{
						exist = doesExist(ipVal,searchList);
					}
					else if(searchType!=null && searchType.equalsIgnoreCase("Component type"))
					{
						exist = doesExist(compType,searchList);
					}
					else if(searchType!=null && searchType.equalsIgnoreCase("Last discovered time"))
					{
						if(endDateTime != "-" && endDateTime!=null)
						{
							StringTokenizer dateTok = new StringTokenizer(endDateTime," ");
							while(dateTok.hasMoreTokens())
							{
								String dateOnly = dateTok.nextToken();
								String time = dateTok.nextToken();
								exist = doesDateExist(endDateTime,fromDateSearch,todateSearch,timeZone,userDateTimeFormat,timelineVal);
							}
						}
					}
					if(exist)
					{
						components = compType+"#::#"+nick+"#::#"+portVal+"#::#"+sid+"#::#"+startdate+"#::#"+endDateTime+"#::#"+disBy+"#::#"+disByIp+"#::#"+disByNick+"#::#"+disByuser;
						serachCompList.add(components);
					}
				}
			}
			totalComponents.clear();
			totalComponents.addAll(serachCompList);
		}
	}
	Date currDate = new Date();
	SimpleDateFormat smdf = new SimpleDateFormat(userDateTimeFormat);
	String currDateStr = smdf.format(currDate); 
	int totalCompSize = totalComponents.size();
%>

<body  style="padding:10px;background-color:#ffffff">
<form action='EgDiscoveredComponentPdf.jsp' style="margin:0px">

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
				<tr>
					<td style="padding:5px 10px 10px 10px"><img src='<%=logo%>' border="0" /></td>
				</tr>
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"  style="border-bottom:1px solid #999;">
				<tr>
					<td style="padding:2px">
						<div style="float:left" > <header><egui:intnl text="admin.infrastructure.DISCOVERED COMPONENTS REPORT"/> </header></div>
<%
	if (print!=null && print.equalsIgnoreCase("printpage"))
	{
%>
						<div style="float:right"><img class="iconPrinter mouse" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" border="0" onClick="javascript:printData()" alt='<egui:intnl text="reporter.common.PRINT"/>' title='<egui:intnl text="reporter.common.PRINT"/>'/></div>
<%
	}
%>
					</td>
				</tr>
			</table>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="border-bottom:1px solid #ccc;">
				<tr>
					<td align="center">
						<div style="float:left;padding:4px;margin-right:30px">
							<div style="float:left" class="formLabel"><egui:intnl text="admin.infrastructure.Report generated on"/></div>
							<div style="float:left;width:10px;" >:</div>
							<div style="float:left;" class="formValue"><%=currDateStr%></div>
						</div>
					</td>
				</tr>
			</table>
<%
	if(searchType!=null && searchType.equalsIgnoreCase("Last discovered time"))
	{
%>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="border-bottom:1px solid #ccc;">
				<tr>
					<td align="center">
						<div style="float:left;padding:4px;margin-right:30px">
							<div style="float:left" class="formLabel"><egui:intnl text="admin.infrastructure.Timeline"/></div>
							<div style="float:left;width:10px;" >:</div>
							<div style="float:left;" class="formValue"><%=timelineVal%></div>
						</div>
						<div style="float:left;padding:4px;margin-right:30px">
							<div style="float:left" class="formLabel"><egui:intnl text="admin.infrastructure.From" /></div>
							<div style="float:left;width:10px;" >:</div>
							<div style="float:left;" class="formValue"><%=firstDiscoveredDate%></div>
						</div>
						<div style="float:left;padding:4px;margin-right:30px">
							<div style="float:left" class="formLabel"><egui:intnl text="admin.infrastructure.To" /></div>
							<div style="float:left;width:10px;" >:</div>
							<div style="float:left;" class="formValue"><%=lastDisoveredDate%></div>
						</div> 
					</td>
				</tr>
			</table>
<%
	}
%>
		</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="border-bottom:1px solid #ccc;">
				<tr>
<%
				if(choosenCompType.equalsIgnoreCase("All"))
				{
%>
					<td class="formLabel" width="100%" align="center">&nbsp;<egui:intnl text="admin.infrastructure.Total discovered components"/>&nbsp;:&nbsp;<span class="formValue"><%=totalDiscCount%></span></td>
<%
				}
				else
				{
%>
					<td class="formLabel" width="100%" align="center">&nbsp;<egui:intnl text="admin.infrastructure.Discovered components"/>&nbsp;:&nbsp;<span class="formValue"><%=totalDiscCount%></span></td>
<%
				}
%>
				</tr>
			</table>
		</td>
	</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"  style="border-bottom:1px solid #ccc;">
	<tr>
		<td class="formLabel" align="center">
			<egui:intnl text="admin.infrastructure.Discovered components details"/>
		</td>
	</tr>
</table><br/>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout:auto" class="printTable">
	<thead>
	<tr>
		<td class="printTableHeader" nowrap style="width:170px;" ><egui:intnl text="admin.infrastructure.Component type"/></td>
		<td class="printTableHeader" nowrap style="width:170px;" ><egui:intnl text="admin.infrastructure.Host Ip/Name"/></td>
		<td class="printTableHeader" nowrap style="width:170px;"><egui:intnl text="admin.infrastructure.Nick name"/></td>
		<td class="printTableHeader" nowrap style="width:70px;" ><egui:intnl text="admin.infrastructure.Port"/></td>
		<td class="printTableHeader" nowrap style="width:90px;" ><egui:intnl text="admin.infrastructure.SID/Service name"/></td>
		<td class="printTableHeader" nowrap style="width:100px;" ><egui:intnl text="admin.infrastructure.First discovered time"/></td>
		<td class="printTableHeader" nowrap style="width:100px;" ><egui:intnl text="admin.infrastructure.Last discovered time"/></td>
		<td class="printTableHeader" nowrap style="width:100px;" ><egui:intnl text="admin.infrastructure.Discovered By"/></td>
		<td class="printTableHeader" nowrap style="width:100px;" ><egui:intnl text="admin.infrastructure.Discovered From"/></td>
	</tr>
	</thead>
	<tbody>
<%
	for(int k=0; k<totalComponents.size(); k++)
	{
		String compwithnick = (String)totalComponents.get(k);
		ArrayList tokList = StringUtils.egTokenizer(compwithnick,"#::#");
		Iterator tok = tokList.iterator();
		while(tok.hasNext())
		{
			String compTypeVal =(String) tok.next();
			String nickVal =(String) tok.next();
			String HostIp ="-";
			Enumeration nickEnum = allNickIpMap.keys();
			while(nickEnum.hasMoreElements())
			{
				String nickKey=(String) nickEnum.nextElement();
				if(nickVal.equalsIgnoreCase(nickKey))
				{
					HostIp =(String)allNickIpMap.get(nickKey);
				}
			}
			String portValue =(String) tok.next();
			String sidValue =(String) tok.next();
			String startDate =(String) tok.next();
			String endDate = (String) tok.next();
			String disBy = (String) tok.next();
			String disByIp = (String) tok.next();
			String disByNick =(String) tok.next();
			String disByuser = (String) tok.next();
			if(HostIp!=null && HostIp!="-")
			{
%>
	<tr>
		<td><%=compTypeVal%></td>
		<td><%=HostIp%></td>
		<td><%=nickVal%></td>
		<td><%=portValue%></td>
		<td><%=sidValue%></td>
		<td align="center"><%=startDate%></td>
		<td align="center"><%=endDate%></td>
		<td><%=disBy%></td>
		<td><%=disByNick%></td>
	</tr>
<%
			}
		}
	}
%>
</tbody>
</table><br/>
</form>
</body>
</html>

<%!
public boolean doesExist(String compType,List searchStr)
{
	Iterator i = searchStr.iterator();
	while(i.hasNext())
	{
		String nextStr = (String) i.next();
		if (compType.indexOf(nextStr)!=-1||(compType.toUpperCase().indexOf(nextStr.toUpperCase()))!=-1)
		{
			return true;
		}
	}
	return false;
}
public boolean doesDateExist(String compDate,String fromDate,String toDate,TimeZone timeZone,String userDateFormat,String timelineVal)
{
	String stFormat=null;
	String endFormat=null;
	IniFile iniFile = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
	String currentDateFormat = iniFile.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	if(DateUtil.isDate(fromDate.trim(), "MM/dd/yyyy"))
		stFormat = "MM/dd/yyyy";
	else
		stFormat = currentDateFormat;

	if(DateUtil.isDate(toDate.trim(), "MM/dd/yyyy"))
		endFormat = "MM/dd/yyyy";
	else
		endFormat = currentDateFormat;

	String fromDateStr = DateUtil.changeDateFormat(fromDate.trim(),stFormat, "E MMM dd yyyy HH:mm:ss");
	String toDateStr = DateUtil.changeDateFormat(toDate.trim(),endFormat, "E MMM dd yyyy 23:59:59");
	String currDateStr = DateUtil.changeDateFormat(compDate,userDateFormat,"E MMM dd yyyy HH:mm:ss");
	Date currDateVal = new Date(currDateStr);
	Date fromDateVal = new Date(fromDateStr);
	Date toDateVal = new Date(toDateStr);

	long firstdateVal = currDateVal.getTime();
	Date currDate = new Date(firstdateVal);

	Calendar cal = Calendar.getInstance();
	cal.setTime(currDate);
	cal.setTimeZone(timeZone);
	Date date = new Date();
	if(timelineVal != null && timelineVal.startsWith("1 hour"))
	{
		long val12 = System.currentTimeMillis();
		Date minusHourDate = new Date(System.currentTimeMillis() - 3600 * 1000);
		if(cal.getTime().after(minusHourDate) || cal.getTime().equals(minusHourDate))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("6 hours"))
	{
		Date minusSixHourDate = new Date(System.currentTimeMillis() - 6 * 3600 * 1000);
		if(cal.getTime().after(minusSixHourDate) || cal.getTime().equals(minusSixHourDate))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("12 hours"))
	{
		Date minusTwelveHourDate = new Date(System.currentTimeMillis() - 12 * 3600 * 1000);
		if(cal.getTime().after(minusTwelveHourDate) || cal.getTime().equals(minusTwelveHourDate))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("24 hours"))
	{
		Date minusTwetyFourHour = new Date(System.currentTimeMillis() - 24 * 3600 * 1000);
		if(cal.getTime().after(minusTwetyFourHour) || cal.getTime().equals(minusTwetyFourHour))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("2 days"))
	{
		Date minusTwodays = new Date(System.currentTimeMillis() - 2 * 24 * 3600 * 1000);
		if(cal.getTime().after(minusTwodays) || cal.getTime().equals(minusTwodays))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("4 days"))
	{
		Date minusFourDays = new Date(System.currentTimeMillis() - 4 * 24 * 3600 * 1000);
		if(cal.getTime().after(minusFourDays) || cal.getTime().equals(minusFourDays))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("1 week"))
	{
		Date minusOneWeek = new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000);
		if(cal.getTime().after(minusOneWeek) || cal.getTime().equals(minusOneWeek))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("4 weeks"))
	{
		Calendar calDate = Calendar.getInstance();
		calDate.add(Calendar.DATE, -28);
		Date minusfourWeek = calDate.getTime();
		if(cal.getTime().after(minusfourWeek) || cal.getTime().equals(minusfourWeek))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("1 month"))
	{
		Calendar calMonth = Calendar.getInstance();
		calMonth.add(Calendar.MONTH, -1);
		Date minusOneMonth = calMonth.getTime();
		if(cal.getTime().after(minusOneMonth) || cal.getTime().equals(minusOneMonth))
		{
			return true;
		}
	}
	else if(timelineVal != null && timelineVal.startsWith("Any"))
	{
		if(cal.getTime().after(fromDateVal) && cal.getTime().before(toDateVal) || cal.getTime().equals(fromDateVal) || cal.getTime().equals(toDateVal)) {
			return true;
		}
	}
	return false;
}
public String getDateValue(String dateValue,String userDateFormat,String userTimeFormat)
{
	Calendar calendar = new GregorianCalendar();
	DateFormat df= new SimpleDateFormat(userDateFormat);
	TimeZone timeZone = TimeZone.getTimeZone(userTimeFormat);
	calendar.setTimeZone(timeZone);
	long firstdateVal = Long.valueOf(dateValue);
	Date dd = new Date(firstdateVal);
	calendar.setTime(dd);
	String start_mgr_time = calendar.get(calendar.HOUR_OF_DAY)+":"+calendar.get(calendar.MINUTE)+":"+calendar.get(calendar.SECOND);
	String startdate = df.format(dd);
	startdate = startdate+" "+start_mgr_time;
	return startdate;
}
public String[] setStartAndEndDateTime(String selectedTimeLine,String userDateTimeFormat)
{
	int blankSpaceIndex = selectedTimeLine.indexOf(" ");
	long value = Long.parseLong(selectedTimeLine.substring(0, blankSpaceIndex));
	String unit = selectedTimeLine.substring(blankSpaceIndex+1).toLowerCase();
	SimpleDateFormat sdf = new SimpleDateFormat(userDateTimeFormat);
	String startAndEndDates[] = {"",""};

	if(unit.startsWith("h"))
	{//hours
		value *= 3600;
	}
	else if(unit.startsWith("d"))
	{//days
		value *= (24 * 3600);
	}
	else if(unit.startsWith("w"))
	{//weeks
		value *= (7 * 24 * 3600);
	}
	else if(unit.startsWith("mo"))
	{//months
		value *= (30 * 24 * 3600);
	}
	Date start = new Date();
	String endDateTime = sdf.format(start);
	start.setTime(start.getTime() - (value * 1000));
	String startDateTime = sdf.format(start);
	startAndEndDates [0] = startDateTime;
	startAndEndDates [1] = endDateTime;
	return startAndEndDates;
}

%>
