<% 
/**************************************************************************************

**********************************************************************************/
%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ include file = "EgMonitorTracker.jsp" %>
<%@ page errorPage = "EgProbsM.jsp" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*"	%>
<%@ page import = "com.eg.EgAlarmTable" %>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import = "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.EgConfigInfo" %>
<%@ page import = "com.eg.EgDateInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import = "com.eg.EgMemInfo" %>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.IniFile"%>
<%@ page import = "com.eg.EgServicesInfo" %>
<%@ page import = "com.eg.EgManagerServlet" %>
<%@ page import = "com.eg.LangInfo"%>
<%@ page import = "com.eg.EgURLEncoder"%>
<%@ page import = "com.eg.EgMaintenanceInfo"%>
<%@ page import = "com.eg.upload" %>
<%@ page import = "java.net.*" %>
<%@ page import = "com.eg.EgTesterInfo"%>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.egurkha.monitor.VmDashboardHelper"%>
<%@ page import = "com.egurkha.monitor.EgMonRemoteScriptingBean"%>
<%@ page import = "com.egurkha.monitor.MonitorUtility"%>
<%@ page import = "com.eg.EgAggregateInfo"%>
<%@ page import = "com.egurkha.EgTimeZoneConverter"%>
<%@ page import = "java.util.Date"%>
<%@ page import="com.egurkha.monitor.*"%>
<%@ page import="com.eg.EgMetaThread"%>


<%---    CLUSTER  ---%> 					
<%@ page import = "com.eg.EgServicesInfo" %>
<%@ page import = "com.eg.EgDiscInfo" %>
<%@ page import = "com.eg.EgFormatInfo" %>
<%@ page import = "com.eg.EgManagersIniForManager" %>
<%@ page import = "com.eg.EgManagerInfo" %>

<%//@ page import = "EgHelpParser" %>
<%@ page import = "com.eg.EgDbAdapterTypeUI" %>
<%@ page import = "com.egurkha.*" %>
<%@ page import = "com.egurkha.ini.IniUI" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.monitor.alarms.AlarmPriorities" %>
<%--         CONTROL ACTION  --%>
<%@ page import = "com.egurkha.monitor.remotecontrol.PreAgentInfo" %>
<%@ page import = "egurkha.EgDbAdapterUI" %>
<%@ page session = "true" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import="com.eg.EgExternalInfo"%>
<%@ page import = "java.util.TreeMap"%>

<%@ page import="net.sf.json.*"%>
<%@ page import = "com.egurkha.User"%>
<%@ page import="egurkha.reporter.ErUtils"%>
<%@ page import = "com.egurkha.UserRegistry"%>
<%@ page import="egurkha.reporter.ErUserData"%>
<%@ page import = "com.egurkha.EgUserRole"%>
<%@ page import = "com.eg.EgAPMInfo"%>
<%@ page import = "com.eg.supermanager.*"%>

<%!
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	String formatFile = "eg_format.ini";
	IniFile formatIniFile = new IniFile(s_iniFile_dir + formatFile);
%>
<%
	EgAPMInfo apm = new EgAPMInfo("manager");
	EgFormatInfo formatInfo = new EgFormatInfo("manager");
	boolean apmTest = false;
	boolean isDouble=EgDbInfo.doubleByteEnabled;
	/* This is for SuperManager - starts */
	String manager_id=null;
	if(com.eg.EgInstallInfo.isSuperManager)
	{
		manager_id="-";
		String currentSession = session.getId();
		String hostname = request.getParameter("host");
		if(hostname != null)
		{
			if(hostname.indexOf(":")>-1)
			{
				hostname = hostname.substring(0,hostname.indexOf(":"));
			}
			ArrayList managerIds = EgElementInfo.getInstance().getManagerIDs("component",hostname);
			if(managerIds != null && !managerIds.isEmpty())
			{
				manager_id=(String)managerIds.get(0);
				session.setAttribute("mgr_id_sm",manager_id);
				SmSessionData smsData = new SmSessionData(currentSession,managerIds);
				EgThreadLocal egtl = new EgThreadLocal();
				egtl.set(smsData);
			}
		}
	}
	/* This is for SuperManager - ends */
	try
	{
		String queryString = request.getQueryString();
		String mgr_time=null;
		String temp1=null;
		if(fromMobile!=null && fromMobile.equals("yes"))
		{
		
			Calendar cal = Calendar.getInstance();
			EgDateInfo egDate = new EgDateInfo();
			Date local_date = new Date(egDate.egetUTCDate());
			cal.setTime(local_date);
			cal.setTimeZone(egDate.getRealTimeZone());
			temp1 =local_date.toString();
			mgr_time=cal.get(cal.HOUR_OF_DAY)+"";
			//String mgr_time = cal.get(cal.HOUR_OF_DAY)+":"+cal.get(cal.MINUTE)+":"+cal.get(cal.SECOND);
			//String dispDate = DateUtil.changeDateFormat(temp1,"MM/dd/yyyy",currentDateFormat);
	
		}
	if(queryString != null)
	{
		String isFromVirtualInside = request.getParameter("isFromVirtualInside");
		if(queryString.indexOf("&moreInfos") > -1)
		{
			if(queryString.indexOf("&moreInfos=")<=5)
			{
				queryString = "&moreInfos=true";
			}
			else
			{
				String front = queryString.substring(queryString.indexOf("&moreInfos="));
				String back = queryString.substring(queryString.indexOf("&moreInfos=")+15,queryString.length());
				queryString = front + back;
			}
		}
		if(isFromVirtualInside!=null && isFromVirtualInside.trim().length()>0 && isFromVirtualInside.equalsIgnoreCase("true"))
			session.removeAttribute("measureUrl");
		else
			session.setAttribute("measureUrl","/final/monitor/egDashBoardDispCompMeasure.jsp?"+queryString);
	}
	String setLatestSession=request.getParameter("setLatestSession");
	if(setLatestSession!=null && setLatestSession.trim().equalsIgnoreCase("true"))
	{
		TreeMap currentLinksMap = (TreeMap)session.getAttribute("currentLinksMap");
		if(currentLinksMap!=null)
			session.setAttribute("linksMap", (TreeMap)currentLinksMap);
		JSONObject json = new JSONObject();
		response.getWriter().write(json.toString());
	}
	else
	{
		String egaggregatedotjs = request.getParameter("egaggregatedotjs");
		boolean showAggJS = !StringUtils.isNull(egaggregatedotjs) && egaggregatedotjs.equals("true");

	String uiFile = "eg_ui.ini";
	
	String dashboardConfig = "eg_dashboardConfig.ini";
	IniFile dashboardConfigIni = new IniFile(s_iniFile_dir + dashboardConfig);
	String ADUserDetailsFile = "ADUserDetails.ini";
	IniFile ADUserIni = new IniFile(s_iniFile_dir + ADUserDetailsFile);
	IniFile searchIni = new IniFile(s_iniFile_dir + "eg_endUserDetails.ini");
	boolean ddEnabled = EgMemInfo.ddEnabled;
	String defInfoStr= "+";
	int dispTempDesc=60;
	String infoString = null;

	String isInterface = request.getParameter("isInterface");
	isInterface = (isInterface==null)?"":isInterface;
	String isMoreSub = request.getParameter("isMoreSub");
	isMoreSub = (isMoreSub==null)?"":isMoreSub;
 
	//Common Global variables
	EgDbInfo MeasureDisplay=new EgDbInfo("manager");
	EgTablesInfo TableData = new EgTablesInfo("manager");
	EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
	EgDateInfo dateInfo = new EgDateInfo();
	EgExternalInfo egExternal=new EgExternalInfo("manager");
	EgDiscInfo discInfo = new EgDiscInfo("manager");
	EgDashBoardModel  egDashboard=new  EgDashBoardModel();
	MonitorUtility mu = new MonitorUtility(u_ser);
	MonitorDAOFactory monitorDaoFactory = MonitorDAOFactory.getInstance();
	MeasuresDAO MeasuresDao = monitorDaoFactory.getMeasuresDAO();
	EgMaintenanceInfo egM=new EgMaintenanceInfo("manager");
	String agLink,gLink;
	String atgLink,tgLink;
	String asumLink,sumLink;
	request.setCharacterEncoding("UTF-8");
	
	response.setContentType("application/json");

	boolean isfromSuper = session.getAttribute("fromSuper") != null &&
	session.getAttribute("fromSuper").toString().equalsIgnoreCase("yes");
%>
<jsp:useBean id="trans" scope="page" class="egurkha.TransactionBean"/>
<jsp:useBean id="trans1" scope="page" class="egurkha.TransactionBean"/>



<jsp:useBean id="controlaction" scope="page"  class="egurkha.UserBean"/> 
<jsp:useBean id="dd" scope="page" class="com.egurkha.monitor.EgDiagnosisBean" />

<jsp:useBean id="teststatus" class="egurkha.TestStatusInfo" scope="page"/>
<% 

JSONObject json = new JSONObject();
JSONObject json_mobile = new JSONObject();

JSONObject screenLabels = new JSONObject();

JSONObject errormsg = new JSONObject();
	
	AlarmPriorities ap = AlarmPriorities.getInstance();
	IniUI ui = IniUI.getInstance();

	EgDbAdapterUI egDb;

	//Local variables
	String tempDispDate="";
	String	status="";
	String	siteName = "";
	String	hostName = "";
	String	compType = "";
	String	tState = "";
	String	portNumber = "";
	String	layerName = "";
	String	timeStr = "";
	String	infoStr,
			measureStr,
			tmpInfo,
			histLink,feedLink,
			testTable=null;
	String	testStr = "";
	String	test = "";
	String	info = "";
	String[]	strFieldList = null;
	String	qstr = null;
	String	testImage="";
	ResultSet rs = null;
	ResultSet rsState = null;
	boolean statusBoolean = false;
	boolean statusState = false;
	String	infoStr2="";
	String	hstInfoStr = "";
	String	badMesList = "";
	String	message = "";
	String compName = null;
	TreeMap linksMap = new TreeMap();

	//New variable declarations for the EgTestStatusInfo.jsp

	String	mesPresent = "no";
	String	sName = "";
	String	testStatusInfoURL = "";
	String	testFrequency = "";
	String	timeSinceLastMeasure = "";
	String	testType = "";
	Vector	testStatusInfo = new Vector();
	Vector	trans4Site = new Vector();

	boolean isAgentRunning = false;
	boolean isTestRunning = false;
	boolean isTestConfigured = false;
	boolean isInfoAvailableForMeasure = false;
	boolean isCommonDDTest = false;
	String backupTest = null;

	// Browser Check
	String ua = request.getHeader( "User-Agent" );
	boolean isFirefox = ( ua != null && ua.indexOf( "Firefox/" ) != -1 );
	boolean isMSIE6 = ( ua != null && ua.indexOf( "MSIE 6.0" ) != -1 );
	boolean isMSIE7 = ( ua != null && ua.indexOf( "MSIE 7.0" ) != -1 );

	// CONTROL ACTION
	String caHost = "";
	String msmtHost_RC = "";
	String sessionUserId=null;
	boolean remoteControlEnabled = EgMemInfo.remoteEnabled;
	 if(fromMobile!=null && fromMobile.equals("yes"))
	{
		 sessionUserId="supermonitor";
	}
	else{
	sessionUserId = (String) session.getValue("sess_userid");
	}
	
	
	String mySid = null;
	//String sessionId_sm = null;

	if(session.getAttribute("sessionId_SM") != null)
	{
		from_sm = true;
		sessionId_sm = (String)session.getAttribute("sessionId_SM");
	}

	UserRegistry registry = UserRegistry.getInstance();
	User user = null;
	if(from_sm)
	{
		user = UserRegistry.getInstance().getUser(sessionId_sm,true);
	}
	else if(fromMobile!=null && fromMobile.equals("yes"))
	{

		String uname=request.getParameter("uname");
		ErUserData userData_n = new ErUserData(uname,false);
	
			if(userData_n!=null)
			{
				user=userData_n.usr;
				if(user==null)
				{
					user = userData_n.getUser(uname);
				}
			}			
			isMobileCall=true;
	}
	else
	{
		user = registry.getUser(session.getId());
	}

	boolean flag = user.getLoginRCEnabled();

	boolean isVM = false;
	if((user.isOnlyVMAssigned() && !user.isVMAssigned()) && (user.getOnlyVMs()!=null && user.getOnlyVMs().size()>0))
		isVM = true;
	String loginid = user.getLoginID();
	String s_default_priority=searchIni.getValue("User_Default_Limits",loginid);
	if(s_default_priority==null || s_default_priority.trim().length()==0)
		s_default_priority=searchIni.getValue("END_USER_DASHBOARD_SETTINGS","Default");
	//LangInfo langinfo = new LangInfo(loginid);
	String thisLanguage = ui.getDefaultLanguage();
	List userTypes = new LinkedList();
	if (user!=null)
	{
		String userLang = user.getLanguage();
		if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
		{
	
			thisLanguage=userLang;
		}
		userTypes = user.getServerTypes();

	}
	String isFromUEDStr = request.getParameter("isFromUEDView");
	boolean isFromUEDView =  false;
	if(isFromUEDStr!=null && isFromUEDStr.trim().length()>0 && isFromUEDStr.equalsIgnoreCase("true"))
		isFromUEDView = true;

	boolean isLicenseViolatedType = false;
	boolean userViolated = false;
	ArrayList userBasedCompTypeList = new ArrayList(); 
	if(loginid !=null && loginid.trim().length()>0 && !EgInstallInfo.isSuperManager)
	{
		com.eg.GroupCertValidator licenseChecker = new com.eg.GroupCertValidator(loginid);
		userViolated = licenseChecker.checkForUserViolation(loginid);
		if(userViolated)
		{
			com.eg.EgUsersInfo usersInfo = new com.eg.EgUsersInfo();
			userBasedCompTypeList = (ArrayList)usersInfo.getAllUserBasedCompTypes();
		}

		String hostType  = request.getParameter("comptype");

		if(hostType != null && hostType.trim().length() > 0 && userBasedCompTypeList != null && userBasedCompTypeList.size() >0 && userBasedCompTypeList.contains(hostType))
			isLicenseViolatedType = true;

		if(!isLicenseViolatedType && hostType !=null && hostType.equalsIgnoreCase("Host_system"))
		{
			String host  = request.getParameter("host");
			String temphostName = (host != null && host.indexOf(":") >0)?host:host+":NULL";
			String tempServerType = discInfo.getServerTypesForComponentNamePort(temphostName);
			if(userBasedCompTypeList != null && userBasedCompTypeList.size() > 0 && userBasedCompTypeList.contains(tempServerType))
				isLicenseViolatedType = true;
		}
	}
	
	EgUserRole userRole = user.getUserRole();
	boolean hasAdminTab = userRole.hasAnyAdminRole(EgUserPermission.ADMIN);
	boolean hasMaintenancePolicyConfiguration = userRole.hasAnyAdminRole(EgUserPermission.MAINTENANCE_POLICY);
	boolean isCompletedUserRole = userRole.hasAllComponentAccess();
	boolean isAdmin = user.isAdmin();
	boolean showMaintenanceConfigIcon = false;
	boolean isNotOpenNewWindow = false;

	boolean isSecondaryManager = false;
	EgManagersIniForManager mi = null;
	if (EgInstallInfo.isClusterSupported)
	{
		mi = EgManagersIniForManager.getInstance();
		if (mi != null && !mi.isPrimaryManager())
		{
			hasAdminTab = false;
			isSecondaryManager = true;
		}
	}


	//EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	String msmtHost = request.getParameter("msmt_host");
	String measureQueryStr = request.getQueryString();

	if(msmtHost != null && !msmtHost.equals(""))
	{
		if (msmtHost.startsWith("("))
		{
			msmtHost = msmtHost.substring(1,msmtHost.length() - 1);
		}
	}
	String hostInfo = "";

	//Checking to see whether there are any parameters
	String qctrString = request.getParameter("qctr");

	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	String currentDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	String dispDate = null;
	String sid = null;
	if(from_sm)
	{
		sid = sessionId_sm;
	}
	else
	{
		sid = session.getId();
	}

	String wname ="";
	String help_measure=egUI.getValue("HELP_MEASURE","show");
	tempDispDate = request.getParameter("dispDate");

	ArrayList siteBasedTestList = new ArrayList();
	IniFile egService = new IniFile(s_iniFile_dir + "eg_services.ini");
	String siteTests = egService.getValue("Site_Based_Tests","Tests");
	if(siteTests != null && siteTests.trim().length() > 0)
	{
		StringTokenizer st = new StringTokenizer(siteTests,",");
		while(st.hasMoreTokens())
		{
			String token = st.nextToken();
			if(token != null && token.trim().length() > 0)
			{
				siteBasedTestList.add(token);
			}
		}
	}
	boolean allowMPolicyCreationForDescriptorInLayerModel=false;
	String allowToCreateMPolcyForDesc = egUI.getValue("MISC_ARGS","AllowMPolicyCreationForDescriptorInLayerModel");
	if(allowToCreateMPolcyForDesc!=null && (allowToCreateMPolcyForDesc.equalsIgnoreCase("yes") || allowToCreateMPolcyForDesc.equalsIgnoreCase("true")))
	{
		allowMPolicyCreationForDescriptorInLayerModel=true;
	}
	// Premkumar infos measure page change
	//boolean isFromMoreInfos = false;
	//String moreInfos = request.getParameter("moreInfos");

	/*if(moreInfos != null && !moreInfos.equals("") && moreInfos.equalsIgnoreCase("true"))
		isFromMoreInfos = true;*/
	
	String logon_Details_Support_types = dashboardConfigIni.getValue("Logon_Details_Support_Types","Types");

	ArrayList supported_types_list = new ArrayList();
	if(logon_Details_Support_types!=null && logon_Details_Support_types.trim().length()>0)
	{
		supported_types_list = com.egurkha.util.StringUtils.egTokenizer(logon_Details_Support_types,",",false,true,true);//param 3-->includeEmpty,4-->unique,5-->trim
	}
	com.eg.IniFile egINI = new com.eg.IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_endUserDetails.ini");
	com.eg.IniFile egAgentIni = new com.eg.IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_agents.ini");
	ArrayList vdiSkipTypes = new ArrayList();
	String[] vdiTypes = dashboardConfigIni.getVariables("Blast_Session_Logon_check");
	if(vdiTypes != null && vdiTypes.length > 0){
		for(int k=0;k<vdiTypes.length;k++)
			vdiSkipTypes.add(vdiTypes[k]);
	}

	if(isLicenseViolatedType){
		screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
		errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel.No data found"));
		json.put("errormsg",errormsg);
	}
	else if(qctrString!=null && qctrString.equals("2"))
	{
		StringTokenizer st = null;
		Vector measures = new Vector();
		testStr = request.getParameter("test");
		if(testStr!=null && testStr.trim().length()>0)
			testStr =com.egurkha.util.StringUtils.decodeSecurityChar(testStr);
		testStr=(testStr==null)?"":testStr;
		if(testStr.equalsIgnoreCase("null"))testStr="";
		String meas = "";
		int index =0;
		if(testStr.indexOf("-")>-1)
			index = testStr.indexOf("-");
		if(testStr.length()>0)
			test = testStr.substring(0, index);
		if(testStr.length()>0)
		{
			info = testStr.substring(index+1);
			info=URLDecoder.decode(info);
			if(info!=null && info.indexOf("|hash|")>-1)
				info=com.egurkha.util.StringUtils.replace(info,"|hash|","#");

			info=ui.getReverseLookupAll(info);
			info=com.egurkha.util.StringUtils.replace(info,"|plus|","+");
			info=com.egurkha.util.StringUtils.replace(info,"|amp|","&");
			info=com.egurkha.util.StringUtils.replace(info,"|pct|","%");
			if(isFromUEDView && (info!=null && info.indexOf("\\\\")!=-1))
				info=com.egurkha.util.StringUtils.replace(info,"\\\\","\\");
			info=info.trim();
		}

		ArrayList hideMeasure = new ArrayList();
		String hide_Meas = dashboardConfigIni.getValue("Hide_Measures_UI",test);	
		if(hide_Meas!= null && hide_Meas.trim().length() > 0 && !hide_Meas.equalsIgnoreCase("All"))
		{
			hideMeasure = com.egurkha.util.StringUtils.egTokenizer(hide_Meas, ",", false,true,false);
		}
		Hashtable commonDdHt = new Hashtable();
		trans.createFile("eg_format.ini");
		String strVarArr[] = trans.getVariables("FORMAT");
		String dummyTestArr[] = trans.getVariables("COMMON_DD_MAPPING");
		
		trans1.createFile("eg_ui.ini");
		String arrange_measures[]=trans1.getVariables("Grouping_Metrics");
		ArrayList arrangeMesList=new ArrayList();
		ArrayList arrangeMesListWithTag=new ArrayList();
		for(int q=0; q<arrange_measures.length; q++)
		{
			String arr_mes=(String)arrange_measures[q];
			if(arr_mes!=null && test!=null && arr_mes.startsWith(test+":"))
			{
				arrangeMesListWithTag.add(arr_mes.trim());
				if(arr_mes!=null && arr_mes.indexOf(":")>0)
				{
					arr_mes=arr_mes.substring(0,arr_mes.indexOf(":"));
				}
				arrangeMesList.add(arr_mes.trim());
			}
		}
		for(int i=0; i<strVarArr.length; i++)
		{
			if(strVarArr[i].startsWith(test))
			{
				meas = strVarArr[i].substring(strVarArr[i].indexOf(":")+1,strVarArr[i].length());
				if(!measures.contains(meas))
				{
					measures.add(meas);
				}
			}
		}
		
		for(int d=0; d<dummyTestArr.length; d++)
		{
			if(dummyTestArr[d].startsWith(test))
			{
				meas = dummyTestArr[d].substring(dummyTestArr[d].indexOf(":")+1,dummyTestArr[d].length());
				if(!measures.contains(meas))
				{
					measures.add(meas);
				}
			}
		}
		hostName = request.getParameter("host");
		if(isDouble)
			hostName=URLDecoder.decode(hostName,"UTF-8");
		compName = hostName;
		layerName = request.getParameter("layer");
		layerName = (layerName == null || layerName.trim().length() == 0)?"":layerName;
		int ind2 = hostName.indexOf(":");
		portNumber = hostName.substring(ind2+1,hostName.length());
		hostName = hostName.substring(0,ind2);
		siteName = request.getParameter("site");
		infoStr = "+" + info.trim();
		testImage = AlarmPriorities.GOOD_STATE;
		hstInfoStr = new String(infoStr);
		int ind3 = portNumber.indexOf(":");
		if(ind3 > 0)
		{
			infoStr = portNumber.substring(ind3+1,portNumber.length()).trim();
			hostInfo = "+" + info.trim();
			mySid = infoStr;
			infoStr = infoStr + "+" + info.trim();
			portNumber = portNumber.substring(0,ind3);
			hstInfoStr = new String(hostInfo);
		}
		String portforHost=null;
		String type  = request.getParameter("comptype");
		if(portNumber!=null&&portNumber.equals("NULL")&&type!=null&&type.equals("Host_system"))
		{
			String componentName  = hostName;
			if(hostName!=null&&hostName.indexOf(":")>-1)
			{
				componentName = hostName.substring(0,hostName.indexOf(":"));
			}

			type = discInfo.getTypeForHostTest(componentName,test);
			portforHost = discInfo.getPortForHost(componentName,type);
		}

		boolean portReleventForTest = specsInfo.isPortRelevantForTest(test);
		boolean isTestRelevantForServer = specsInfo.isTestRelevantForServer(type,test);

		infoStr2 = new String(infoStr);
		
		testTable = MeasureDisplay.getTableForTest(test);
		
		strFieldList = MeasureDisplay.getColumnNamesForTest(testTable,layerName);
		
		if(siteName!=null&&siteName.equalsIgnoreCase("egurkha.physical.topology"))
			siteName="NULL";

		gLink = "../monitor/dispComponentGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" +test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");

		tgLink ="../monitor/dispComponentTrendGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");

		sumLink ="../monitor/dispComponentSummaryGraphs.jsp?site="	+EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
		String  aggLink="../monitor/dispAggComponentGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
		
		String dLink = "../monitor/EgDiagnosis.jsp?site=" + EgURLEncoder.encode(siteName,"UTF-8") + "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test=" + test;

		String histTempComp="";
		if(request.getParameter("host")!=null)
			histTempComp=com.eg.EgURLEncoder.encode(request.getParameter("host"),"UTF-8");
		else
			histTempComp=request.getParameter("host");

		if(request.getParameter("comptype")!=null)
		histTempComp=histTempComp+":"+com.eg.EgURLEncoder.encode(request.getParameter("comptype"),"UTF-8");
		else
			histTempComp=histTempComp+":"+request.getParameter("comptype");

		String historyLink="../monitor/dispComponentHistory.jsp?site=" + siteName + "&info=" + com.eg.EgURLEncoder.encode(info.trim(),"UTF-8") + "&test=" + test + "&component=" +histTempComp; //request.getParameter("host") + ":" +request.getParameter("comptype");

		String feedbackLink="../monitor/dispComponentFeedback.jsp?site=" + siteName + "&trgthost=" + com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test=" + test + "&comptype=" +com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
		
		egDb=EgDbAdapterTypeUI.getObject();
		String infoSelected ="";
		String showUserLocStyle = dashboardConfigIni.getValue("Show_User_Location",test);
		String strSeparator = dashboardConfigIni.getValue("Show_User_Location","Separator");
		String strReplaceSep = dashboardConfigIni.getValue("Show_User_Location","ReplaceSeparatorTo");
		boolean isShowUserLocation = false;
		if(showUserLocStyle!=null && !showUserLocStyle.equalsIgnoreCase("NULL") && showUserLocStyle.trim().length()>0)
			isShowUserLocation = true;

		
		String user_Type = "";
		String userTypeTypes = searchIni.getValue("COMP_TYPE_TYPES",request.getParameter("comptype"));
		if(userTypeTypes!=null && userTypeTypes.trim().length()>0){
			user_Type = userTypeTypes;
		}
		if(user_Type ==null || user_Type.trim().length() == 0)
			user_Type = "XenApp7";
		String locStr = dashboardConfigIni.getValue("USER_LOCATION_TEST_CONFIG",user_Type+":ShowLocationFromADOnly");
		boolean isDetailsFromADOnly = false;
		if(locStr!=null && locStr.trim().length() > 0 && (locStr.equalsIgnoreCase("yes") || locStr.equalsIgnoreCase("true")))
			isDetailsFromADOnly = true;

		boolean isEnableDomainLoop=false;
		String strDomainLoop = dashboardConfigIni.getValue("Show_User_Location","EnableDomainLoop");
		if(strDomainLoop!=null && strDomainLoop.trim().length()>0 && (strDomainLoop.equalsIgnoreCase("true") || strDomainLoop.equalsIgnoreCase("yes")))
		{
			isEnableDomainLoop=true;
		}
		
		try
		{
			status = egDb.setConnection();

			testTable=testTable.trim();
			hostName=hostName.trim();
			if(testTable.equalsIgnoreCase("null")) testTable="";
			if(hostName.equalsIgnoreCase("null")) hostName="";

			infoSelected = ui.getReverseLookedupString(infoStr);
			if((testTable!=null && testTable.length()>0) && (hostName!=null && hostName.length()>0))
			{
				rs=egDb.SelectDispMeasure_1(strFieldList, testTable+"~eg~"+layerName, hostName, portNumber, siteName, ui.getReverseLookedupString(infoStr), defInfoStr, ui.getReverseLookedupString(hostInfo), msmtHost);
				//rs=egDb.SelectDispMeasure_1(strFieldList, testTable, hostName, portNumber, siteName, ui.getReverseLookedupString(infoStr), defInfoStr, ui.getReverseLookedupString(hostInfo), msmtHost);
				statusBoolean = egDb.getState();
			}
			ResultSetMetaData rsmd = null;
			if(rs!=null)
				rsmd = rs.getMetaData();
			Vector store = new Vector();
			Vector storeStates = new Vector();
			/*****************************************************************************/
			// To popup the window that displays help relevant to test
			// constructing the query string needed for the test status info
			compType = request.getParameter("comptype");
			tState = request.getParameter("tstate");
			//testStatusInfoURL = "site=" +siteName +"&stype=" +compType+"&sname=" +hostName+"&sport=" + portNumber +"&sinfo=" + infoStr2.substring(0,infoStr2.indexOf("+")) +"&tname=" + test +"&tstate=" + tState +"&faketype=" + request.getParameter("faketype") +"&msmt_host=" +com.eg.EgURLEncoder.encode(msmtHost,"UTF-8");
			testStatusInfoURL = "site=" +siteName +"&stype=" +compType+"&sname=" +hostName+"&sport=" + portNumber +"&sinfo=" + infoStr2.substring(0,infoStr2.indexOf("+")) +"&tname=" + test +"&tstate=" + tState +"&faketype=" + request.getParameter("faketype") +"&msmt_host=" +msmtHost;

			 /********** CONTROL ACTION ********************* */
			caHost = hostName;  //bug fixed
			/*****************************************************************************/
			String mHost = null;
			int columnCount = 0;
			boolean dataExists = false;
			boolean isSuccessScreenshotRequired = false;
			//boolean isFaliureScreenshotRequired = false;
			String[] sucessSS = dashboardConfigIni.getVariables("SuccessScreenshot_TestMeasure_Mapping");
			List testForSucessSS = (List) Arrays.asList(sucessSS);
			String[] notSupportScreenshotTests = dashboardConfigIni.getVariables("NotSupportedScreenshot_Test");
			List testForNotSupportScreenshot = (List) Arrays.asList(notSupportScreenshotTests);
			boolean isSucessSSTest = (testForSucessSS != null && testForSucessSS.size() > 0);
			if(rs!=null && rs.next())
			{
				columnCount = rsmd.getColumnCount();
				if(columnCount<=3)
				{
					dataExists=false;
				}
				else
				{
					dataExists=true;
				}
			}
			if(dataExists)
			{
				if(msmtHost == null || msmtHost.trim().length()==0 || msmtHost.equalsIgnoreCase("NULL"))
				{
					List agents=egExternal.getAgentsFor(test,compType,hostName);
					if(agents!=null && agents.size()>0)
						msmtHost=(String)agents.get(0);
					else
						msmtHost=compName;
				}
				if(isSucessSSTest && testForSucessSS.contains(test))
				{
					String tempStr = "";
					boolean flag1 = specsInfo.isPortRelevantForTest(test);

					if(flag1)		
						tempStr = test +"::"+compName;
					else
						tempStr = test +":"+compType+":"+ compName;
									
					
					String agentData = egAgentIni.getValue(msmtHost,tempStr);
					if(agentData != null && agentData.trim().length()>0 && !agentData.equalsIgnoreCase("NULL"))
					{
						if(agentData.indexOf("-Success_screenshot_required ")>-1)
						{
							String aData = agentData.substring(agentData.indexOf("-Success_screenshot_required ")+29);
							String bData = aData.substring(0,aData.indexOf(" "));
							if(bData.equalsIgnoreCase("true") || bData.equalsIgnoreCase("yes"))
								isSuccessScreenshotRequired = true;
						}	
					}
				}
				/*else if(test.equalsIgnoreCase("CitraTest"))
				{
					String tempStr = "";
					boolean flag1 = specsInfo.isPortRelevantForTest(test);

					if(flag1)		
						tempStr = test +"::"+compName;
					else
						tempStr = test +":"+compType+":"+ compName;

					String agentData = egAgentIni.getValue(msmtHost,tempStr);
					if(agentData != null && agentData.trim().length()>0 && !agentData.equalsIgnoreCase("NULL"))
					{
						if(agentData.indexOf("-Failure_Screens ")>-1)
						{
							String aData = agentData.substring(agentData.indexOf("-Failure_Screens ")+17);
							String bData = aData.substring(0,aData.indexOf(" "));
							if(bData.equalsIgnoreCase("true") || bData.equalsIgnoreCase("yes"))
								isFaliureScreenshotRequired = true;
						}	
					}
				}*/
				mesPresent = "yes";
				timeStr = rs.getString(columnCount-2);
				String tmp_mHost=msmtHost;
				if(msmtHost == null || msmtHost.equals(""))
				{
					msmtHost_RC = rs.getString(columnCount);
					//No msmt_host passed from prev page. Use the one from the db
					mHost = rs.getString(columnCount);
					tmp_mHost = mHost;
					testStatusInfoURL = testStatusInfoURL.substring(0,testStatusInfoURL.indexOf("&msmt_host=")) + "&msmt_host=" + mHost;
				}
				else if(testStatusInfoURL != null && testStatusInfoURL.endsWith("&msmt_host="))
					testStatusInfoURL = testStatusInfoURL.substring(0,testStatusInfoURL.indexOf("&msmt_host=")) + "&msmt_host=" + msmtHost;
				String time=timeStr.replace(' ','*');
				dispDate = timeStr;
				
				boolean isSkipData=true;
				if(request.getParameter("moreinfo")!=null && request.getParameter("moreinfo").equalsIgnoreCase("true"))
				{
					if(isInterface==null || isInterface.equalsIgnoreCase(""))
					{
						if(isMoreSub==null || isMoreSub.equalsIgnoreCase("no") || isMoreSub.equalsIgnoreCase("false") || isMoreSub.equalsIgnoreCase(""))
						{
							String compName_for_timeout=compName;
							if(!portReleventForTest)
							{
								if (compName!=null && compName.indexOf(":")>-1)
								{
									compName_for_timeout=compName.substring(0,compName.indexOf(":"));
								}
							}

							boolean isTimeout=MeasuresDao.isTimeOut(dispDate,test+"#"+tmp_mHost,compName_for_timeout,type);

							if(isTestRelevantForServer && !isTimeout)
							{
								isSkipData=false;
							}
						}
					}
				}
				else
				{
					if(isInterface==null || isInterface.equalsIgnoreCase(""))
					{
						if(isMoreSub==null || isMoreSub.equalsIgnoreCase("no") || isMoreSub.equalsIgnoreCase("false") || isMoreSub.equalsIgnoreCase(""))
						{
							isSkipData=false;
						}
					}
				}
				
				if(!isSkipData)
				{
					dispDate = DateUtil.changeDateFormat(dispDate,"MM/dd/yyyy HH:mm:ss",currentDateFormat + " HH:mm:ss");
					screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
					EgTimeZoneConverter timeZoneConverter = new EgTimeZoneConverter(dispDate,user);
					String loginUserDateTime = (String)timeZoneConverter.getDateTime();
					Date loginUserDate = (Date)timeZoneConverter.getDate(true);
					
					if( loginUserDateTime != null && !loginUserDateTime.trim().equals(""))
					{
						dispDate = loginUserDateTime;
					}
					if(dispDate!=null && dispDate!="null"){
						screenLabels.put("LastMeasurementTime",mappingInfo.getTextDescription("monitor.layermodel.Last Measurement Time") + " : " + dispDate);
					}
					infoStr = rs.getString(columnCount);
					for(int j=1;j<=columnCount-3;j=j+2)//get rs into a vector
					{
						String col_Name= rsmd.getColumnName(j);
						String meas_Name = MeasureDisplay.getMeasureForColumn(test,col_Name);
						if(hideMeasure != null && hideMeasure.size()>0)
						{
							if(meas_Name != null && !hideMeasure.contains(meas_Name)) 
							{
								store.addElement(rsmd.getColumnName(j));
								store.addElement(rs.getString(j));
								String tmpstate = rs.getString(j+1);
								//if(tmpstate.equals("NONE"))
								{
									tmpstate = AlarmPriorities.GOOD_STATE;
								}
								store.addElement(tmpstate);
								store.addElement(infoStr);
							}
						}
						else if(hideMeasure != null && hideMeasure.size()==0)
						{
							store.addElement(rsmd.getColumnName(j));
							store.addElement(rs.getString(j));
							String tmpstate = rs.getString(j+1);
							//if(tmpstate.equals("NONE"))
							{
								tmpstate = AlarmPriorities.GOOD_STATE;
							}
							store.addElement(tmpstate);
							store.addElement(infoStr);
						}
					}//end of for

					if (rs != null)
					{
						try {
							rs.close();
						} catch (Exception grr) {}
					}
					rs = null;
					String portNum="";
					if(compType!=null&&compType.equals("Oracle_server"))
					{
						portNum=portNumber+":"+mySid;
					}
					else
					{
						portNum=portNumber;
					}
					//fix for port based  component 9/24/2008
					String portOfComponent = null;
					if(compType!=null&&compType.equals("Host_system")&&portNum.endsWith("NULL"))
					{
						portOfComponent=portforHost;
					}
					else
					{
						portOfComponent  = portNum;
					}
					rsState = egDb.SelectDispMeasure_2(siteName, hostName, portOfComponent, infoSelected, defInfoStr, ui.getReverseLookedupString(hostInfo), layerName, test, msmtHost);
					statusState = egDb.getState();
					boolean isPortRelevant = specsInfo.isPortRelevantForTest(test);
					String portForComp = null;
					if(isPortRelevant)
						portForComp =  portNumber;
					else
						portForComp ="NULL";
						
					ArrayList indexes = new ArrayList();
					ArrayList measuresForAlarms  = new ArrayList();
					ArrayList rptState = new ArrayList();

					while(rsState != null && rsState.next())
					{
						String measure = rsState.getString(1).trim();
						String mcol = MeasureDisplay.getColumnForMeasure(test,measure);		
						String measureV = "";
						for(int k=0;k<store.size();k=k+4)
						{
							measureV=(String) store.elementAt(k);
							measureV = measureV.trim();
							if(measureV.equalsIgnoreCase(mcol))
							{
								String tempS=rsState.getString(2);

								if(tempS!=null&&(tempS.equals("HIGH") || tempS.equals("INTERMEDIATE") ||
									tempS.equals("LOW")))
								{	
									indexes.add(new Integer(k+2));
									measuresForAlarms.add(measure);
									rptState.add(tempS);
								}
								store.set(k+2,tempS);//Change of state
								store.set(k+3,rsState.getString(3));//Change of info
								break;
							}
						}
					}//end of while
					if (rsState != null)
						rsState.close();
					rsState = null;
					ArrayList states = new ArrayList();
					if (indexes.size() > 0)
					{
						ArrayList cname, ctype, site, layer, infos, tests, mh;
						cname = new ArrayList();
						ctype = new ArrayList();
						site = new ArrayList();
						layer = new ArrayList();
						infos = new ArrayList();
						tests = new ArrayList();
						mh = new ArrayList();
						String realCname = hostName+":"+portForComp;
						if (mySid != null && !portForComp.equals("NULL"))
							realCname = realCname +":"+mySid;
						String realInfo = "+"+info;
						for (int x=0; x<indexes.size(); x++)
						{
							cname.add(realCname);
							ctype.add(compType);
							site.add(siteName);
							infos.add(realInfo);
							layer.add(layerName);
							tests.add(test);
							mh.add(mHost);
						}
						states = com.eg.EgAlarmTable.getPriorities(cname,
							ctype ,site,layer,infos,tests,measuresForAlarms,mh,
									rptState,true);
						if (states != null && states.size() == indexes.size())
						{
							for (int x=0; x<indexes.size(); x++)
							{
								Integer ii = (Integer) indexes.get(x);
								int k = ii.intValue();
								store.set(k,(String) states.get(x));
							}
						}
					}
					EgAgentInfo agentInfo = new EgAgentInfo(EgConstants.MANAGER);
					EgTesterInfo tt = new EgTesterInfo(EgConstants.MANAGER);
					ArrayList DDEnabledList=tt.DefaultDDEnabledTypes();
					ArrayList DDEnabledTestList=tt.DefaultDDEnabledTests(); 
					boolean isRemoteDetailed = false;
					if(DDEnabledTestList!=null && DDEnabledTestList.size()>0 && DDEnabledTestList.contains(type+":"+test))
					{
						isRemoteDetailed=true;
					}
					else if(DDEnabledList!=null && DDEnabledList.size()>0 && DDEnabledList.contains(type))
					{
						isRemoteDetailed=true;
					}
					else
					{
						isRemoteDetailed = tt.getRemoteDetailed();
					}
					
					tt = null;
					boolean isAgentlessServer = false;
					if (!isRemoteDetailed)
						isAgentlessServer = agentInfo.isAgentlessServer(hostName, compType);

					testStatusInfoURL += "&msmttime=" + timeStr.replace(' ','*');
					if(testStr!=null && testStr.indexOf("|hash|")>-1)
						testStr=com.egurkha.util.StringUtils.replace(testStr,"|hash|","#");
					String desc_testStr=URLDecoder.decode(testStr);
					desc_testStr=com.egurkha.util.StringUtils.encodeSecurityChar(desc_testStr);
					if(desc_testStr!=null)
						desc_testStr=com.egurkha.util.StringUtils.replace(desc_testStr,"\"","&#34");
					if(desc_testStr!= null && desc_testStr.indexOf("#")>-1)
					{
						desc_testStr=com.egurkha.util.StringUtils.replace(desc_testStr,"#","|hash|");
						testStatusInfoURL += "&desc=" + desc_testStr;//testStr;
					}
					else
					{
						testStatusInfoURL += "&desc=" + desc_testStr;
					}

					int maxDispLength = 150;
					String tmpTest = ui.getReverseLookedupString(testStr.replace(' ', '+'));
					
					
					String testName = null;
					if (tmpTest.endsWith("-+"))
					{
						testName = tmpTest.substring(0, tmpTest.lastIndexOf("-"));
					}
					else
					{
						testName = StringUtils.replace(tmpTest, "-+"," - ");
					}

					storeStates = new Vector();
					for(int jj=0; jj<store.size(); jj=jj+4)
					{
						String meaState = (String)store.elementAt(jj+2);
						if(meaState!=null && meaState.trim().length()>0)
							storeStates.add(meaState);
					}
					String tempState = null;
					if (storeStates.contains(EgConfigInfo.HIGH_PRIORITY))
					{
						tempState = EgConfigInfo.HIGH_PRIORITY;
					}
					else if (storeStates.contains(EgConfigInfo.MEDIUM_PRIORITY))
					{
						tempState = EgConfigInfo.MEDIUM_PRIORITY;
					}
					else if (storeStates.contains(EgConfigInfo.LOW_PRIORITY))
					{
						tempState = EgConfigInfo.LOW_PRIORITY;
					}

					if (tempState != null)
					{
						tmpTest = URLDecoder.decode(tmpTest);
						testImage = (String)ap.getTestPriority(compName, compType, layerName, tmpTest.replace(' ', '+'));
						if (EgConfigInfo.isGood(testImage))
						{
							testImage = tempState;
						}
					}
					else if(storeStates.contains(AlarmPriorities.UNKNOWN_STATE))
					{
						testImage = AlarmPriorities.UNKNOWN_STATE;
					}
					String tmpTestStatusInfoURL = testStatusInfoURL;
					String tmpBadMesList = badMesList;
					
					tmpTestStatusInfoURL += "&mstate=" + testImage;
					tmpTestStatusInfoURL += "&mespresent=yes";
					Hashtable measureAllValues=new Hashtable();
					ArrayList dispLableList=new ArrayList();
					try{
						for(int g=0; g<arrangeMesListWithTag.size(); g++)
						{
							
							ArrayList all_mes=new ArrayList();
							String arrange_Mes=(String)arrangeMesListWithTag.get(g);
							dispLableList.add(arrange_Mes);
							String mes_values_cpu=(String)egUI.getValue("Grouping_Metrics",arrange_Mes);
							StringTokenizer mes_tokens_cpu=new StringTokenizer(mes_values_cpu,",");
							while(mes_tokens_cpu.hasMoreTokens())
							{
								String measure = (String)mes_tokens_cpu.nextToken();
								for(int j=0; j<store.size(); j=j+4)
								{
									String mes = MeasureDisplay.getMeasureForColumn(test,(String)store.elementAt(j));
									if(mes!=null && measure!=null && measure.equalsIgnoreCase(mes))
									{
										all_mes.add(mes);
										all_mes.add(store.elementAt(j+1));
										all_mes.add(store.elementAt(j+2));
										all_mes.add(store.elementAt(j+3));
										
									}
								}
							}
							measureAllValues.put(arrange_Mes,all_mes);
						}
					}

					catch(Exception ee)
					{
						ee.printStackTrace();
						System.out.println("Exception due to........."+ee.getMessage());
					}
					for(int j=0; j<store.size(); j=j+4)
					{
						String mes = MeasureDisplay.getMeasureForColumn(test,(String)store.elementAt(j));
						if (EgConfigInfo.isBad((String)store.elementAt(j+2)))
						{
							tmpBadMesList += mes + ",";
						}
					}
					JSONObject TestinfoJson = new JSONObject();
					//Toolbar info

					TestinfoJson.put("State",testImage);
					testStatusInfoURL += "&mstate=" + testImage;
					testStatusInfoURL += "&mespresent=yes";
					String testNameWithInfo = testName;
					String tmpTestName =""; 
					String tmpDesc =""; 
					if (testNameWithInfo.indexOf("-")>-1)
					{
						tmpTestName = testNameWithInfo.substring(0,testNameWithInfo.indexOf("-")).trim();
						tmpDesc = testNameWithInfo.substring(testNameWithInfo.indexOf("-")+1).trim();
						if(isFromUEDView && (tmpDesc!=null && tmpDesc.indexOf("\\\\")!=-1))
							tmpDesc = com.egurkha.util.StringUtils.replace(tmpDesc, "\\\\", "\\");
						if(tmpDesc.endsWith("+"))
							tmpDesc = tmpDesc.substring(0,tmpDesc.length()-1);
						tmpDesc=URLDecoder.decode(tmpDesc);
						//Changed on  12/12/2008
						tmpDesc= ui.getReverseLookupAll(tmpDesc);
					}
					else
					{
						tmpTestName = testNameWithInfo; 
					}

					if(isShowUserLocation)
					{
						String usrInfo = "";
						String usrLocation = "";
						String domainName = "";
						boolean haveUser=false;
						if(tmpDesc!=null && tmpDesc.trim().length()>0 && tmpDesc.indexOf("\\")>-1)
						{
							domainName = tmpDesc.substring(0,tmpDesc.indexOf("\\"));
							usrInfo = tmpDesc.substring(tmpDesc.indexOf("\\")+1);
							if(usrInfo!=null && usrInfo.trim().length()>0 && usrInfo.indexOf("_on_")>-1)
							{
								usrInfo = usrInfo.substring(0,usrInfo.indexOf("_on_"));
							}
							haveUser=true;
						}
						else
						{
							domainName = "NONE";
							usrInfo = tmpDesc;
							haveUser=true;
						}

						if(domainName!=null && domainName.trim().length()>0)
						{
							usrLocation = (String)mu.getUserLocation(compType+":"+compName,domainName,usrInfo,isDetailsFromADOnly,isEnableDomainLoop);
							
						}
						
						if(usrLocation!=null && usrLocation.trim().length()>0)
						{
							if(strSeparator!=null && strSeparator.trim().length()>0 && strReplaceSep!=null && strReplaceSep.trim().length()>0)
							{
								usrLocation = com.egurkha.util.StringUtils.replace(usrLocation,strSeparator,strReplaceSep);
							}

							tmpDesc = "&nbsp;<span><img class='"+showUserLocStyle+"' src ='/final/images/clear.png' border = '0' style='vertical-align:middle'  title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/></span>&nbsp;<span>" + tmpDesc +  "</span>&nbsp;&nbsp;<span><img class='iconLocator' src ='/final/images/clear.png' border = '0'  style='vertical-align:middle' title='"+mappingInfo.getTextDescription("monitor.layermodel.Location")+"'/></span><span>" + usrLocation + "</span>";
							// tmpDesc = "<table cellspacing='0' cellpadding='0' border='0' style='margin-top:2px'><tr><td style='padding:0px 4px 0px 0px !important'><img class='"+showUserLocStyle+"' src ='/final/images/clear.png' border = '0' style='margin-top:2px' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/></td><td>" + tmpDesc +  "</td><td style='padding:2px 0px 0px 7px !important'><img style='margin-top:3px' class='iconLocator' src ='/final/images/clear.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Location")+"'/></td><td >" + usrLocation + "</td></tr></table>";
						}
						else if(haveUser)
						{
							tmpDesc = "<span><img class='"+showUserLocStyle+"' src ='/final/images/clear.png' border = '0' style='vertical-align:middle' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/></span><span>" + tmpDesc +  "</span>";
							// tmpDesc = "<table cellspacing='0' cellpadding='0' border='0' style='margin-top:2px'><tr><td style='padding:0px 4px 0px 0px !important'><img class='"+showUserLocStyle+"' src ='/final/images/clear.png' border = '0' style='margin-top:2px' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/></td><td>" + tmpDesc +  "</td></tr></table>";
						}
					}
					String tmpTestNameMap = mappingInfo.getTestDescription(tmpTestName);
					int MeasurementsPageTitlelength=tmpTestNameMap.length()+tmpDesc.length();
					if(MeasurementsPageTitlelength<dispTempDesc)
					{
						TestinfoJson.put("Testname" ,mappingInfo.getTestDescription(tmpTestName));
						
						if(tmpDesc!=null && tmpDesc.length()>0)
						{
							TestinfoJson.put("TestDesc"," "+"-" +" "+tmpDesc);
						}
					}
					else
					{
						//String MeasurementPageTitle=mappingInfo.getTestDescription(tmpTestName)+"-"+tmpDesc;
						String MeasurementPageTitle="<span>"+mappingInfo.getTestDescription(tmpTestName)+" -</span><span>"+tmpDesc +"</span>";
				//		String MeasurementPageTitle="<table cellspacing='0' cellpadding='0' border='0' style='margin-top:2px'><tr><td style='padding:3px 4px 0px 0px !important'>"+mappingInfo.getTestDescription(tmpTestName)+" -</td><td>"+tmpDesc +"</td></tr></table>";
						if(MeasurementPageTitle!=null && MeasurementPageTitle.length()>0 && MeasurementPageTitle.length()>dispTempDesc)
						{
							TestinfoJson.put("Testname",MeasurementPageTitle);
						}
					}
					//Added on 6-6-2008 for Display msmtHost
					String onlyTest="";
					if(testName!=null && testName.indexOf("-")>-1)
					{
						onlyTest=testName.substring(0,testName.indexOf("-"));
						onlyTest=onlyTest.trim();
					}
					else
					{
						onlyTest=testName;
					}
					String onlyCompName="";
					if(compName!=null && compName.indexOf(":")>-1)
					{
						onlyCompName=compName.substring(0,compName.indexOf(":"));
					}
					String[] extAgents=egExternal.getExternalAgentsForHost(onlyCompName);
					boolean isExternalTest=specsInfo.isExternalTest(onlyTest.trim());
					///---End----
					if (!StringUtils.isNull(msmtHost))
					{
						if(!(extAgents.length <=1 || !isExternalTest))
						{
							TestinfoJson.put("unit",msmtHost);
						}
					}
					json.put("testInfo",TestinfoJson);
					boolean isTestinMaintenance = egM.isItMaintenanceTime(test,dateInfo.egetDate(),true);
					boolean isHostTestinMaintenace=egM.isItMaintenanceTime(test,dateInfo.egetDate(),hostName,"","",true);
					boolean isCompTestinMaintenance=egM.isItMaintenanceTime(test,dateInfo.egetDate(),hostName,portOfComponent,mySid,true);
					boolean istestandHostinMaintenance=egM.isItMaintenanceTime(test,dateInfo.egetDate(),hostName,"",info,true);
					boolean istestandComponentinMaintenance  =egM.isItMaintenanceTime(test,dateInfo.egetDate(),hostName,portOfComponent,info,true);
					boolean isDescriptorMaintenanceForComponent=egM.isItMaintenanceTime(test, dateInfo.egetDate(), hostName, portOfComponent, mySid,info,true);
					boolean isDescriptorMaintenanceForTest=egM.isItMaintenanceTime(hostName, dateInfo.egetDate(),info,true);
					if(allowMPolicyCreationForDescriptorInLayerModel && (!isTestinMaintenance && !isHostTestinMaintenace && !isCompTestinMaintenance && !istestandHostinMaintenance && !istestandComponentinMaintenance && !isDescriptorMaintenanceForTest &&!isDescriptorMaintenanceForComponent))
					{
						if (!EgInstallInfo.isSuperManager && !isSecondaryManager)
						{
							String strChildWindow = (String)session.getAttribute("isNewChildWindow");
							if(StringUtils.isNull(strChildWindow))
							{
								strChildWindow = "no";
							}
							isNotOpenNewWindow = (!StringUtils.isNull(strChildWindow) && strChildWindow.equalsIgnoreCase("no"));
							if(isAdmin)
							{
								showMaintenanceConfigIcon = true;
							}
							else if(hasAdminTab && hasMaintenancePolicyConfiguration)
							{
								showMaintenanceConfigIcon=true;
							}
						}

						if(showMaintenanceConfigIcon)
						{
							String testDispName=mappingInfo.getTestDescription(""+ui.getReverseLookupAll(test));
							//testDispName=StringUtils.replace(testDispName," ","!spc!");
							String maintenanceType="Descriptor for Component";
							String descForComp=test+":"+info;
							descForComp=com.egurkha.util.StringUtils.encodeSecurityChar(descForComp);
							String instantMaintenanceConfigURL="from=saveQuickMaintenancePolicy&type=showPolicies&operation=create&combination="+EgURLEncoder.encode(maintenanceType,"UTF-8")+"&test="+EgURLEncoder.encode(test,"UTF-8")+"&infratypename=&serverType=&fassociate="+EgURLEncoder.encode(descForComp,"UTF-8")+"&comp="+EgURLEncoder.encode(compType+":"+compName,"UTF-8");
							String compDispName=compName;
							if(compDispName!=null && compDispName.indexOf(":NULL")>-1)
							{
								compDispName=compDispName.substring(0,compDispName.indexOf(":"));
							}
							String infoDisp=StringUtils.replace(info,"&#39;","\\&#39;");
							JSONObject mainPlcyConfigJson = new JSONObject();
							mainPlcyConfigJson.put("urlParam1",compDispName+"!sep!"+testDispName+"!sep!"+infoDisp);
							mainPlcyConfigJson.put("urlParam2",instantMaintenanceConfigURL);
							mainPlcyConfigJson.put("stackTooltip",mappingInfo.getTextDescription("monitor.layermodel.Maintenance Policy"));
							json.put("mainPlcyConfigIcon",mainPlcyConfigJson);
						}
					}
					//................This is for CtxXcXDUserTest to display Icon ..........
					String isLogon_Details_Support = dashboardConfigIni.getValue("Logon_Details_Support",test);
					//boolean isRelevant=specsInfo.isTestRelevantForServer(compType,"VmgCtxXcXAEuemTest");
					if(supported_types_list!=null && compType!=null && supported_types_list.contains(compType) && isLogon_Details_Support!=null && isLogon_Details_Support.length()>0 && (isLogon_Details_Support.equalsIgnoreCase("yes") || isLogon_Details_Support.equalsIgnoreCase("true")))
					{
						if(info!=null && info.length()>0 && info.indexOf("\\")>-1)
						{
							String userType="XenApp7";
							if(test!=null && test.length()>0 && (test.equalsIgnoreCase("CtxXcXDUserTest") || test.equalsIgnoreCase("CtxCdUserTest")))
							{
								String userTypeForLogon=(String)getUserTypeForLogon(test,"+"+info);
								if(userTypeForLogon!=null && (userTypeForLogon.startsWith("+Server") || userTypeForLogon.startsWith("+Windows Server")))
								{
									userType="XenApp7";
								}
								else if(userTypeForLogon!=null && (userTypeForLogon.startsWith("+Desktop") || userTypeForLogon.startsWith("+Windows Desktop")))
								{
									userType="VDI";
								}
							}
							else if(test!=null && test.length()>0 && test.equalsIgnoreCase("CtxXcXAEuemTest"))
							{
								userType="XenApp7";
							}
							else if(test!=null && test.length()>0 && (test.equalsIgnoreCase("VmgCtxXcXAEuemTest") || test.startsWith("Vmg")))
							{
								userType="VDI";
							}

							String director_types = egINI.getValue("Enable_Director_Link",userType);
							director_types=(director_types==null || director_types.trim().length()==0)?"":director_types;
							ArrayList directorSupportedTypes =  com.egurkha.util.StringUtils.egTokenizer(director_types.trim(), ",",false,true,true);//param 3-->includeEmpty,4-->unique,5-->trim

							boolean isUserHaveDirector=false;
							if(directorSupportedTypes!=null && directorSupportedTypes.size()>0)
							{
								for (int i=0;i<directorSupportedTypes.size() ; i++)
								{
									String supp_type=(String)directorSupportedTypes.get(i);
									if(userTypes != null && supp_type!=null && userTypes.contains(supp_type))
									{
										isUserHaveDirector = true;
										break;
									}
								}
							}
							boolean isShowLogonIcon=true;
							if(userType!=null && userType.length()>0 && userType.equalsIgnoreCase("VDI") && info.toLowerCase().indexOf("_on_")<0 && test!=null && test.length()>0 && test.startsWith("Vmg"))
							{
								isShowLogonIcon=false;
							}
							else if(userType!=null && userType.equals("VDI") && vdiSkipTypes != null && vdiSkipTypes.size() > 0 && vdiSkipTypes.contains(compType))
							{
								String vdiTest = dashboardConfigIni.getValue("Blast_Session_Logon_check",compType);
								Hashtable metaTest=(Hashtable)EgMetaThread.metaTest;
								if(metaTest == null)
									metaTest=new Hashtable();
								Hashtable testDetails =(Hashtable) metaTest.get(compType+":"+compName);
								ArrayList testData  = (ArrayList)testDetails.get(vdiTest);
								String tmpInf = info;
								tmpInf = (tmpInf != null && !tmpInf.startsWith("+"))?"+"+tmpInf:tmpInf;
								if(testData!=null && testData.size()>0 && tmpInf!=null && !testData.contains(tmpInf))
								{
									isShowLogonIcon=false;
								}
								else if(testData == null || testData.size() == 0)
									isShowLogonIcon=false;
							}

							if(isUserHaveDirector && isShowLogonIcon)
							{
								String tInfo=info;
								if(userType!=null && userType.length()>0 && userType.equalsIgnoreCase("VDI"))
								{
									if(tInfo!=null && tInfo.indexOf(":")>-1 && tInfo.toLowerCase().indexOf("_on_")>-1)
									{
										tInfo=tInfo.substring(0,tInfo.indexOf(":"));
									}
								}
								
								JSONObject Logon_Details_SupportJson = new JSONObject();
								String Url = response.encodeURL("/final/monitor/endUserLogonDetails.jsp?access=allusers&userType="+userType+"&fromMenu=true")+"&comptype="+request.getParameter("comptype")+"&compName="+com.eg.EgURLEncoder.encode(compName+":"+request.getParameter("comptype"),"UTF-8")+"&info="+com.eg.EgURLEncoder.encode("*"+tInfo,"UTF-8")+"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&tab=layerModel&testNameForLogon="+test;

								Logon_Details_SupportJson.put("urlParam1",Url);
								String titleInfo ="";
								String getInfoTitle = "";
								if(tInfo!=null && tInfo.trim().length()>0)
								{
									titleInfo = StringUtils.replace(tInfo, '*', '+');
									titleInfo=com.egurkha.util.StringUtils.replace(titleInfo, "\\", "\\\\");
									getInfoTitle = StringUtils.replace(titleInfo, "+", "");
								}
						
								String titleforLogon=mappingInfo.getTextDescription("monitor.layermodel.Logon Details for user :")+" "+getInfoTitle+" ";
								Logon_Details_SupportJson.put("logonTooltip",mappingInfo.getTextDescription("monitor.layermodel.Logon Details"));
								Logon_Details_SupportJson.put("titleforLogon",titleforLogon);
								json.put("Logon_Details_Support",Logon_Details_SupportJson);

								JSONObject UX_Dash_SupportJson = new JSONObject();
								String testCheck = test+"-+"+info;
								testCheck = com.egurkha.util.StringUtils.encodeSecurityChar(testCheck);
								String url_for_ux_dash = "/final/monitor/endUserDashboardDetailsData.jsp?comp="+EgURLEncoder.encode(compName,"UTf-8")+"&comptype="+request.getParameter("comptype")+"&info=*"+EgURLEncoder.encode(tInfo,"UTf-8")+"&compName="+EgURLEncoder.encode(compName,"UTf-8")+":"+request.getParameter("comptype")+"&componentName="+EgURLEncoder.encode(onlyCompName,"UTf-8")+"&msmt_host="+EgURLEncoder.encode(infoStr,"UTf-8")+"&user="+EgURLEncoder.encode(loginid,"UTf-8")+"&searchString=&priority="+s_default_priority+"&vdiType=&userType="+userType+"&enableBackButton=true&fromLayerModel=true&fromTest="+EgURLEncoder.encode(testCheck,"UTf-8")+"&fromLayerName="+EgURLEncoder.encode(layerName,"UTf-8")+"&desktopState="+testImage;

								if(test!=null && test.length()>0 && (test.equalsIgnoreCase("CtxXcXDUserTest") || test.equalsIgnoreCase("CtxCdUserTest")))
								{
									url_for_ux_dash = "NA";
								}

								UX_Dash_SupportJson.put("urlParamUxDash",url_for_ux_dash);
								String titleforUxDash=mappingInfo.getTextDescription("monitor.layermodel.UX Dashboard for user :")+" "+getInfoTitle+" ";
								UX_Dash_SupportJson.put("uxDashTooltip",mappingInfo.getTextDescription("monitor.layermodel.UX Dashboard"));
								UX_Dash_SupportJson.put("titleforUxDash",titleforUxDash);
								json.put("UX_Dashboard_Support",UX_Dash_SupportJson);
							}
						}
					}

					//................This is for JvmThreadTest to display stacktrace ..........
					if(testName.equalsIgnoreCase("JvmThreadTest") || onlyTest.equalsIgnoreCase("JvmThreadTest"))
					{
						EgAgentInfo agentInfoo = new EgAgentInfo("manager");
						String showMode = agentInfoo.getParamValue(test,hostName,portNumber,"+",infoStr,"mode");
						if(showMode!=null && showMode.equalsIgnoreCase("false"))
						{
							String Url = response.encodeURL("/final/monitor/ThreadDetails.jsp?")+"site=" + EgURLEncoder.encode(siteName,"UTF-8") + "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test="+test+"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+ "&flag=1&firsttime=true";
							JSONObject StackinfoJson = new JSONObject();
							StackinfoJson.put("urlParam1",Url);
							StackinfoJson.put("urlParam2","Thread Diagnosis - "+hostName);
							StackinfoJson.put("stackTooltip",mappingInfo.getTextDescription("monitor.layermodel.STACK TRACE"));
							json.put("stackInfo",StackinfoJson);

						}
					}
					else if(testName.equalsIgnoreCase("JvmMemoryDetailsTest - Heap+Memory+Usage") || testName.equalsIgnoreCase("JvmMemoryDetailsTest - Heap_Memory_Usage"))
					{
						EgAgentInfo agentInfoo = new EgAgentInfo("manager");
						String heapOnOff = agentInfoo.getParamValue(test,hostName,portNumber,"+",infoStr,"Heap_Analysis");
						if(heapOnOff!=null && heapOnOff.equalsIgnoreCase("true"))
						{
							String Url = response.encodeURL("/final/monitor/ThreadDetails.jsp?")+"site=" + EgURLEncoder.encode(siteName,"UTF-8") + "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test="+test+"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+ "&flag=1&firsttime=true&s_info="+com.eg.EgURLEncoder.encode("*"+info,"UTF-8");
							JSONObject HeapinfoJson = new JSONObject();
							HeapinfoJson.put("urlParam1",Url);
							HeapinfoJson.put("urlParam2","Heap Analysis - "+hostName);
							HeapinfoJson.put("heapTooltip",mappingInfo.getTextDescription("monitor.layermodel.HEAP DETAILS"));
							json.put("heapInfo",HeapinfoJson);

						}
					}
					JSONObject DetailinfoJson = new JSONObject();
					if(isfromSuper)
					{
						DetailinfoJson.put("urlParam1",response.encodeURL("../monitor/EgTestStatusInfo.jsp?")+tmpTestStatusInfoURL);
						DetailinfoJson.put("urlParam2",layerName);
						DetailinfoJson.put("urlParam3",tmpBadMesList);
						DetailinfoJson.put("methodSuper",true);
					}
					else
					{
						DetailinfoJson.put("urlParam1",tmpTestStatusInfoURL);
						DetailinfoJson.put("urlParam2",layerName);
						DetailinfoJson.put("urlParam3",tmpBadMesList);
						DetailinfoJson.put("methodSuper",false);
					}
					DetailinfoJson.put("detailText",mappingInfo.getTextDescription("monitor.layermodel.DETAILS"));	
					json.put("detailInfo",DetailinfoJson);

					if (!isAgentlessServer)
					{
						//CLUSTERING
						Vector reportingAgents = null;
						boolean remoteControl = true;
						if(!EgInstallInfo.isClusterSupported || (remoteControl) )
						{
							
							if((remoteControlEnabled && sessionUserId.equalsIgnoreCase("supermonitor"))
								|| (remoteControlEnabled && flag))
							{
								// "ca_host" has been changed as "msmtHost"
								String url = null;
								String tt_name=request.getParameter("test");
								if(tt_name!=null)
									tt_name=EgURLEncoder.encode(tt_name,"UTF-8");
								if(msmtHost != null && !msmtHost.equals(""))
								{
									url = response.encodeURL("../monitor/DispAgentInfo.jsp?")+"agentIP="+msmtHost+"&agentModeCalc=true&hostName="+hostName+"&form1=layer&qctr="+qctrString+"&test="+tt_name+"&faketype="+request.getParameter("faketype")+"&layername="+request.getParameter("layer")+"&site="+request.getParameter("site")+"&comptype="+request.getParameter("comptype")+"&tstate="+request.getParameter("tstate")+"&portNumber="+portNumber+"&sid="+mySid+"&firstCall=true";
									session.setAttribute("hostName", hostName);
								}
								else
								{
									url = response.encodeURL("../monitor/DispAgentInfo.jsp?")+"agentIP="+msmtHost_RC+"&agentModeCalc=true&hostName="+hostName+"&form1=layer&qctr="+qctrString+"&test="+tt_name+"&faketype="+request.getParameter("faketype")+"&layername="+request.getParameter("layer")+"&site="+request.getParameter("site")+"&comptype="+request.getParameter("comptype")+"&tstate="+request.getParameter("tstate")+"&portNumber="+portNumber+"&sid="+mySid+"&firstCall=true";
									session.setAttribute("hostName", hostName);
								}
	//If I take out target="eg_operations" from the <A href> tag, then the window opens correctly in EgDispMeasures.jsp and EgMoreInfos.jsp
								session.setAttribute("form", "layer");

								if(request.getParameter("moreinfo")==null)
								{
									JSONObject RemoteinfoJson = new JSONObject();
									RemoteinfoJson.put("url",url+"&fromDashBoardLayerModel=true");
									RemoteinfoJson.put("remoteText",mappingInfo.getTextDescription("monitor.layermodel.REMOTE CONTROL"));
									json.put("remoteInfo",RemoteinfoJson);
								}
								else if(request.getParameter("moreinfo")!=null && request.getParameter("moreinfo").equalsIgnoreCase("true"))
								{
									JSONObject RemoteinfoJson = new JSONObject();
									RemoteinfoJson.put("url",url+"&fromDashBoardLayerModel=true");
									RemoteinfoJson.put("remoteText",mappingInfo.getTextDescription("monitor.layermodel.REMOTE CONTROL"));
									json.put("remoteInfo",RemoteinfoJson);
								}
							}
						}
					}

	//If I take out target="eg_operations" from the <A href> tag, then the window opens correctly in EgDispMeasures.jsp and EgMoreInfos.jsp
					JSONObject HelpinfoJson = new JSONObject();
					if(isfromSuper)
					{
						HelpinfoJson.put("urlParam1",response.encodeURL("../eghelp/EgMHelp.jsp?"));
						HelpinfoJson.put("urlParam2",test);
						HelpinfoJson.put("methodSuper",false);
					}
					else
					{
						HelpinfoJson.put("urlParam1",test);
						HelpinfoJson.put("methodSuper",false);
					}
					HelpinfoJson.put("helpText",mappingInfo.getTextDescription("monitor.layermodel.HELP"));
					json.put("helpInfo",HelpinfoJson);

					if(hstInfoStr != null)
					{
						hstInfoStr = hstInfoStr.replace('+','*');
						if(hstInfoStr.startsWith("*"))
						{
							hstInfoStr = hstInfoStr.substring(1,hstInfoStr.length());
						}
					}
					else
					{
						hstInfoStr = "";
					}
					
					int ind = infoStr2.indexOf("+");
					String infoStrForFB=infoStr2;
					if(ind>0)
					{
						infoStrForFB = infoStrForFB.substring(0,ind)+"*"+infoStrForFB.substring(ind+1);
					}
					if (ind >=0)
					{
						infoStr2 = infoStr2.substring(0,ind)+"*"+infoStr2.substring(ind+1);
					}
					boolean allNegative5 = true;
					for(int j=0; j<store.size(); j=j+4)
					{
						String measureValue = (String)store.elementAt(j+1);
						if (!measureValue.equals("-5") && !measureValue.equals("-5.0000"))
						{
							allNegative5 = false;
							break;
						}
					}
					boolean cellBreakCounter = true;	//td related changes --jaiwin
					boolean if_continue=false;
					int j=0;
					String test_name="";
					String dispLable="";
					//Added by ChandraSekhar toshow measures in Measurement panel some order
					//means cpu related measures one group,disk,memory.......
					JSONObject  measures_M=new JSONObject();
					Hashtable show_dd_hash = null;
					if(ddEnabled)
					{
						show_dd_hash = dd.ShowDDDataByTest("NULL",hostName,test,infoStr);						
					}

					ArrayList check_List = null;
					boolean test_flag= false;
					String horizon_logon_support_meas = dashboardConfigIni.getValue("SuccessScreenshot_TestMeasure_Mapping",test);
					if(horizon_logon_support_meas != null && horizon_logon_support_meas.trim().length() > 0)
						check_List = com.egurkha.util.StringUtils.egTokenizer(horizon_logon_support_meas,",",false,true,true);
					if(check_List != null && check_List.size() > 0 && !check_List.contains("Availability"))
						test_flag = true;

					if(arrangeMesList!=null && arrangeMesList.contains(test))
					{
						//JSONArray dispLableJsonArray = new JSONArray(); 
						JSONArray GridinfoJsonArray = new JSONArray();
						JSONArray measure_mobile=new JSONArray();
						boolean groupingGridFlag = true;
						
						//JSONArray GridinfoJsonAltArray = new JSONArray();
						//boolean alternate = false;
						EgAggregateInfo aggregateInfo = null;
						if(EgInstallInfo.isAggregationSupported() && type.startsWith("Agg_"))
						{
							aggregateInfo = new EgAggregateInfo("manager");
						}
						for(int k=0; k<dispLableList.size(); k++)
						{
							JSONArray GridinfoJsonArray_mobile = new JSONArray();
							JSONObject measure_obj_mobile=new JSONObject();
							//JSONObject dispLableJson = new JSONObject();
							String lableName=(String)dispLableList.get(k);
							if(lableName!=null && lableName.indexOf(":")>0)
							{
								test_name=lableName.substring(0,lableName.indexOf(":"));
								dispLable=lableName.substring(lableName.indexOf(":")+1);
							}
							
							if(test_name!=null && test_name.equals(test))
							{
								cellBreakCounter = true;
								if_continue = false;
								ArrayList list_mes=(ArrayList)measureAllValues.get(lableName);
								Vector totalMeasureList=new Vector();
								for(int p=0; p<list_mes.size(); p=p+4)
								{
									String measVal=(String)list_mes.get(p+1);
									if (!allNegative5 && (measVal.equals("-5") || measVal.equals("-5.0000")))
									{
										continue;
									}
									else
									{
										String mes=(String)list_mes.get(p);
										String meaState=(String)list_mes.get(p+2);
										String measMsmtHost=(String)list_mes.get(p+3);
										String mcol = MeasureDisplay.getColumnForMeasure(test,mes);
										totalMeasureList.add(mcol.trim());
										totalMeasureList.add(measVal.trim());
										totalMeasureList.add(meaState.trim());
										totalMeasureList.add(measMsmtHost.trim());
									}
								}
								if(totalMeasureList!=null && totalMeasureList.size()>0)
								{
									/* dispLableJson.put("dispLable",dispLable); */
								}
								else if(totalMeasureList==null || totalMeasureList.size()==0)
								{
									continue;
								}
								//JSONArray GridinfoJsonArray = new JSONArray();
								JSONArray hiddenValuesJsonArray = new JSONArray();
								for(j=0; j<totalMeasureList.size(); j=j+4)
								{
									JSONObject GridinfoJson = new JSONObject();
									JSONObject GridinfoJson_mobile = new JSONObject();
									if(dispLable == null || dispLable.trim().length() <= 0)
										groupingGridFlag = false;
									else
										groupingGridFlag = true;
									GridinfoJson.put("groupingIndex",dispLable);
									JSONObject hiddenValuesJson = new JSONObject();
									String measVal="";
									if(arrangeMesList!=null && arrangeMesList.contains(test))
									{
										measVal = (String)totalMeasureList.elementAt(j+1);
									}
									if (!allNegative5 
									&& (measVal.equals("-5") || measVal.equals("-5.0000")))
									{
										if((j+4)>=totalMeasureList.size()) 
											if_continue=true;
										continue;
									}
									String value = null;
									try
									{
										Double d = new Double(measVal);
										value = ui.getMeasureLookup(String.valueOf(d.intValue()));	
									}
									catch(NumberFormatException nfe)
									{
										System.out.println("EgDispMeasure.jsp : Could not format "+measVal+" into a number");
									}
									if(StringUtils.isNull(value))
									{
										value = measVal;
									}
									String messy ="";
									String stateString="";
									if(arrangeMesList!=null && arrangeMesList.contains(test))
									{
										messy = MeasureDisplay.getMeasureForColumn(test,(String)totalMeasureList.elementAt(j));
										stateString = (String)totalMeasureList.elementAt(j+2);
									}
									tmpTest = URLDecoder.decode(tmpTest);
								
									if (EgConfigInfo.isBad(stateString))
									{
										badMesList += messy + ",";
										String priority = (String)ap.getTestMeasurePriority(compName, compType, layerName, tmpTest.replace(' ','+'), messy);
										if(AlarmPriorities.GOOD_STATE.equals(priority))
										{
											/*
											 * Happens when last set of measures being displayed are old and new alarms are not present in the database. Setting to a different colour because the real priority of that measure is not known.
											 */
										}
										else
										{
											stateString = priority;
										}
									}
									if(stateString!=null&&(stateString.equals("HIGH") || stateString.equals("INTERMEDIATE")
												|| stateString.equals("LOW")))
									{
										int indo = measuresForAlarms.indexOf(messy);
										if (indo >= 0 && states != null && states.size()>0)
										{
											stateString = (String)states.get(indo);
										}
									}
									String msmtHostPopUp = request.getParameter("msmt_host");
									if(msmtHostPopUp!=null && msmtHostPopUp.indexOf(",")>-1)
										msmtHostPopUp = msmtHostPopUp.substring(0,msmtHostPopUp.indexOf(","));

									if(stateString!=null && (stateString.equalsIgnoreCase("HIGH") || stateString.equalsIgnoreCase("INTERMEDIATE") || stateString.equalsIgnoreCase("LOW")))
									{
										String testWithInfo = "";
										testWithInfo = (String)request.getParameter("test");
										if(testWithInfo!=null)
											testWithInfo=com.egurkha.util.StringUtils.replace(testWithInfo,"\"","&#34");

										if(testWithInfo!=null && testWithInfo.indexOf("\\")>-1 && testWithInfo.indexOf("\\\\")<0)
											testWithInfo = com.egurkha.util.StringUtils.replace(testWithInfo, "\\", "\\\\");

										String ftypeif=request.getParameter("faketype");
										ftypeif=(ftypeif==null || ftypeif.trim().length()==0)?"":ftypeif;
									
										//GridinfoJson.put("stateImageUrlParam1",com.eg.EgURLEncoder.encode(testWithInfo,"UTF-8"));
										GridinfoJson.put("stateImageUrlParam1",testWithInfo);
										GridinfoJson.put("stateImageUrlParam2",request.getParameter("layer"));
										GridinfoJson.put("stateImageUrlParam3",request.getParameter("host"));
										GridinfoJson.put("stateImageUrlParam4",request.getParameter("comptype"));
										GridinfoJson.put("stateImageUrlParam5",messy);
										GridinfoJson.put("stateImageUrlParam6",infoStr);
										GridinfoJson.put("stateImageUrlParam7",msmtHostPopUp);
										GridinfoJson.put("stateImageUrlParam8",ftypeif);

										GridinfoJson.put("state",stateString);
										GridinfoJson_mobile.put("state",stateString);
										hiddenValuesJson.put("measure",messy);
										hiddenValuesJson.put("infoStr",infoStr);
										hiddenValuesJson.put("test",request.getParameter("test"));
										hiddenValuesJson.put("layer",request.getParameter("layer"));
										hiddenValuesJson.put("mHost",request.getParameter("msmt_host"));
										hiddenValuesJson.put("faketype",request.getParameter("faketype"));
										
										hiddenValuesJsonArray.add(hiddenValuesJson);
									}
									else
									{
										GridinfoJson.put("state",stateString);
										GridinfoJson_mobile.put("state",stateString);
									}
									String measValue="";
									if(stateString!=null && (stateString.equalsIgnoreCase("HIGH") || stateString.equalsIgnoreCase("INTERMEDIATE") || stateString.equalsIgnoreCase("LOW")))
									{
										String testWithInfo = "";
										testWithInfo = (String)request.getParameter("test");
										if(testWithInfo!=null)
											testWithInfo=com.egurkha.util.StringUtils.replace(testWithInfo,"\"","&#34");

										if(testWithInfo!=null && testWithInfo.indexOf("\\")>-1 && testWithInfo.indexOf("\\\\")<0)
											testWithInfo = com.egurkha.util.StringUtils.replace(testWithInfo, "\\", "\\\\");

										//GridinfoJson.put("urlParam1",com.eg.EgURLEncoder.encode(testWithInfo,"UTF-8"));
										GridinfoJson.put("urlParam1",testWithInfo);
										GridinfoJson.put("urlParam2",request.getParameter("layer"));
										GridinfoJson.put("urlParam3",request.getParameter("host"));
										GridinfoJson.put("urlParam4",request.getParameter("comptype"));
										GridinfoJson.put("urlParam5",messy);
										GridinfoJson.put("urlParam6",infoStr);
										GridinfoJson.put("urlParam7",msmtHostPopUp);
										GridinfoJson.put("urlParam8",request.getParameter("faketype"));
										
										boolean batt_status=false;	
										IniFile egUi = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
				
										String testMeas_Name=test+":"+messy;

										if((test.endsWith("_ag") || test.endsWith("_agx")) && aggregateInfo != null)
										{
											String testMeas_NameTemp=aggregateInfo.getValue("COLUMN_NAME_MAPPING",testMeas_Name);
											if(testMeas_NameTemp != null && testMeas_NameTemp.trim().length()>0)
											{
												testMeas_Name = testMeas_NameTemp.trim();
											}
										}
										
										String meas_Unit=(String)mu.doUnitConversion(test,messy,value);
										String org_unit= meas_Unit.substring(meas_Unit.indexOf("$")+1);
										measValue= meas_Unit.substring(0,meas_Unit.indexOf("$"));

										String convert_Days=dashboardConfigIni.getValue("Convert_To_Days",testMeas_Name);
										if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
										{
											String dateDiff="";
											String currentValue=measValue;	
											try
											{
												if(currentValue!=null && !currentValue.trim().equals(""))
												{
													long minutes=0;
													float seconds=0.0f;
													if(currentValue!=null && currentValue.indexOf(".")>0)
													{
														minutes=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
														if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
														{
															seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf("."),currentValue.indexOf(".")+3));
														}
														else
														{
															seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf(".")));
														}
													}
													else
													{
														minutes=Long.parseLong(currentValue);
													}

													long valueInSecond=(minutes*60)+(long)(seconds*60);
													dateDiff=egDashboard.getDateDifferenceStringforUptime(valueInSecond);
												}			
												measValue=dateDiff;
											}
											catch(Exception e)
											{
												measValue=measValue;
											}
										}

										String iniVar=test+":"+messy+":"+measValue;
										String iniValue=egUi.getValue("Measure_value_display",iniVar);
										
										String unitValue = "";
										if(iniValue!=null && iniValue.length() > 0)
										{
											batt_status=true;
											measValue=iniValue;
										}else if (!value.equalsIgnoreCase("Unknown") && !value.equalsIgnoreCase("Unlimited") && !value.equalsIgnoreCase("Not Applicable") && !value.equalsIgnoreCase("Not Supported") && !value.equalsIgnoreCase("Not Available"))
										{
											unitValue = " ("+org_unit+")";
											//GridinfoJson.put("measureUnit",TableData.getUnitForMeasure(test,messy));
											GridinfoJson_mobile.put("measureUnit",org_unit);
										}
										
										String mappingString = test+":"+messy;
										if(isCommonDDTest)
										{
											mappingString = backupTest+":"+messy;
											if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
												GridinfoJson_mobile.put("internalMeasure",messy);

											}
											else
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+unitValue);
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+unitValue);
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
											
										}
										else
										{
											if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy));
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy));
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
											else
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy)+unitValue);
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy)+unitValue);
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
											
										}
										//Alagu added for display the text value for certain measures like powered on.
										
									}
									else
									{
										IniFile egUi = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
										
										boolean batt_status=false;	
										
										String testMeas_Name=test+":"+messy;
										if((test.endsWith("_ag") || test.endsWith("_agx")) && aggregateInfo != null)
										{
											String testMeas_NameTemp=aggregateInfo.getValue("COLUMN_NAME_MAPPING",testMeas_Name);
											if(testMeas_NameTemp != null && testMeas_NameTemp.trim().length()>0)
											{
												testMeas_Name = testMeas_NameTemp.trim();
											}
										}
										
										String meas_Unit=(String)mu.doUnitConversion(test,messy,value);
										String org_unit= meas_Unit.substring(meas_Unit.indexOf("$")+1);
										measValue= meas_Unit.substring(0,meas_Unit.indexOf("$"));

										String convert_Days=dashboardConfigIni.getValue("Convert_To_Days",testMeas_Name);
										if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
										{
											String dateDiff="";
											String currentValue=measValue;	
											try
											{
												if(currentValue!=null && !currentValue.trim().equals(""))
												{
													long minutes=0;
													float seconds=0.0f;
													if(currentValue!=null && currentValue.indexOf(".")>0)
													{
														minutes=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
														if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
														{
															seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf("."),currentValue.indexOf(".")+3));
														}
														else
														{
															seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf(".")));
														}
													}
													else
													{
														minutes=Long.parseLong(currentValue);
													}
													long valueInSecond=(minutes*60)+(long)(seconds*60);
													dateDiff=egDashboard.getDateDifferenceStringforUptime(valueInSecond);
												}			
												measValue=dateDiff;
											}
											catch(Exception e)
											{
												measValue=measValue;
											}
										}

										String iniVar=test+":"+messy+":"+measValue;
										String iniValue=egUi.getValue("Measure_value_display",iniVar);
										String unitTmp = "";
										if(iniValue!=null && iniValue.length() > 0)
										{
											batt_status=true;
											measValue=iniValue;
										}else if (!value.equalsIgnoreCase("Unknown") && !value.equalsIgnoreCase("Unlimited") && !value.equalsIgnoreCase("Not Applicable") && !value.equalsIgnoreCase("Not Supported") && !value.equalsIgnoreCase("Not Available"))
										{
											unitTmp = " ("+org_unit+")";
											//GridinfoJson.put("measureUnit",TableData.getUnitForMeasure(test,messy));
											GridinfoJson_mobile.put("measureUnit",org_unit);
										}

										String mappingString = test+":"+messy;
										if(isCommonDDTest)
										{
											mappingString = backupTest+":"+messy;
											if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
											else
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+unitTmp);
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+unitTmp);
												GridinfoJson_mobile.put("internalMeasure",messy);

											}
										}
										else
										{
											if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy));
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy));
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
											else
											{
												GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy)+unitTmp);
												GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy)+unitTmp);
												GridinfoJson_mobile.put("internalMeasure",messy);
											}
										}
										//Alagu added for display the text value for certain measures like powered on.
										
									}
									tmpInfo =(String)totalMeasureList.elementAt(j+3);
									tmpInfo = tmpInfo.replace('+','*');
									histLink = historyLink + "&measure=" + messy+ "&msmt_host=" + com.eg.EgURLEncoder.encode(infoStr,"UTF-8") ;
									feedLink = feedbackLink +"&info="+com.eg.EgURLEncoder.encode(infoStrForFB,"UTF-8")+ "&measure="+messy+ "&msmttime="+time +"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8");
									//Commented because of unique info lost problem during unknown state
									agLink = gLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)totalMeasureList.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
									atgLink = tgLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)totalMeasureList.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
									asumLink = sumLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)totalMeasureList.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
									
									String aggregateLink=aggLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)totalMeasureList.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
									String tempInfo = infoStr2;
									tempInfo = tempInfo.equals("*")?"NONE":tempInfo;
									String adlink = dLink + "&info="+com.eg.EgURLEncoder.encode(tempInfo,"UTF-8")+"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+ "&from=0&measure="+messy+ "&flag=1&firsttime=true";
									String popupLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+request.getParameter("comptype")+"&site="+siteName+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNumber+"&info="+EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString+"&messy="+messy+"&isVM="+isVM;
									linksMap.put(messy+"aggregateLink",aggregateLink);
									
									if(MeasureDisplay.formatValue(value)!=null && (MeasureDisplay.formatValue(value)).equalsIgnoreCase("Unknown"))
									{
										GridinfoJson.put("value",mappingInfo.getTextDescription("monitor.common.Unknown"));
										GridinfoJson_mobile.put("value",mappingInfo.getTextDescription("monitor.common.Unknown"));
									}
									else
									{
										if(isfromSuper)
										{
											GridinfoJson.put("valueUrlMethodSuper","true");
											GridinfoJson.put("valueUrl",popupLink+"&clicked=graph");
										}
										else
										{
											GridinfoJson.put("valueUrlMethodSuper","false");
											GridinfoJson.put("valueUrl",popupLink+"&clicked=graph");
										}
										GridinfoJson.put("value",measValue);
										GridinfoJson_mobile.put("value",measValue);
									}
									if(test!=null && test.endsWith("_rx"))
									{
										String cmxPopupUrl = response.encodeURL("../monitor/compositeMeasureInfo.jsp?")+"type="+request.getParameter("comptype")+"&site="+siteName+"&host="+hostName+"&port="+portNumber+"&info="+EgURLEncoder.encode(info,"UTF-8")+"&state="+stateString+"&measure="+messy+"&measure_value="+measValue;
										JSONObject cmxDiv = new JSONObject();

										cmxDiv.put("cmxUrl",cmxPopupUrl);
										cmxDiv.put("cmxTooltip",mappingInfo.getTextDescription("monitor.common.Rating"));
										cmxDiv.put("iconClass","sym_composite");

										GridinfoJson.put("cmxDiv",cmxDiv);
									}
									
									boolean isScreenShotEnabled = (formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && !measValue.equals("100"));

									//if(isScreenShotEnabled && test.equalsIgnoreCase("CitraTest") && (!isFaliureScreenshotRequired))
										//isScreenShotEnabled = false;

									String needed_infoStr = tempInfo;
									if(isScreenShotEnabled && test.equalsIgnoreCase("GenericLogonSimTest"))
									{
										ddEnabled = true;								
										needed_infoStr = tempInfo.substring(0,tempInfo.indexOf(":")+1)+"Total";
									}
									boolean isForSuccessScreenshot=false;

									if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("100") && isSucessSSTest && isSuccessScreenshotRequired && !isScreenShotEnabled && ((testForSucessSS.contains(test) && needed_infoStr.endsWith("Total")) || (testForSucessSS.contains(test) && test_flag && check_List.contains(messy))))
									{
										isScreenShotEnabled = true;
										isForSuccessScreenshot = true;
									}
									if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && (measValue.equals("100") ||measValue.equals("0")) && isSucessSSTest && testForSucessSS.contains(test) && tempInfo.endsWith("Total") && !isSuccessScreenshotRequired && isScreenShotEnabled)
										isScreenShotEnabled = false;
									else if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("0") && isSucessSSTest && testForSucessSS.contains(test) && tempInfo.endsWith("Total") && isSuccessScreenshotRequired && isScreenShotEnabled)
										isScreenShotEnabled = false;
							
									if(ddEnabled)
									{
										if(measures.contains(messy))
										{
											wname = sid + "DIAGNOSIS";
											boolean showDDIcon = false;
											if (ui.getVirtualServerTypes().contains(compType)||!isAgentlessServer || specsInfo.isTestExternal(test))
											{
												//code starts to check DD data available for this test and info
												String commTestDD = trans. getStrValue("COMMON_DDTEST_MAPPING", test+":"+messy);
												String temp_test=test;
												String temp_messy=messy;
												if(commTestDD!=null && commTestDD.length() > 0)
												{
													isCommonDDTest = true;
													backupTest = test;
													temp_test = commTestDD.substring(0,commTestDD.indexOf(":"));
													temp_messy = commTestDD.substring(commTestDD.indexOf(":")+1);
												}
												if(needed_infoStr!=null&&needed_infoStr.equals("NONE"))
													needed_infoStr="+";
												if(needed_infoStr!=null)
												{
													int indexInfo = needed_infoStr.indexOf("*");
													if(indexInfo  >  -1)
													{
														StringBuffer sb = new StringBuffer(needed_infoStr);
														sb.setCharAt(indexInfo, '+');
														needed_infoStr = sb.toString();
													}
												}
												String tempInfoForDD=needed_infoStr;
												boolean isPortRelForTest = specsInfo.isPortRelevantForTest(temp_test);
												if(!isPortRelForTest && needed_infoStr!=null && needed_infoStr.trim().length()>0 && needed_infoStr .indexOf("+")>-1 && !needed_infoStr.startsWith("+"))
												{
													tempInfoForDD=needed_infoStr.substring(needed_infoStr .indexOf("+"));
												}
									
												if( (siteName==null || siteName.length() == 0 || siteName.equals("null")) || (siteName!=null && siteBasedTestList != null && siteBasedTestList.size() > 0 && !siteBasedTestList.contains(temp_test)))
													siteName="NULL";

												String s_info_to_db = null;
												String ddWithoutInfo = formatIniFile.getValue("Tests_For_DDWithoutInfos", temp_test + ":" + temp_messy);
												boolean lookforActualDes = false;

												if(ddWithoutInfo!=null && ddWithoutInfo.equalsIgnoreCase("yes"))
												{
													lookforActualDes = true;
													s_info_to_db = "+";
												}
												else
												{
													s_info_to_db = tempInfoForDD;
												}
												String ddWithallInfo = formatIniFile.getValue("Tests_For_DDAllInfos", temp_test + ":" + s_info_to_db);
												if(ddWithallInfo != null && ddWithallInfo.equalsIgnoreCase("yes"))
												{
													lookforActualDes = true;
													s_info_to_db = "";
												}
												apmTest = apm.isAPMTest(temp_test);
												//showDDIcon = dd.ShowDDData(siteName,hostName,temp_test,temp_messy,s_info_to_db,infoStr);
												showDDIcon = isDDDPresents(show_dd_hash,temp_test,temp_messy,s_info_to_db);
												if(!showDDIcon && apmTest && temp_messy.equals("All_urls_avg_time"))
												{
													
													if(isDDDPresents(show_dd_hash,temp_test,"Slow_percentage",s_info_to_db) || isDDDPresents(show_dd_hash,temp_test,"Error_percentage",s_info_to_db) || isDDDPresents(show_dd_hash,temp_test,"Stalled_percentage",s_info_to_db) || isDDDPresents(show_dd_hash,temp_test,"Healthy_percentage",s_info_to_db))
													{
														showDDIcon = true;
													}

													/*if(dd.ShowDDData(siteName,hostName,temp_test,"Slow_percentage",s_info_to_db,infoStr) || dd.ShowDDData(siteName,hostName,temp_test,"Error_percentage",s_info_to_db,infoStr) || dd.ShowDDData(siteName,hostName,temp_test,"Stalled_percentage",s_info_to_db,infoStr) || dd.ShowDDData(siteName,hostName,temp_test,"Healthy_percentage",s_info_to_db,infoStr))
													{
														showDDIcon = true;
													}*/
												}
												if(lookforActualDes && !showDDIcon)
												{
													//showDDIcon = dd.ShowDDData(siteName,hostName,temp_test,temp_messy,tempInfoForDD,infoStr);
													showDDIcon = isDDDPresents(show_dd_hash,temp_test,temp_messy,tempInfoForDD);
												}

												if(temp_test.equalsIgnoreCase("Citratest") && measValue.equals("100") && showDDIcon)
													showDDIcon = false;

												linksMap.put(messy+"compddlink", adlink);
												if(showDDIcon)
												{
													popupLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(request.getParameter("comptype"),"UTF-8")+"&site="+siteName+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNumber+"&info="+EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString+"&messy="+messy+"&isVM="+isVM;
													if(isfromSuper)
													{
														GridinfoJson.put("ddUrlMethodSuper","true");
														GridinfoJson.put("ddUrlParam1",popupLink+"&isForSuccessScreenshot="+isForSuccessScreenshot+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=dd");
														GridinfoJson.put("ddUrlParam2",wname);
													}
													else
													{
														GridinfoJson.put("ddUrlMethodSuper","false");
														GridinfoJson.put("ddUrlParam1",popupLink+"&isForSuccessScreenshot="+isForSuccessScreenshot+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=dd");
														GridinfoJson.put("ddUrlParam2",wname);
													}
													GridinfoJson.put("ddIconExist","true");
													GridinfoJson_mobile.put("ddIconExist",true);
													GridinfoJson.put("ddTooltip",mappingInfo.getTextDescription("monitor.common.Diagnosis"));

													popupLink +="&show=dd"; 
												}
												else
														GridinfoJson_mobile.put("ddIconExist",false);
											}
											else
												GridinfoJson_mobile.put("ddIconExist",false);
										}
										else
											GridinfoJson_mobile.put("ddIconExist",false);
									}

									if(isScreenShotEnabled)
									{
										String changedInfo = needed_infoStr;
										String title ="Failure Screenshot";
										if(isSucessSSTest && testForSucessSS.contains(test))
										{
											if(test.equalsIgnoreCase("GenericLogonSimTest"))
												 changedInfo = needed_infoStr.substring(0,needed_infoStr.indexOf(":")+1)+"Total";
											 if(messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("100") && stateString.equalsIgnoreCase("Good"))
												title = "Success Screenshot";
											 else
												title = "Failure Screenshot";
										}
										
										String trgt_host = hostName;
										String port_no = "NULL";
										if(hostName.indexOf(":") != -1)
										{
											trgt_host = hostName.substring(0,hostName.indexOf(":"));
											port_no = hostName.substring(hostName.indexOf(":")+1);
										}
										
										String screenShot = null;
										if(!testForNotSupportScreenshot.contains(test))
											screenShot = mu.getScreenShot(siteName,trgt_host,port_no,test+"_DDD",messy,changedInfo,timeStr);

										if(screenShot != null && screenShot.trim().length() > 0  && !screenShot.equals("-"))
										{
											JSONObject cmDiv = new JSONObject();
											
											cmDiv.put("title",title);
											if(EgInstallInfo.isSuperManager)
											{
												cmDiv.put("screenShot",screenShot+"|"+manager_id);
											}
											else
											{
												cmDiv.put("screenShot",screenShot);
											}
											cmDiv.put("cmTooltip",mappingInfo.getTextDescription("monitor.common.Screenshot"));
											cmDiv.put("iconClass","iconTopology");

											GridinfoJson.put("cmDiv",cmDiv);
										}
									}

									wname = sid + "GRAPH";
									linksMap.put(messy+"compgraphlink", agLink);

									if(isfromSuper)
									{
										GridinfoJson.put("graphUrlMethodSuper","true");	
										GridinfoJson.put("graphUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=graph");	
									}
									else
									{
										GridinfoJson.put("graphUrlMethodSuper","false");
										GridinfoJson.put("graphUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=graph");	
									}
									GridinfoJson.put("graphTooltip",mappingInfo.getTextDescription("monitor.common.Graph"));

									wname = sid + "TRENDGRAPH";
									linksMap.put(messy+"comptrendgraphlink", atgLink);
									wname = sid + "SUMMARYGRAPH";
									linksMap.put(messy+"compsummarygraphlink", asumLink);

									wname = sid + "HISTORY" ;
									linksMap.put(messy+"comphistorylink", histLink);

									if(isfromSuper)
									{
										GridinfoJson.put("historyUrlMethodSuper","true");
										GridinfoJson.put("historyUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=history");	
									}
									else
									{
										GridinfoJson.put("historyUrlMethodSuper","false");
										GridinfoJson.put("historyUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=history");	
									}
									GridinfoJson.put("historyTooltip",mappingInfo.getTextDescription("monitor.text.History"));
									
									if(help_measure!=null && help_measure.equalsIgnoreCase("true"))
									{
										if(isfromSuper)
										{
											GridinfoJson.put("helpUrlMethodSuper","true");
											GridinfoJson.put("helpUrlParam1",response.encodeURL("../eghelp/EgMHelp.jsp?"));	
											GridinfoJson.put("helpUrlParam2",messy);
											GridinfoJson.put("helpUrlParam3",test);
										}
										else
										{
											GridinfoJson.put("historyUrlMethodSuper","false");
											GridinfoJson.put("helpUrlParam1",messy);
											GridinfoJson.put("helpUrlParam2",test);
										}
										GridinfoJson.put("helpTooltip",mappingInfo.getTextDescription("monitor.common.HELP"));
									}

									/*if(isFromMoreInfos){
										if(alternate)
											GridinfoJsonAltArray.add(GridinfoJson);
											GridinfoJsonArray_mobile.add(GridinfoJson_mobile);
										else
											GridinfoJsonArray.add(GridinfoJson);
											GridinfoJsonArray_mobile.add(GridinfoJson_mobile);
										alternate = !alternate;
									}
									else{*/
						
									GridinfoJsonArray.add(GridinfoJson);
									GridinfoJsonArray_mobile.add(GridinfoJson_mobile);

									//}
									
									wname = sid + "FEEDBACK" ;
									linksMap.put(messy+"compfeedbacklink",feedLink);
									session.setAttribute("currentLinksMap", linksMap);
								} //inner for loop is end
								//dispLableJson.put("hiddenValues",hiddenValuesJsonArray);
								//dispLableJson.put("gridInfo",GridinfoJsonArray);
							measures_M.put("measuretitle",dispLable);
							measures_M.put("info",infoStr2);	
							measures_M.put("endhr",mgr_time);
							measures_M.put("mgr_date",temp1);
							measures_M.put("lastmeasuretime",dispDate);
							measures_M.put("listitems",GridinfoJsonArray_mobile);
							measure_mobile.add(measures_M);
							
						
							}
							//dispLableJsonArray.add(dispLableJson);
						}
						//json.put("groupingGrid","true");
						json.put("groupingGrid",groupingGridFlag);
						/*if(isFromMoreInfos)
						{
							JSONObject moreInfosGrid = new JSONObject();
							moreInfosGrid.put("firstGrid",GridinfoJsonArray);
							moreInfosGrid.put("secondGrid",GridinfoJsonAltArray);
							json.put("gridInfo",moreInfosGrid);
						}
						else
						{*/
							json.put("gridInfo",GridinfoJsonArray);
							json_mobile.put("lastmeasuretime",dispDate);
							json_mobile.put("measurements",measure_mobile);

						//}
					}//ended here
					else // Prem
					{
						EgAggregateInfo aggregateInfo = null;
						if(EgInstallInfo.isAggregationSupported() && type.startsWith("Agg_"))
						{
							aggregateInfo = new EgAggregateInfo("manager");
						}
						
						JSONArray GridinfoJsonArray = new JSONArray();
						JSONArray GridinfoJsonArray_mobile = new JSONArray();
						JSONArray measure_mobile=new JSONArray();
						JSONArray hiddenValuesJsonArray = new JSONArray();

						// Premkumar added variables for more infos
						//JSONArray GridinfoJsonAltArray = new JSONArray();
						//boolean alternate = false;

						for(j=0; j<store.size(); j=j+4)
						{
							JSONObject GridinfoJson = new JSONObject();
							JSONObject GridinfoJson_mobile = new JSONObject();
							JSONObject hiddenValuesJson = new JSONObject();
							GridinfoJson_mobile.put("measuretitle","");
							
							measures_M.put("measuretitle","");
							measures_M.put("info",infoStr2);	
							measures_M.put("endhr",mgr_time);
							measures_M.put("mgr_date",temp1);
							measures_M.put("lastmeasuretime",dispDate);
							String measVal="";
							measVal = (String)store.elementAt(j+1);
							if (!allNegative5 
								&& (measVal.equals("-5") || measVal.equals("-5.0000")))
							{
								
								if((j+4)>=store.size())
									if_continue=true;
								continue;
									
							}
							String value = null;
							try
							{
								Double d = new Double(measVal);
								value = ui.getMeasureLookup(String.valueOf(d.intValue()));	
							}
							catch(NumberFormatException nfe)
							{
								System.out.println("EgDispMeasure.jsp : Could not format "+measVal+" into a number");
							}
									
							if (StringUtils.isNull(value))
							{
								value = measVal;
							}
							String messy ="";
							String stateString="";
							messy = MeasureDisplay.getMeasureForColumn(test,(String)store.elementAt(j));
							stateString = (String)store.elementAt(j+2);

							tmpTest = URLDecoder.decode(tmpTest);
						
							if (EgConfigInfo.isBad(stateString))
							{
								badMesList += messy + ",";	
								String priority = (String)ap.getTestMeasurePriority(compName, compType, layerName, tmpTest.replace(' ','+'), messy);
								if (AlarmPriorities.GOOD_STATE.equals(priority))
								{
									/*
									 * Happens when last set of measures being displayed are old and new alarms are not present in the database. Setting to a different colour because the real priority of that measure is not known.
									 */
								}
								else
								{
									stateString = priority;
								}
							}
							if(stateString!=null&&(stateString.equals("HIGH") || stateString.equals("INTERMEDIATE")
										|| stateString.equals("LOW")))
							{
								int indo = measuresForAlarms.indexOf(messy);
								if (indo >= 0 && states != null && states.size()>0)
								{
									stateString = (String)states.get(indo);
								}
							}
							String msmtHostPopUp = request.getParameter("msmt_host");
							if(msmtHostPopUp!=null && msmtHostPopUp.indexOf(",")>-1)
								msmtHostPopUp = msmtHostPopUp.substring(0,msmtHostPopUp.indexOf(","));

							if(stateString!=null && (stateString.equalsIgnoreCase("HIGH") || stateString.equalsIgnoreCase("INTERMEDIATE") || stateString.equalsIgnoreCase("LOW")))
							{						
								String testWithInfo = "";
								testWithInfo = (String)request.getParameter("test");
								if(testWithInfo!=null)
									testWithInfo=com.egurkha.util.StringUtils.replace(testWithInfo,"\"","&#34");

								if(testWithInfo!=null && testWithInfo.indexOf("\\")>-1 && testWithInfo.indexOf("\\\\")<0)
									testWithInfo = com.egurkha.util.StringUtils.replace(testWithInfo, "\\", "\\\\");

								String fType=request.getParameter("faketype");
								fType=(fType==null || fType.trim().length()==0)?"":fType;
							
								GridinfoJson.put("state",stateString);
								GridinfoJson_mobile.put("state",stateString);

								GridinfoJson.put("stateImageUrlParam1",testWithInfo);
								GridinfoJson.put("stateImageUrlParam2",request.getParameter("layer"));
								GridinfoJson.put("stateImageUrlParam3",request.getParameter("host"));
								GridinfoJson.put("stateImageUrlParam4",request.getParameter("comptype"));
								GridinfoJson.put("stateImageUrlParam5",messy);
								GridinfoJson.put("stateImageUrlParam6",infoStr);
								GridinfoJson.put("stateImageUrlParam7",msmtHostPopUp);
								GridinfoJson.put("stateImageUrlParam8",fType);

								hiddenValuesJson.put("measure",messy);
								hiddenValuesJson.put("infoStr",infoStr);
								hiddenValuesJson.put("test",request.getParameter("test"));
								hiddenValuesJson.put("layer",request.getParameter("layer"));
								hiddenValuesJson.put("mHost",request.getParameter("msmt_host"));
								hiddenValuesJson.put("faketype",request.getParameter("faketype"));
								hiddenValuesJsonArray.add(hiddenValuesJson);
							}
							else
							{
								GridinfoJson.put("state",stateString);
								GridinfoJson_mobile.put("state",stateString);
							}
							String measValue="";
							if(stateString!=null && (stateString.equalsIgnoreCase("HIGH") || stateString.equalsIgnoreCase("INTERMEDIATE") || stateString.equalsIgnoreCase("LOW")))
							{
								String testWithInfo = "";
								testWithInfo = (String)request.getParameter("test");
								if(testWithInfo!=null)
									testWithInfo=com.egurkha.util.StringUtils.replace(testWithInfo,"\"","&#34");

								if(testWithInfo!=null && testWithInfo.indexOf("\\")>-1 && testWithInfo.indexOf("\\\\")<0)
									testWithInfo = com.egurkha.util.StringUtils.replace(testWithInfo, "\\", "\\\\");

								GridinfoJson.put("urlParam1",testWithInfo);
								GridinfoJson.put("urlParam2",request.getParameter("layer"));
								GridinfoJson.put("urlParam3",request.getParameter("host"));
								GridinfoJson.put("urlParam4",request.getParameter("comptype"));
								GridinfoJson.put("urlParam5",messy);
								GridinfoJson.put("urlParam6",infoStr);
								GridinfoJson.put("urlParam7",msmtHostPopUp);
								GridinfoJson.put("urlParam8",request.getParameter("faketype"));	
								
								boolean batt_status=false;	
								IniFile egUi = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
					
								String testMeas_Name=test+":"+messy;
								if(test.endsWith("_ag") || test.endsWith("_agx"))
								{
									String testMeas_NameTemp=aggregateInfo.getValue("COLUMN_NAME_MAPPING",testMeas_Name);
									if(testMeas_NameTemp != null && testMeas_NameTemp.trim().length()>0)
									{
										testMeas_Name = testMeas_NameTemp.trim();
									}
								}
								
								String meas_Unit=(String)mu.doUnitConversion(test,messy,value);
								String org_unit= meas_Unit.substring(meas_Unit.indexOf("$")+1);
								measValue= meas_Unit.substring(0,meas_Unit.indexOf("$"));

								String convert_Days=dashboardConfigIni.getValue("Convert_To_Days",testMeas_Name);
								if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
								{
									String dateDiff="";
									String currentValue=measValue;	
									try
									{
										if(currentValue!=null && !currentValue.trim().equals(""))
										{
											long minutes=0;
											float seconds=0.0f;
											if(currentValue!=null && currentValue.indexOf(".")>0)
											{
												minutes=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
												if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
												{
													seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf("."),currentValue.indexOf(".")+3));
												}
												else
												{
													seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf(".")));
												}
											}
											else
											{
												minutes=Long.parseLong(currentValue);
											}
											long valueInSecond=(minutes*60)+(long)(seconds*60);
											dateDiff=egDashboard.getDateDifferenceStringforUptime(valueInSecond);
										}			
										measValue=dateDiff;
									}
									catch(Exception e)
									{
										measValue=measValue;
									}
								}


								String iniVar=test+":"+messy+":"+measValue;
								String iniValue=egUi.getValue("Measure_value_display",iniVar);
								if((test.endsWith("_ag") || test.endsWith("_agx")) && (iniValue == null || iniValue.trim().length()==0))
								{								
									String functionUsed = aggregateInfo.getValue("AGGREGATE_FUNCTION",test+":"+messy.toUpperCase());
									functionUsed = functionUsed.substring(functionUsed.indexOf(":")+1,functionUsed.lastIndexOf(":"));
									if(functionUsed != null && functionUsed.equalsIgnoreCase("multi_condition"))
									{
										if(measValue.equals("0")) {
											iniValue="Normal";
										}
										else if(measValue.equals("1")) {
											iniValue="Minor";
										}
										else if(measValue.equals("2")) {
											iniValue="Major";
										}
										else if(measValue.equals("3")) {
											iniValue="Critical";
										}
									}
								}
								String measureUnit = "";
								if(iniValue!=null && iniValue.length() > 0)
								{
									batt_status=true;
									measValue=iniValue;
								}else if (!value.equalsIgnoreCase("Unknown") && !value.equalsIgnoreCase("Unlimited") && !value.equalsIgnoreCase("Not Applicable") && !value.equalsIgnoreCase("Not Supported") && !value.equalsIgnoreCase("Not Available"))
								{
									measureUnit = " ("+org_unit+")";
									//GridinfoJson.put("measureUnit",TableData.getUnitForMeasure(test,messy));
									GridinfoJson_mobile.put("measureUnit",org_unit);
								}

								String mappingString = test+":"+messy;
								if(isCommonDDTest)
								{
									mappingString = backupTest+":"+messy;
									if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
									else
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+measureUnit);
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+measureUnit);
										GridinfoJson_mobile.put("internalMeasure",messy);
									}
									
								}
								else
								{
									if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy));
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy));
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
									else
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy)+measureUnit);
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy)+measureUnit);
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
								}
										//Alagu added for display the text value for certain measures like powered on.
									
							}
							else
							{
								IniFile egUi = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
								
								boolean batt_status=false;	
							
								String testMeas_Name=test+":"+messy;
								if(test.endsWith("_ag") || test.endsWith("_agx"))
								{
									String testMeas_NameTemp=aggregateInfo.getValue("COLUMN_NAME_MAPPING",testMeas_Name);
									if(testMeas_NameTemp != null && testMeas_NameTemp.trim().length()>0)
									{
										testMeas_Name = testMeas_NameTemp.trim();
									}
								}
								
								String meas_Unit=(String)mu.doUnitConversion(test,messy,value);
								String org_unit= meas_Unit.substring(meas_Unit.indexOf("$")+1);
								measValue= meas_Unit.substring(0,meas_Unit.indexOf("$"));

								String convert_Days=dashboardConfigIni.getValue("Convert_To_Days",testMeas_Name);
								if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
								{
									String dateDiff="";
									String currentValue=measValue;	
									try
									{
										if(currentValue!=null && !currentValue.trim().equals(""))
										{
											long minutes=0;
											float seconds=0.0f;
											if(currentValue!=null && currentValue.indexOf(".")>0)
											{
												minutes=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
												if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
												{
													seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf("."),currentValue.indexOf(".")+3));
												}
												else
												{
													seconds=Float.parseFloat(currentValue.substring(currentValue.indexOf(".")));
												}
											}
											else
											{
												minutes=Long.parseLong(currentValue);
											}
											long valueInSecond=(minutes*60)+(long)(seconds*60);
											dateDiff=egDashboard.getDateDifferenceStringforUptime(valueInSecond);
										}			
										measValue=dateDiff;
									}
									catch(Exception e)
									{
										measValue=measValue;
									}
								}

								String iniVar=test+":"+messy+":"+measValue;
								String iniValue=egUi.getValue("Measure_value_display",iniVar);
								if((test.endsWith("_ag") || test.endsWith("_agx")) && (iniValue == null || iniValue.trim().length()==0))
								{								
									String functionUsed = aggregateInfo.getValue("AGGREGATE_FUNCTION",test+":"+messy.toUpperCase());
									functionUsed = functionUsed.substring(functionUsed.indexOf(":")+1,functionUsed.lastIndexOf(":"));
									if(functionUsed != null && functionUsed.equalsIgnoreCase("multi_condition"))
									{
										if(measValue.equals("0")) {
											iniValue="Normal";
										}
										else if(measValue.equals("1")) {
											iniValue="Minor";
										}
										else if(measValue.equals("2")) {
											iniValue="Major";
										}
										else if(measValue.equals("3")) {
											iniValue="Critical";
										}
									}
								}
								String measUnit = "";
								if(iniValue!=null && iniValue.length() >0)
								{
									batt_status=true;
									measValue=iniValue;
								}else if (!value.equalsIgnoreCase("Unknown") && !value.equalsIgnoreCase("Unlimited") && !value.equalsIgnoreCase("Not Applicable") && !value.equalsIgnoreCase("Not Supported") && !value.equalsIgnoreCase("Not Available"))
								{
									measUnit = " ("+org_unit+")";
									//GridinfoJson.put("measureUnit",TableData.getUnitForMeasure(test,messy));
									GridinfoJson_mobile.put("measureUnit",org_unit);
								}							
								String mappingString = test+":"+messy;
								if(isCommonDDTest)
								{
									mappingString = backupTest+":"+messy;
									if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy));
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
									else
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+measUnit);
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(backupTest,messy)+measUnit);
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
								}
								else
								{
									if(convert_Days!=null && !convert_Days.trim().equals("") && (convert_Days.equalsIgnoreCase("yes") || convert_Days.equalsIgnoreCase("true")))
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy));
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy));
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
									else
									{
										GridinfoJson.put("measureText",mappingInfo.getMeasureDescription(test,messy)+measUnit);
										GridinfoJson_mobile.put("measureText",mappingInfo.getMeasureDescription(test,messy)+measUnit);
										GridinfoJson_mobile.put("internalMeasure",messy);

									}
								}
									//Alagu added for display the text value for certain measures like powered on.
								
							}
							tmpInfo =(String)store.elementAt(j+3);
							tmpInfo = tmpInfo.replace('+','*');
							histLink = historyLink + "&measure=" + messy+ "&msmt_host=" + com.eg.EgURLEncoder.encode(infoStr,"UTF-8") ;
							feedLink = feedbackLink +"&info="+com.eg.EgURLEncoder.encode(infoStrForFB,"UTF-8")+ "&measure="+messy+ "&msmttime="+time +"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8");
							//Commented because of unique info lost problem during unknown state
							agLink = gLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)store.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
							atgLink = tgLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)store.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
							asumLink = sumLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)store.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;

							String aggregateLink=aggLink + "&info="+com.eg.EgURLEncoder.encode(infoStr2,"UTF-8")+ "&gtype=1&measure="+(String)store.elementAt(j)+ "&msmt_host="+	com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString;
							String tempInfo = infoStr2;
							tempInfo = tempInfo.equals("*")?"NONE":tempInfo;
							String tempinfo = tempInfo;
							if(tempinfo!=null && tempinfo.indexOf("#")>-1)
							{
								tempinfo=com.egurkha.util.StringUtils.replace(tempinfo,"#","|hash|");
							}
							String adlink = dLink + "&info="+com.eg.EgURLEncoder.encode(tempInfo,"UTF-8")+"&msmt_host="+com.eg.EgURLEncoder.encode(infoStr,"UTF-8")+ "&from=0&measure="+messy+ "&flag=1&firsttime=true";
							String popupLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+request.getParameter("comptype")+"&site="+siteName+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNumber+"&info="+EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString+"&messy="+messy+"&isVM="+isVM;
							
							

							linksMap.put(messy+"aggregateLink",aggregateLink);

							if(MeasureDisplay.formatValue(value)!=null && (MeasureDisplay.formatValue(value)).equalsIgnoreCase("Unknown"))
							{
								GridinfoJson.put("value",mappingInfo.getTextDescription("monitor.common.Unknown"));
								GridinfoJson_mobile.put("value",mappingInfo.getTextDescription("monitor.common.Unknown"));
							}
							else
							{
								if(isfromSuper)
								{
									GridinfoJson.put("valueUrlMethodSuper",true);
									GridinfoJson.put("valueUrl",popupLink+"&clicked=graph");
								}
								else
								{
									GridinfoJson.put("valueUrlMethodSuper",false);
									GridinfoJson.put("valueUrl",popupLink+"&clicked=graph");
								}
								 GridinfoJson.put("value",measValue);
								 GridinfoJson_mobile.put("value",measValue);
							}
							if(test!=null && test.endsWith("_rx"))
							{
								wname = sid + "CMX";
								String cmxPopupUrl = response.encodeURL("../monitor/compositeMeasureInfo.jsp?")+"type="+request.getParameter("comptype")+"&site="+siteName+"&host="+hostName+"&port="+portNumber+"&info="+EgURLEncoder.encode(info,"UTF-8")+"&state="+stateString+"&measure="+messy+"&layer="+layerName+"&test="+test+"&msmttime="+time+"&measure_value="+measValue;
								JSONObject cmxDiv = new JSONObject();
								cmxDiv.put("cmxUrl",cmxPopupUrl);
								cmxDiv.put("cmxUrlParam2",wname);
								cmxDiv.put("cmxTooltip",mappingInfo.getTextDescription("monitor.common.Rating"));
								cmxDiv.put("iconClass","sym_composite");
								GridinfoJson.put("cmxDiv",cmxDiv);
							}
							if(EgInstallInfo.isAggregationSupported() && type.startsWith("Agg_") && test!=null && !test.endsWith("_rx"))
							{
								JSONObject aggregateDiv = new JSONObject();
								String p_info = "Nil";
								if(!infoStr2.trim().equals("*"))
								{
									p_info = infoStr2.substring(1);
								}
								p_info=com.egurkha.util.StringUtils.encodeSecurityChar(p_info);

								int startIndex = time.indexOf("*");
								String testStatusMsrTime = time.substring(0,startIndex)+" "+time.substring(startIndex+1);
								String measureUrl = "/final/monitor/aggMeasureInfo.jsp?site="+EgURLEncoder.encode(siteName,"UTF-8")+"&stype="+EgURLEncoder.encode(type,"UTF-8")+"&sname="+EgURLEncoder.encode(hostName,"UTF-8")+"&sport=NULL&tname="+EgURLEncoder.encode(test,"UTF-8")+"&tstate="+tState+"&msmt_host="+EgURLEncoder.encode(infoStr,"UTF-8")+"&msmttime="+testStatusMsrTime+"&layer="+EgURLEncoder.encode(request.getParameter("layer"),"UTF-8")+"&measurename="+EgURLEncoder.encode(messy,"UTF-8")+"&sinfo="+EgURLEncoder.encode(p_info,"UTF-8")+"&measure_value="+measValue;

								aggregateDiv.put("aggregateUrl",measureUrl);
								aggregateDiv.put("tooltip",mappingInfo.getTextDescription("monitor.common.AGGREGATE"));
								aggregateDiv.put("iconClass","iconPlus");
								GridinfoJson.put("aggregateDiv",aggregateDiv);
							}
							
							boolean isScreenShotEnabled = (formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && !measValue.equals("100"));

							//if(isScreenShotEnabled && test.equalsIgnoreCase("CitraTest") && (!isFaliureScreenshotRequired))
								//isScreenShotEnabled = false;

							String needed_infoStr = tempInfo;
							boolean isForGenericLogonSimTest = false;
							boolean isForSuccessScreenshot = false;
							if(isScreenShotEnabled && test.equalsIgnoreCase("GenericLogonSimTest"))
							{
								ddEnabled = true;	
								isForGenericLogonSimTest = true;
								needed_infoStr = tempInfo.substring(0,tempInfo.indexOf(":")+1)+"Total";
							}
							
							if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("100") && isSucessSSTest && isSuccessScreenshotRequired && !isScreenShotEnabled && ((testForSucessSS.contains(test) && needed_infoStr.endsWith("Total")) || (testForSucessSS.contains(test) && test_flag && check_List.contains(messy))))
							{
								isScreenShotEnabled = true;
								isForSuccessScreenshot = true;
							}
							
							if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && (measValue.equals("100") || measValue.equals("0")) && isSucessSSTest && testForSucessSS.contains(test) && tempInfo.endsWith("Total") && !isSuccessScreenshotRequired && isScreenShotEnabled)
								isScreenShotEnabled = false;
							else if(formatInfo.isSSHandledTest(test) && messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("0") && isSucessSSTest && testForSucessSS.contains(test) && tempInfo.endsWith("Total") && isSuccessScreenshotRequired && isScreenShotEnabled)
								isScreenShotEnabled = false;

							if(ddEnabled || type.startsWith("Agg_"))
							{
								if(measures.contains(messy))
								{
									wname = sid + "DIAGNOSIS";
									boolean showDDIcon = false;
									if (type.startsWith("Agg_") || ui.getVirtualServerTypes().contains(compType)||!isAgentlessServer || specsInfo.isTestExternal(test))
									{
										//code starts to check DD data available for this test and info
										String commTestDD = trans. getStrValue("COMMON_DDTEST_MAPPING", test+":"+messy);
										String temp_test=test;
										String temp_messy=messy;
										if(commTestDD!=null && commTestDD.length() > 0)
										{
											isCommonDDTest = true;
											backupTest = test;
											temp_test = commTestDD.substring(0,commTestDD.indexOf(":"));
											temp_messy = commTestDD.substring(commTestDD.indexOf(":")+1);
										}
										if(needed_infoStr!=null && needed_infoStr.equals("NONE"))
											needed_infoStr="+";
										if(needed_infoStr!=null)
										{
											int indexInfo = needed_infoStr.indexOf("*");
											if(indexInfo  >  -1)
											{
												StringBuffer sb = new StringBuffer(needed_infoStr);
												sb.setCharAt(indexInfo, '+');
												needed_infoStr = sb.toString();
											}
										}
										String tempInfoForDD=needed_infoStr;
										
										boolean isPortRelForTest = specsInfo.isPortRelevantForTest(temp_test);
					
										if(!isPortRelForTest && needed_infoStr!=null && needed_infoStr.trim().length()>0 && needed_infoStr .indexOf("+")>-1 && !needed_infoStr.startsWith("+"))
										{
											tempInfoForDD=needed_infoStr.substring(needed_infoStr .indexOf("+"));
										}
							
										if( siteName==null || siteName.length() == 0 || siteName.equals("null") || siteName!=null)
											siteName="NULL";

										String s_info_to_db = null;
										String ddWithoutInfo = formatIniFile.getValue("Tests_For_DDWithoutInfos", temp_test + ":" + temp_messy);
										boolean lookforActualDes = false;

										if(ddWithoutInfo!=null && ddWithoutInfo.equalsIgnoreCase("yes"))
										{
											lookforActualDes = true;
											s_info_to_db = "+";
										}
										else
										{
											s_info_to_db = tempInfoForDD;
										}
										
										String ddWithallInfo = formatIniFile.getValue("Tests_For_DDAllInfos", temp_test + ":" + s_info_to_db);
										if(ddWithallInfo != null && ddWithallInfo.equalsIgnoreCase("yes"))
										{
											lookforActualDes = true;
											s_info_to_db = "";
										}
										
										//showDDIcon = dd.ShowDDData(siteName,hostName,temp_test,temp_messy,s_info_to_db,infoStr);
										showDDIcon = isDDDPresents(show_dd_hash,temp_test,temp_messy,s_info_to_db);
										if(lookforActualDes && !showDDIcon)
										{
											//showDDIcon = dd.ShowDDData(siteName,hostName,temp_test,temp_messy,tempInfoForDD,infoStr);
											showDDIcon = isDDDPresents(show_dd_hash,temp_test,temp_messy,tempInfoForDD);
										}
										
										if(temp_test.equalsIgnoreCase("Citratest") && measValue.equals("100") && showDDIcon)
											showDDIcon = false;
										
										linksMap.put(messy+"compddlink", adlink);

										if(type.startsWith("Agg_") || showDDIcon)
										{
											popupLink = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+EgURLEncoder.encode(request.getParameter("comptype"),"UTF-8")+"&site="+siteName+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNumber+"&info="+EgURLEncoder.encode(infoStr,"UTF-8")+"&state="+stateString+"&messy="+messy+"&isVM="+isVM;
											if(isfromSuper)
											{
												GridinfoJson.put("ddUrlMethodSuper",true);
												GridinfoJson.put("ddUrlParam1",popupLink+"&isForSuccessScreenshot="+isForSuccessScreenshot+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=dd");
												GridinfoJson.put("ddUrlParam2",wname);
											}
											else
											{
												GridinfoJson.put("ddUrlMethodSuper",false);
												GridinfoJson.put("ddUrlParam1",popupLink+"&isForSuccessScreenshot="+isForSuccessScreenshot+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=dd");
												GridinfoJson.put("ddUrlParam2",wname);
											}
											GridinfoJson.put("ddIconExist",true);
											GridinfoJson_mobile.put("ddIconExist",true);
											GridinfoJson.put("ddTooltip",mappingInfo.getTextDescription("monitor.common.Diagnosis"));
			
											if(!isForGenericLogonSimTest)
												popupLink +="&show=dd"; 
										}
										else
											GridinfoJson_mobile.put("ddIconExist",false);
									}
									else
										GridinfoJson_mobile.put("ddIconExist",false);
								}
								else
									GridinfoJson_mobile.put("ddIconExist",false);
							}						
							if(isScreenShotEnabled)
							{
								String changedInfo = needed_infoStr;
								String title ="Failure Screenshot";
								if(isSucessSSTest && testForSucessSS.contains(test))
								{
									if(test.equalsIgnoreCase("GenericLogonSimTest"))
										changedInfo = needed_infoStr.substring(0,needed_infoStr.indexOf(":")+1)+"Total";
									
									 if(messy.toLowerCase().indexOf("availability") != -1 && measValue.equals("100") && stateString.equalsIgnoreCase("Good"))
										title = "Success Screenshot";
									 else
										title = "Failure Screenshot";
								}
								String trgt_host = hostName;
								String port_no = "NULL";
								if(hostName.indexOf(":") != -1)
								{
									trgt_host = hostName.substring(0,hostName.indexOf(":"));
									port_no = hostName.substring(hostName.indexOf(":")+1);
								}
								
								String screenShot = null;
								if(!testForNotSupportScreenshot.contains(test))
									screenShot = mu.getScreenShot(siteName,trgt_host,port_no,test+"_DDD",messy,changedInfo,timeStr);
			
								if(screenShot != null && screenShot.trim().length() > 0  && !screenShot.equals("-"))
								{
									JSONObject cmDiv = new JSONObject();

									cmDiv.put("title",title);
									if(EgInstallInfo.isSuperManager)
									{
										cmDiv.put("screenShot",screenShot+"|"+manager_id);
									}
									else
									{
										cmDiv.put("screenShot",screenShot);
									}
									cmDiv.put("cmTooltip",mappingInfo.getTextDescription("monitor.common.Screenshot"));
									cmDiv.put("iconClass","iconTopology");

									GridinfoJson.put("cmDiv",cmDiv);
								}
							}
							wname = sid + "GRAPH";
							linksMap.put(messy+"compgraphlink", agLink);
							if(isfromSuper)
							{
								GridinfoJson.put("graphUrlMethodSuper",true);	
								GridinfoJson.put("graphUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=graph");	
							}
							else
							{
								GridinfoJson.put("graphUrlMethodSuper",false);
								GridinfoJson.put("graphUrlParam",popupLink+"&isForSuccessScreenshot="+isForSuccessScreenshot+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=graph");
							}
							GridinfoJson.put("graphTooltip",mappingInfo.getTextDescription("monitor.common.Graph"));
			
							wname = sid + "TRENDGRAPH";
							linksMap.put(messy+"comptrendgraphlink", atgLink);
							wname = sid + "SUMMARYGRAPH";
							linksMap.put(messy+"compsummarygraphlink", asumLink);

							wname = sid + "HISTORY" ;
							linksMap.put(messy+"comphistorylink", histLink);
							if(isfromSuper)
							{
								GridinfoJson.put("historyUrlMethodSuper",true);
								GridinfoJson.put("historyUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=history");
							}
							else
							{
								GridinfoJson.put("historyUrlMethodSuper",false);
								GridinfoJson.put("historyUrlParam",popupLink+"&isScreenShotEnabled="+isScreenShotEnabled+"&clicked=history");
							}
							GridinfoJson.put("historyTooltip",mappingInfo.getTextDescription("monitor.text.History"));
			
							if(help_measure!=null && help_measure.equalsIgnoreCase("true"))
							{
								if(isfromSuper)
								{
									GridinfoJson.put("helpUrlMethodSuper",true);
									GridinfoJson.put("helpUrlParam1",response.encodeURL("../eghelp/EgMHelp.jsp?"));	
									GridinfoJson.put("helpUrlParam2",messy);
									GridinfoJson.put("helpUrlParam3",test);
								}
								else
								{
									GridinfoJson.put("historyUrlMethodSuper",false);
									GridinfoJson.put("helpUrlParam1",messy);
									GridinfoJson.put("helpUrlParam2",test);
								}
								GridinfoJson.put("helpTooltip",mappingInfo.getTextDescription("monitor.common.HELP"));
							}
							wname = sid + "FEEDBACK" ;
							linksMap.put(messy+"compfeedbacklink", feedLink);
							session.setAttribute("currentLinksMap", linksMap);

							// Premkumar for more infos measure page change
							/*if(isFromMoreInfos){
								if(alternate)
									GridinfoJsonAltArray.add(GridinfoJson);
								else
									GridinfoJsonArray.add(GridinfoJson);
									GridinfoJsonArray_mobile.add(GridinfoJson_mobile);
								alternate = !alternate;
							}
							else{*/
								GridinfoJsonArray.add(GridinfoJson);
								GridinfoJsonArray_mobile.add(GridinfoJson_mobile);
							//}

							// Premkumar change ends
						}
						measure_mobile.add(dispLable);
						
						json.put("hiddenValues",hiddenValuesJsonArray);
						/*if(isFromMoreInfos)
						{
							JSONObject moreInfosGrid = new JSONObject();
							moreInfosGrid.put("firstGrid",GridinfoJsonArray);
							moreInfosGrid.put("secondGrid",GridinfoJsonAltArray);
							json.put("gridInfo",moreInfosGrid);
						}
						else
						{*/
							measures_M.put("measuretitle",measure_mobile);	
							measures_M.put("info",infoStr2);	
							measures_M.put("endhr",mgr_time);
							measures_M.put("mgr_date",temp1);
							measures_M.put("lastmeasuretime",dispDate);
							json.put("gridInfo",GridinfoJsonArray);
							measures_M.put("listitems",GridinfoJsonArray_mobile);
							json_mobile.put("lastmeasuretime",dispDate);
							json_mobile.put("measurements",measures_M);
					}
				}
				else if(isSkipData)
				{
					screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
					errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel.Please select a test to see the measurements"));
					json.put("errormsg",errormsg);
				}
			}//end of if(rs.next())
			else
			{
				JSONArray unknownInfoJsonArray = new JSONArray();
				testStatusInfoURL += "&mespresent=no"+"&msmttime="+"&mstate=null";
					
				screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));

				sName = hostName + ":" + portNumber;
				if(compType.equals("Oracle_server"))
				{
					if(infoStr2 != null && !infoStr2.equals(""))
					{
						sName = sName + ":" + infoStr2.substring(0,infoStr2.indexOf("+"));
					}
				}
				boolean isTestExternal = specsInfo.isTestExternal(test,compType);
				if(isTestExternal)
				{
					testType = "External";
				}
				else
				{
					EgAgentInfo agentInfo = new EgAgentInfo("manager");
					boolean isAgentlessServer = agentInfo.isAgentlessServer(hostName,compType);
					if(isAgentlessServer)
						testType = "Remote";
					else
					testType = "Internal";
				}
				boolean isPortRelevantForTest = specsInfo.isPortRelevantForTest(test);
				if(!isPortRelevantForTest)
				{
					//New code
					//to display sun08.chn.egurkha.com
					//instead of sun08.chn.egurkha.com:1521:egurkha
					if(compType.equals("Oracle_server"))
					{
						sName = sName.substring(0,sName.indexOf(":"));
					}
					else
					{
						sName = sName.substring(0,sName.lastIndexOf(":"));
					}
				}
				boolean isTestDisabled = teststatus.isTestDisabled(compType, sName, test);
				if(!isTestDisabled)
				{
					testFrequency = teststatus.frequencyOfTest(compType, sName, test);
				}
				else
				{
					testFrequency = "Not Applicable";
				}

				VmDashboardHelper vmDashHelper=new VmDashboardHelper(user);
				String measTimeWithInfo=vmDashHelper.getMeasurementTimeForComponent(test,sName,msmtHost);
				String measTime="";
				String descriptor="";
				String measHost="";
				if(measTimeWithInfo!=null && measTimeWithInfo.indexOf("#")>-1)
				{
					measTime = measTimeWithInfo.substring(0,measTimeWithInfo.indexOf("#"));
					measHost = measTimeWithInfo.substring(measTimeWithInfo.indexOf("#")+1,measTimeWithInfo.lastIndexOf("#"));
					descriptor= measTimeWithInfo.substring(measTimeWithInfo.lastIndexOf("#")+1);
					int desc = descriptor.indexOf("+");
					if(descriptor!=null && descriptor.trim().length()>0 && !descriptor.startsWith("+") && desc>0)
					{
						String first_in=descriptor.substring(0,desc);
						String sec_in=descriptor.substring(desc+1);
						descriptor=first_in+"*"+sec_in;
					}
					else
					{
						descriptor="*"+(descriptor.substring(desc+1));
					}
				}
				measTime = DateUtil.changeDateFormat(measTime,"yyyy-MM-dd HH:mm:ss","MM/dd/yyyy HH:mm:ss");
				measTime=measTime.replace(' ','*');
				descriptor=descriptor.trim();
				EgMonRemoteScriptingBean monBean=new EgMonRemoteScriptingBean(sessionUserId);
				String meas_name=monBean.getMeasuresForTest(test);
				String measName="";
				String tempMeasName=meas_name;
				boolean showDdIcon = false;
				
				ArrayList al =  com.egurkha.util.StringUtils.egTokenizer(tempMeasName, "\t",false,false,true);//param 3-->includeEmpty,4-->unique,5-->trim
				String info_name=descriptor;
				String mea="";
				for(int i=0; i<al.size(); i++)
				{
					mea=(String)al.get(i);
					
					
					String ddWithoutInfo = formatIniFile.getValue("Tests_For_DDWithoutInfos", test + ":" + mea);
					boolean lookforActualDes = false;

					if(ddWithoutInfo!=null && ddWithoutInfo.equalsIgnoreCase("yes"))
					{
						lookforActualDes = true;
						info_name = "+";
					}

					String ddWithallInfo = formatIniFile.getValue("Tests_For_DDAllInfos", test + ":" + descriptor);
					if(ddWithallInfo != null && ddWithallInfo.equalsIgnoreCase("yes"))
					{
						lookforActualDes = true;
						info_name = "";
					}

					String mesName = MeasureDisplay.getMeasureForColumn(test,mea);
					if(mesName==null || mesName.trim().length()==0)
					{
						mesName=mea;
					}
					showDdIcon = dd.ShowDDData(siteName,hostName,test,mesName,info_name,measHost);
					if(showDdIcon)
						break;
				}
				measName = MeasureDisplay.getColumnForMeasure(test,mea);

				String feedbackLink1="../monitor/dispComponentFeedback.jsp?site=" + siteName + "&trgthost=" + com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test=" + test + "&comptype=" +com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
				
				String feedLink1 = feedbackLink1+"&info="+com.eg.EgURLEncoder.encode(descriptor,"UTF-8")+"&measure="+measName+ "&msmttime="+measTime +"&msmt_host="+com.eg.EgURLEncoder.encode(measHost,"UTF-8");

				String ct_val=request.getParameter("comptype");
				
				
				String popupLink1 = response.encodeURL("../monitor/componentMeasureTabSet.jsp?")+"type="+request.getParameter("comptype")+"&site="+siteName+"&host="+hostName+"&port="+portNumber+"&info="+measHost+"&state="+tState+"&messy="+measName+"&clicked=graph";

				String gLink1 = "";
				if(ct_val!=null && ct_val.trim().length()>0)
				{
					gLink1 = "../monitor/dispComponentGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" +test + "&comptype="+com.eg.EgURLEncoder.encode(ct_val,"UTF-8")+"&isVM="+isVM;
				}
				else
				{
					gLink1 = "../monitor/dispComponentGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" +test + "&comptype=&isVM="+isVM;
				}
				

			
				String agLink1 = gLink1 + "&info="+com.eg.EgURLEncoder.encode(descriptor,"UTF-8")+ "&gtype=1&measure="+measName+ "&msmt_host="+	com.eg.EgURLEncoder.encode(measHost,"UTF-8")+"&state="+tState;

				
				String tgLink1 ="../monitor/dispComponentTrendGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
				
				String atgLink1 = tgLink1 + "&info="+com.eg.EgURLEncoder.encode(descriptor,"UTF-8")+ "&gtype=1&measure="+measName+ "&msmt_host="+	com.eg.EgURLEncoder.encode(measHost,"UTF-8")+"&state="+tState;
				
				String historyLink1="../monitor/dispComponentHistory.jsp?site=" + siteName + "&info=" + com.eg.EgURLEncoder.encode(descriptor.trim(),"UTF-8") + "&test=" + test + "&component=" +histTempComp;

				String histLink1 = historyLink1 + "&measure=" + measName+ "&msmt_host=" + com.eg.EgURLEncoder.encode(measHost,"UTF-8") ;

				String	sumLink1 ="../monitor/dispComponentSummaryGraphs.jsp?site="	+EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
				
				String asumLink1 = sumLink1 + "&info="+com.eg.EgURLEncoder.encode(descriptor,"UTF-8")+ "&gtype=1&measure="+measName+ "&msmt_host="+	com.eg.EgURLEncoder.encode(measHost,"UTF-8")+"&state="+tState;
				
				String dLink1 = "../monitor/EgDiagnosis.jsp?site=" + EgURLEncoder.encode(siteName,"UTF-8") + "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8") +"&port=" + portNumber + "&test=" + test;

				String adlink1 = dLink1 + "&info="+com.eg.EgURLEncoder.encode(descriptor,"UTF-8")+"&msmt_host="+com.eg.EgURLEncoder.encode(measHost,"UTF-8")+ "&from=0&measure="+measName+ "&flag=1&firsttime=true";

				String  aggLink1="../monitor/dispAggComponentGraphs.jsp?site=" +EgURLEncoder.encode(siteName,"UTF-8")+ "&host=" +com.eg.EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNumber + "&layer=" +com.eg.EgURLEncoder.encode(layerName,"UTF-8")+ "&test=" + test + "&comptype="+com.eg.EgURLEncoder.encode(((request.getParameter("comptype")==null)?"":request.getParameter("comptype")),"UTF-8");
		
				linksMap.put(measName+"compgraphlink", agLink1);

				linksMap.put(measName+"compfeedbacklink", feedLink1);

				linksMap.put(measName+"compsummarygraphlink", asumLink1);
				linksMap.put(measName+"comptrendgraphlink", atgLink1);
				linksMap.put(measName+"comphistorylink", histLink1);
				boolean ddEnabled1 = EgMemInfo.ddEnabled;
				if(showDdIcon && ddEnabled1)
				{
					linksMap.put(measName+"compddlink", adlink1);
				}
				session.setAttribute("currentLinksMap", linksMap);
				if(tState != null && tState.equals(AlarmPriorities.UNKNOWN_STATE) && mesPresent.equals("no"))
				{
					isTestConfigured = teststatus.isTestConfigured(compType, sName, test);
					if(isTestConfigured)
					{
						if(measTime!=null && measTime.trim().length()>0 )
						{
							testStatusInfo.addElement("<td><a href='javascript:void(0)' onClick=javascript:showHistoryTab('"+popupLink1+"')><div style='float:left;width:20px;height:20px' class='iconBarChart'></div></a></td>");
						}
						else
						{
							testStatusInfo.addElement("<table id=\"eg_12\" border='0'><tr><td><div class='iconAdmin'></div></td><td><b>The agent has not reported measures yet&#46</b></td></tr></table>");
							testStatusInfo.addElement("<div style='display:block;text-align:justify' ><p style='font-weight:bold;font-size:12px;'>Possible reasons:</p><p style='font-size:11px'>The agent might not be running on the system or it might have just been started.If the agent has just been started, the state of the test will soon turn to Normal/Critical/Major/Minor&#46If the agent has been running for a long time, either the agent is unable to connect to the manager or the agent is not reporting any measures as the component being monitored might not be running&#46</p></div>");
							//testStatusInfo.addElement("<span style='display:block;text-align:justify' ><b>Possible reasons:</b>");
							//testStatusInfo.addElement("The agent might not be running on the system or it might have just been started&#46");
							//testStatusInfo.addElement("If the agent has just been started, the state of the test will soon turn to Normal/Critical/Major/Minor&#46");
							//testStatusInfo.addElement("If the agent has been running for a long time, either the agent is unable to connect to the manager or the agent is not reporting any measures as the component being monitored might not be running&#46");
						}
					}
					else
					{
						testStatusInfo.addElement("<table id=\"eg_12\" border='0'><tr><td><div class='iconAdmin'></div></td><td><b>The agent is not reporting measures to the manager&#46</b>");
						testStatusInfo.addElement("<b>The test has not been configured&#46</b></td></tr></table>");
					}
				}

				if(tState != null && tState.equals(AlarmPriorities.GOOD_STATE) && mesPresent.equals("no"))
				{
					isInfoAvailableForMeasure = teststatus.isInfoAvailableForMeasure(test, hostName, siteName, portNumber);
					if(isTestDisabled)
					{
						testStatusInfo.addElement("<b>The test has been disabled for the component&#46</b>");
					}
					else if(isInfoAvailableForMeasure)
					{
						testStatusInfo.addElement("The eG manager has received data for this test and is in the process of indexing the data&#46 Please wait for a short while for the process to complete&#46");
					}
					else
					{
						if(test.equals("WebSiteTransactionTest"))
						{
							if((siteName != null) && !siteName.equals(""))
							{
								trans4Site = teststatus.trans4Site(siteName);
								if(trans4Site.size() == 0)
								{
									testStatusInfo.addElement("<table id=\"eg_12\" border='0'><tr><td><div class='iconAdmin'></div></td><td><b>The agent has not reported measures yet&#46</b></td></tr></table>");
									testStatusInfo.addElement("<span style='display:block;text-align:justify'><b>Possible reasons:</b>");
									testStatusInfo.addElement("Transactions have not been configured for the site&#46</span>");
								}
								else
								{
									testStatusInfo.addElement("<table id=\"eg_12\" border='0'><tr><td><div class='iconAdmin'></div></td><td><b>The agent has not reported measures yet&#46</b></td></tr></table>");
								}
							}
						}
						else
						{
							if(measTime!=null && measTime.trim().length()>0 )
							{
								testStatusInfo.addElement("<td><a href='javascript:void(0)' onClick=javascript:showHistoryTab('"+popupLink1+"')><img  border='0' align='right' src='/final/monitor/eg_images/graph-o.gif'/></a></td>");
							}
							else
							{
								testStatusInfo.addElement("<table id=\"eg_12\" border='0'><tr><td><div class='iconAdmin'></div></td><td><b>The agent has not reported measures yet&#46</b></td></tr></table>");
								testStatusInfo.addElement("<span style='display:block;text-align:justify'><b>Possible reasons:</b>");
								testStatusInfo.addElement("The corresponding agent might not be running or the agent might not have started this test yet&#46");
								testStatusInfo.addElement("If the agent is not running, the state of this test will soon turn to UNKNOWN&#46 Otherwise, the measures will appear in a short while&#46");
								testStatusInfo.addElement("Note that if the agent has been running for a long time but the measures are not showing up, this means that the agent is unable to communicate to the manager&#46 Please refer to the trouble shooting guide&#46</span>");
							}
						}
					}
				}
				String tmpInfoStr = "";
				if(infoStr!=null && infoStr.trim().length()>0 && !infoStr.trim().equals("+"))
				{
					try
					{
						if(infoStr.indexOf("+")>-1 && infoStr.trim().length()>1)
							tmpInfoStr = infoStr.substring(infoStr.indexOf("+")+1);
						else
							tmpInfoStr = infoStr;
					}
					catch(Exception eee)
					{
						tmpInfoStr = null;
						eee.printStackTrace();
					}
				}
				JSONObject TestinfoJson = new JSONObject();
				TestinfoJson.put("State", tState );
			 	TestinfoJson.put("Testname" ,mappingInfo.getTestDescription(test));
				if(tmpInfoStr!=null && tmpInfoStr.trim().length()>0)
					TestinfoJson.put("Infoname",tmpInfoStr);
				json.put("testInfo",TestinfoJson);
			 	if(msmtHost == null || msmtHost.equals(""))
				{
					msmtHost = teststatus.getMeasurementHost(compType, sName, test);
				}

				String serverName = sName;
				String serverPort = "";
				if(serverName!=null && serverName.indexOf(":")>-1)
				{
					serverPort = serverName.substring(serverName.indexOf(":")+1);
					serverName = serverName.substring(0,serverName.indexOf(":"));
					// To display 'Test Frequency' of Oracle Server component type in details popup
					if(compType != null && compType.equalsIgnoreCase("Oracle_server") && !serverPort.equals("")&& serverPort.indexOf(":")>-1)
					{
						int indexOfColon = serverPort.indexOf(":");
						infoString = serverPort.substring(indexOfColon+1);
						serverPort = serverPort.substring(0,indexOfColon);
					}
				}
				else
				{
					serverPort="NULL";
				}

				String tmpUrl= "site=NULL";
				tmpUrl += "&stype="+compType+"&sname="+serverName+"&sport="+serverPort+"&sinfo="+infoString+"&tname="+test+"&tstate="+tState+"&faketype=null&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&msmttime="+measTime+"&desc="+com.eg.EgURLEncoder.encode(testStr,"UTF-8")+"&mstate="+tState+"&mespresent=yes";
				
				JSONObject DetailinfoJson = new JSONObject();				
				if(isfromSuper)
				{
					DetailinfoJson.put("methodSuper",true);
					DetailinfoJson.put("urlParam1",response.encodeURL("../monitor/EgTestStatusInfo.jsp?")+tmpUrl);
					DetailinfoJson.put("urlParam2",layerName);
				}
				else
				{
					DetailinfoJson.put("methodSuper",false);
					DetailinfoJson.put("urlParam1",tmpUrl);
					DetailinfoJson.put("urlParam2",layerName);
				}
				DetailinfoJson.put("detailText",mappingInfo.getTextDescription("monitor.layermodel.DETAILS"));
				json.put("detailInfo",DetailinfoJson);
				
				JSONObject HelpinfoJson = new JSONObject();	
				if(isfromSuper)
				{
					HelpinfoJson.put("urlParam1",response.encodeURL("../eghelp/EgMHelp.jsp?"));
					HelpinfoJson.put("urlParam2",test);
					HelpinfoJson.put("methodSuper",true);
				}
				else
				{
					HelpinfoJson.put("methodSuper",false);
					HelpinfoJson.put("urlParam1",test);
				}
				HelpinfoJson.put("helpText",mappingInfo.getTextDescription("monitor.layermodel.HELP"));
               	json.put("helpInfo",HelpinfoJson);
							
                JSONObject unknownInfoJson = new JSONObject();						
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Measurement Host"));
				unknownInfoJson.put("value",msmtHost);
				unknownInfoJsonArray.add(unknownInfoJson);
				
				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Component type"));
				unknownInfoJson.put("value",mappingInfo.getComponentTypeDescription(compType));
				unknownInfoJsonArray.add(unknownInfoJson);

				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.common.Component"));
				unknownInfoJson.put("value",sName.endsWith(":NULL")?sName.substring(0,sName.lastIndexOf(":")):sName);
				unknownInfoJsonArray.add(unknownInfoJson);

				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Test name"));
				unknownInfoJson.put("value",mappingInfo.getTestDescription(test));
				unknownInfoJsonArray.add(unknownInfoJson);

				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Test type"));
				unknownInfoJson.put("value",testType);
				unknownInfoJsonArray.add(unknownInfoJson);

				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Test frequency(secs)"));
				unknownInfoJson.put("value",testFrequency);
				unknownInfoJsonArray.add(unknownInfoJson);

				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Time since last measure"));

				// To display the 'Time Since Last Measure' when the test status is UNKNOWN and has a Measure History
				String measureTime = measTime.replace('*',' ');
				if(!teststatus.isAgentRunning(measureTime))
					timeSinceLastMeasure = teststatus.returnTimeSinceLastMeasure();

				if(!timeSinceLastMeasure.equals(""))
				{
		            unknownInfoJson.put("value",timeSinceLastMeasure);
				}
				else
				{
		             unknownInfoJson.put("value",mappingInfo.getTextDescription("monitor.layermodel.Not Available"));
				}
				unknownInfoJsonArray.add(unknownInfoJson);
				
				unknownInfoJson = new JSONObject();
				unknownInfoJson.put("key",mappingInfo.getTextDescription("monitor.layermodel.Test state"));
				unknownInfoJson.put("value",mappingInfo.getLabelDescription(tState));
				unknownInfoJson.put("highlight", true);
				unknownInfoJsonArray.add(unknownInfoJson);

				boolean flagDisplay=false;
				String substringDisp="";
				JSONArray testStatusInfoJsonArray = new JSONArray();
				for(int i=0;i < testStatusInfo.size();i++)
				{
					JSONObject testStatusInfoJson = new JSONObject();
					String tempDisp=(String)testStatusInfo.elementAt(i);
					substringDisp="";
					if(tempDisp.indexOf("<b>")>-1)
					{
						substringDisp=tempDisp.substring(tempDisp.indexOf("<b>")+3,tempDisp.lastIndexOf("</b>"));
						if(substringDisp.indexOf(":")>-1)
						{
						substringDisp=substringDisp.substring(0,substringDisp.indexOf(":"));
							flagDisplay=true;
						}
					}
					if(tempDisp!=null && tempDisp.indexOf("showHistoryTab")>-1)
					{
						testStatusInfoJson.put("AgentText",mappingInfo.getTextDescription("monitor.layermodel.The agent is not reporting measures currently."));
						testStatusInfoJson.put("Text",tempDisp+"<a href='javascript:void(0)' onClick=javascript:showHistoryTab('"+popupLink1+"')><div style='margin-top:2px;'>"+mappingInfo.getTextDescription("monitor.layermodel.View historical metrics.")+"</div></a>");
					}
					else
					{
						if(flagDisplay)
						{
							if(tempDisp.indexOf("<b>")>-1)
							{
								testStatusInfoJson.put("PreText",tempDisp.substring(0,tempDisp.indexOf("<b>")+3));
							}
							if(substringDisp.length()>0)
							{
								testStatusInfoJson.put("Text",mappingInfo.getTextDescription("monitor.layermodel."+substringDisp));	
		
							}
							flagDisplay=false;
							if(tempDisp.indexOf("<b>")>-1)
							{
								testStatusInfoJson.put("PostText",tempDisp.substring(tempDisp.lastIndexOf("</b>")));
							}
						}
						else
						{
							if(tempDisp.indexOf("<b>")>-1)
							{
								testStatusInfoJson.put("PreText",tempDisp.substring(0,tempDisp.indexOf("<b>")+3));
								if(substringDisp.length()>0)
								{
									testStatusInfoJson.put("Text",mappingInfo.getTextDescription("monitor.layermodel."+substringDisp));
								}
								if(tempDisp.indexOf("<b>")>-1)
								{
									testStatusInfoJson.put("PostText",tempDisp.substring(tempDisp.lastIndexOf("</b>")));
								}
							}
							else if(tempDisp.length()>0)
							{
								testStatusInfoJson.put("Text",mappingInfo.getTextDescription("monitor.layermodel."+tempDisp));
							}
						}
					}
					testStatusInfoJsonArray.add(testStatusInfoJson);
				}
				testStatusInfo.removeAllElements();
				trans4Site.removeAllElements();
				json.put("testStatusInfo",testStatusInfoJsonArray);
				json.put("unknownInfo",unknownInfoJsonArray);
			}
			//end of else
			if (rs != null)
			{
				try
				{
					rs.close();
				}
				catch (Exception bug123) {}
			}
			egDb.releaseConnection(false);
			EgDbAdapterTypeUI.releaseObject(egDb);
		}
		catch (Throwable e)
		{
			e.printStackTrace();
			if(!status.equals("CONNECTED"))
			{
				message = "Could not establish connection";
			}
			else
			{
				
				if(rs == null)
				{
					if(!statusBoolean)
					{
						message = "No measures found for this test in the database !!";
					}
					else
					{
						message = "No measures found for this test in the database !!";
					}
				}
				else if(rs != null)
				{
					if(!statusBoolean)
					{
						message = "An unknown error occured while fetching records";
					}
					else
					{
						message = "An unknown error occured while fetching records";
					}
				}
				else if(!statusState)
				{
					message = "You have exceeded your limit for the number of agents! This component is not being monitored by eG currently!!";
				}
				else
				{
					message = e.toString();
				}
				if (rs != null)
				{
					try {
						rs.close();
					} catch (Exception bug123) {}
				}
				if (rsState != null)
				{
					try {
						rsState.close();
					} catch (Exception bug123) {}
				}
				egDb.releaseConnection(true);
			}
			EgDbAdapterTypeUI.releaseObject(egDb);

			compType = request.getParameter("comptype");
			tState = request.getParameter("tstate");
			tState=(tState==null)?"GOOD":tState;

	%>	
	<jsp:useBean id="teststatus2" class="egurkha.TestStatusInfo" scope="page"/>
	<% 
			JSONObject TestinfoJson = new JSONObject();
			TestinfoJson.put("State", tState );

			String testNameWithInfo = testStr;
			String tmpTestName =""; 
			String tmpDesc =""; 
			if (testNameWithInfo.indexOf("-")>-1)
			{
				tmpTestName = testNameWithInfo.substring(0,testNameWithInfo.indexOf("-")).trim();
				tmpDesc = testNameWithInfo.substring(testNameWithInfo.indexOf("-")+1).trim();
				
				if(tmpDesc.endsWith("+"))
					tmpDesc = tmpDesc.substring(0,tmpDesc.length()-1);
				tmpDesc=URLDecoder.decode(tmpDesc);
				//Changed on  12/12/2008
				tmpDesc= ui.getReverseLookupAll(tmpDesc);
			}
			else
			{
				tmpTestName = testNameWithInfo; 
			}
			if(isShowUserLocation)
			{
				String usrInfo = "";
				String usrLocation = "";
				String domainName = "";

				if(tmpDesc!=null && tmpDesc.trim().length()>0 && tmpDesc.indexOf("\\")>-1)
				{
					domainName = tmpDesc.substring(0,tmpDesc.indexOf("\\"));
					usrInfo = tmpDesc.substring(tmpDesc.indexOf("\\")+1);
					if(usrInfo!=null && usrInfo.trim().length()>0 && usrInfo.indexOf("_on_")>-1)
					{
						usrInfo = usrInfo.substring(0,usrInfo.indexOf("_on_"));
					}
				}
				if(domainName!=null && domainName.trim().length()>0){
					/*HashMap usrloc = (HashMap)mu.getlocationFromTestTable(compType+":"+compName,usrInfo);
					usrLocation = (String)usrloc.get("Location");
					if(usrLocation == null || usrLocation.trim().length() == 0)
						usrLocation = ADUserIni.getValue(domainName,usrInfo);*/

					usrLocation = (String)mu.getUserLocation(compType+":"+compName,domainName,usrInfo,false,false,false);
				}
				
				tmpDesc = " <img class='"+showUserLocStyle+"' style='margin-top:2px' src ='/final/images/clear.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.User")+"'/> " + tmpDesc ;
				
				if(usrLocation!=null && usrLocation.trim().length()>0)
				{
					if(strSeparator!=null && strSeparator.trim().length()>0 && strReplaceSep!=null && strReplaceSep.trim().length()>0)
					{
						usrLocation = com.egurkha.util.StringUtils.replace(usrLocation,strSeparator,strReplaceSep);
					}

					tmpDesc = tmpDesc + " <img class='descriptor_database' style='margin-top:2px' src ='/final/images/clear.png' border = '0' title='"+mappingInfo.getTextDescription("monitor.layermodel.Location")+"'/> " + usrLocation;
				}
			}
			String tmpTestNameMap = mappingInfo.getTestDescription(tmpTestName);

			int MeasurementsPageTitlelength=tmpTestNameMap.length()+tmpDesc.length();
			if(MeasurementsPageTitlelength<dispTempDesc)
			{

				TestinfoJson.put("Testname" ,mappingInfo.getTestDescription(tmpTestName));

				if(tmpDesc!=null && tmpDesc.length()>0)
				{
					TestinfoJson.put("TestDesc"," "+"-"+" " +tmpDesc);
				}
			}
			else
			{
				String MeasurementPageTitle=mappingInfo.getTestDescription(tmpTestName)+"-"+tmpDesc;
				if(MeasurementPageTitle!=null && MeasurementPageTitle.length()>0 && MeasurementPageTitle.length()>dispTempDesc)
				{

				    TestinfoJson.put("Testname",MeasurementPageTitle);

				}
			}
			//Added on 6-6-2008 for Display msmtHost
			String onlyTest="";
			if(test!=null && test.indexOf("-")>-1)
			{
				onlyTest=test.substring(0,test.indexOf("-"));
				onlyTest=onlyTest.trim();
			}
			else
			{
				onlyTest=test;
			}
			String onlyCompName="";
			if(compName!=null && compName.indexOf(":")>-1)
			{
				onlyCompName=compName.substring(0,compName.indexOf(":"));
			}
			String[] extAgents=egExternal.getExternalAgentsForHost(onlyCompName);
			boolean isExternalTest=specsInfo.isExternalTest(onlyTest.trim());
			///---End----
			if (!StringUtils.isNull(msmtHost))
			{
				if(!(extAgents.length <=1 || !isExternalTest))
				{
					TestinfoJson.put("unit",msmtHost);
				}
			}
			json.put("testInfo",TestinfoJson);
			sName = hostName + ":" + portNumber;
			if(compType.equals("Oracle_server"))
			{
				if(infoStr2 != null && !infoStr2.equals(""))
				{
					sName = sName + ":" + infoStr2.substring(0,infoStr2.indexOf("+"));
				}
			}

			boolean isPortRelevantForTest = specsInfo.isPortRelevantForTest(test);
			if(!isPortRelevantForTest)
			{
				//New code
				//to display sun08.chn.egurkha.com
				//instead of sun08.chn.egurkha.com:1521:egurkha
				if(compType.equals("Oracle_server"))
				{
					sName = sName.substring(0,sName.indexOf(":"));
				}
				else
				{
					sName = sName.substring(0,sName.lastIndexOf(":"));
				}
			}

			boolean isTestDisabled = teststatus2.isTestDisabled(compType, sName, test);
			if(!isTestDisabled)
			{
				testFrequency = teststatus2.frequencyOfTest(compType, sName, test);
			}
			else
			{
				testFrequency = "Not Applicable";
			}

			if(msmtHost == null || msmtHost.equals(""))
			{
				msmtHost = teststatus2.getMeasurementHost(compType, sName, test);
			}

			String serverName = sName;
			String serverPort = "";
			if(serverName.indexOf(":")>-1)
			{
				serverPort = serverName.substring(serverName.indexOf(":")+1);
				serverName = serverName.substring(0,serverName.indexOf(":"));
			}
			else
			{
				serverPort="NULL";
			}
			String faketypevalue = request.getParameter("faketype");
			faketypevalue=(faketypevalue==null)?"":faketypevalue;

			String tmpUrl= "site=NULL";
			tmpUrl += "&stype="+compType+"&sname="+serverName+"&sport="+serverPort+"&sinfo=&tname="+test+"&tstate="+tState+"&faketype="+com.eg.EgURLEncoder.encode(faketypevalue,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&msmttime=&desc="+com.eg.EgURLEncoder.encode(testStr,"UTF-8")+"&mstate="+tState+"&mespresent=yes";
			
			JSONObject DetailinfoJson = new JSONObject();
			if(isfromSuper)
			{
				DetailinfoJson.put("methodSuper",true);
				DetailinfoJson.put("urlParam1",response.encodeURL("../monitor/EgTestStatusInfo.jsp?")+tmpUrl);
				DetailinfoJson.put("urlParam2",layerName);
				DetailinfoJson.put("urlParam3","");
			}
			else
			{
				DetailinfoJson.put("methodSuper",false);
				DetailinfoJson.put("urlParam1",tmpUrl);
				DetailinfoJson.put("urlParam2",layerName);
				DetailinfoJson.put("urlParam3","");
			}
			DetailinfoJson.put("detailText",mappingInfo.getTextDescription("monitor.layermodel.DETAILS"));
			json.put("detailInfo",DetailinfoJson);
			
			JSONObject HelpinfoJson = new JSONObject();
			if(isfromSuper)
			{
				HelpinfoJson.put("methodSuper",true);
				HelpinfoJson.put("urlParam1",response.encodeURL("../eghelp/EgMHelp.jsp?"));
				HelpinfoJson.put("urlParam2",test);
			}
			else
			{
				HelpinfoJson.put("methodSuper",false);
				HelpinfoJson.put("urlParam1",test);
			}
			HelpinfoJson.put("helpText",mappingInfo.getTextDescription("monitor.layermodel.HELP"));
			json.put("helpInfo",HelpinfoJson);
			if(message.length()>0)
			{
				errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel."+message));
				json.put("errormsg",errormsg);
			}
		}
	}
	else if(qctrString!=null && qctrString.equals("1"))
	{
		screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
		errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel.Please select a test to see the measurements"));
		json.put("errormsg",errormsg);
	}
	else if(qctrString!=null && qctrString.equals("0"))
	{
		screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
		if(dispDate!=null && dispDate!="null"){
			screenLabels.put("LastMeasurementTime",mappingInfo.getTextDescription("monitor.layermodel.Last Measurement Time") + " : " + dispDate);
		}
		errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel.Please select a layer to see the measurements"));
		json.put("errormsg",errormsg);

	}
	else if(request.getQueryString() == null || dispDate == null || qctrString == null)
	{
		screenLabels.put("Measurements",mappingInfo.getTextDescription("monitor.layermodel.Measurements"));
		errormsg.put("msg",mappingInfo.getTextDescription("monitor.layermodel.Please select a test to see the measurements"));
		json.put("errormsg",errormsg);
	}
	json.put("screenLabels",screenLabels);
	if(isMobileCall)
			response.getWriter().write(json_mobile.toString());
	else
			response.getWriter().write(json.toString());
		}
}
catch(Throwable t){
	t.printStackTrace();
	response.getWriter().write(t.toString());
}
%>
<%!
public String getUserTypeForLogon(String testName,String infoName)
{
	String delivery_gr="";
	String compNameforLog="";
	String status = "";
	String query="";
	String query1="";
	ResultSet rs2 = null;
	ResultSet rs3 = null;
	EgDbAdapterUI egDb = EgDbAdapterTypeUI.getObject();
	status = egDb.setConnection();
	try
	{
		if(EgInstallInfo.isSuperManager)
		{
			String oraquery="select * from (select Delivery_group from "+testName+"_DDD where info='"+infoName+"' order by msmt_time desc) where rownum=1";
			String sqlquery="select top 1 Delivery_group from "+testName+"_DDD  where info='"+infoName+"' order by msmt_time desc";
			Hashtable ht = new Hashtable();
			ht.put("OracleQuery",oraquery);
			ht.put("SqlQuery",sqlquery);
			rs2 = new EgSMDBHelper().getResultSet(ht);
		}
		else
		{
			if (EgDbInfo.isOraAdapter)
			{
				query="select * from (select Delivery_group from "+testName+"_DDD  where info='"+infoName+"'  order by msmt_time desc)where rownum = 1";
			}
			else
			{
				
				query="select top 1 Delivery_group from "+testName+"_DDD  where info='"+infoName+"' order by msmt_time desc";
			}
			rs2 = egDb.dbselect(query);
		}
		if(rs2!=null)
		{
			if (rs2.next())
			{
				 delivery_gr = rs2.getString("Delivery_group");
			}
		}
		if(rs2!=null)
		{
			rs2.close();
		}
		rs2=null;

		if(EgInstallInfo.isSuperManager)
		{
			if(testName.equals("CtxCdUserTest"))
			{
				String oraquery="select * from (select info from CtxCdLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc) where rownum=1";
				String sqlquery="select top 1 info from CtxCdLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc";
				Hashtable ht = new Hashtable();
				ht.put("OracleQuery",oraquery);
				ht.put("SqlQuery",sqlquery);
				rs3 = new EgSMDBHelper().getResultSet(ht);
			}
			else
			{
				String oraquery="select * from (select info from CtxXcXDLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc) where rownum=1";
				String sqlquery="select top 1 info from CtxXcXDLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc";
				Hashtable ht = new Hashtable();
				ht.put("OracleQuery",oraquery);
				ht.put("SqlQuery",sqlquery);
				rs3 = new EgSMDBHelper().getResultSet(ht);
			}
		}
		else
		{
			if(testName.equals("CtxCdUserTest"))
			{
				if (EgDbInfo.isOraAdapter)
				{
					query1="select * from (select info from CtxCdLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc) where rownum=1";
				}
				else
				{
					query1="select top 1 info from CtxCdLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc";
				}
			}
			else
			{
				if (EgDbInfo.isOraAdapter)
				{
					query1="select * from (select info from CtxXcXDLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc) where rownum=1";
				}
				else
				{
					query1="select top 1 info from CtxXcXDLogonTest where info like ('%:"+delivery_gr+"') order by msmt_time desc";
				}
			}
			rs3 = egDb.dbselect(query1);
		}
		if(rs3!=null)
		{
			if (rs3.next())
			{
				 compNameforLog = rs3.getString("info");
			}
		}
		if(rs3!=null)
		{
			rs3.close();
		}
		rs3=null;
	}
	catch(Exception e)
	{
		e.printStackTrace();
		try
		{
			if (rs2!=null)
			{
				rs2.close();
			}
			rs2=null;
			if (rs3!=null)
			{
				rs3.close();
			}
			rs3=null;
		}
		catch (Exception ec)
		{
			ec.printStackTrace();
		}
	}
	finally
	{
		egDb.releaseConnection(true);
		EgDbAdapterTypeUI.releaseObject(egDb);
	}
	return compNameforLog;
}

public boolean isDDDPresents(Hashtable show_dd , String test , String measure , String info)
{
	boolean showDD = false;
	String commonDD = formatIniFile.getValue("COMMON_DD_MAPPING",test+":"+measure);
	String commonDDTest = formatIniFile.getValue("COMMON_DDTEST_MAPPING",test+":"+measure);
	if(commonDD!=null && commonDD.length()>0)
	{
		measure = commonDD.substring(commonDD.indexOf(":")+1);
	}
	
	if(commonDDTest!=null && commonDDTest.length()>0)
	{
		test = commonDDTest.substring(0,commonDDTest.indexOf(":"));
		measure = commonDDTest.substring(commonDDTest.indexOf(":")+1);
	}

	try
	{
		if(show_dd != null)
		{
			if(info == null || info.trim().length() == 0)
			{
				Iterator it = show_dd.entrySet().iterator();
				while(it.hasNext())
				{
					Map.Entry entry = (Map.Entry)it.next();
					String key = (String)entry.getKey();
					if(key.startsWith(measure))
					{
						String value = (String)entry.getValue();
						if(value != null && value.equalsIgnoreCase("true"))
							return true;
					}
				}
			}
			else
			{
				String key = measure+"||"+info;
				if(show_dd.containsKey(test))
				{
					String dd_test = (String)show_dd.get(test);
					if(dd_test != null && dd_test.equalsIgnoreCase("true"))
						showDD = true;
				}
				else if(show_dd.containsKey(key))
				{
					String dd_key = (String)show_dd.get(key);
					if(dd_key != null && dd_key.equalsIgnoreCase("true"))
						showDD = true;
				}
			}
		}
	}
	catch (Exception er)
	{
		showDD = false;
	}
	return showDD;
}

%>