<%
/************************************************************************************************************************
*				20/12/2011 Sri Devi G User - VM Changes 
*				New UI changes by Omnicent and Saravanan.A on 12-9-2013
*************************************************************************************************************************/
%>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ include file = "EgMonitorTracker.jsp"%>
<%@ page errorPage = "EgProbsM.jsp" %>
<%@ page import = "com.egurkha.User"%>
<%@ page import = "com.egurkha.UserRegistry"%>
<%@ page import = "java.util.*"%>
<%@ page import = "com.egurkha.*"%>
<%@ page import = "com.eg.*"%>
<%@ page import = "com.egurkha.monitor.VmDashboardHelper"%>
<%@ page import = "com.egurkha.monitor.VMDesktopBean"%>
<%@ page import = "com.egurkha.monitor.VmSummaryView"%>
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import = "com.eg.EgURLEncoder"%>
<%@ page import = "com.eg.IniFile"%>

<%@ page import="net.sf.json.*"%>
<%@ page import="com.egurkha.admin.EgMaintenanceUtility"%>

<%@ page import = "com.egurkha.*" %>
<%@ page import = "com.egurkha.ini.*" %>

<%@ page import="com.eg.SidCheck" %>
<%@page import = "egurkha.reporter.*"%>

<%@ page import = "java.text.*" %>
<%@ page import = "java.math.*" %>


<%
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader ("Expires", -1);
	request.setCharacterEncoding("UTF-8");
	
	response.setContentType("application/json");
%>

<%

JSONObject json = new JSONObject();
JSONArray GridHeader = new JSONArray();
JSONArray GridData = new JSONArray();

	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 );


	int recount=0;
	int pagesizec=0;
	int pageSize = 0;

//<table border="0" cellspacing="0" cellpadding="6" width="100%" class="eg_lightlight" height="100%">
//	<tr>
//		<td width="100%" valign="top" height="100%">

	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());
	EgUserRole userRole = EgUserRole.getRoleObject(user.getLoginType());
	com.egurkha.ini.IniUI ui = (com.egurkha.ini.IniUI)com.egurkha.ini.IniUI.getInstance();
	IniFile egEx = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_external.ini");
	String iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile vmConfigFilee = new IniFile(iniFile_dir + "eg_dashboardConfig.ini");
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	EgDbInfo dbInfo = new EgDbInfo ("manager");

	String thisLanguage = ui.getDefaultLanguage();
	List a_userVMs = new LinkedList();
	boolean onlyVMAssigned = false;
	boolean vmAssigned = false;
	String monCmdComeFrom=request.getParameter("monCmdComeFrom");
	String isOnlyVmCase = request.getParameter("isOnlyVmCase");
	boolean _isOnlyVmCase = false;
	if(isOnlyVmCase != null && isOnlyVmCase.equalsIgnoreCase("true"))
		_isOnlyVmCase = true;

	String vmType = "";
	String subject="VMDashboard_Display";
	String cmpTypeValue=request.getParameter("cmpTypeValue");
	String paramValue=request.getParameter("type");
	if(paramValue!=null && paramValue.indexOf("$cap$")>-1)
	{
		paramValue = com.egurkha.util.StringUtils.replace(paramValue,"$cap$","^");
		paramValue = com.egurkha.util.StringUtils.decodeSecurityChar(paramValue);
	}

	if(paramValue!=null && paramValue.indexOf("\\\\") != -1)
	{
		String t_paramValue1 = paramValue.substring(0,paramValue.indexOf("\\\\"));
		String t_paramValue2 = paramValue.substring(paramValue.indexOf("\\\\")+2);
		paramValue = t_paramValue1+"\\"+t_paramValue2;
	}
	String showHAC = vmConfigFilee.getValue(subject,"Hosts&Clusters");
	String showVM = vmConfigFilee.getValue(subject,"showVMs");
	boolean showInsideView = false;
	if(showHAC!=null && showHAC.equalsIgnoreCase("no"))
	{
		if(showVM!=null && showVM.equalsIgnoreCase("yes"))
		{
			showInsideView = true;
		}
	}
	boolean typeIsVM = false;
	if (user!=null)
	{
		vmType = user.getVMType();
		String userLang = user.getLanguage();
		if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
		{
			thisLanguage=userLang;
		}
		if(_isOnlyVmCase)
		{
			onlyVMAssigned = user.isOnlyVMAssigned();
			vmAssigned = user.isVMAssigned();
		}
		if(!userRole.hasAllComponentAccess())
		{
			if(onlyVMAssigned)
				a_userVMs = user.getOnlyVMs();
			else
			{
				if(paramValue!=null && paramValue.indexOf(vmType)>-1)
				{
					typeIsVM = true;
				}
				if(_isOnlyVmCase)
					a_userVMs = user.getOnlyVMs();
			}
		}
	}
	String check = request.getParameter("check");
	String from = request.getParameter("from");
	String stateName = request.getParameter("stateName");
	String isVMa = request.getParameter("isVM");
	//EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	VmDashboardHelper vmDashHelper=new VmDashboardHelper(user,_isOnlyVmCase);
	EgDbInfo Dbdata = new EgDbInfo("manager");
	EgGroupInfo groupInfo = new EgGroupInfo();
	Hashtable Vmware_esx=new Hashtable();
	Hashtable Vmware_esx_Temp=new Hashtable();
	Hashtable Valid_info=new Hashtable();
	if(paramValue!=null)
	{
		while(paramValue.indexOf("|slash|")>-1)
		{
			paramValue=com.egurkha.util.StringUtils.replace(paramValue, "|slash|", "\\");
		}

		paramValue=com.egurkha.util.StringUtils.replace(paramValue, "|plus|", "+");
		paramValue=com.egurkha.util.StringUtils.replace(paramValue, "|pct|", "%");
		paramValue=com.egurkha.util.StringUtils.replace(paramValue, "|amp|", "&");
		paramValue=com.egurkha.util.StringUtils.replace(paramValue, "|hash|", "#");
	}

	String noOfInfoToDisplay=request.getParameter("priority");
	String comboValue=request.getParameter("comboValue");
	noOfInfoToDisplay=(noOfInfoToDisplay==null)?"15":noOfInfoToDisplay;
	String noOfInfoToDisplay_temp=noOfInfoToDisplay;
	String noOfInfoToDisplayDB = "ALL";
	String isDatastoreTab=request.getParameter("isDatastore");
	String poweredOnVMs=request.getParameter("poweredOnVMs");
	String isTotalVm=request.getParameter("totalVMs");
	String columnForMeasureName=request.getParameter("columnForMeasure");
	String parentVm = "";
	parentVm = request.getParameter("forvm");
	boolean parentIsVM = false;
	boolean isVM = false;
	if(parentVm!=null && (!parentVm.equals("null") || !parentVm.equals(""))&& parentVm.equals("VM"))
	{
		parentIsVM = true;
	}
	if(columnForMeasureName!=null && columnForMeasureName.trim().length()>0)
	{
		noOfInfoToDisplay="ALL";
	}
	String orderBy=request.getParameter("orderBy");
	if(orderBy==null || orderBy.trim().length()==0)
	{
		orderBy="desc";
	}
	if(onlyVMAssigned || parentIsVM || typeIsVM)
	{
		isVM = true;
	}
	EgList egList=new EgList();
	ArrayList comp_type_list=new ArrayList();
	JSONArray gr_com_obj = new JSONArray();
	JSONObject gr_com_nVpair = new JSONObject();
	Hashtable comp_type_base_hash=new Hashtable();
	Hashtable comp_type_eg_list=new Hashtable();
	ArrayList a_vmList = new ArrayList();
	boolean userHasManyVSTypes = false;
	EgList tempEgList = new EgList();
	if(paramValue.indexOf("GUEST")<0 && isVM)
	{
		//Collect all the virtual server types assigned to the user.
		//Collect the vms and display the inside view metrics.
		if(paramValue!=null && !(paramValue.indexOf("NOTMANAGED")>-1))
		{
			if(paramValue.indexOf("GUEST")<0)
			{
				List userVMTypes = user.getOnlyVMTypes();
				String tempParamValue = null;
				if(userVMTypes!=null && userVMTypes.size() >0)
				{
					userHasManyVSTypes = true;
					for(int ut = 0;ut < userVMTypes.size(); ut++) 
					{
						tempParamValue = (String)userVMTypes.get(ut);
						if(typeIsVM)
						{
							tempEgList=vmDashHelper.allVmHostInfosStateWish(paramValue,noOfInfoToDisplay);
						}
						else
						{
							tempEgList=vmDashHelper.allVmHostInfosStateWish(tempParamValue,noOfInfoToDisplay);
						}
						if(tempEgList!=null && tempEgList.size() >0)
						{
							for(int j=0;j<tempEgList.size();j++)
							{
								EgService tempServiceList=(EgService)tempEgList.get(j);
								String info_with_component_Temp=tempServiceList.getName();
								if(!egList.contains(tempServiceList))
									egList.add(tempServiceList);
							}
						}
					}
				}
			}
		}
	}
	else
	{
		if(paramValue!=null && !(paramValue.indexOf("NOTMANAGED")>-1))
		{
			if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
			{
				//egList=vmDashHelper.allVmHostInfosStateWish(paramValue+"^DSTab",noOfInfoToDisplay);
				egList=vmDashHelper.allVmHostInfosStateWish(paramValue+"^DSTab",noOfInfoToDisplayDB);
			}
			else
			{
				if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
				{
					egList=vmDashHelper.allVmHostInfosStateWish(paramValue,"ALL");
					noOfInfoToDisplay = "ALL";
				}
				else if(isTotalVm!=null && isTotalVm.equalsIgnoreCase("yes"))
				{
					egList=vmDashHelper.allVmHostInfosStateWish(paramValue,"ALL");
					noOfInfoToDisplay = "ALL";
				}
				else
				{
					//egList=vmDashHelper.allVmHostInfosStateWish(paramValue,noOfInfoToDisplay);
					egList=vmDashHelper.allVmHostInfosStateWish(paramValue,noOfInfoToDisplayDB);
				}
			}
		}
	}

	if(egList!=null && egList.size()>0 && !(paramValue.indexOf("NOTMANAGED")>-1))
	{
		for(int j=0;j<egList.size();j++)
		{
			EgService eg_serviceTemp=(EgService)egList.get(j);
			String info_with_component_Temp=eg_serviceTemp.getName();
			String info_Temp="";
			State temp_state_Temp=eg_serviceTemp.getState();
			String Component_Temp="";
			String comp_type_value=null;
			if(info_with_component_Temp!=null && info_with_component_Temp.indexOf("^")>-1)
			{
				info_Temp=info_with_component_Temp.substring(0,info_with_component_Temp.lastIndexOf("^"));
				Component_Temp=info_with_component_Temp.substring(info_with_component_Temp.lastIndexOf("^")+1);


				comp_type_value = Component_Temp.substring(0,Component_Temp.indexOf(":"));

				if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
				{
					String g_testname=egEx.getValue("VMSearch_Types",comp_type_value);
					if(g_testname!=null && g_testname.trim().length()>0)
					{
						VmSummaryView view = new VmSummaryView();
						String isPoweredOn = view.isVmPoweredOn(info_Temp,g_testname);
						if(isPoweredOn!=null && isPoweredOn.equalsIgnoreCase("off"))
							continue;
					}
					else
						continue;
				}

				if(comp_type_list!=null && !comp_type_list.contains(comp_type_value))
				{
					comp_type_list.add(comp_type_value);
					gr_com_nVpair.put("displayField",mappingInfo.getComponentTypeDescription(comp_type_value));
					gr_com_nVpair.put("valueField",comp_type_value);
					gr_com_obj.add(gr_com_nVpair);
				}
				
				if(comp_type_base_hash.size()==0)
				{
					ArrayList temp_array=new ArrayList();
					temp_array.add(info_Temp);
					Hashtable temp=new Hashtable();
					temp.put(Component_Temp,(ArrayList)temp_array);
					comp_type_base_hash.put(comp_type_value,(Hashtable)temp);
				}
				else if(comp_type_base_hash.size()>0)
				{
					if(comp_type_base_hash.containsKey(comp_type_value))
					{
						Hashtable temp=(Hashtable)comp_type_base_hash.get(new String(comp_type_value));
						if(temp!=null && temp.size()>0)
						{
							if(temp.containsKey(Component_Temp))
							{
								ArrayList temp_array=(ArrayList)temp.get(new String(Component_Temp));
								temp_array.add(info_Temp);
								temp.put(Component_Temp,(ArrayList)temp_array);
							}
							else
							{
								ArrayList temp_array=new ArrayList();
								temp_array.add(info_Temp);
								temp.put(Component_Temp,(ArrayList)temp_array);
							}
							comp_type_base_hash.put(comp_type_value,(Hashtable)temp);
						}
					}
					else
					{
						ArrayList temp_array=new ArrayList();
						temp_array.add(info_Temp);
						Hashtable temp=new Hashtable();
						temp.put(Component_Temp,(ArrayList)temp_array);
						comp_type_base_hash.put(comp_type_value,(Hashtable)temp);
					}
				}

				if(comp_type_eg_list.size()==0)
				{
					EgList temp_egList=new EgList();
					temp_egList.add((EgService)eg_serviceTemp);
					comp_type_eg_list.put(comp_type_value,(EgList)temp_egList);
				}
				else if(comp_type_eg_list.size()>0)
				{
					EgList temp_egList=(EgList)comp_type_eg_list.get(new String(comp_type_value));
					//if(comp_type_eg_list.containsKey(comp_type_value))
					if(temp_egList!=null)
					{
						//EgList temp_egList=(EgList)comp_type_eg_list.get(new String(comp_type_value));
						if(!temp_egList.contains(eg_serviceTemp))
							temp_egList.add((EgService)eg_serviceTemp);
						//comp_type_eg_list.put(comp_type_value,(EgList)temp_egList);
					}
					else
					{
						//EgList temp_egList=new EgList();
						temp_egList=new EgList();
						temp_egList.add((EgService)eg_serviceTemp);
						comp_type_eg_list.put(comp_type_value,(EgList)temp_egList);
					}
				}
			}
		}
	}
	ArrayList testMeasureList=null;
	ArrayList copyTestMeasureList = new ArrayList();
	Hashtable state_hash=new Hashtable();
	JSONArray gridArray = new JSONArray();
	JSONArray gridComboArray = new JSONArray();
	JSONObject countJson= new JSONObject();
	if(paramValue.indexOf("GUEST")<0 && isVM)
	{
		Hashtable result_hash=new Hashtable();
		String whichTab="virtual";
		String isPoweredOn = "";
		String testName = "";
		tempEgList = new EgList();

		recount=0;
		pagesizec=0;
		pageSize = 0;
		JSONObject gr_obj = new JSONObject();
		try
		{
			pageSize = Integer.parseInt(noOfInfoToDisplay_temp);
		}
		catch(Exception e)
		{
			pageSize = egList.size();
		}

		int pageStartIndex = 0;
		int pageEndIndex = 0;

		recount=egList.size();

		if(pageSize > 0)
			pagesizec=recount/pageSize;
		int tem = recount;
		int mod = 0;
		if(pageSize > 0)
			mod = tem%pageSize;

		if(mod > 0)
			pagesizec=pagesizec+1;
		countJson.put("recount",recount);
		countJson.put("pagesizec",pageSize);
		countJson.put("totalPages",pagesizec);

		if(pagesizec<=1)
			countJson.put("isHidePaging",new Boolean(true));
		else
			countJson.put("isHidePaging",new Boolean(false));

		String pageNoReqN = request.getParameter("pageNo");
		if(pageNoReqN==null || pageNoReqN.trim().length()==0 || pageNoReqN.equalsIgnoreCase("null"))
			pageNoReqN="1";

		 pageStartIndex = 0;
		 pageEndIndex = pageSize;
		int pageNum = 1;
		
		try
		{
			pageNum = Integer.parseInt(pageNoReqN.trim());
			pageNum = (pageNum == 0 )?1:pageNum;
			if(pageNum==1)
			{
				pageStartIndex=0;
				pageEndIndex = pageSize+pageStartIndex;
			}
			else
			{
				pageStartIndex = (pageNum*pageSize)-pageSize;
				pageEndIndex = pageSize+pageStartIndex;
				if( pageEndIndex > egList.size())
					pageEndIndex = egList.size();
			}
		}
		catch(Exception ee)
		{
			ee.printStackTrace();
			pageNum=1;
		}
		if(comp_type_list!=null && comp_type_list.size()>0)
		{
			String comp_type_value=null;
			for(int x=0;x<comp_type_list.size();x++)
			{
				comp_type_value=(String)comp_type_list.get(x);
				egList=new EgList();
				egList=(EgList)comp_type_eg_list.get(comp_type_value);

				if(egList!=null && egList.size() > 0)
				{
					for(int e=0; e< egList.size();e++)
					{
						tempEgList.add((EgService)egList.get(e));
					}
				}
				
				Hashtable temp_result = new Hashtable();
				if(typeIsVM || parentIsVM || showInsideView || isVM)
				{
					if(typeIsVM)
					{
						testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",paramValue+"^VM",comp_type_value);
					}
					else
					{
						testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",comp_type_value+"^VM",comp_type_value);
					}
					if(testMeasureList.size() > 0)
					{
						for(int t=0; t < testMeasureList.size(); t++)
						{
							
							String test = (String)testMeasureList.get(t);
							if(!copyTestMeasureList.contains(test))
								copyTestMeasureList.add(test);
						}
					}
				}
				if(egList!=null && egList.size()>0 && !(paramValue.indexOf("NOTMANAGED")>-1))
				{
					Hashtable key_is_comp_value_is_info=new Hashtable();
					
					
					key_is_comp_value_is_info=(Hashtable)comp_type_base_hash.get(comp_type_value);
					
					if(onlyVMAssigned || (paramValue!=null && paramValue.indexOf(vmType)>-1) || (parentIsVM) || showInsideView)
					{	//When user has only vms or Virtual_Machine node is selected only inside view measures to be shown.Added the parameter to
						//get inside view measures from eg_ui.ini.
						temp_result=vmDashHelper.getMeasuresForVms(key_is_comp_value_is_info,comp_type_value+"^INSIDE_VIEW_VM");
						if(temp_result!=null && temp_result.size() > 0)
						{
							for(Enumeration e=temp_result.keys();e.hasMoreElements();)
							{
								String key = (String)e.nextElement();
								Hashtable value = (Hashtable)temp_result.get(key);
								result_hash.put(key,value);
							}
						}
					}
				}
			}
			if(columnForMeasureName!=null && columnForMeasureName.trim().length()>0)
			{
				tempEgList=vmDashHelper.getSortedList(tempEgList,result_hash,whichTab,columnForMeasureName,orderBy);
			}
			if(noOfInfoToDisplay_temp!=null && noOfInfoToDisplay_temp.trim().length()>0 && !noOfInfoToDisplay_temp.equalsIgnoreCase("null") && !noOfInfoToDisplay_temp.startsWith("ALL"))
			{
				int count_toDisplay=Integer.parseInt(noOfInfoToDisplay_temp);

				if(pageEndIndex<tempEgList.size())
					tempEgList.subList(pageEndIndex , tempEgList.size()).clear();
				tempEgList.subList(0 , pageStartIndex).clear();
			}
			boolean showTitle = false;
			if((onlyVMAssigned)|| typeIsVM || showInsideView || parentIsVM)
			{
				ArrayList dispInfos = new ArrayList();
				for(int j=0;j<tempEgList.size();j++)
				{
					boolean displayInfo = true;
					EgService eg_service=(EgService)tempEgList.get(j);
					String info_with_component=eg_service.getName();
					String info="";
					State temp_state=eg_service.getState();
					String Component="";
					if(info_with_component!=null && info_with_component.indexOf("^")>-1)
					{
						info=info_with_component.substring(0,info_with_component.lastIndexOf("^"));
						Component=info_with_component.substring(info_with_component.lastIndexOf("^")+1);
					}
					if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
					{
						VmSummaryView view = new VmSummaryView();
						isPoweredOn = view.isVmPoweredOn(info,testName);
						if(isPoweredOn!=null && isPoweredOn.equalsIgnoreCase("off"))
							continue;
						String info_check=info;
						if(info_check!=null)
						{
							info_check=info_check.trim().toLowerCase();
							if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
								continue;
						}
					}
					else if(isTotalVm!=null && isTotalVm.equalsIgnoreCase("yes"))
					{
						String info_check=info;
						if(info_check!=null)
						{
							info_check=info_check.trim().toLowerCase();
							if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
								continue;
						}
					}
					String comp_type="";
					if(Component!=null && Component.indexOf(":")>-1)
					{
						comp_type=Component.substring(0,Component.indexOf(":"));
					}
					String compName  = Component.substring(Component.indexOf(":")+1);
					String compNameWithoutPort="";
					if(compName!=null && compName.indexOf(":")>-1)
					{
						compNameWithoutPort=compName.substring(0,compName.indexOf(":"));
					}
					Vmware_esx=(Hashtable)result_hash.get(Component);
					testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",comp_type+"^VM",comp_type);
					
					displayInfo = vmDashHelper.getDisplayStatus(info,Vmware_esx,copyTestMeasureList,compNameWithoutPort);
					dispInfos.add(new Boolean(displayInfo).toString());
					
					
				}
				if(dispInfos!=null && !dispInfos.isEmpty() && dispInfos.contains("true"))
				{
					showTitle= true;
				}
				
				if(result_hash!=null && result_hash.size()>0 && showTitle)
				{
					String widthOfTheHead="";
					JSONObject nameheader = new JSONObject();
					nameheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.State"));
					nameheader.put("textType","string");
					nameheader.put("sortByColumn","");
					nameheader.put("dataIndex","value-1");
					nameheader.put("colWidth",47);
					nameheader.put("locked",true);
					GridHeader.add(nameheader);
					
					nameheader = new JSONObject();
					nameheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.Name"));
					nameheader.put("sortByColumn","");
					nameheader.put("textType","string");
					nameheader.put("dataIndex","value0");
					nameheader.put("locked",true);
					//nameheader.put("columnWidth",widthOfTheHead);
					GridHeader.add(nameheader);

//			<table style="width:100%;" border="0" bordercolor="red" cellspacing="0" cellpadding="2" class="dhtmlxGrid vmborder" id="dhtmlxGrid" valign="top">
			
				
//				<tr>
//					<td align="center" id="data_headbg3" style="height:27px" onclick="javascript:sortByMeasureValue('<%=whichTab%','','<%=orderBy%');" class="mouse"> <egui:intnl text='monitor.VirtualDashboard.Name'/> </td>
		
					
					
						if(!onlyVMAssigned && (paramValue!=null && paramValue.indexOf(vmType)<0) && (!parentIsVM))
						{

//							<td align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','','');" class="mouse"> <egui:intnl text='monitor.VirtualDashboard.Host'/> </td>
							JSONObject hostheader = new JSONObject();
							hostheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.Host"));
							hostheader.put("sortByColumn","");
							hostheader.put("textType","string");
							hostheader.put("dataIndex","value1");
							//hostheader.put("columnWidth",widthOfTheHead);
							hostheader.put("locked",true);
							GridHeader.add(hostheader);
	
						}
					
					if(copyTestMeasureList!=null && copyTestMeasureList.size()>0)
					{
						ArrayList headerName = new ArrayList();
						for(int i=0;i<copyTestMeasureList.size();i++)
						{
							//JSONObject headerinfo = new JSONObject();
							
							String testMeasure=(String)copyTestMeasureList.get(i);
							String tempTest=null;
							String tempMeasure=null;
							String displayMeasureName=null;
							String orgMeasure=null;
							if(testMeasure!=null && testMeasure.indexOf(":")>-1)
							{
								tempTest=testMeasure.substring(0,testMeasure.indexOf(":"));
								tempMeasure=testMeasure.substring(testMeasure.indexOf(":")+1);
								if(tempMeasure!=null &&  tempMeasure.indexOf(":")>-1)
								{
									displayMeasureName=tempMeasure.substring(tempMeasure.indexOf(":")+1);
									tempMeasure=tempMeasure.substring(0,tempMeasure.indexOf(":"));
									orgMeasure = tempMeasure;
								}
							}
							//String unitForMeasure="&nbsp;("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
							String unitForMeasure="</br>("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
							String columnForMeasure = Dbdata.getColumnForMeasure(tempTest,tempMeasure);

							if(unitForMeasure!=null && unitForMeasure.indexOf("MB")>-1)
								unitForMeasure ="</br>"+"("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
								//unitForMeasure ="&nbsp;(GB)";

							widthOfTheHead="60";
							if(unitForMeasure!=null && unitForMeasure.indexOf("%")>-1&&!tempMeasure.equals("Ready")) 
								widthOfTheHead="100";
							if(displayMeasureName!=null && displayMeasureName.equalsIgnoreCase("Status"))
							{
								widthOfTheHead="40";
								tempMeasure=displayMeasureName;
								unitForMeasure="";
							}
							else
							{
								tempMeasure=displayMeasureName;
							}

							if(columnForMeasureName!=null && columnForMeasure!=null && columnForMeasure.equalsIgnoreCase(columnForMeasureName))
							{
								/*String nextOrderBy="desc";
								String imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
								if(orderBy!=null && orderBy.equals("desc"))
								{
									nextOrderBy="asc";
									imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
								}
								else if(orderBy!=null && orderBy.equals("asc"))
								{
									nextOrderBy="desc";
									imgurl="/final/monitor/eg_images/arrow_up_black_small.gif";
								}*/

//					<td width="<%=widthOfTheHead%" align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=nextOrderBy%');" class="mouse">
//						<table border="0" cellspacing="0" cellpadding="0" bordercolor="blue"> <col width="95%"> <col width="5%">
//							<tr>
//								<td class="eg_75bold" align="center"> <%=tempMeasure%</td>

								//headerinfo.put("name",tempMeasure);
								headerName.add(i, tempMeasure);

//								<td><img id="sortImg" src ="<%=imgurl%" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=nextOrderBy%');" class="mouse">
//								</td>
//							</tr>
//						</table>
//					</td>

							}
							else
							{

//					<td width="<%=widthOfTheHead%" align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=orderBy%');" class="mouse"> <%=tempMeasure% </td>
								headerName.add(i, tempMeasure);
							

							}
							//headerinfo.put("dataIndex","value"+(i+2));

							//GridHeader.add(headerinfo);
						}
						
//				</tr>
//				<tr>
//					<td class="padding2 eg_75bold agg_elight">&nbsp;</td>
						
						//JSONObject unitmeasure1 = new JSONObject();
						//unitmeasure1.put("value0","");
						
						if(isDatastoreTab==null)
						{
							if(!onlyVMAssigned && (paramValue!=null && paramValue.indexOf(vmType) <0) && (!parentIsVM))
							{

								//<td class="padding2 eg_75bold agg_elight">&nbsp;</td>
								//unitmeasure1.put("value1","");

							}
						}
						//GridData.add(unitmeasure1);
						
						for(int i=0;i<copyTestMeasureList.size();i++)
						{
							JSONObject unitmeasure2 = new JSONObject();
							
							String testMeasure=(String)copyTestMeasureList.get(i);
							String tempTest=null;
							String tempMeasure=null;
							String displayMeasureName=null;
							String orgMeasure=null;
							if(testMeasure!=null && testMeasure.indexOf(":")>-1)
							{
								tempTest=testMeasure.substring(0,testMeasure.indexOf(":"));
								if(tempTest!=null && tempTest.indexOf("GuestTest")>-1)
									testName = tempTest;
								tempMeasure=testMeasure.substring(testMeasure.indexOf(":")+1);
								if(tempMeasure!=null &&  tempMeasure.indexOf(":")>-1)
								{
									displayMeasureName=tempMeasure.substring(tempMeasure.indexOf(":")+1);
									tempMeasure=tempMeasure.substring(0,tempMeasure.indexOf(":"));
									orgMeasure = tempMeasure;
								}
							}
							//String unitForMeasure="&nbsp;("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
							String unitForMeasure="</br>("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";

							if(unitForMeasure!=null && unitForMeasure.indexOf("MB")>-1)
								unitForMeasure ="</br>"+"("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
								//unitForMeasure ="&nbsp;(GB)";

							widthOfTheHead="60";
							if(unitForMeasure!=null && unitForMeasure.indexOf("%")>-1&&!tempMeasure.equals("Ready")) 
								widthOfTheHead="100";
							if(displayMeasureName!=null && displayMeasureName.equalsIgnoreCase("Status"))
							{
								widthOfTheHead="40";
								tempMeasure=displayMeasureName;
								unitForMeasure="";
							}
							else if(displayMeasureName!=null && (displayMeasureName.equalsIgnoreCase("Disk Used") || displayMeasureName.equalsIgnoreCase("Used Space")))
							{
								tempMeasure=displayMeasureName;
								unitForMeasure="("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
							}
							else
							{
								tempMeasure=displayMeasureName;
							}
							String columnForMeasure = Dbdata.getColumnForMeasure(tempTest,orgMeasure);
							if(columnForMeasureName!=null && columnForMeasure!=null && columnForMeasure.equalsIgnoreCase(columnForMeasureName))
							{
								
								String nextOrderBy="desc";
								if(orderBy!=null && orderBy.equalsIgnoreCase("desc"))
								{
									nextOrderBy="asc";
								}
								else if(orderBy!=null && orderBy.equalsIgnoreCase("asc"))
								{
									nextOrderBy="desc";
								}
								unitmeasure2.put("SortTypeForCompName",nextOrderBy);
								unitmeasure2.put("SortTypeOrg",nextOrderBy);
							}
							else
							{
								unitmeasure2.put("SortTypeForCompName","desc");
								unitmeasure2.put("SortTypeOrg","desc");
							}
							if(unitForMeasure==null || unitForMeasure.equals(""))
							{

								//<td width="<%=widthOfTheHead%" align="center" class="padding2 agg_elight" style="border-top-width:0px"> &nbsp; </td>
								
								unitmeasure2.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard."+headerName.get(i)));

							}
							else
							{

								//<td width="<%=widthOfTheHead%" align="center" class="padding2 agg_elight" style="font-size:8px;font-weight:bold;border-top-width:0px"> <%=unitForMeasure% </td>
								unitmeasure2.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard."+headerName.get(i)) + unitForMeasure);
								unitmeasure2.put("text", headerName.get(i) + unitForMeasure);
							}
							String orgMeasureColumn = Dbdata.getColumnForMeasure(tempTest,orgMeasure);
							if(columnForMeasure==null || columnForMeasure.trim().length()==0)
								columnForMeasure= orgMeasure;
							unitmeasure2.put("sortByColumn", columnForMeasure.trim());
							unitmeasure2.put("textType", "asFloat");
							//unitmeasure2.put("columnWidth",widthOfTheHead);
							unitmeasure2.put("dataIndex","value"+(i+2));
							GridHeader.add(unitmeasure2);
						}
					}

//				</tr>
					boolean cell_color=false;
					int val0_header_len=-1;
					int val1_header_len=-1;
					for(int j=0;j < tempEgList.size();j++)
					{
						JSONObject gridinfo = new JSONObject();
						
						boolean displayInfo = true;
						EgService eg_service=(EgService)tempEgList.get(j);
						String info_with_component=eg_service.getName();
						String info="";
						State temp_state=eg_service.getState();
						String Component="";
						if(info_with_component!=null && info_with_component.indexOf("^")>-1)
						{
							info=info_with_component.substring(0,info_with_component.lastIndexOf("^"));
							Component=info_with_component.substring(info_with_component.lastIndexOf("^")+1);
						}
						if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
						{
							VmSummaryView view = new VmSummaryView();
							isPoweredOn = view.isVmPoweredOn(info,testName);

							if(isPoweredOn!=null && isPoweredOn.equalsIgnoreCase("off"))
								continue;

							String info_check=info;
							if(info_check!=null)
							{
								info_check=info_check.trim().toLowerCase();
								if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
									continue;
							}
						}
						else if(isTotalVm!=null && isTotalVm.equalsIgnoreCase("yes"))
						{
							String info_check=info;
							
							if(info_check!=null)
							{
								info_check=info_check.trim().toLowerCase();
								if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
									continue;
							}

						}
						String comp_type="";
						if(Component!=null && Component.indexOf(":")>-1)
						{
							comp_type=Component.substring(0,Component.indexOf(":"));
						}
						String compName  = Component.substring(Component.indexOf(":")+1);
						String compNameWithoutPort="";
						if(compName!=null && compName.indexOf(":")>-1)
						{
							compNameWithoutPort=compName.substring(0,compName.indexOf(":"));
						}
						
						int tmp_Val0_Header_Len=0;
						if(info!=null && info.length()>0)
						{
							tmp_Val0_Header_Len=info.length();
						}
						if(tmp_Val0_Header_Len>val0_header_len)
							val0_header_len=tmp_Val0_Header_Len;
						

						int val0ColumnWith=150;
						if(val0_header_len>15 && val0_header_len<30)
						{
							val0ColumnWith=200;
						}
						else if(val0_header_len>=30)
						{
							val0ColumnWith=250;
						}
						GridHeader.getJSONObject(1).put("colWidth",new Integer(val0ColumnWith));
						

						int tmp_Val1_Header_Len=0;
						if(compNameWithoutPort!=null && compNameWithoutPort.length()>0)
						{
							tmp_Val1_Header_Len=compNameWithoutPort.length();
						}
						if(tmp_Val1_Header_Len>val1_header_len)
							val1_header_len=tmp_Val1_Header_Len;
						

						int val1ColumnWith=100;
						if(val1_header_len>15 && val1_header_len<30)
						{
							val1ColumnWith=150;
						}
						else if(val1_header_len>=30)
						{
							val1ColumnWith=200;
						}
						GridHeader.getJSONObject(2).put("colWidth", new Integer(val1ColumnWith));

						if(onlyVMAssigned || typeIsVM || showInsideView)
						{
							Vmware_esx=(Hashtable)result_hash.get(Component);
							displayInfo = vmDashHelper.getDisplayStatus(info,Vmware_esx,copyTestMeasureList,compNameWithoutPort);
						}
						String compNameType = compName+":"+comp_type;
						String layer_name ="VIRTUAL_SERVERS";
						layer_name=egEx.getValue("VMSearch_InsideviewLayer",comp_type);
						if(layer_name==null || layer_name.trim().length()==0)
						{
							if(comp_type!=null && (comp_type.toLowerCase().indexOf("vdi")>-1 || comp_type.toLowerCase().indexOf("_desktop")>-1))
								layer_name = "VIRTUAL_DESKTOP";
							else
								layer_name = "VIRTUAL_SERVERS";
						}

						String URLinfo =com.egurkha.util.StringUtils.replace(((info==null)?"":info), "\\", "\\\\");

						ArrayList powerd_on_vm_list=new ArrayList();

						String key_for_hash=comp_type+"^eg^"+compName+"^eg^"+layer_name;

						if(state_hash!=null && state_hash.size()>0 && state_hash.containsKey(key_for_hash))
						{
							powerd_on_vm_list=(ArrayList)state_hash.get(key_for_hash);
						}
						else
						{
							VMDesktopBean vmdeskBean=new VMDesktopBean(comp_type,compName,layer_name);
							Valid_info=vmdeskBean.getInfoForTest();
							if(Valid_info!=null && Valid_info.size()>0)
							{
								Enumeration keys=Valid_info.keys();
								while(keys.hasMoreElements())
								{
									String key = (String)keys.nextElement();
									if(!userRole.hasAllComponentAccess())
									{
										if(onlyVMAssigned)
										{
											if(a_userVMs!=null && a_userVMs.size() > 0)
											{

												if(!a_userVMs.contains(key))
												{
													continue;
												}
											}
										}
										else
										{
											if(typeIsVM || parentIsVM)
											{
												if(a_userVMs!=null && a_userVMs.size() > 0)
												{

													if(!a_userVMs.contains(key))
													{
														continue;
													}
												}
											}
										}
									}
									powerd_on_vm_list.add(key.toLowerCase());
									if(comp_type!=null && comp_type.equals("VmVdi_i_server"))
									{
										if(key.indexOf("_on_")>-1 && info.indexOf("_on_")<0)
										{
											String key_vm=key.substring(key.indexOf("_on_")+4);
											powerd_on_vm_list.add(key_vm.toLowerCase());
										}
										if(key.indexOf("\\")>-1)
										{
											String key_uname=key.substring(0,key.indexOf("\\"));
											powerd_on_vm_list.add(key_uname.toLowerCase());
										}
									}
								}
							}

							if(powerd_on_vm_list!=null)
							{
								state_hash.put(key_for_hash,(ArrayList)powerd_on_vm_list);
							}
						}
						boolean ifDatastore=false;
						if(!displayInfo)
						{
							continue;
						}
						if(powerd_on_vm_list!=null && powerd_on_vm_list.size()>0 && powerd_on_vm_list.contains(info.toLowerCase()))
						{

//				<tr>
//					<td class="<%=cell_color?"eg_lightlight":""%" id="paddingleft4">
//						<table cellspacing="0" cellpadding="0" border="0" style="height:8px">
//							<tr>
//								<td width="15">

								if(info.endsWith("[Template]") || info.endsWith("[template]"))
								{

//									<img src="/final/monitor/eg_images/template_vm_<%=temp_state.getName()%.gif">
									//gridinfo.put("state","/final/monitor/eg_images/template_vm_"+temp_state.getName()+".gif");
									gridinfo.put("state","template_vm_"+temp_state.getName());

								}
								else if(info.endsWith("[Orphaned]") || info.endsWith("[orphaned]"))
								{

	//								<img src="/final/monitor/eg_images/orphan_vm_<%=temp_state.getName()%.gif">
									//gridinfo.put("state","/final/monitor/eg_images/orphan_vm_"+temp_state.getName()+".gif");
									gridinfo.put("state","orphan_vm_"+temp_state.getName());

								}
								else
								{
									

//									<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif">

									//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");
									gridinfo.put("state","vm_"+temp_state.getName());

								}

//								</td>
//								<td style="padding-left:5px"><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToVmMeasures('../monitor/egInsideviewDashboard.jsp?getFor=measure&comp=<%=EgURLEncoder.encode(compName,"UTF-8")%&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&Layer=<%=layer_name%&info=<%=EgURLEncoder.encode(URLinfo,"UTF-8")%&compName=<%=EgURLEncoder.encode(compNameType,"UTF-8")%&componentName=<%=compNameWithoutPort%&isFromVmDashboard=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%&isVM=<%=isVM%&source=MainDashboard');">

//								out.println(info);
								gridinfo.put("value0",info);
								gridinfo.put("value0_url","/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&Layer="+layer_name+"&info="+EgURLEncoder.encode(URLinfo,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameType,"UTF-8")+"&componentName="+compNameWithoutPort+"&isFromVmDashboard=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&isVM="+isVM+"&source=MainDashboard&check="+check+"&from="+from+"&stateName="+stateName+"&isOnlyVmCase="+isOnlyVmCase);

//								</a>
//								</td>
//							</tr>
//						</table>
//					</td>

						}
						else
						{
							if(typeIsVM)
							{
								if(a_userVMs!=null && a_userVMs.size() > 0)
								{

									if(!a_userVMs.contains(info))
									{
										continue;
									}
								}
							}
							String test_str=null;
							String temp_layer=null;
							if(comp_type!=null)
							{
								test_str=ui.getValue("Test_for_ComponentType",comp_type_value);
								temp_layer=ui.getValue("Layer_for_ComponentType",comp_type_value);
							}
							

//				<tr>
//					<td class="<%=cell_color?"eg_lightlight":""%" id="paddingleft4">
//						<table cellspacing="0" cellpadding="0" border="0" style="height:8px">
//							<tr>
//								<td width="15">

								if(info.endsWith("[Template]") || info.endsWith("[template]"))
								{

								//	<img src="/final/monitor/eg_images/template_vm_<%=temp_state.getName()%.gif">
									//gridinfo.put("state","/final/monitor/eg_images/template_vm_"+temp_state.getName()+".gif");
									gridinfo.put("state","template_vm_"+temp_state.getName());
								

								}
								else if(info.endsWith("[Orphaned]") || info.endsWith("[orphaned]"))
								{

		//									<img src="/final/monitor/eg_images/orphan_vm_<%=temp_state.getName()%.gif">
									//gridinfo.put("state","/final/monitor/eg_images/orphan_vm_"+temp_state.getName()+".gif");
									gridinfo.put("state","orphan_vm_"+temp_state.getName());

								}
								else
								{
									if(info!=null&&info.toLowerCase().indexOf("vio")>-1)
									{

//									<img src="/final/monitor/eg_images/vio_<%=temp_state.getName()%.gif">
										//gridinfo.put("state","/final/monitor/eg_images/vio_"+temp_state.getName()+".gif");
										gridinfo.put("state","vio_"+temp_state.getName());

									}
									else
									{

//									<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif">

										//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");
										gridinfo.put("state","vm_"+temp_state.getName());
									}
								}

//							</td>
//								<td style="padding-left:5px">

//								out.println(info);

									gridinfo.put("value0",info);							

//								</td>
//							</tr>
//						</table>
//					</td>

						}
							
						//GridData.add(gridinfo);
											
						Vmware_esx=(Hashtable)result_hash.get(Component);

						if(Vmware_esx!=null && Vmware_esx.size()>0)
						{
							int p=0;
							String info_to_lower=info.toLowerCase();
							while(p<copyTestMeasureList.size())
							{
								//JSONObject gridinfo2 = new JSONObject();
								
								String keyForList=(String)copyTestMeasureList.get(p);
								String keyMeasure="";
								String keyTest="";
								String keydisplayMeasure="";
								if(keyForList!=null && keyForList.indexOf(":")>-1)
								{
									keyTest=keyForList.substring(0,keyForList.indexOf(":"));
									keyMeasure=keyForList.substring(keyForList.indexOf(":")+1);
									if(keyMeasure!=null && keyMeasure.indexOf(":")>-1)
									{
										keydisplayMeasure=keyMeasure.substring(keyMeasure.indexOf(":")+1);
										keyMeasure=keyMeasure.substring(0,keyMeasure.indexOf(":"));
									}
								}
								String units=tablesInfo.getUnitForMeasure(keyTest,keyMeasure);

								keyMeasure = Dbdata.getColumnForMeasure(keyTest,keyMeasure);
								String Value=(String)Vmware_esx.get(keyMeasure+"^"+info_to_lower+"^"+compNameWithoutPort);
								String mes_state="";
								String mes_name="";
								String total_spc="0";
								if(Value!=null && Value.indexOf("^")>-1)
								{
									mes_state=Value.substring(Value.indexOf("^")+1);
									if(mes_state!=null && mes_state.indexOf("^")>-1)
									{
										mes_name=mes_state.substring(mes_state.indexOf("^")+1);
										mes_state=mes_state.substring(0,mes_state.indexOf("^"));
										if(mes_name!=null && mes_name.indexOf("^")>-1)
										{
											total_spc=mes_name.substring(mes_name.indexOf("^")+1);
											mes_name=mes_name.substring(0,mes_name.indexOf("^"));
										}
									}
									Value=Value.substring(0,Value.indexOf("^"));
								}
								else if(Value==null)
								{
									Value="-";
									mes_name=keyMeasure;
									mes_state="GOOD";
								}
								widthOfTheHead="60";
								if(units!=null && units.equals("%") || units.equalsIgnoreCase("Percent"))
									widthOfTheHead="150";
								
								String orgValue="0.0";
								try
								{
									if(Value!=null && Value.trim().length()>0 && Value.indexOf(".")>-1 && Double.parseDouble(Value)>0)
									{
										orgValue=Value;
										Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));
										Value=String.valueOf(Value);
									}
									else if(Value!=null && Value.trim().length()>0  && Double.parseDouble(Value)>0)
									{
										orgValue=Value;
										Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));
										Value=String.valueOf(Value);
									}
								}
								catch(Exception ee)
								{
									Value=Value;
								}
								if(mes_state!=null && mes_state.length()>0 && mes_state.equalsIgnoreCase("NONE"))
								{
									mes_state="GOOD";
								}
								else if(mes_state!=null && mes_state.trim().length()==0)
								{
									mes_state="GOOD";
								}
								if(displayInfo)
								{
								if(Value.equalsIgnoreCase("on"))
								{

			//		<td align="center" id="padding3" class="<%=cell_color?"eg_lightlight":""%"><img  src="/final/monitor/eg_images/yes2.gif"></td> 
			
									gridinfo.put("value"+(p+2)+"_image","iconPoweredOn");

								}
								else if(Value.equalsIgnoreCase("off"))
								{

//					 <td align="center" id="padding3" class="<%=cell_color?"eg_lightlight":""%"><img  src="/final/monitor/eg_images/no2.gif"></td>
									
									gridinfo.put("value"+(p+2)+"_image","iconPoweredOff");
								}
								else
								{
									if(mes_name!=null)
									{
										if(Value!=null && !Value.equals("-"))
										{
											double fillColorValue=Double.parseDouble(orgValue);
											if(units!=null && units.equals("MB"))
											{
												//units = "GB";
												fillColorValue=fillColorValue/1024.0;
											}
											Value=String.valueOf(fillColorValue);
											Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));

//					<td  align="left" class="<%=cell_color?"eg_lightlight":""%"id="paddingright4">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="right" style="padding-left:2px;width:40px;padding-right:2px">

										}
										else
										{

//					<td  align="left" class="<%=cell_color?"eg_lightlight":""%"id="paddingright4">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="left" style="padding-left:20px">

										}
									}
									else
									{

//					<td  align="right" class="<%=cell_color?"eg_lightlight":""%" id="paddingright6">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="right" style="padding-right:2px">

									}
									if(units!=null && units.equalsIgnoreCase("Number"))
									{
										if(Value!=null && !Value.equals("-") && Value.indexOf(".")>0)
										{
											Value=Value.substring(0,Value.indexOf("."));
										}
									}

//								<%//=Value%</td>
								gridinfo.put("value"+(p+2),formatDbValue(Value));
									
//								<td height="8">

									if(Value!=null && !Value.equals("-"))
									{
										boolean usage =true;
										if(mes_name!=null && mes_name.equalsIgnoreCase("Cpu_used"))
										{
											usage = false;

											int columnWidth = 100;
											Long temp_measure_value=new Long(Math.round(Double.parseDouble(Value)));
											long fillColorValue=temp_measure_value.longValue();
											long value1 = (fillColorValue*100)/columnWidth;
											if(fillColorValue >=0)
											{

//									<table width="80" cellpadding="0" cellspacing="0" border="0"  height="8" class="prog_border">
//										<tr>
//											<td align="left" width="100%" height="8" class="prog_line" >
//												<table width="<%=value1%%" height="8"  cellpadding="0" cellspacing="0" border="0">
//													<tr>
//														<td class ="progress_<%=mes_state%" width="100%"> </td>

														gridinfo.put("value"+(p+2)+"_progress",value1);
//													</tr>
//												</table>
//											</td>
//										</tr>
//									</table>


											}
										}
										else if(units!=null && (units.equals("%") || units.equalsIgnoreCase("Percent"))&&!mes_name.equalsIgnoreCase("Ready")&&usage)
										{
											int columnWidth = 100;
											Long temp_measure_value=new Long(Math.round(Double.parseDouble(Value)));
											long fillColorValue=temp_measure_value.longValue();
											long value2 = (fillColorValue*100)/columnWidth;
											if(fillColorValue >=0)
											{

//									<table width="80" cellpadding="0" cellspacing="0" border="0"  height="8" class="prog_border">
//										<tr>
//											<td align="left" width="100%" height="8px" class="prog_line" >
//												<table width="<%=value2%%" height="8" cellpadding="0" cellspacing="0" border="0">
//													<tr>
//														<td class ="progress_<%=mes_state%" width="100%"></td>

														gridinfo.put("value"+(p+2)+"_progress",value2);
//													</tr>
//												</table>
//											</td>
//										</tr>
//									</table>

											}
										}
									}
								//	else out.println("&nbsp;");

//							</td>
//							</tr>
//						</table>
//					</td>

								}
								}
								p++;
								
								//GridData.add(gridinfo);
							}
						}
						else
						{
							int p=0;
							while(p<copyTestMeasureList.size())
							{
								//JSONObject gridinfo2 = new JSONObject();
								if(displayInfo)
								{

//					<td align="center" class="<%=cell_color?"eg_lightlight":""%">&nbsp;-</td>
									gridinfo.put("value"+(p+2),"-");				
			
								}	
								p++;
								
							}				
						}
						GridData.add(gridinfo);

//				</tr>

						if(cell_color)
						{
							cell_color=false;
						}
						else
						{
							cell_color=true;
						}
						
					}


//				</table>
				}
				else
				{
					int col_span=copyTestMeasureList.size();

//			<table border="0" width="100%" height="100%" border="1" bordercolor="green">
//			<tr>
//					<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%">
//						<img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>
	//					<br><egui:intnl text='monitor.VirtualDashboard.No Data found'/>
	
								json.put("Errormsg",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Data found"));
//					</td>
//				</tr>
//			</table>

				}

				
			}
		}
		else
		{

//				<table border="0" width="100%" height="100%" border="1" bordercolor="green">
//				<tr>
//					<td align="center" id="eg_errorsmall" width="100%"  height="100%">
//						<img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>
//						<br><egui:intnl text='monitor.VirtualDashboard.No Data found'/>

							json.put("Errormsg",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Data found"));

//					</td>
//				</tr>
//			</table>
		}

	}
	else
	{
		String showVMWithNoData = vmConfigFilee.getValue("VMDashboard_Display","showVMWithNoData");
		boolean isShowVMWithNoData = false;
		if(showVMWithNoData != null && showVMWithNoData != "null" && showVMWithNoData.trim().length()>0 && showVMWithNoData.equalsIgnoreCase("No"))
		{
			isShowVMWithNoData = true;
		}
		if(comp_type_list!=null && comp_type_list.size()>0)
		{
			String comp_type_value=null;
			int sizeComp = comp_type_list.size();
			boolean isComboValue = false;
			if(comboValue != null && comboValue.trim().length()>0)
			{
				isComboValue = true;
				comp_type_value = comboValue;
				sizeComp= 1;
			}
			for(int x=0;x<sizeComp;x++)
			{
				GridHeader = new JSONArray();
				GridData = new JSONArray();
				recount=0;
				pagesizec=0;
				pageSize = 0;
				JSONObject gr_obj = new JSONObject();
				if(!isComboValue)
					comp_type_value=(String)comp_type_list.get(x);
				egList=new EgList();
				EgList tempEgListDup=new EgList();
				egList=(EgList)comp_type_eg_list.get(comp_type_value);
				String whichTab="virtual";
				if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("yes"))
				{
					testMeasureList=vmDashHelper.getVmHostTestWithMeasures("DATASTORE",paramValue+"^DSTab",comp_type_value);
					whichTab="datastore";
				}
				else
				{
					if(typeIsVM || parentIsVM || showInsideView)
					{
						testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",paramValue+"^VM",comp_type_value);
					}
					else
					{
						testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",paramValue,comp_type_value);
					}
					whichTab="virtual";
				}

				if(egList!=null && egList.size()>0 && !(paramValue.indexOf("NOTMANAGED")>-1))
				{
					Hashtable key_is_comp_value_is_info=new Hashtable();
					Hashtable result_hash=new Hashtable();
					String isPoweredOn = "";
					String testName = "";
					key_is_comp_value_is_info=(Hashtable)comp_type_base_hash.get(comp_type_value);
					
					if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
					{
						result_hash=vmDashHelper.getMeasuresForVms(key_is_comp_value_is_info,comp_type_value,"DATASTORE");
					}
					else if(onlyVMAssigned || (paramValue!=null && paramValue.indexOf(vmType)>-1) || (parentIsVM) || showInsideView)
					{	//When user has only vms or Virtual_Machine node is selected only inside view measures to be shown.Added the parameter to
						//get inside view measures from eg_ui.ini.
						result_hash=vmDashHelper.getMeasuresForVms(key_is_comp_value_is_info,comp_type_value+"^INSIDE_VIEW_VM");
					}
					else
					{
						result_hash=vmDashHelper.getMeasuresForVms(key_is_comp_value_is_info,comp_type_value);
					}
					if(columnForMeasureName!=null && columnForMeasureName.trim().length()>0)
					{
						orderBy=orderBy.toLowerCase();
						egList=vmDashHelper.getSortedList(egList,result_hash,whichTab,columnForMeasureName,orderBy);
						/*if(noOfInfoToDisplay_temp!=null && noOfInfoToDisplay_temp.trim().length()>0 && !noOfInfoToDisplay_temp.equalsIgnoreCase("null") && !noOfInfoToDisplay_temp.startsWith("ALL"))
						{
							int count_toDisplay=Integer.parseInt(noOfInfoToDisplay_temp);
							if (egList.size() > count_toDisplay)
								egList.subList(count_toDisplay , egList.size()).clear();
						}*/
					}
					
					boolean showTitle = true;
					if((onlyVMAssigned)|| typeIsVM || showInsideView || parentIsVM || isShowVMWithNoData)
					{
						ArrayList dispInfos = new ArrayList();
						for(int j=0;j<egList.size();j++)
						{
							boolean displayInfo = true;
							EgService eg_service=(EgService)egList.get(j);
							String info_with_component=eg_service.getName();
							String info="";
							State temp_state=eg_service.getState();
							String Component="";
							if(info_with_component!=null && info_with_component.indexOf("^")>-1)
							{
								info=info_with_component.substring(0,info_with_component.lastIndexOf("^"));
								Component=info_with_component.substring(info_with_component.lastIndexOf("^")+1);
							}
							if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
							{
								VmSummaryView view = new VmSummaryView();
								isPoweredOn = view.isVmPoweredOn(info,testName);
								if(isPoweredOn!=null && isPoweredOn.equalsIgnoreCase("off"))
									continue;
								String info_check=info;
								if(info_check!=null)
								{
									info_check=info_check.trim().toLowerCase();
									if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
										continue;
								}
							}
							else if(isTotalVm!=null && isTotalVm.equalsIgnoreCase("yes"))
							{
								String info_check=info;
								if(info_check!=null)
								{
									info_check=info_check.trim().toLowerCase();
									if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
										continue;
								}
							}
							String comp_type="";
							if(Component!=null && Component.indexOf(":")>-1)
							{
								comp_type=Component.substring(0,Component.indexOf(":"));
							}
							String compName  = Component.substring(Component.indexOf(":")+1);
							String compNameWithoutPort="";
							if(compName!=null && compName.indexOf(":")>-1)
							{
								compNameWithoutPort=compName.substring(0,compName.indexOf(":"));
							}
							
							
								Vmware_esx=(Hashtable)result_hash.get(Component);
								displayInfo = vmDashHelper.getDisplayStatus(info,Vmware_esx,testMeasureList,compNameWithoutPort);
								dispInfos.add(new Boolean(displayInfo).toString());
								if(displayInfo)
								{
									tempEgListDup.add(eg_service);
								}
							
						}
						if(dispInfos!=null && !dispInfos.isEmpty() && dispInfos.contains("true"))
						{
							showTitle= true;
						}
						else
						{
							showTitle = false;
						}
					}
					if(isShowVMWithNoData && tempEgListDup.size()>0)
					{
						egList.clear();
						egList.addAll(tempEgListDup);
					}

					try
					{
						pageSize = Integer.parseInt(noOfInfoToDisplay_temp);
					}
					catch(Exception e)
					{
						pageSize = egList.size();
					}

					int pageStartIndex = 0;
					int pageEndIndex = 0;

					recount=egList.size();

					if(pageSize > 0)
						pagesizec=recount/pageSize;
					int tem = recount;
					int mod = 0;
					if(pageSize > 0)
						mod = tem%pageSize;

					if(mod > 0)
						pagesizec=pagesizec+1;
					countJson.put("recount",recount);
					countJson.put("pagesizec",pageSize);
					countJson.put("totalPages",pagesizec);

					if(pagesizec<=1)
						countJson.put("isHidePaging",new Boolean(true));
					else
						countJson.put("isHidePaging",new Boolean(false));

					String pageNoReqN = request.getParameter("pageNo");
					if(pageNoReqN==null || pageNoReqN.trim().length()==0 || pageNoReqN.equalsIgnoreCase("null"))
						pageNoReqN="1";
					//int pageStartIndex = 0;
					//int pageEndIndex = pageSize;
					 pageStartIndex = 0;
					 pageEndIndex = pageSize;
					int pageNum = 1;
					try
					{
						pageNum = Integer.parseInt(pageNoReqN.trim());
						pageNum = (pageNum == 0 )?1:pageNum;
						if(pageNum==1)
						{
							pageStartIndex=0;
							//pageEndIndex = pageStartIndex+(pageSize-1);//10+10-1
							pageEndIndex = pageSize+pageStartIndex;
						}
						else
						{
							//pageStartIndex=((pageNum-1)*pageSize);//2-1*10
							//pageEndIndex = pageStartIndex+(pageSize-1);//10+10-1
							pageStartIndex = (pageNum*pageSize)-pageSize;
							pageEndIndex = pageSize+pageStartIndex;
							if( pageEndIndex > egList.size())
								pageEndIndex = egList.size();
						}
					}
					catch(Exception ee)
					{
						ee.printStackTrace();
						pageNum=1;
					}
					if(noOfInfoToDisplay_temp!=null && noOfInfoToDisplay_temp.trim().length()>0 && !noOfInfoToDisplay_temp.equalsIgnoreCase("null") && !noOfInfoToDisplay_temp.startsWith("ALL"))
					{
						int count_toDisplay=Integer.parseInt(noOfInfoToDisplay_temp);
						if(pageEndIndex<egList.size())
							egList.subList(pageEndIndex , egList.size()).clear();
						egList.subList(0 , pageStartIndex).clear();
					}
					if(result_hash!=null && result_hash.size()>0 && showTitle)
					{
						String widthOfTheHead="";

//		 	<table style="width:100%;" border="0" bordercolor="red" cellspacing="0" cellpadding="2" class="dhtmlxGrid vmborder" id="dhtmlxGrid" valign="top">
			
				
//				<tr>
//					<td align="center" id="data_headbg3" style="height:27px" onclick="javascript:sortByMeasureValue('<%=whichTab%','','<%=orderBy%');" class="mouse"> <egui:intnl text='monitor.VirtualDashboard.Name'/> </td>

						JSONObject nameheader = new JSONObject();
						nameheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.State"));
						nameheader.put("textType","string");
						nameheader.put("sortByColumn", "");
						nameheader.put("dataIndex","value-1");
						nameheader.put("locked",true);
						nameheader.put("colWidth",47);
						GridHeader.add(nameheader);
						nameheader = new JSONObject();
						nameheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.Name"));
						nameheader.put("sortByColumn", "");
						nameheader.put("textType","string");
						nameheader.put("dataIndex","value0");
						nameheader.put("locked",true);
						GridHeader.add(nameheader);
						
						if(testMeasureList!=null && testMeasureList.size()>0)
						{
							ArrayList headerName = new ArrayList();
							for(int i=0;i<testMeasureList.size();i++)
							{
								//JSONObject headerinfo = new JSONObject();
								
								String testMeasure=(String)testMeasureList.get(i);
								String tempTest=null;
								String tempMeasure=null;
								String displayMeasureName=null;
								if(testMeasure!=null && testMeasure.indexOf(":")>-1)
								{
									tempTest=testMeasure.substring(0,testMeasure.indexOf(":"));
									tempMeasure=testMeasure.substring(testMeasure.indexOf(":")+1);
									if(tempMeasure!=null &&  tempMeasure.indexOf(":")>-1)
									{
										displayMeasureName=tempMeasure.substring(tempMeasure.indexOf(":")+1);
										tempMeasure=tempMeasure.substring(0,tempMeasure.indexOf(":"));
									}
								}
								String unitForMeasure="</br>("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
								//String unitForMeasure="&nbsp;("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
								String columnForMeasure = Dbdata.getColumnForMeasure(tempTest,tempMeasure);

								if(unitForMeasure!=null && unitForMeasure.indexOf("MB")>-1)
									unitForMeasure ="</br>"+"("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
									//unitForMeasure ="&nbsp;(GB)";

								widthOfTheHead="60";
								if(unitForMeasure!=null && unitForMeasure.indexOf("%")>-1&&!tempMeasure.equals("Ready")) 
									widthOfTheHead="100";
								if(displayMeasureName!=null && displayMeasureName.equalsIgnoreCase("Status"))
								{
									widthOfTheHead="40";
									tempMeasure=displayMeasureName;
									unitForMeasure="";
								}
								else
								{
									tempMeasure=displayMeasureName;
								}

								//if(columnForMeasureName!=null && columnForMeasure!=null && columnForMeasure.equalsIgnoreCase(columnForMeasureName))
								//{
									//String nextOrderBy="desc";
									//String imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
									//if(orderBy!=null && orderBy.equalsIngoreCase("desc"))
									//{
										//nextOrderBy="asc";
										//imgurl="/final/monitor/eg_images/arrow_down_black_small.gif";
									//}
									//else if(orderBy!=null && orderBy.equalsIngoreCase("asc"))
									//{
										//nextOrderBy="desc";
										//imgurl="/final/monitor/eg_images/arrow_up_black_small.gif";
									//}

	//				<td width="<%=widthOfTheHead%" align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=nextOrderBy%');" class="mouse">
	//					<table border="0" cellspacing="0" cellpadding="0" bordercolor="blue"> <col width="95%"> <col width="5%">
	//						<tr>
	//							<td class="eg_75bold" align="center"> <%=tempMeasure%</td>
									//headerName.add(i, tempMeasure);
									//headerinfo.put("name",tempMeasure);
	
	//							<td><img id="sortImg" src ="<%=imgurl%" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=nextOrderBy%');" class="mouse">
	//							</td>
	//						</tr>
	//					</table>
	//				</td>

								//}
								//else
								//{

	//				<td width="<%=widthOfTheHead%" align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','<%=columnForMeasure%','<%=orderBy%');" class="mouse"> <%=tempMeasure% </td>
								//	headerName.add(i, tempMeasure);
								//headerinfo.put("name",tempMeasure);

								//}
								headerName.add(i, tempMeasure);
							//headerinfo.put("dataIndex","value"+(i+2));
							//GridHeader.add(headerinfo);
							}
							if(isDatastoreTab==null)
							{
								if(!onlyVMAssigned && (paramValue!=null && paramValue.indexOf(vmType)<0) && (!parentIsVM))
								{

							//	<td align="center" id="data_headbg3" style="border-top-width:0px" onclick="javascript:sortByMeasureValue('<%=whichTab%','','');" class="mouse"> <egui:intnl text='monitor.VirtualDashboard.Host'/> </td>
							
								
									JSONObject hostheader = new JSONObject();
									hostheader.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard.Host"));
									hostheader.put("sortByColumn", "");
									hostheader.put("textType","string");
									hostheader.put("dataIndex","value1");
									//hostheader.put("columnWidth",widthOfTheHead);
									hostheader.put("locked",true);
									GridHeader.add(hostheader);
								}
							}
//					</tr>
//				<tr>
//					<td class="padding2 eg_75bold agg_elight">&nbsp;</td>

				//JSONObject unitmeasure1 = new JSONObject();
				//unitmeasure1.put("value0","");

							if(isDatastoreTab==null)
							{
								if(!onlyVMAssigned && (paramValue!=null && paramValue.indexOf(vmType) <0) && (!parentIsVM))
								{

							//	<td class="padding2 eg_75bold agg_elight">&nbsp;</td>
								//unitmeasure1.put("value1","");

								}
							}
						
						//GridData.add(unitmeasure1);
						
							for(int i=0;i<testMeasureList.size();i++)
							{
								JSONObject unitmeasure2 = new JSONObject();
								
								String testMeasure=(String)testMeasureList.get(i);
								String tempTest=null;
								String tempMeasure=null;
								String displayMeasureName=null;
								String orgMeasure=null;
								if(testMeasure!=null && testMeasure.indexOf(":")>-1)
								{
									tempTest=testMeasure.substring(0,testMeasure.indexOf(":"));
									if(tempTest!=null && tempTest.indexOf("GuestTest")>-1)
										testName = tempTest;
									tempMeasure=testMeasure.substring(testMeasure.indexOf(":")+1);
									if(tempMeasure!=null &&  tempMeasure.indexOf(":")>-1)
									{
										displayMeasureName=tempMeasure.substring(tempMeasure.indexOf(":")+1);
										tempMeasure=tempMeasure.substring(0,tempMeasure.indexOf(":"));
										orgMeasure=tempMeasure;
									}
								}
								//String unitForMeasure="&nbsp;("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";
								String unitForMeasure="("+tablesInfo.getUnitForMeasure(tempTest,tempMeasure.trim())+")";

								if(unitForMeasure!=null && unitForMeasure.indexOf("MB")>-1)
									unitForMeasure ="("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
									//unitForMeasure ="&nbsp;(GB)";
								widthOfTheHead="60";
								if(unitForMeasure!=null && unitForMeasure.indexOf("%")>-1&&!tempMeasure.equals("Ready")) 
									widthOfTheHead="100";
								if(displayMeasureName!=null && displayMeasureName.equalsIgnoreCase("Status"))
								{
									widthOfTheHead="40";
									tempMeasure=displayMeasureName;
									unitForMeasure="";
								}
								else if(displayMeasureName!=null && (displayMeasureName.equalsIgnoreCase("Disk Used") || displayMeasureName.equalsIgnoreCase("Used Space")))
								{
									tempMeasure=displayMeasureName;
									unitForMeasure="("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
								}
								else
								{
									tempMeasure=displayMeasureName;
								}
					
								if(unitForMeasure==null || unitForMeasure.equals(""))
								{

//					<td width="<%=widthOfTheHead%" align="center" class="padding2 agg_elight" style="border-top-width:0px"> &nbsp; </td>

									unitmeasure2.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard."+headerName.get(i)));

								}
								else
								{

	//				<td width="<%=widthOfTheHead%" align="center" class="padding2 agg_elight" style="font-size:8px;font-weight:bold;border-top-width:0px"> <%=unitForMeasure%</td>		
									String temp_unit =mappingInfo.getTextDescription("monitor.VirtualDashboard."+unitForMeasure);
									unitmeasure2.put("text",mappingInfo.getTextDescription("monitor.VirtualDashboard."+headerName.get(i)));
									unitmeasure2.put("unit",temp_unit);
								}
								String columnForMeasure = Dbdata.getColumnForMeasure(tempTest,orgMeasure);
								if(columnForMeasureName!=null && columnForMeasure!=null && columnForMeasure.equalsIgnoreCase(columnForMeasureName))
								{
									String nextOrderBy="desc";
									if(orderBy!=null && orderBy.equalsIgnoreCase("desc"))
									{
										nextOrderBy="asc";
									}
									else if(orderBy!=null && orderBy.equalsIgnoreCase("asc"))
									{
										nextOrderBy="desc";
									}
									unitmeasure2.put("SortTypeForCompName",nextOrderBy);
									unitmeasure2.put("SortTypeOrg",nextOrderBy);
								}
								else
								{
									unitmeasure2.put("SortTypeForCompName","desc");
									unitmeasure2.put("SortTypeOrg","desc");
								}

								String orgMeasureColumn = Dbdata.getColumnForMeasure(tempTest,orgMeasure);
								if(orgMeasureColumn==null || orgMeasureColumn.trim().length()==0)
									orgMeasureColumn= orgMeasure;

								unitmeasure2.put("sortByColumn", orgMeasureColumn.trim());
								unitmeasure2.put("textType", "asFloat");
							//unitmeasure2.put("convert", "convertValue");
								unitmeasure2.put("dataIndex", "value"+(i+2));
								//unitmeasure2.put("columnWidth",widthOfTheHead);
								GridHeader.add(unitmeasure2);
							}
						}
	//			 </tr>
						boolean cell_color=false;
						int val0_header_len=-1;
						int val1_header_len=-1;
						for(int j=0;j<egList.size();j++)
						{
							JSONObject gridinfo = new JSONObject();
							
							boolean displayInfo = true;
							EgService eg_service=(EgService)egList.get(j);
							String info_with_component=eg_service.getName();
							String info="";
							State temp_state=eg_service.getState();
							String Component="";
							if(info_with_component!=null && info_with_component.indexOf("^")>-1)
							{
								info=info_with_component.substring(0,info_with_component.lastIndexOf("^"));
								Component=info_with_component.substring(info_with_component.lastIndexOf("^")+1);
							}
							if(poweredOnVMs!=null && poweredOnVMs.equalsIgnoreCase("yes"))
							{
								VmSummaryView view = new VmSummaryView();
								isPoweredOn = view.isVmPoweredOn(info,testName);

								if(isPoweredOn!=null && isPoweredOn.equalsIgnoreCase("off"))
									continue;

								String info_check=info;
								if(info_check!=null)
								{
									info_check=info_check.trim().toLowerCase();
									if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
										continue;
								}
							}
							else if(isTotalVm!=null && isTotalVm.equalsIgnoreCase("yes"))
							{
								String info_check=info;
								
								if(info_check!=null)
								{
									info_check=info_check.trim().toLowerCase();
									if(info_check!=null && (info_check.indexOf("[orphaned]")>-1 || info_check.indexOf("[template]")>-1 || info_check.indexOf("[inaccessible]")>-1))
										continue;
								}

							}
							String comp_type="";
							if(Component!=null && Component.indexOf(":")>-1)
							{
								comp_type=Component.substring(0,Component.indexOf(":"));
							}
							String compName  = Component.substring(Component.indexOf(":")+1);
							String compNameWithoutPort="";
							if(compName!=null && compName.indexOf(":")>-1)
							{
								compNameWithoutPort=compName.substring(0,compName.indexOf(":"));
							}

							int tmp_Val0_Header_Len=0;
							if(info!=null && info.length()>0)
							{
								tmp_Val0_Header_Len=info.length();
							}
							if(tmp_Val0_Header_Len>val0_header_len)
								val0_header_len=tmp_Val0_Header_Len;

							int val0ColumnWith=150;
							if(val0_header_len>15 && val0_header_len<30)
							{
								val0ColumnWith=200;
							}
							else if(val0_header_len>=30)
							{
								val0ColumnWith=250;
							}
							GridHeader.getJSONObject(1).put("colWidth", new Integer(val0ColumnWith));
							

							int tmp_Val1_Header_Len=0;
							if(compNameWithoutPort!=null && compNameWithoutPort.length()>0)
							{
								tmp_Val1_Header_Len=compNameWithoutPort.length();
							}
							if(tmp_Val1_Header_Len>val1_header_len)
								val1_header_len=tmp_Val1_Header_Len;
							

							int val1ColumnWith=100;
							if(val1_header_len>15 && val1_header_len<30)
							{
								val1ColumnWith=150;
							}
							else if(val1_header_len>=30)
							{
								val1ColumnWith=200;
							}
							GridHeader.getJSONObject(2).put("colWidth", new Integer(val1ColumnWith));

							if(onlyVMAssigned || typeIsVM || showInsideView)
							{
								Vmware_esx=(Hashtable)result_hash.get(Component);
								displayInfo = vmDashHelper.getDisplayStatus(info,Vmware_esx,testMeasureList,compNameWithoutPort);
							}
							String compNameType = compName+":"+comp_type;
							String layer_name ="VIRTUAL_SERVERS";
							layer_name=egEx.getValue("VMSearch_InsideviewLayer",comp_type);
							if(layer_name==null || layer_name.trim().length()==0)
							{
								if(comp_type!=null && (comp_type.toLowerCase().indexOf("vdi")>-1 || comp_type.toLowerCase().indexOf("_desktop")>-1))
									layer_name = "VIRTUAL_DESKTOP";
								else
									layer_name = "VIRTUAL_SERVERS";
							}

							String URLinfo =com.egurkha.util.StringUtils.replace(((info==null)?"":info), "\\", "\\\\");

							ArrayList powerd_on_vm_list=new ArrayList();

							String key_for_hash=comp_type+"^eg^"+compName+"^eg^"+layer_name;

							if(state_hash!=null && state_hash.size()>0 && state_hash.containsKey(key_for_hash))
							{
								powerd_on_vm_list=(ArrayList)state_hash.get(key_for_hash);
							}
							else
							{
								VMDesktopBean vmdeskBean=new VMDesktopBean(comp_type,compName,layer_name);
								Valid_info=vmdeskBean.getInfoForTest();
								if(Valid_info!=null && Valid_info.size()>0)
								{
									Enumeration keys=Valid_info.keys();
									while(keys.hasMoreElements())
									{
										String key = (String)keys.nextElement();
										if(!userRole.hasAllComponentAccess())
										{
											if(onlyVMAssigned)
											{
												if(a_userVMs!=null && a_userVMs.size() > 0)
												{

													if(!a_userVMs.contains(key))
													{
														continue;
													}
												}
											}
											else
											{
												if(typeIsVM || parentIsVM)
												{
													if(a_userVMs!=null && a_userVMs.size() > 0)
													{

														if(!a_userVMs.contains(key))
														{
															continue;
														}
													}
												}
											}
										}
										powerd_on_vm_list.add(key.toLowerCase());
									}
								}

								if(powerd_on_vm_list!=null)
								{
									state_hash.put(key_for_hash,(ArrayList)powerd_on_vm_list);
								}
							}
							boolean ifDatastore=false;
							if(!displayInfo)
							{
								continue;
							}
							if(powerd_on_vm_list!=null && powerd_on_vm_list.size()>0 && powerd_on_vm_list.contains(info.toLowerCase()))
							{
								if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
								{
									ifDatastore=true;
								}

//				<tr>
//					<td class="<%=cell_color?"eg_lightlight":""%" id="paddingleft4">
//						<table cellspacing="0" cellpadding="0" border="0" style="height:8px">
//							<tr>
//								<td width="15">

								if(ifDatastore)
								{

//									<img src="/final/monitor/eg_images/data_store_<%=temp_state.getName()%.gif">
										
									//gridinfo.put("state","/final/monitor/eg_images/data_store_"+temp_state.getName()+".gif");
									gridinfo.put("state","data_store_"+temp_state.getName());

								}
								else
								{
									if(info.endsWith("[Template]") || info.endsWith("[template]"))
									{

								//	<img src="/final/monitor/eg_images/template_vm_<%=temp_state.getName()%.gif">
										//gridinfo.put("state","/final/monitor/eg_images/template_vm_"+temp_state.getName()+".gif");
										gridinfo.put("state","template_vm_"+temp_state.getName());
									}
									else if(info.endsWith("[Orphaned]") || info.endsWith("[orphaned]"))
									{

								//	<img src="/final/monitor/eg_images/orphan_vm_<%=temp_state.getName()%.gif">
										//gridinfo.put("state","/final/monitor/eg_images/orphan_vm_"+temp_state.getName()+".gif");
										gridinfo.put("state","orphan_vm_"+temp_state.getName());
									}
									else
									{
										if(!onlyVMAssigned  && (paramValue!=null && paramValue.indexOf(vmType)<0)&& (!parentIsVM))
										{
											if(comp_type!=null && comp_type.equalsIgnoreCase("pSeries_server"))
											{
												if(info!=null&&info.toLowerCase().indexOf("vio")>-1)
												{
	
									//	<img src="/final/monitor/eg_images/vio_<%=temp_state.getName()%.gif">
										
													//gridinfo.put("state","/final/monitor/eg_images/vio_"+temp_state.getName()+".gif");
													gridinfo.put("state","vio_"+temp_state.getName());
	
												}
												else
												{
	
									//	<img src="/final/monitor/eg_images/lpar_<%=temp_state.getName()%.gif">
									
													//gridinfo.put("state","/final/monitor/eg_images/lpar_"+temp_state.getName()+".gif");
													gridinfo.put("state","lpar_"+temp_state.getName());
	
												}
											}
											else
											{
	
									//	<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif">
									
												//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");
												gridinfo.put("state","vm_"+temp_state.getName());
	
											}
										}
										else
										{
											if(onlyVMAssigned && !vmAssigned)
											{

//											<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif">
												//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");
												gridinfo.put("state","vm_"+temp_state.getName());

											}
											else
											{
												if(typeIsVM || parentIsVM || showInsideView)
												{

											//	<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif"
													//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");
													gridinfo.put("state","vm_"+temp_state.getName());
												}
											}
										}
									}
								}

						//		 </td>
						
								String test_str=null;
								String temp_layer=null;
								if(comp_type!=null)
								{
									test_str=ui.getValue("Test_for_ComponentType",comp_type_value);
									temp_layer=ui.getValue("Layer_for_ComponentType",comp_type_value);
								}
							
								if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
								{
									temp_layer=ui.getValue("DATASTORE_LAYER",comp_type);
									String iniValue=ui.getValue("DATASTORE",comp_type);
									if(iniValue!=null && iniValue.trim().length()>0)
									{
										StringTokenizer st=new StringTokenizer(iniValue.trim(),",");
										if(st.hasMoreElements())
										{
											String test_with_measure=st.nextToken();
											if(test_with_measure!=null && test_with_measure.indexOf(":")>-1)
											{
												String test_only=test_with_measure.substring(0,test_with_measure.indexOf(":"));
												if(test_only!=null && test_only.trim().length()>0)
												{
													test_str=test_only;
													ifDatastore=true;
												}
											}
										}
									}
								}
								
//								<td style="padding-left:5px"><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToVmMeasures('../monitor/egInsideviewDashboard.jsp?getFor=measure&comp=<%=EgURLEncoder.encode(compName,"UTF-8")%&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&Layer=<%=layer_name%&info=<%=EgURLEncoder.encode(URLinfo,"UTF-8")%&compName=<%=EgURLEncoder.encode(compNameType,"UTF-8")%&componentName=<%=compNameWithoutPort%&isFromVmDashboard=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%&isVM=<%=isVM%&source=MainDashboard');">

								
								if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes") && paramValue!=null && (paramValue.startsWith("DATACENTER^") || paramValue.startsWith("FOLDER^")))
								{
									String infoForDisp = "";
									if(info!=null && info.trim().length()>0 && !info.equalsIgnoreCase("NULL") && info.lastIndexOf("/")>-1)
										infoForDisp = info.substring(info.lastIndexOf("/")+1);
									if(infoForDisp!=null && infoForDisp.indexOf("::")>-1)
									{
										//out.println(info.substring(info.indexOf("::")+2));
										gridinfo.put("value0",infoForDisp.substring(infoForDisp.indexOf("::")+2));	
									}
									else //out.println(info);
										gridinfo.put("value0",infoForDisp);
								}
								else
								{
									//out.println(info);
									gridinfo.put("value0",info);
								}
								gridinfo.put("value0_url","/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&Layer="+layer_name+"&info="+EgURLEncoder.encode(URLinfo,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameType,"UTF-8")+"&componentName="+compNameWithoutPort+"&isFromVmDashboard=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&isVM="+isVM+"&source=MainDashboard&check="+check+"&from="+from+"&stateName="+stateName+"&isOnlyVmCase="+isOnlyVmCase);

//								</a>
//								</td>
//							</tr>
//						</table>
//					</td>

							}
							else
							{
								if(typeIsVM)
								{
									if(a_userVMs!=null && a_userVMs.size() > 0)
									{
										if(!a_userVMs.contains(info))
										{
											continue;
										}
									}
								}
								String test_str=null;
								String temp_layer=null;
								if(comp_type!=null)
								{
									test_str=ui.getValue("Test_for_ComponentType",comp_type_value);
									temp_layer=ui.getValue("Layer_for_ComponentType",comp_type_value);
								}
							
								if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
								{
									temp_layer=ui.getValue("DATASTORE_LAYER",comp_type);
									String iniValue=ui.getValue("DATASTORE",comp_type);
									if(iniValue!=null && iniValue.trim().length()>0)
									{
										StringTokenizer st=new StringTokenizer(iniValue.trim(),",");
										if(st.hasMoreElements())
										{
											String test_with_measure=st.nextToken();
											if(test_with_measure!=null && test_with_measure.indexOf(":")>-1)
											{
												String test_only=test_with_measure.substring(0,test_with_measure.indexOf(":"));
												if(test_only!=null && test_only.trim().length()>0)
												{
													test_str=test_only;
													ifDatastore=true;
												}
											}
										}
									}
								}

	//			<tr>
	//			<td class="<%=cell_color?"eg_lightlight":""%" id="paddingleft4">
	//					<table cellspacing="0" cellpadding="0" border="0" style="height:8px">
	//						<tr>
	//							<td width="15">

								if(ifDatastore)
								{

								//	<img src="/final/monitor/eg_images/data_store_<%=temp_state.getName()%.gif">
								
									//gridinfo.put("state","/final/monitor/eg_images/data_store_"+temp_state.getName()+".gif");
									gridinfo.put("state","data_store_"+temp_state.getName());

								}
								else
								{
									if(info.endsWith("[Template]") || info.endsWith("[template]"))
									{

								//	<img src="/final/monitor/eg_images/template_vm_<%=temp_state.getName()%.gif">
								
										//gridinfo.put("state","/final/monitor/eg_images/template_vm_"+temp_state.getName()+".gif");
										gridinfo.put("state","template_vm_"+temp_state.getName());

									}
									else if(info.endsWith("[Orphaned]") || info.endsWith("[orphaned]"))
									{
								//	<img src="/final/monitor/eg_images/orphan_vm_<%=temp_state.getName()%.gif">
										//gridinfo.put("state","/final/monitor/eg_images/orphan_vm_"+temp_state.getName()+".gif");
										gridinfo.put("state","orphan_vm_"+temp_state.getName());

									}
									else
									{
										if(info!=null&&info.toLowerCase().indexOf("vio")>-1)
										{

								//	<img src="/final/monitor/eg_images/vio_<%=temp_state.getName()%.gif">
								
											//gridinfo.put("state","/final/monitor/eg_images/vio_"+temp_state.getName()+".gif");
											gridinfo.put("state","vio_"+temp_state.getName());
										}
										else
										{

								//	<img src="/final/monitor/eg_images/vm_<%=temp_state.getName()%.gif">
											//gridinfo.put("state","/final/monitor/eg_images/vm_"+temp_state.getName()+".gif");	
											gridinfo.put("state","vm_"+temp_state.getName());	

										}
									}
								}
							
//								</td>
//								<td style="padding-left:5px">
								if(!onlyVMAssigned  && (paramValue!=null && paramValue.indexOf(vmType)<0)&& (!parentIsVM))
								{
									if(showInsideView && !userRole.hasAllComponentAccess())
									{
										gridinfo.put("value0_url","/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&Layer="+layer_name+"&info="+EgURLEncoder.encode(URLinfo,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameType,"UTF-8")+"&componentName="+compNameWithoutPort+"&isFromVmDashboard=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&isVM="+isVM+"&source=MainDashboard&check="+check+"&from="+from+"&stateName="+stateName+"&isOnlyVmCase="+isOnlyVmCase);
//										<td style="padding-left:5px"><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToVmMeasures('../monitor/egInsideviewDashboard.jsp?getFor=measure&comp=<%=EgURLEncoder.encode(compName,"UTF-8")%&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&Layer=<%=layer_name%&info=<%=EgURLEncoder.encode(URLinfo,"UTF-8")%&compName=<%=EgURLEncoder.encode(compNameType,"UTF-8")%&componentName=<%=compNameWithoutPort%&isFromVmDashboard=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%&isVM=<%=isVM%&source=MainDashboard');">
									}
									else
									{
										//	<a class="eg_monlink"	href="javascript:void(0);" onClick="javascript:return goToLayerModel('/final/monitor/EgSiteInfraView.jsp?site=NULL&qctr=2&fromalarm=1&fromPage=vm&newWindow=false&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&host=<%=EgURLEncoder.encode(compName,"UTF-8")%&layer=<%=EgURLEncoder.encode(temp_layer,"UTF-8")%&test=<%=EgURLEncoder.encode(test_str,"UTF-8")%-<%=EgURLEncoder.encode(info,"UTF-8")%&msmt_host=&isFromVmHost=true&gotoLayerModel=true&tab=LayerModel&toDashBoardLayer=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&tstate=<%=temp_state%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%');">
										gridinfo.put("value0_urlToLayers",new Boolean(true));
										gridinfo.put("value0_url","/final/monitor/EgSiteInfraView.jsp?site=NULL&qctr=2&fromalarm=1&fromPage=vm&newWindow=false&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&layer="+EgURLEncoder.encode(temp_layer,"UTF-8")+"&test="+EgURLEncoder.encode(test_str,"UTF-8")+"-"+EgURLEncoder.encode(info,"UTF-8")+"&msmt_host=&isFromVmHost=true&gotoLayerModel=true&tab=LayerModel&toDashBoardLayer=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&tstate="+temp_state+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8"));
									}
								}
								else
								{
									gridinfo.put("value0_url","/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&Layer="+layer_name+"&info="+EgURLEncoder.encode(URLinfo,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameType,"UTF-8")+"&componentName="+compNameWithoutPort+"&isFromVmDashboard=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&isVM="+isVM+"&source=MainDashboard&check="+check+"&from="+from+"&stateName="+stateName+"&isOnlyVmCase="+isOnlyVmCase);
	//<td style="padding-left:5px"><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToVmMeasures('../monitor/egInsideviewDashboard.jsp?getFor=measure&comp=<%=EgURLEncoder.encode(compName,"UTF-8")%&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&Layer=<%=layer_name%&info=<%=EgURLEncoder.encode(URLinfo,"UTF-8")%&compName=<%=EgURLEncoder.encode(compNameType,"UTF-8")%&componentName=<%=compNameWithoutPort%&isFromVmDashboard=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%&isVM=<%=isVM%&source=MainDashboard');">

								}
								if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes") && paramValue!=null && (paramValue.startsWith("DATACENTER^") || paramValue.startsWith("FOLDER^")))
								{
									String infoForDisp = "";
									if(info!=null && info.trim().length()>0 && !info.equalsIgnoreCase("NULL") && info.lastIndexOf("/")>-1)
										infoForDisp = info.substring(info.lastIndexOf("/")+1);
									if(infoForDisp!=null && infoForDisp.indexOf("::")>-1)
									{
		//							out.println(info.substring(info.indexOf("::")+2));
										gridinfo.put("value0",infoForDisp.substring(infoForDisp.indexOf("::")+2));
									}
									else //out.println(info);
										gridinfo.put("value0",infoForDisp);
								
								}
								else
								{
								//out.println(info);
									gridinfo.put("value0",info);
								}

//								</a>
//								</td>
//							</tr>
//						</table>
//					</td>

							}
						
							if(isDatastoreTab==null || (isDatastoreTab!=null && !isDatastoreTab.equalsIgnoreCase("Yes")))
							{
								int inx=1;
								if(!onlyVMAssigned && (paramValue!=null && paramValue.indexOf(vmType)<0)&& (!parentIsVM) && displayInfo)
								{
									if(showInsideView && !userRole.hasAllComponentAccess())
									{

//do this									<td id="paddingleft4" class="<%=cell_color?"eg_lightlight":""%" ><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToVmMeasures('../monitor/egInsideviewDashboard.jsp?getFor=measure&comp=<%=EgURLEncoder.encode(compName,"UTF-8")%&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&Layer=<%=layer_name%&info=<%=EgURLEncoder.encode(URLinfo,"UTF-8")%&compName=<%=EgURLEncoder.encode(compNameType,"UTF-8")%&componentName=<%=compNameWithoutPort%&isFromVmDashboard=true&isTotalVm=<%=isTotalVm%&poweredOnVMs=<%=poweredOnVMs%&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%&isVM=<%=isVM%&source=MainDashboard');"><%=compNameWithoutPort% </a></td>
										gridinfo.put("value"+(inx),compNameWithoutPort);
										gridinfo.put("value"+(inx)+"_url","/final/monitor/egInsideviewDashboard.jsp?getFor=measure&comp="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&Layer="+layer_name+"&info="+EgURLEncoder.encode(URLinfo,"UTF-8")+"&compName="+EgURLEncoder.encode(compNameType,"UTF-8")+"&componentName="+compNameWithoutPort+"&isFromVmDashboard=true&isTotalVm="+isTotalVm+"&poweredOnVMs="+poweredOnVMs+"&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&isVM="+isVM+"&source=MainDashboard&check="+check+"&from="+from+"&stateName="+stateName+"&isOnlyVmCase="+isOnlyVmCase);

									}
									else
									{

//					<td id="paddingleft4" class="<%=cell_color?"eg_lightlight":""%" ><a class="eg_monlink" href="javascript:void(0);" onClick="javascript:return goToLayerModel('../servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=vm&newWindow=false&comptype=<%=EgURLEncoder.encode(comp_type,"UTF-8")%&host=<%=EgURLEncoder.encode(compName,"UTF-8")%&isFromVmHost=true&priority=<%=EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")%');"> <%=compNameWithoutPort% </a>
										gridinfo.put("value"+(inx),compNameWithoutPort);
										gridinfo.put("value"+(inx)+"_urlToLayers", new Boolean(true));
										gridinfo.put("value"+(inx)+"_url","../servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=vm&newWindow=false&comptype="+EgURLEncoder.encode(comp_type,"UTF-8")+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&isFromVmHost=true&priority="+EgURLEncoder.encode(noOfInfoToDisplay,"UTF-8")+"&monCmdComeFrom="+monCmdComeFrom);
//					</td>

									}
								}
							}
						//GridData.add(gridinfo);
							Vmware_esx=(Hashtable)result_hash.get(Component);

							if(Vmware_esx!=null && Vmware_esx.size()>0)
							{
								int p=0;
								String info_to_lower=info.toLowerCase();
								while(p<testMeasureList.size())
								{
									//JSONObject gridinfo2 = new JSONObject();
									
									String keyForList=(String)testMeasureList.get(p);
									String keyMeasure="";
									String keyTest="";
									String keydisplayMeasure="";
									if(keyForList!=null && keyForList.indexOf(":")>-1)
									{
										keyTest=keyForList.substring(0,keyForList.indexOf(":"));
										keyMeasure=keyForList.substring(keyForList.indexOf(":")+1);
										if(keyMeasure!=null && keyMeasure.indexOf(":")>-1)
										{
											keydisplayMeasure=keyMeasure.substring(keyMeasure.indexOf(":")+1);
											keyMeasure=keyMeasure.substring(0,keyMeasure.indexOf(":"));
										}
									}
									String units=tablesInfo.getUnitForMeasure(keyTest,keyMeasure);

									keyMeasure = Dbdata.getColumnForMeasure(keyTest,keyMeasure);
									String Value=(String)Vmware_esx.get(keyMeasure+"^"+info_to_lower+"^"+compNameWithoutPort);
									String mes_state="";
									String mes_name="";
									String total_spc="0";
									if(Value!=null && Value.indexOf("^")>-1)
									{
										mes_state=Value.substring(Value.indexOf("^")+1);
										if(mes_state!=null && mes_state.indexOf("^")>-1)
										{
											mes_name=mes_state.substring(mes_state.indexOf("^")+1);
											mes_state=mes_state.substring(0,mes_state.indexOf("^"));
											if(mes_name!=null && mes_name.indexOf("^")>-1)
											{
												total_spc=mes_name.substring(mes_name.indexOf("^")+1);
												mes_name=mes_name.substring(0,mes_name.indexOf("^"));
											}
										}
										Value=Value.substring(0,Value.indexOf("^"));
									}
									else if(Value==null)
									{
										Value="-";
										mes_name=keyMeasure;
										mes_state="GOOD";
									}
									widthOfTheHead="60";
									if(units!=null && units.equals("%") || units.equalsIgnoreCase("Percent"))
										widthOfTheHead="150";
									
									String orgValue="0.0";
									try
									{
										if(Value!=null && Value.trim().length()>0 && Value.indexOf(".")>-1 && Double.parseDouble(Value)>0)
										{
											orgValue=Value;
											Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));
											Value=String.valueOf(Value);
										}
										else if(Value!=null && Value.trim().length()>0  && Double.parseDouble(Value)>0)
										{
											orgValue=Value;
											Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));
											Value=String.valueOf(Value);
										}
									}
									catch(Exception ee)
									{
										Value=Value;
									}
									if(mes_state!=null && mes_state.length()>0 && mes_state.equalsIgnoreCase("NONE"))
									{
										mes_state="GOOD";
									}
									else if(mes_state!=null && mes_state.trim().length()==0)
									{
										mes_state="GOOD";
									}
									if(displayInfo)
									{
										if(Value.equalsIgnoreCase("on"))
										{
 
			//		<td align="center" id="padding3" class="<%=cell_color?"eg_lightlight":""%"><img  src="/final/monitor/eg_images/yes2.gif"></td> 
				
											gridinfo.put("value"+(p+2)+"_image", "iconPoweredOn");

										}
										else if(Value.equalsIgnoreCase("off"))
										{

				//		<td align="center" id="padding3" class="<%=cell_color?"eg_lightlight":""%"><img  src="/final/monitor/eg_images/no2.gif"></td>
				
											gridinfo.put("value"+(p+2)+"_image","iconPoweredOff");

										}
										else
										{
											if(mes_name!=null)
											{
												if(Value!=null && !Value.equals("-"))
												{
													double fillColorValue=Double.parseDouble(orgValue);
													if(units!=null && units.equals("MB"))
													{
														//units = "GB";
														fillColorValue=fillColorValue/1024.0;
													}
													Value=String.valueOf(fillColorValue);
													Value=String.valueOf(com.egurkha.util.MathUtils.round(Double.parseDouble(Value),2));

//					<td  align="left" class="<%=cell_color?"eg_lightlight":""%"id="paddingright4">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="right" style="padding-left:2px;width:40px;padding-right:2px">

												}
												else
												{

//					<td  align="left" class="<%=cell_color?"eg_lightlight":""%"id="paddingright4">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="left" style="padding-left:20px">

												}
											}
											else
											{

//					<td  align="right" class="<%=cell_color?"eg_lightlight":""%" id="paddingright6">
//						<table cellspacing="0" cellpadding="0" border="0" style="table-layout:auto;" >
//							<tr>
//								<td align="right" style="padding-right:2px">

											}
											if(units!=null && units.equalsIgnoreCase("Number"))
											{
												if(Value!=null && !Value.equals("-") && Value.indexOf(".")>0)
												{
												//Value=Value.substring(0,Value.indexOf("."));
												}
											}

//		 						<%=Value%</td>
											if(Value.equals("-"))
												Value="-";
											gridinfo.put("value"+(p+2),formatDbValue(Value));

//								<td height="8">

											if(Value!=null && !Value.equals("-"))
											{
												boolean usage =true;
												if(mes_name!=null && mes_name.equalsIgnoreCase("Cpu_used"))
												{
													usage = false;

													int columnWidth = 100;
													Long temp_measure_value=new Long(Math.round(Double.parseDouble(Value)));
													long fillColorValue=temp_measure_value.longValue();
													long value1 = (fillColorValue*100)/columnWidth;
													if(fillColorValue >=0)
													{

//									<table width="80" cellpadding="0" cellspacing="0" border="0"  height="8" class="prog_border">
//										<tr>
//											<td align="left" width="100%" height="8" class="prog_line" >
//												<table width="<%=value1%%" height="8"  cellpadding="0" cellspacing="0" border="0">
//													<tr>
//														<td class ="progress_<%=mes_state%" width="100%"> </td>
														gridinfo.put("value"+(p+2)+"_progress",value1);

//													</tr>
//												</table>
//											</td>
//										</tr>
//									</table>
													}
												}
												else if(units!=null && (units.equals("%") || units.equalsIgnoreCase("Percent"))&&!mes_name.equalsIgnoreCase("Ready")&&usage)
												{
													int columnWidth = 100;
													Long temp_measure_value=new Long(Math.round(Double.parseDouble(Value)));
													long fillColorValue=temp_measure_value.longValue();
													long value2 = (fillColorValue*100)/columnWidth;
													if(fillColorValue >=0)
													{

//									<table width="80" cellpadding="0" cellspacing="0" border="0"  height="8" class="prog_border">
//										<tr>
//											<td align="left" width="100%" height="8px" class="prog_line" >
//												<table width="<%=value2%%" height="8" cellpadding="0" cellspacing="0" border="0">
//													<tr>
//														<td class ="progress_<%=mes_state%" width="100%"></td>
														gridinfo.put("value"+(p+2)+"_progress",value2);
//													</tr>
//												</table>
//											</td>
//										</tr>
//									</table>

													}
												}
											}
									//else  out.println("&nbsp;");

//								</td>
//							</tr>
//						</table>
//					</td>
										}
									}
									p++;
								//GridData.add(gridinfo);
								}
							}
							else
							{
								int p=0;
								while(p<testMeasureList.size())
								{
									//JSONObject gridinfo2 = new JSONObject();
									if(displayInfo)
									{
					//<td align="center" class="<%=cell_color?"eg_lightlight":""%">&nbsp;-</td> 
									gridinfo.put("value"+(p+2),"-");	
									}
									p++;
								
								}
							}
							GridData.add(gridinfo);
//			 	</tr>
							if(cell_color)
							{
								cell_color=false;
							}
							else
							{
								cell_color=true;
							}
						}
//			</table>
					}
					else
					{
						int col_span=testMeasureList.size();

	//		<table border="0" width="100%" height="100%" bordercolor="green">
	//			<tr>
	//				<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%">
	//					<img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>
	//					<br><egui:intnl text='monitor.VirtualDashboard.No Data found'/>
	
						json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Data found"));
	
	//				</td>
	//			</tr>
	//		</table>

					}
				}
				else if(paramValue!=null && paramValue.indexOf("NOTMANAGED")>-1)
				{
					int col_span=testMeasureList.size();

//			<table border="0" width="100%" height="100%" bordercolor="blue">
//				<tr>
//					<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%">
//						<img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>
//						<br><egui:intnl text='monitor.VirtualDashboard.Currently We are not managing this Host'/>

					json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.Currently We are not managing this Host"));
//					</td>
//				</tr>
//			</table>

				}
				else
				{
					int col_span=testMeasureList.size();

//			<table border="0" width="100%" height="100%" bordercolor="red">
//				<tr>
//					<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%"><img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>

					if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
					{

						//<br><egui:intnl text='monitor.VirtualDashboard.No Datastore metrics found'/>
						
						json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Datastore metrics found"));

					}
					else
					{

					//	<br><egui:intnl text='monitor.VirtualDashboard.No Virtual Machine metrics found'/>
						json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Virtual Machine metrics found"));

					}

//					</td>
//				</tr>
//			</table>
				}
				if(comp_type_list.size() > 1){
					gr_obj.put("countJson",countJson);
					gr_obj.put("comp_type",comp_type_value);
					gr_obj.put("headers",GridHeader);
					gr_obj.put("items",GridData);
					gridArray.add(gr_obj);
				}
			}
		}
		else if(paramValue!=null && paramValue.indexOf("NOTMANAGED")>-1)
		{
			if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
			{
				testMeasureList=vmDashHelper.getVmHostTestWithMeasures("DATASTORE",paramValue+"^DSTab");
			}
			else
			{
				testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",paramValue);
			}

			int col_span=testMeasureList.size();

		//	<table border="0" width="100%" height="100%">
		//		<tr>
		//			<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%">
		//				<img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>
		//			<br><egui:intnl text='monitor.VirtualDashboard.Currently We are not managing this Host'/>
		
			json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.Currently We are not managing this Host"));		
		
		//			</td>
		//		</tr>
		//	</table>
		}
		else
		{
			if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
			{
				testMeasureList=vmDashHelper.getVmHostTestWithMeasures("DATASTORE",paramValue+"^DSTab");
			}
			else
			{
				testMeasureList=vmDashHelper.getVmHostTestWithMeasures("VM_GUEST",paramValue);
			}

			int col_span=testMeasureList.size();

//			<table border="0" width="100%" height="100%" bordercolor="orange">
//				<tr>
//					<td align="center" id="eg_errorsmall" width="100%" colspan="<%=col_span%" height="100%"><img src = "../monitor/eg_images/<%=monitor_Skin%/exclamation-icon.gif" align = "center" border = "0"  vspace = "10"/>

			if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes"))
			{

					//		<br><egui:intnl text='monitor.VirtualDashboard.No Datastore metrics found'/>
				json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Datastore metrics found"));

			}
			else
			{

	//						<br><egui:intnl text='monitor.VirtualDashboard.No Virtual Machine metrics found'/>
				json.put("error",mappingInfo.getTextDescription("monitor.VirtualDashboard.No Virtual Machine metrics found"));

			}

	//			</td>
	//			</tr>
	//		</table>
		}
	}

	//	</td>
//	</tr>
//</table>
	if(!paramValue.equalsIgnoreCase("Virtual_center") && paramValue.indexOf("Virtual_center")<0 && !cmpTypeValue.equalsIgnoreCase("Virtual_center"))
	{
		json.put("isGridComboHide",true);
	}
	else if(paramValue.equalsIgnoreCase("Virtual_center") || paramValue.indexOf("Virtual_center")>0 || cmpTypeValue.equalsIgnoreCase("Virtual_center"))
		json.put("isGridComboHide",false);
	json.put("groupingGrid",true);
	//json.put("columns",GridHeader);
	json.put("measures",GridData);
	json.put("countJson",countJson);
	json.put("isDataAvail",true); 
	json.put("gridComboArray",gr_com_obj);
	json.put("headers",GridHeader);
	json.put("items",GridData);
	json.put("gridArray",gridArray);
	if(isDatastoreTab!=null && isDatastoreTab.equalsIgnoreCase("Yes")){
		json.put("title",mappingInfo.getTextDescription("monitor.VirtualDashboard.Datastore Details"));
	} else {
		json.put("title",mappingInfo.getTextDescription("monitor.VirtualDashboard.Virtual Machine Details"));
	}
	response.getWriter().write(json.toString());

%>

<%!
	private static DecimalFormat df = (DecimalFormat)NumberFormat.getNumberInstance();
	static{
        DecimalFormatSymbols dfs = new DecimalFormatSymbols();
        dfs.setDecimalSeparator('.');

        df.applyPattern("#.##");
        df.setDecimalFormatSymbols(dfs);
        df.setGroupingSize(0);
	}

	private static DecimalFormat df2 = (DecimalFormat)NumberFormat.getNumberInstance();
	static{
        DecimalFormatSymbols dfs2 = new DecimalFormatSymbols();
        dfs2.setDecimalSeparator('.');

        df2.applyPattern("#.####");
        df2.setDecimalFormatSymbols(dfs2);
        df2.setGroupingSize(0);
	}

	private static DecimalFormat df3 = (DecimalFormat)NumberFormat.getNumberInstance();
	static{
        DecimalFormatSymbols dfs3 = new DecimalFormatSymbols();
        dfs3.setDecimalSeparator('.');

        df3.applyPattern("#");
        df3.setDecimalFormatSymbols(dfs3);
        df3.setGroupingSize(0);
	}

	public static String formatDbValue(String measure)
	{
		String value="";
		try
		{
			/*
				* Check the indexOf "e", For avoid Exponent or Scientific Notation in a String, 
				Because of Address and other String field changed like double data type value
				when we use Double.parseDouble, Its wrong, So put this fix.

				* The real double value not affected because of this change. its shown as per db..

				* changed by Saravanan.A on 31-1-2012.
			*/

			/*
				* Double parsing have problem when double value range exceed, So used BigDecimal instead of Double parsing.

				* changed by Saravanan.A on 15-2-2012.
			*/

			String measure_lower=null;
			if(measure!=null && measure.length()>0)
				measure_lower=measure.toLowerCase().trim();
			
			if(measure_lower!=null && measure_lower.indexOf("e")>-1)
			{
				value=measure;
			}
			else
			{
				//double val=Double.parseDouble(measure);
				//value = df.format(val);

				BigDecimal bigDecRef = new BigDecimal(measure);
				value = df.format(bigDecRef);
				double xxx=bigDecRef.doubleValue();
				if(xxx>=100.0)
				{
					value = df3.format(bigDecRef);
				}
				else if(xxx>=1 && xxx<100)
				{
					value = df.format(bigDecRef);
				}

			}
		}catch(Exception e)
		{
			value=measure;
		}
		return value;
	}

%>
