<%
/********************************************************************************************************
*	Name			:	comparisonComponent.jsp
*	Version			:	6.2
*	CreationDate	:	May 30 2016
*	Author			:	Saranya.N
*******************************************************************************************************/
%>
<%@ include file = "EgMonitorTracker.jsp" %>
<%@ taglib prefix = "egui" uri = "../WEB-INF/eg-taglib.tld"%>
<%@ page import = "com.egurkha.ini.IniUI"%>
<%@ page import = "com.egurkha.*"%>
<%@ page import = "com.eg.*"%>
<%@ page import = "com.egurkha.util.*" %>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ page import = "com.egurkha.monitor.VmDashboardHelper"%>
<%@ page import = "com.egurkha.monitor.ServicesDashboardBean"%>
<%@ page import = "com.egurkha.User"%>
<%@ page import = "com.egurkha.UserRegistry"%>
<%@ page import = "java.text.DecimalFormat"%> 
<%@ page import = "java.util.Enumeration"%>
<%@ page import="com.eg.EgURLEncoder" %>
<%@ page import="net.sf.json.*"%>
<%@page import = "java.util.*"%>
<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "com.eg.supermanager.*" %>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import="com.egurkha.util.EgSorter"%>
<%@ page import="com.eg.EgExternalInfo"%>
<%@ page import = "egurkha.reporter.ErUserData"%>
<%@ page import = "com.egurkha.monitor.alarms.AlarmPriorities"%>
<%@ page import="com.egurkha.admin.EgMaintenanceUtility"%>
<%@ page import = "com.eg.EgConfigChangeThread"%>
<%!
	public List getUserAssociateSubZones(List zoneList)
	{
		EgGroupInfo groupInfo = new EgGroupInfo();
		List result=new ArrayList();
		if(zoneList!=null && zoneList.size()>0)
		{
			ArrayList tempZones=new ArrayList(zoneList);
			boolean isTrue=true;
			for(int i=0;i<tempZones.size();i++)
			{
				String tempZone =(String)tempZones.get(i);
				ArrayList subZones=(ArrayList)groupInfo.getSubZoneList(tempZone,false,isTrue);

				if(isTrue)
					isTrue = false;

				result.addAll(subZones);
			}
			result=ListUtils.removeDuplicates(result);
		}
		return result;
	}
%>
<%
String compType = "";
try
{
	if(EgInstallInfo.isSuperManager)
	{
		String currentSession = session.getId();
		String selected_Param = request.getParameter("selectedParam");
		if(selected_Param != null && (selected_Param=selected_Param.trim()).length()>0)
		{
			ArrayList managerIDs = EgElementInfo.getInstance().getManagerIDs("service",selected_Param);
			if(managerIDs != null && !managerIDs.isEmpty())
			{
				SmSessionData smsData = new SmSessionData(currentSession,managerIDs);
				EgThreadLocal egtl = new EgThreadLocal();
				egtl.set(smsData);
				new SMDateTimeConverter(managerIDs);
			}
		}
	}
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader ("Expires", -1);
	response.setContentType("application/json");
	request.setCharacterEncoding("UTF-8");

	String smeasure="";
	boolean resconsumIconEnabled=false;
	String stest="";
	String key = "";
	
	String compName = "";
	String compState = "";
	String dispComp = "";
	String url = "";
	String Measureurl = "";
	String site = "";
	String sdispName="";
	String testMeasure[] = null;
	String measureValue="";
	String dbMeasure = "";
	int colCount = 0;
	boolean cell_color=false;
	String compTest="";
	String compMeasure="";
	String CompDispName="";
	String widthOfTheHead="";
	String dbMeasureName="";
	String displayUnit="";
	String unitMeasure="";
	Enumeration e = null;
	String hostNameToken[]=null;
	String hostName = "";
	String hostPort  = "";
	String msmtHost = "";
	String db_Measureandtest="";
	EgDbInfo dbInfo = new EgDbInfo("manager");
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	EgExternalInfo egExternalInfo=new EgExternalInfo("manager");
	EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
	EgDiscInfo discInfo = new EgDiscInfo("manager");
	AlarmPriorities ap = AlarmPriorities.getInstance();

	EgDateInfo dateInfo=new EgDateInfo();
	EgMaintenanceInfo egM=new EgMaintenanceInfo("manager");
	EgMaintenanceUtility maintenanceUtil=new EgMaintenanceUtility();

	int pages=0;
	int totalRecords=10000;
	int totalRecordsCount=0;
	int recount=0;
	int pagesizec=0;
	int pageSize = 0;
	ErUserData userData=null;
	boolean isComponent = true;
	
	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());
	User er_user = null;
	String uiFile = "eg_ui.ini";
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	com.eg.IniFile iniFilefornet = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_infrastructure.ini", false);
	com.eg.IniFile iniDashboardCon = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_dashboardConfig.ini", false);

	com.eg.IniFile enduserIni = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_endUserDetails.ini", false);

	com.eg.IniFile iniMsDashboard = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_msdashboard.ini", false);

	ArrayList msCompList= new ArrayList();
	Hashtable msDashboardLinkHash = new Hashtable();

	boolean isRedirectUrlpresent = false;
	String msCompListStr = (String)iniDashboardCon.getValue("URL_TO_DASHBOARD","Component_Type_List");
	if(msCompListStr != null && msCompListStr.trim().length()>0)
	{
		msCompList = StringUtils.egTokenizer(msCompListStr,",",true,false,true);
		for(int i=0;i<msCompList.size();i++)
		{
			String compTypeStr = (String)msCompList.get(i);
			String redirectUrl = iniDashboardCon.getValue("InfraDashboard_compType_redirectURL",compTypeStr);
			if(redirectUrl != null && redirectUrl.trim().length()>0)
			{
				msDashboardLinkHash.put(compTypeStr,redirectUrl);
			}
		}

		if(msDashboardLinkHash.size()>0)
			isRedirectUrlpresent = true;
	}

	String endUserIniEntry[]=enduserIni.getVariables("USER_TYPE_COMPONENTS");
	String skipUserTypeEntry[]=enduserIni.getVariables("SKIP_USERTYPE_UED_MENU");
	String skip_type_str = (String)enduserIni.getValue("SKIP_RESOURCE_ANALYSIS_LINK_IN_METRICS_VIEW","Types");
	ArrayList skip_ra_list = new ArrayList();
	if(skip_type_str!=null && skip_type_str.trim().length()>0)
		skip_ra_list = StringUtils.egTokenizer(skip_type_str,",",false,true,true);

	List skipUserTypeList = null;
	if(skipUserTypeEntry!=null && skipUserTypeEntry.length>0)
		skipUserTypeList = Arrays.asList(skipUserTypeEntry);
	Hashtable endUserLinkHash = new Hashtable();
	if(endUserIniEntry != null && endUserIniEntry.length > 0){
		for(int k=0;k<endUserIniEntry.length;k++){
			String el = endUserIniEntry[k];
			//if(el == null || el.trim().length() == 0 || el.equalsIgnoreCase("Terminal") )
			if(el == null || el.trim().length() == 0 || el.startsWith("App") || el.startsWith("CitrixXenVDI") || el.startsWith("VDIESX") || (skipUserTypeList!=null && skipUserTypeList.contains(el)))
				continue;
			String elLits = (String)enduserIni.getValue("USER_TYPE_COMPONENTS",el);
			ArrayList tmpMeasureList = new ArrayList(); 
			tmpMeasureList = StringUtils.egTokenizer(elLits,",",true,false,true);//param 3-->includeEmpty,4-->unique,5-->trim
			if(tmpMeasureList!=null && tmpMeasureList.size()>0){
				for(int l=0;l<tmpMeasureList.size();l++)
				{
					String comp_type_new=(String)tmpMeasureList.get(l);
					if(comp_type_new!=null && (skip_ra_list==null || skip_ra_list.size()==0 || !skip_ra_list.contains(comp_type_new)))
						endUserLinkHash.put(comp_type_new,el);
				}
			}
			
		}
	}

	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	//String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	com.eg.IniFile egDashConfig = new com.eg.IniFile(s_iniFile_dir+"eg_dashboardConfig.ini");
	String Default_Pagesize=egDashConfig.getValue("TREE_SYSTEM_SETTINGS","Default_Pagesize");
	Default_Pagesize=(Default_Pagesize==null || Default_Pagesize.trim().length()==0)?"10":Default_Pagesize;
	pageSize=Integer.parseInt(Default_Pagesize.trim());

	EgName nameObj1 = null;
	ServicesDashboardBean serviceBean = new ServicesDashboardBean();
	String subj="TREE_APPLICATION";
	//String subj="COMPARISON_APPLICATION";

	String selectedParam=request.getParameter("selectedParam");
	String selectedNode=request.getParameter("selectedParam");

	String treeTitle = request.getParameter("treeTitle");
	treeTitle=(treeTitle==null || treeTitle.trim().length()==0)?"Component":treeTitle;
	String filterBy = request.getParameter("filterBy");
	filterBy=(filterBy==null)?treeTitle:filterBy;
	if(filterBy!=null && filterBy.equalsIgnoreCase("Components"))
	{
		filterBy="Component";
	}
	String subFilter = request.getParameter("subFilter");
	subFilter=(subFilter==null)?"":subFilter;
	String componentType=request.getParameter("componentType");
	componentType=(componentType==null)?"":componentType;

	String componentNameSearch = request.getParameter("componentNameSearch");
	componentNameSearch=(componentNameSearch==null)?"":componentNameSearch;
	if(componentNameSearch!=null && componentNameSearch.trim().length()>0)
	{
		componentNameSearch=com.egurkha.util.StringUtils.decodeSecurityChar(componentNameSearch);
	}
	String measure_sort=request.getParameter("appcolumn");
	measure_sort=(measure_sort==null)?"":measure_sort;
	String sort_type=request.getParameter("appsortOrder");
	sort_type=(sort_type==null)?"":sort_type;
	String selectedState=request.getParameter("selectedState");
	selectedState = (selectedState==null||selectedState.trim().length()==0||selectedState.equalsIgnoreCase("null")||selectedState.equalsIgnoreCase("undefined"))?"":selectedState;
	String imageId=request.getParameter("appimgId");
	String fromPageView=request.getParameter("fromPageView");
	fromPageView=(fromPageView==null)?"Menu":fromPageView;
	String viewPageTitle=request.getParameter("viewPageTitle");
	viewPageTitle=(viewPageTitle==null)?"":viewPageTitle;
	String action=request.getParameter("action");
	action=(action==null)?"":action;
	String fromHomepage=request.getParameter("fromHomepage");
	fromHomepage=(fromHomepage==null)?"":fromHomepage;
	String userName=request.getParameter("userName");
	userName=(userName==null)?"":userName;
	String isServiceBusiViewMetrics=request.getParameter("isServiceBusiViewMetrics");
	isServiceBusiViewMetrics=(isServiceBusiViewMetrics==null)?"":isServiceBusiViewMetrics;
	String stateName = request.getParameter("stateName");
	String treeFlag_SBD = request.getParameter("treeFlag_SBD");
	String outsideService_SBD = request.getParameter("outsideService_SBD");
	String titleText_SBD = request.getParameter("titleText_SBD");
	String selectNode_SBD = request.getParameter("selectNode_SBD");
	String isEmulTrans_SBD = request.getParameter("isEmulTrans_SBD");
	String serviceName = request.getParameter("serviceName");
	String serviceState_SBD = request.getParameter("serviceState_SBD");

	String isfromCitrix = request.getParameter("isfromCitrix");
	String isfromRum = request.getParameter("isfromRum");
	String appliesTo = request.getParameter("appliesTo");
	String isFromZone = request.getParameter("isFromZone");
	String iszoneName = request.getParameter("iszoneName");
	iszoneName=(iszoneName==null)?subFilter:iszoneName;
	iszoneName=EgURLEncoder.encode(iszoneName,"UTF-8");
	String parentZone = request.getParameter("parentZone");
	String dashboard_mapping = request.getParameter("dashboard_mapping");
	String dashboard_name = request.getParameter("dashboard_name");
	String user_name = request.getParameter("user_name");
	String view_name = request.getParameter("view_name");
	String iniName = request.getParameter("iniName");
	String fromServiceHomePage = request.getParameter("fromServiceHomePage");
	String fromSerComboChange = request.getParameter("fromSerComboChange");
	String firstTime = request.getParameter("firstTime");
	String hasCitrix = request.getParameter("hasCitrix");

	String isServiceBusiDash = request.getParameter("isServiceBusiDash");
	String timeline = request.getParameter("timeline");

	String filter=request.getParameter("filter");
	String filterBy1 = request.getParameter("filterBy");
	String selectedRum=request.getParameter("selectedRum");	
	String isFromServiceMenu=request.getParameter("isFromServiceMenu");	
	String isFromZoneMain=request.getParameter("isFromZoneMain");	
	String isFromZoneMenu=request.getParameter("isFromZoneMenu");	
	String isFromServiceGroup=request.getParameter("isFromServiceGroup");

	String isfromZoneDash=request.getParameter("isfromZoneDash");
	if(iniName != null && iniName.trim().length()>0 && !iniName.equalsIgnoreCase("null") && iniName.equalsIgnoreCase("eg_rumdashboard"))
	{
		iniName = "eg_citrixdashboard";
	}
	if(dashboard_name != null && dashboard_name.trim().length()>0 && !dashboard_name.equalsIgnoreCase("null") && dashboard_name.equalsIgnoreCase("rum_dashboard"))
	{
		dashboard_name = "Citrix_Dashboard";
	}
	boolean isCitrixComp = false;
	String citrixComp =request.getParameter("isCitrixComp");
	if(citrixComp != null && citrixComp.trim().length() > 0 && (citrixComp.equalsIgnoreCase("true") || citrixComp.equalsIgnoreCase("yes")))
		isCitrixComp = true;

	boolean isRumComp = false;
	String rumComp =request.getParameter("isRumComp");
	if(rumComp != null && rumComp.trim().length() > 0 && (rumComp.equalsIgnoreCase("true") || rumComp.equalsIgnoreCase("yes")))
		isRumComp = true;
	String dashCompType = null;
	boolean hasXenApp = false;
	String dashboardCompType = null;
	ArrayList directorCompType = new ArrayList();
	ArrayList directorCompList = new ArrayList();
	
	com.eg.IniFile citrixIni = null;
	ArrayList compTypesForMetricsView = new ArrayList();
	String tmp_iniName = iniName;
	if(tmp_iniName != null && tmp_iniName.trim().length() > 0){
		tmp_iniName = (tmp_iniName.endsWith(".ini"))?tmp_iniName:tmp_iniName+".ini";
		citrixIni = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/"+tmp_iniName, false);
		String componentsList = citrixIni.getValue("Metrics_View_Supported_Types","Types");
		if(componentsList != null && componentsList.trim().length() > 0)
			compTypesForMetricsView = StringUtils.egTokenizer(componentsList,",",false,true,true);

		if(dashboard_name != null && dashboard_name.trim().length() > 0){
			dashCompType = citrixIni.getValue(dashboard_name,"Dashboard_ComponentType");
			if(dashCompType != null && dashCompType.trim().length() > 0 && dashCompType.startsWith("Agg_")){
				dashCompType = citrixIni.getValue(dashboard_name,"Dashboard_Original_ComponentType");
			}
			else if(dashCompType == null || dashCompType.trim().length() == 0)
				dashCompType = citrixIni.getValue(dashboard_name,"Dashboard_Original_ComponentType");
		}
		dashboardCompType = dashCompType;
		
		//Modified by Menaka for Default Dashboard Component List Page on 27-7-2018
		String director_types=citrixIni.getValue("Broker_Supported_Types",dashCompType);
		director_types=(director_types==null || director_types.trim().length()==0)?"":director_types;
		ArrayList directorSupportedTypes =  com.egurkha.util.StringUtils.egTokenizer(director_types.trim(), ",",false,true,true);//param 3-->includeEmpty,4-->unique,5-->trim

		if(dashboard_mapping != null && dashboard_mapping.trim().length() > 0){
			String entry = citrixIni.getValue(user_name+":"+dashboard_name+":Mapping",dashboard_mapping);
			if(entry != null && entry.indexOf("#~#") > 0){
				if(entry.startsWith("ComponentType") || entry.startsWith("Components")){
					String val = entry.substring(entry.indexOf(":")+1);
					if(val.startsWith("Agg_"))
						dashCompType = "";
				}
				entry = entry.substring(entry.indexOf("#~#")+3);
				ArrayList entryComp =  com.egurkha.util.StringUtils.egTokenizer(entry.trim(), ",",false,true,true);
				for(int k=0;k<entryComp.size();k++){
					String comp1 = (String)entryComp.get(k);
					String componame = (comp1.indexOf(":") > 0) ?comp1.substring(comp1.indexOf(":")+1):comp1;
					comp1 = (comp1.indexOf(":") > 0) ?comp1.substring(0,comp1.indexOf(":")):comp1;
					if(comp1.equalsIgnoreCase("All") && directorSupportedTypes != null && directorSupportedTypes.size()>0)
					{						
						directorCompType.addAll(directorSupportedTypes);
						directorCompList.add(componame);
					}
					else if(directorSupportedTypes.contains(comp1))
					{
						directorCompList.add(componame);
						if(directorCompType.size()==0 || (directorCompType.size()>0 && !directorCompType.contains(comp1)))
							directorCompType.add(comp1);
					}
				}
			}
		}

	}
	
	if(componentType != null && componentType.trim().length()>0 && dashboardCompType != null && dashboardCompType.trim().length()>0 && componentType.equalsIgnoreCase(dashboardCompType))
	{
		componentType = dashCompType;
	}
	String network_dev_types = iniDashboardCon.getValue("NETWORK_DEVICES_SUBJECTS","Network_Device_Types");
	if (network_dev_types==null || network_dev_types.trim().length()==0 || network_dev_types.equalsIgnoreCase("NULL"))
		network_dev_types = "NETWORK_GENERIC";
	String s_iniFile = EgInstallInfo.getInstallDir()+ "/manager/config/eg_customdashboard.ini";
	IniFile customDashboardInI = new IniFile(s_iniFile);
	String showPerformanceDashboard=customDashboardInI.getValue("DASHBOARD_SETTINGS","showPerformanceDashboard");
	String userId=user.getLoginID();
	String performanceDashboardURL="";
	boolean isShowPerformanceDashboard=false;
	if(showPerformanceDashboard!=null && showPerformanceDashboard.equalsIgnoreCase("yes"))
	{
		isShowPerformanceDashboard=true;
	}
	
	if (treeTitle!= null && !treeTitle.equalsIgnoreCase("undefined") &&  treeTitle.equalsIgnoreCase("Network"))
	{
		if(session!=null)
		{
			session.setAttribute("Page_IdentifierM", request.getRequestURI());
			session.setAttribute("Source","MetricViewNetwork"); // for eg help
		}
		
	}
	else if(treeTitle!= null && !treeTitle.equalsIgnoreCase("undefined") &&  treeTitle.equalsIgnoreCase("Component"))
	{
		if(session!=null)
		{
			session.setAttribute("Page_IdentifierM", request.getRequestURI());
			session.setAttribute("Source","MetricViewComponent"); // for eg help
		}
		
	}

	if(imageId==null)
	{
		imageId="";
	}

	if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
	{
		subj="TREE_APPLICATION";
		//subj="COMPARISON_NETWORK";
	}
	IniUI iniUI = IniUI.getInstance();
	String thisLanguage = iniUI.getDefaultLanguage();
	//EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	if (user!=null)
	{
		String userLang = user.getLanguage();
		if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
		{
			thisLanguage=userLang;
		}
	}
	boolean isUserLanguageEnglish=true;
	if(thisLanguage!=null && !thisLanguage.equals("en_US"))
	{
		isUserLanguageEnglish=false;
	}
	int headerLength=18;
	ArrayList compType_list=new ArrayList();
	String imgsrc="";

	JSONObject json  = new JSONObject();
	JSONArray  columns = new JSONArray();
	JSONArray  measures = new JSONArray();
	JSONObject componentTypeOptions  = new JSONObject();
	JSONArray  selectOptions = new JSONArray();
	JSONObject sortByMainOptions  = new JSONObject();
	JSONArray  sortByOptions = new JSONArray();
	JSONArray filterByOptions = new JSONArray();
	JSONObject jOpt = new JSONObject();
	JSONObject pageParams = new JSONObject();
	request.setAttribute("jsonObject",json);
	request.setAttribute("category","service");
	request.setAttribute("itemName",selectedParam);
	pageParams.put("fromPageView", fromPageView);
	pageParams.put("selectedState", selectedState);
	pageParams.put("userName", userName);
	
	EgList applicationComponent =null;
	EgList searchApplicationComponent =null;
	//applicationComponent = serviceBean.getComponentsForSelection(treeTitle,selectedParam,"");
	List usr_server=user.getServers(false);
	List zones_list = new LinkedList();
	List services_list = new LinkedList();
	List segments_list = new LinkedList();
	List components_list = new LinkedList();
	zones_list.addAll(user.getZones());
	segments_list.addAll(user.getSegments());
	services_list.addAll(user.getServices());
	services_list.addAll(user.getSites());
	services_list = ListUtils.removeDuplicates(services_list);
	components_list.addAll(user.getServerTypes());
	ArrayList siteServers = discInfo.getSiteServers();

	EgUserRole userRole = user.getUserRole();
	boolean hasConfigSupport = userRole.hasAnyConfigRole(EgUserPermission.CONFIG);
	Hashtable ht_changeHash = EgConfigChangeThread.ht_changeHash;

	if(fromPageView!=null && fromPageView.equalsIgnoreCase("UserView") && userName!=null && userName.length()>0 )
	{
		if (userName != null && userName.trim().length() > 0 && !userName.equalsIgnoreCase("null") && !userName.equals("-1")) 
		{
			userData = new ErUserData(userName,false);
			if (userData != null)
				er_user = userData.usr;

			if(er_user!=null)
			{
				if(selectedState!=null && selectedState.length()>0)
				{
					usr_server=new LinkedList();
					components_list = new LinkedList();
					zones_list = new LinkedList();
					services_list = new LinkedList();
					segments_list = new LinkedList();

					List tmp_usr_server=er_user.getServers(false);

					for(int i=0;i<tmp_usr_server.size();i++)
					{
						String serverType="";
						String serverName="";
						String server="";
						String serverState = "";

						server=(String)tmp_usr_server.get(i);
						serverType=server.substring(0,server.indexOf(":"));
						serverName=server.substring(server.indexOf(":")+1);
						
						if (siteServers.indexOf(serverType) > -1)
						{
							ArrayList layers=tablesInfo.getLayersForComponent(serverType);
							if ((layers.indexOf("WEB_SITE") > -1) || (layers.indexOf("WEB_TRANSACTIONS") > -1))
							{
								serverState = ap.getAlarmPriority(serverName, serverType,"NULL");
							}
							else
							{
								serverState = ap.getAlarmPriority(serverName, serverType);
							}
						}
						else
						{
							serverState = ap.getAlarmPriority(serverName, serverType);
						}

						if(serverState!=null && serverState.equals(selectedState))
						{
							usr_server.add(server);
							components_list.add(serverType);
						}
					}
				}
				else
				{
					usr_server=new LinkedList();
					usr_server=er_user.getServers(false);

					zones_list = new LinkedList();
					//zones_list.addAll(er_user.getZones());

					services_list = new LinkedList();
					//services_list.addAll(er_user.getServices());
					
					segments_list = new LinkedList();
					//segments_list.addAll(er_user.getSegments());

					components_list = new LinkedList();
					components_list.addAll(er_user.getServerTypes());
				}
			}
		}
	}

	List network_list = new LinkedList();
	if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
	{
		StringTokenizer nwDevTok1 = new StringTokenizer(network_dev_types.toUpperCase(),",");
		while(nwDevTok1.hasMoreTokens())
		{
			String nw_dev_subject = nwDevTok1.nextToken();
			String networktype[]=iniFilefornet.getVariables(nw_dev_subject);
			List network_list1 = new LinkedList();
			if(networktype!=null && networktype.length>0)
			{
				network_list1 = Arrays.asList(networktype);
				if(network_list1!=null && network_list1.size()>0)
					network_list.addAll(network_list1);
			}
		}
		if(network_list!=null && network_list.size()>0)
		{
			List net_zones_list = new LinkedList();
			for (int i = 0; i < zones_list.size(); i++)
			{
				String v_zone = (String)zones_list.get(i);
				EgList tmpCompList = serviceBean.getComponentsForZone("Zone",v_zone,"");
				if(tmpCompList!=null && tmpCompList.size() > 0 )
				{
					for(int c = 0; c < tmpCompList.size(); c++)
					{
						EgComponent component = (EgComponent)tmpCompList.get(c);
						String componentTypeVal = (String)component.getType();
						if(network_list.contains(componentTypeVal))
						{
							if(!net_zones_list.contains(v_zone))
								net_zones_list.add(v_zone);
						}
					}
				}
			}

			zones_list = new LinkedList();
			if(net_zones_list!=null && net_zones_list.size()>0)
			{
				zones_list.addAll(net_zones_list);
			}

			List net_service_list = new LinkedList();
			for (int i = 0; i < services_list.size(); i++)
			{
				String service_name = (String)services_list.get(i);
				EgList tmpCompList = serviceBean.getComponentsForSelection("services",service_name,"");
				if(tmpCompList!=null && tmpCompList.size() > 0 )
				{
					for(int c = 0; c < tmpCompList.size(); c++)
					{
						EgComponent component = (EgComponent)tmpCompList.get(c);
						String componentTypeVal = (String)component.getType();
						if(network_list.contains(componentTypeVal))
						{
							if(!net_service_list.contains(service_name))
								net_service_list.add(service_name);
						}
					}
				}
			}

			services_list = new LinkedList();
			if(net_service_list!=null && net_service_list.size()>0)
			{
				services_list.addAll(net_service_list);
			}

			List net_seg_list = new LinkedList();
			for (int i = 0; i < segments_list.size(); i++)
			{
				String seg_name = (String)segments_list.get(i);
				EgList tmpCompList = serviceBean.getComponentsForSegment("segment",seg_name,"");
				if(tmpCompList!=null && tmpCompList.size() > 0 )
				{
					for(int c = 0; c < tmpCompList.size(); c++)
					{
						EgComponent component = (EgComponent)tmpCompList.get(c);
						String componentTypeVal = (String)component.getType();
						if(network_list.contains(componentTypeVal))
						{
							if(!net_seg_list.contains(seg_name))
								net_seg_list.add(seg_name);
						}
					}
				}
			}

			segments_list = new LinkedList();
			if(net_seg_list!=null && net_seg_list.size()>0)
			{
				segments_list.addAll(net_seg_list);
			}

			List net_comp_list = new LinkedList();
			for (int i = 0; i < components_list.size(); i++)
			{
				String comp_type_name = (String)components_list.get(i);
				if(comp_type_name!=null && network_list.contains(comp_type_name))
				{
					if(!net_comp_list.contains(comp_type_name))
						net_comp_list.add(comp_type_name);
				}
					
			}

			components_list = new LinkedList();
			if(net_comp_list!=null && net_comp_list.size()>0)
			{
				components_list.addAll(net_comp_list);
			}
		}
		else
		{
			zones_list = new LinkedList();
			services_list = new LinkedList();
			segments_list = new LinkedList();
		}
	}

	if (zones_list != null && zones_list.size() > 0)
	{
		jOpt = new JSONObject();
		jOpt.put("displayField", mappingInfo.getTextDescription("monitor.home.Zone"));
		jOpt.put("valueField", "zone");
		filterByOptions.add(jOpt);
	}
	if (segments_list != null && segments_list.size() > 0)
	{
		jOpt = new JSONObject();
		jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Segment"));
		jOpt.put("valueField", "segment");
		filterByOptions.add(jOpt);
	}
	if (services_list != null && services_list.size() > 0)
	{
		jOpt = new JSONObject();
		jOpt.put("displayField", mappingInfo.getTextDescription("monitor.home.Service"));
		jOpt.put("valueField", "services");
		filterByOptions.add(jOpt);
	}
	if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
	{
		if (components_list != null && components_list.size() > 0)
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Component Type"));
			jOpt.put("valueField","Network");
			filterByOptions.add(jOpt);
		}
		else
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Component Type"));
			jOpt.put("valueField", "Network");
			filterByOptions.add(jOpt);
		}
	}
	else
	{
		if (components_list != null && components_list.size() > 0)
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Component Type"));
			jOpt.put("valueField", "Component");
			filterByOptions.add(jOpt);
		}
		else
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Component Type"));
			jOpt.put("valueField", "Component");
			filterByOptions.add(jOpt);
		}
	}
	
	if (!StringUtils.isNull(filterBy))
		pageParams.put("selectedFilterByOption", filterBy);
	else
		pageParams.put("selectedFilterByOption", treeTitle);
	
	JSONArray subFilterOptions = new JSONArray();

	pageParams.put("selectedPage", "Component");

	pageParams.put("isSubFilterOption",new Boolean(true));
	ArrayList mainZoneList = new ArrayList();
	String zoneName = null;
	if (filterBy != null && filterBy.equalsIgnoreCase("zone"))
	{
		if (!userRole.hasAllComponentAccess())
		{
			List thisList = this.getUserAssociateSubZones(zones_list);
			if(thisList != null)
			{
				for (int i=0;i<thisList.size();i++)
				{
					String thisZone = (String) thisList.get(i);
					if(!zones_list.contains(thisZone))
						zones_list.add(thisZone);
				}
			}
		}
		//sorting Zones
		if (zones_list != null && zones_list.size() > 1)
		{
			EgSorter esort = new EgSorter(zones_list, 1);
			zones_list = esort.sort(1, "String", "asc");
		}
		isComponent = false;
		pageParams.put("subFilterLabel", mappingInfo.getTextDescription("monitor.common.Zone"));
		if (zones_list != null && zones_list.size() > 0)
		{
			String s_selectedOption = "";
			jOpt = new JSONObject();
			jOpt.put("displayField",mappingInfo.getTextDescription("monitor.common.Please choose a Zone"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);

			for (int i = 0; i < zones_list.size(); i++)
			{
				String v_zone = (String) zones_list.get(i);
				jOpt = new JSONObject();
				jOpt.put("displayField", v_zone);
				jOpt.put("valueField", v_zone);
				subFilterOptions.add(jOpt);
				if (subFilter != null && subFilter.equals(v_zone))
				{
					s_selectedOption = v_zone;
				}
			}
			if (StringUtils.isNull(s_selectedOption))
			{
				//pageParams.put("selectedSubFilterOption", zones_list.get(0).toString());
				//selectedNode = zones_list.get(0).toString();
				//subFilter = zones_list.get(0).toString();
				//pageParams.put("selectedSubFilterOption", subFilter);
				pageParams.put("selectedSubFilterOption", "-1");
				subFilter = "-1";
				pageParams.put("isSubFilterOption",new Boolean(false));
				
			}
			else
			{
				pageParams.put("selectedSubFilterOption", s_selectedOption);
				pageParams.put("isSubFilterOption",new Boolean(false));
			}
		}
		else
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Not Available"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);
			subFilter = "-1";
			pageParams.put("selectedSubFilterOption", "-1");
			//pageParams.put("selectedSubFilterOption", "Not Available");
			pageParams.put("isSubFilterOption",new Boolean(true));
		}
	}
	else if (filterBy != null && filterBy.equalsIgnoreCase("segment"))
	{
		//sorting Segment
		if (segments_list != null && segments_list.size() > 0)
		{
			EgSorter esort = new EgSorter(segments_list, 1);
			segments_list = esort.sort(1, "String", "asc");
		}
		isComponent = false;
		pageParams.put("subFilterLabel", mappingInfo.getTextDescription("monitor.home.Segment"));
		if (segments_list != null && segments_list.size() > 0)
		{
			String s_selectedOption = "";

			jOpt = new JSONObject();
			jOpt.put("displayField",mappingInfo.getTextDescription("monitor.common.Please choose a Segment"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);

			for (int i = 0; i < segments_list.size(); i++)
			{
				String v_segment = (String) segments_list.get(i);
				jOpt = new JSONObject();
				jOpt.put("displayField", v_segment);
				jOpt.put("valueField", v_segment);
				subFilterOptions.add(jOpt);
				if (subFilter != null && subFilter.equals(v_segment))
				{
					s_selectedOption = v_segment;
				}
			}

			if (StringUtils.isNull(s_selectedOption))
			{
				//pageParams.put("selectedSubFilterOption", segments_list.get(0).toString());
				//subFilter = segments_list.get(0).toString();
				//pageParams.put("selectedSubFilterOption", subFilter);
				pageParams.put("selectedSubFilterOption", "-1");
				subFilter = "-1";
				pageParams.put("isSubFilterOption",new Boolean(false));
			}
			else
			{
				pageParams.put("selectedSubFilterOption", s_selectedOption);
				pageParams.put("isSubFilterOption",new Boolean(false));
			}
		}
		else
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Not Available"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);
			subFilter = "-1";
			pageParams.put("selectedSubFilterOption", "-1");
			pageParams.put("isSubFilterOption",new Boolean(true));
		}
	}
	else if (filterBy != null && (filterBy.equals("services") || filterBy.equalsIgnoreCase("Service")))
	{
		//sorting Service
		if (services_list != null && services_list.size() > 0)
		{
			EgSorter esort = new EgSorter(services_list, 1);
			services_list = esort.sort(1, "String", "asc");
		}
		isComponent = false;
		pageParams.put("subFilterLabel", mappingInfo.getTextDescription("monitor.home.Service"));
		if (services_list != null && services_list.size() > 0)
		{
			String s_selectedOption = "";

			jOpt = new JSONObject();
			jOpt.put("displayField",mappingInfo.getTextDescription("monitor.common.Please choose a Service"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);

			for (int i = 0; i < services_list.size(); i++)
			{
				String v_service = (String) services_list.get(i);
				jOpt = new JSONObject();
				jOpt.put("displayField", v_service);
				jOpt.put("valueField", v_service);
				subFilterOptions.add(jOpt);
				if (subFilter != null && subFilter.equals(v_service))
				{
					s_selectedOption = v_service;
				}
			}
			if (StringUtils.isNull(s_selectedOption))
			{
				//pageParams.put("selectedSubFilterOption", services_list.get(0).toString());
				//subFilter = services_list.get(0).toString();
				//pageParams.put("selectedSubFilterOption", subFilter);
				pageParams.put("selectedSubFilterOption", "-1");
				subFilter = "-1";
				pageParams.put("isSubFilterOption",new Boolean(false));
				
			}
			else
			{
				pageParams.put("selectedSubFilterOption", s_selectedOption);
				pageParams.put("isSubFilterOption",new Boolean(false));
			}
		}
		else
		{
			jOpt = new JSONObject();
			jOpt.put("displayField", mappingInfo.getTextDescription("monitor.common.Not Available"));
			jOpt.put("valueField", "-1");
			subFilterOptions.add(jOpt);
			subFilter = "-1";
			pageParams.put("selectedSubFilterOption", "-1");
			pageParams.put("isSubFilterOption",new Boolean(true));
		}
	}
	/*else if (filterBy != null && (filterBy.equalsIgnoreCase("components") || filterBy.equalsIgnoreCase("component") || equalsIgnoreCase.equals("network")))
	{
		
	}*/
	/*if(isComponent && firstTime != null && firstTime.equalsIgnoreCase("true") && subFilter != null && subFilter.trim().length() > 0 && !subFilter.startsWith("Agg_")){
		directorCompType = (componentType != null && !componentType.equalsIgnoreCase(dashCompType))?componentType:"";
		componentType = dashCompType;
	}*/

	json.put("subFilterOptions",subFilterOptions);
	boolean checkUserComponents = true;
	if(filterBy!=null && filterBy.equalsIgnoreCase("zone") )
	{
		if(componentNameSearch!=null && componentNameSearch.length()>0)
		{
			applicationComponent = serviceBean.getComponentsForZone(filterBy,subFilter,"");
			searchApplicationComponent=applicationComponent.search(componentNameSearch);
			pageParams.put("searchnickname", componentNameSearch);
		}
		else
		{
			applicationComponent = serviceBean.getComponentsForZone(filterBy,subFilter,"");
			pageParams.put("searchnickname", componentNameSearch);
		}
	}
	else if(filterBy!=null && filterBy.equalsIgnoreCase("segment") )
	{
		if(componentNameSearch!=null && componentNameSearch.length()>0)
		{
			applicationComponent = serviceBean.getComponentsForSegment(filterBy,subFilter,"");
			searchApplicationComponent=applicationComponent.search(componentNameSearch);
			pageParams.put("searchnickname", componentNameSearch);
		}
		else
		{
			applicationComponent = serviceBean.getComponentsForSegment(filterBy,subFilter,"");
			pageParams.put("searchnickname", componentNameSearch);
		}
	
	}
	else if(filterBy!=null && filterBy.equalsIgnoreCase("services") )
	{
		if(componentNameSearch!=null && componentNameSearch.length()>0)
		{
			applicationComponent = serviceBean.getComponentsForSelection(filterBy,subFilter,"");
			searchApplicationComponent=applicationComponent.search(componentNameSearch);
			pageParams.put("searchnickname", componentNameSearch);
		}
		else
		{
			applicationComponent = serviceBean.getComponentsForSelection(filterBy,subFilter,"");
			pageParams.put("searchnickname", componentNameSearch);
		}
	}
	else
	{
		checkUserComponents = false;
		if(componentNameSearch!=null && componentNameSearch.length()>0 && !componentNameSearch.equalsIgnoreCase("null"))
		{
			applicationComponent = serviceBean.getComponentsForUser(usr_server);
			searchApplicationComponent=applicationComponent.search(componentNameSearch);
			pageParams.put("searchnickname", componentNameSearch);
		}
		else
		{
			applicationComponent = serviceBean.getComponentsForUser(usr_server);
			pageParams.put("searchnickname", componentNameSearch);
		}
	}
	
	//applicationComponent = serviceBean.getComponentsForSelection(treeTitle,selectedParam,"");
	//EgList applicationComponent = serviceBean.getComponentsForSelection(treeTitle,selectedParam,"");

	EgList temp_applicationComponent=new EgList();
	if(checkUserComponents){
		boolean userViolated = false;
		ArrayList userBasedCompTypeList = new ArrayList(); 
		if(userId !=null && userId.trim().length()>0)
		{
			com.eg.GroupCertValidator licenseChecker = new com.eg.GroupCertValidator(userId);
			userViolated = licenseChecker.checkForUserViolation(userId);
			if(userViolated)
			{
				com.eg.EgUsersInfo usersInfo = new com.eg.EgUsersInfo();
				userBasedCompTypeList = (ArrayList)usersInfo.getAllUserBasedCompTypes();
			}
		}
		if(applicationComponent!=null && applicationComponent.size()>0 && userBasedCompTypeList!=null && userBasedCompTypeList.size()>0)
		{
			for(int k=0;k<applicationComponent.size();k++)
			{
				EgComponent component = (EgComponent)applicationComponent.get(k);
				String tem_compType = component.getType();
				if(userBasedCompTypeList!=null && userBasedCompTypeList.size()>0 && userBasedCompTypeList.contains(tem_compType))
					continue;
				temp_applicationComponent.add(component);
			}

			applicationComponent=new EgList();
			if(temp_applicationComponent!=null && temp_applicationComponent.size()>0)
			{
				for(int k=0;k<temp_applicationComponent.size();k++)
				{
					EgComponent component = (EgComponent)temp_applicationComponent.get(k);
					applicationComponent.add(component);
				}
			}
		}
	}

	String excludedCompType=egDashConfig.getValue("EXCLUDED_TYPES_IN_METRICS_VIEW","Types");
	ArrayList excludedCompTypeList=new ArrayList(); 
	if(excludedCompType!=null && excludedCompType.trim().length()>0)
	{
		StringTokenizer tokenComp=new StringTokenizer(excludedCompType,",");
		if(tokenComp!=null)
		{
			while(tokenComp.hasMoreTokens())
			{
				String com_Type=(String)tokenComp.nextToken();
				excludedCompTypeList.add(com_Type);
			}
		}
	}
	
	temp_applicationComponent=new EgList();
	if(applicationComponent!=null && applicationComponent.size()>0 && excludedCompTypeList!=null && excludedCompTypeList.size()>0)
	{
		for(int k=0;k<applicationComponent.size();k++)
		{
			EgComponent component = (EgComponent)applicationComponent.get(k);
			String tem_compType = component.getType();
			if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && !excludedCompTypeList.contains(tem_compType))
			{
				temp_applicationComponent.add(component);
			}
		}

		applicationComponent=new EgList();
		if(temp_applicationComponent!=null && temp_applicationComponent.size()>0)
		{
			for(int k=0;k<temp_applicationComponent.size();k++)
			{
				EgComponent component = (EgComponent)temp_applicationComponent.get(k);
				applicationComponent.add(component);
			}
		}
	}

	ArrayList includeComponentsList=new ArrayList();  
	if((fromPageView!=null && fromPageView.trim().length()>0 && fromPageView.equals("CitrixDashboard")) || (isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true")))
	{
		if(filterBy!=null && (filterBy.equalsIgnoreCase("Components") || filterBy.equalsIgnoreCase("Component")))
		{
			if(subFilter!=null && subFilter.trim().length()>0)
			{
				includeComponentsList = StringUtils.egTokenizer(subFilter,",",false,true,true);//param 3-->includeEmpty,4-->unique,5-->trim
			}

			ArrayList subFilterCompTypeList=new ArrayList();
			if(includeComponentsList != null && includeComponentsList.size()> 0){
				for(int k=0;k<includeComponentsList.size();k++){
					String cTypewithnick = (String)includeComponentsList.get(k);
					if(cTypewithnick != null && cTypewithnick.trim().length() > 0 && cTypewithnick.indexOf(":") > 0){
						String cType = cTypewithnick.substring(0,cTypewithnick.indexOf(":"));
						if(cType != null && cType.trim().length() > 0 && !subFilterCompTypeList.contains(cType))
							subFilterCompTypeList.add(cType);
					}
				}
			}

			if(compTypesForMetricsView != null && compTypesForMetricsView.size()> 0){
				for(int k=0;k<compTypesForMetricsView.size();k++){
					String cType = (String)compTypesForMetricsView.get(k);
					if(cType != null && cType.trim().length() > 0 && !includeComponentsList.contains(cType) && !subFilterCompTypeList.contains(cType))
						includeComponentsList.add(cType);
				}
			}
		}
	}

	temp_applicationComponent=new EgList();
	if(applicationComponent!=null && applicationComponent.size()>0 && includeComponentsList!=null && includeComponentsList.size()>0)
	{
		for(int k=0;k<applicationComponent.size();k++)
		{
			EgComponent component = (EgComponent)applicationComponent.get(k);
			String tmp_compType = component.getType();
			String tmp_compName = component.getName();
			String tmp_comp=tmp_compType+":"+tmp_compName;
			if(includeComponentsList!=null && includeComponentsList.size()>0 && (includeComponentsList.contains(tmp_comp) || includeComponentsList.contains(tmp_compType)))
			{
				temp_applicationComponent.add(component);
			}
		}

		applicationComponent=new EgList();
		if(temp_applicationComponent!=null && temp_applicationComponent.size()>0)
		{
			for(int k=0;k<temp_applicationComponent.size();k++)
			{
				EgComponent component = (EgComponent)temp_applicationComponent.get(k);
				applicationComponent.add(component);
			}
		}
	}

	EgList temp_searchApplicationComponent=new EgList();
	if(searchApplicationComponent!=null && searchApplicationComponent.size()>0 && excludedCompTypeList!=null && excludedCompTypeList.size()>0)
	{
		for(int k=0;k<searchApplicationComponent.size();k++)
		{
			EgComponent component = (EgComponent)searchApplicationComponent.get(k);
			String tem_compType = component.getType();
			if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && !excludedCompTypeList.contains(tem_compType))
			{
				temp_searchApplicationComponent.add(component);
			}
		}
		searchApplicationComponent=new EgList();
		if(temp_searchApplicationComponent!=null && temp_searchApplicationComponent.size()>0)
		{
			for(int k=0;k<temp_searchApplicationComponent.size();k++)
			{
				EgComponent component = (EgComponent)temp_searchApplicationComponent.get(k);
				searchApplicationComponent.add(component);
			}
		}
	}
	
	
	String cu="";
	List sortForCurrentHost=new ArrayList();
	if(applicationComponent!=null && applicationComponent.size() > 0 )
	{
		for(int c = 0; c < applicationComponent.size(); c++)
		{
			EgComponent component = (EgComponent)applicationComponent.get(c);
			//String componentTypeVal = component.getName();
			String componentTypeVal = (String)component.getType();
			String componentTypeDispVal = mappingInfo.getComponentTypeDescription(componentTypeVal);
			sortForCurrentHost.add(componentTypeDispVal);
			sortForCurrentHost.add(componentTypeVal);
			sortForCurrentHost.add((EgComponent)component);
		}
		if (sortForCurrentHost != null && sortForCurrentHost.size() > 0)
		{
			EgSorter esort = new EgSorter(sortForCurrentHost, 3);
			sortForCurrentHost = esort.sort(1, "String", "asc");
		}
	}
	
	if (sortForCurrentHost != null && sortForCurrentHost.size() > 0)
	{
		//String networktype[]=iniFilefornet.getVariables("NETWORK_GENERIC");

		if((fromPageView!=null && fromPageView.trim().length()>0 && fromPageView.equals("CitrixDashboard")) || (isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true")))
		{
			if((componentType==null || componentType.equalsIgnoreCase("null") || componentType.trim().length()==0 || (sortForCurrentHost != null && !sortForCurrentHost.contains(componentType))) && sortForCurrentHost.contains(dashCompType) && dashCompType != null && dashCompType.trim().length() > 0)
				componentType = dashCompType;
		}
		for (int i = 0; i < sortForCurrentHost.size(); i += 3)
		{
			String compTypeDispName = (String) sortForCurrentHost.get(i);
			String compTypeName = (String) sortForCurrentHost.get(i+1);
			EgComponent currentComObject = (EgComponent) sortForCurrentHost.get(i+2);
			//EgComponent currentComObject = (EgComponent)sortForCurrentHost.get(0+1);
			//EgComponent currentComObject1 = (EgComponent)sortForCurrentHost.get(i+1);
			//String cu1 = currentComObject1.getType();
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
			{
				if(network_list!=null && compTypeName!=null && network_list.contains(compTypeName))
				{
					cu=compTypeName;
				}
			}
			else
				cu = compTypeName;

			if(cu!=null && cu.trim().length()>0)
				break;
		}
	}

	EgList componentList=new EgList();
	if(applicationComponent!=null && applicationComponent.size() > 0 )
	{
		for(int c = 0; c < applicationComponent.size(); c++)
		{
			EgComponent component = (EgComponent)applicationComponent.get(c);
			String componentTypeVal = component.getType();
			String compName1 = component.getName();
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
			{
				StringTokenizer nwDevTok1 = new StringTokenizer(network_dev_types.toUpperCase(),",");
				while(nwDevTok1.hasMoreTokens())
				{
					String nw_dev_subject = nwDevTok1.nextToken();
					String networktype[] = iniFilefornet.getVariables(nw_dev_subject);
					if(networktype!=null && networktype.length>0)
					{
						for(int net=0;net<networktype.length;net++)
						{
							String networkgeneric=iniFilefornet.getValue(nw_dev_subject,networktype[net]);
							String selectedValueNet=networktype[0].toString();
							if(networkgeneric!=null && networkgeneric.length()>0)
							{
								if(componentTypeVal.equalsIgnoreCase(networkgeneric))
								{
									if(componentType==null || componentType.equalsIgnoreCase("null") || componentType.trim().length()==0)
									{
										//currenthost=componentTypeVal; 
										componentType=cu;
									}
									if(componentTypeVal.equalsIgnoreCase(componentType))
									{
										componentList.add(component);//2
									}
									if(!compType_list.contains(componentTypeVal))
									{
										compType_list.add(componentTypeVal);
									}
								}
							}
						}
					}
				}				
			}
			else if((fromPageView!=null && fromPageView.trim().length()>0 && fromPageView.equals("CitrixDashboard")) || (isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true")))
			{
				if(isComponent){
					if(componentTypeVal.equalsIgnoreCase(componentType))
					{
						if(directorCompType != null && directorCompType.contains(componentTypeVal)){
							if(directorCompList!= null && directorCompList.contains(compName1))
								componentList.add(component);//2
						}
						else
							componentList.add(component);//2
						if(!compType_list.contains(componentTypeVal))
							compType_list.add(componentTypeVal);
					}
					else if(directorCompType != null && directorCompType.size() > 0 && directorCompType.contains(componentTypeVal)){
						if(!compType_list.contains(componentTypeVal))
							compType_list.add(componentTypeVal);
					}
					else{
						if(dashCompType != null && dashCompType.trim().length() > 0){
							hasXenApp = true;
							if(componentTypeVal.equalsIgnoreCase(dashCompType) && (componentType==null || componentType.trim().length()==0 || componentType.equalsIgnoreCase("null")))
							{
								if(compType_list == null || compType_list.size() == 0 || (compType_list != null && compType_list.size() == 1 && compType_list.contains(componentTypeVal))){
									if(directorCompType != null && directorCompType.contains(componentTypeVal)){
										if(directorCompList!= null && directorCompList.contains(compName1))
											componentList.add(component);//2
									}
									else
										componentList.add(component);//2
								}

								if(!compType_list.contains(componentTypeVal))
									compType_list.add(componentTypeVal);
		
							}
						}
					}
				}
				else{
					if(componentType != null && componentType.startsWith("Agg_"))
						componentType = "";
					if(componentTypeVal != null && componentTypeVal.startsWith("Agg_"))
						continue;
					if(componentType==null || componentType.equalsIgnoreCase("null") || componentType.trim().length()==0)
					{
						componentType=cu;
					}
					if(componentTypeVal.equalsIgnoreCase(componentType))
					{
						if(directorCompType != null && directorCompType.contains(componentTypeVal)){
							if(directorCompList!= null && directorCompList.contains(compName1))
								componentList.add(component);//2
						}
						else
							componentList.add(component);//2
						if(!compType_list.contains(componentTypeVal))
							compType_list.add(componentTypeVal);
					}
					if(!compType_list.contains(componentTypeVal))
					{
						compType_list.add(componentTypeVal);
					}
				}
			}
			else
			{
				if(componentType==null || componentType.equalsIgnoreCase("null") || componentType.trim().length()==0)
				{
					//currenthost=componentTypeVal; 
					componentType=cu;
				}
				if(componentTypeVal.equalsIgnoreCase(componentType))
				{
					componentList.add(component);//2
				}
				if(!compType_list.contains(componentTypeVal))
				{
					compType_list.add(componentTypeVal);
				}
			}
			//Collections.sort(compType_list);
		}
		
	}

	if(componentNameSearch!=null && componentNameSearch.length()>0 && !componentNameSearch.equalsIgnoreCase("null"))
	{
		componentList=new EgList();
		if(searchApplicationComponent!=null && searchApplicationComponent.size() > 0 )
		{
			//EgList componentList=new EgList();
			for(int c = 0; c < searchApplicationComponent.size(); c++)
			{
				EgComponent component = (EgComponent)searchApplicationComponent.get(c);
				String componentTypeVal = component.getType();
				if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
				{
					StringTokenizer nwDevTok1 = new StringTokenizer(network_dev_types.toUpperCase(),",");
					while(nwDevTok1.hasMoreTokens())
					{
						String nw_dev_subject = nwDevTok1.nextToken();
					
						String networktype[] = iniFilefornet.getVariables(nw_dev_subject);
						if(networktype!=null && networktype.length>0)
						{
							for(int net=0;net<networktype.length;net++)
							{
								String networkgeneric=iniFilefornet.getValue(nw_dev_subject,networktype[net]);
								String selectedValueNet=networktype[0].toString();
								if(networkgeneric!=null && networkgeneric.length()>0)
								{
									if(componentTypeVal.equalsIgnoreCase(networkgeneric))
									{
										if(componentTypeVal.equalsIgnoreCase(componentType))
										{
											componentList.add(component);	//2
										}
									}
								}
							}
						}
					}
				}
				else
				{
					if(componentTypeVal.equalsIgnoreCase(componentType))
					{
						componentList.add(component);//2
					}
				}
			}
		}
	}

	ArrayList tempCompList=new ArrayList();
	int countAggComp=0;
	if(dashCompType != null && dashCompType.trim().length()>0 && compType_list.size()>0 && !compType_list.contains(dashCompType) && hasXenApp)
	{
		compType_list.add(dashCompType);
	}
	for(int k=0;k<compType_list.size();k++)
	{
		String tempComp=(String)compType_list.get(k);
		if(tempComp!=null)
		{
			if(tempComp!=null && tempComp.startsWith("Agg_"))
			{
				countAggComp++;
				continue;
			}

			tempCompList.add(tempComp);
			tempCompList.add(mappingInfo.getComponentTypeDescription(tempComp));
		}
	}
	boolean isAllAggComp=false;
	if((countAggComp>0) && (countAggComp==compType_list.size()))
	{
		isAllAggComp=true;
	}

	//Hashtable measureData = serviceBean.getTestMeasureData(componentList,subj,componentType);
	Hashtable measureData = new Hashtable();
	if(componentList!=null && componentList.size()>0){
		if(fromPageView != null && fromPageView.trim().length() > 0 && fromPageView.equalsIgnoreCase("CitrixDashboard") && timeline != null && timeline.trim().length() > 0)
			measureData = serviceBean.getTestMeasureDataForComparison(componentList,subj,componentType,timeline);
		else
			measureData = serviceBean.getTestMeasureDataForComparison(componentList,subj,componentType);
	}
	Hashtable temp_Table = serviceBean.getApplicationTestMeasureList(subj,componentType);


	Hashtable measureList =new Hashtable();
	ArrayList keyList=new ArrayList();
	Enumeration enumer; 
	if(temp_Table!=null && temp_Table.size()>0)
	{
		enumer = temp_Table.keys();
		while(enumer.hasMoreElements())
		{
			keyList=(ArrayList)enumer.nextElement();
			measureList=(Hashtable)temp_Table.get(keyList);
		}
	}
	TreeMap treeMap = new TreeMap(); 
	ArrayList comp_value=new ArrayList();
	Enumeration hash_key=null;
	List comNameSort=new ArrayList();
	EgList compList=new EgList();
	EgList tempList=new EgList();
	if(measure_sort!=null && !measure_sort.equalsIgnoreCase("undefined") && !measure_sort.equalsIgnoreCase("") && !measure_sort.equalsIgnoreCase("null") && !measure_sort.equalsIgnoreCase("-2"))
	{
		hash_key=measureData.keys();
		ArrayList noMeasureComp=new ArrayList();
		while(hash_key.hasMoreElements())
		{
			String measure_key=(String)hash_key.nextElement();
			if(measure_key!=null && measure_key.length()>0)
			{
				StringTokenizer st = new StringTokenizer(measure_key, "^"); 
				while(st.hasMoreTokens())
				{ 
					String comp = st.nextToken(); 
					String measure = st.nextToken();
					boolean dup_val=false;
					ArrayList temp=new ArrayList();
					if(measure.equalsIgnoreCase(measure_sort))
					{
						String measure_value=(String)measureData.get(measure_key);//get value from measure data 
						if(measureData.containsKey(measure_key+":OrgTime"))
							measure_value = (String)measureData.get(measure_key+":OrgTime");
						if(measure_value!=null && measure_value.equalsIgnoreCase("-"))
						{
							measure_value="0.0";
							noMeasureComp.add(comp);
						}
						Float temp_data = new Float(Float.parseFloat(measure_value));
						if(treeMap!=null && treeMap.size()>0)
						{
							ArrayList temp1=new ArrayList();
							dup_val=treeMap.containsKey(temp_data);
							//if the value is duplicated, add the comp in arrayList for particular Component
							if(dup_val)
							{
								Object ob=treeMap.get(temp_data);
								if(ob instanceof String)
								{
									temp1.add((String)ob);
								}
								else if(ob instanceof ArrayList)
								{
									temp1=(ArrayList)ob;
								}
								if(temp1!=null && temp1.size()>0)
								{
									for(int k=0;k<temp1.size();k++)
									{
										temp.add(temp1.get(k));
									}
								}
								temp.add(comp);
								treeMap.put(temp_data,temp);
							}
						}
						if(dup_val==false)
						{
							treeMap.put(temp_data,comp);
						}
					}
				}
			}
		}
		Collections.sort(noMeasureComp);
		if(treeMap!=null && treeMap.size()>0)
		{
			Set set = treeMap.entrySet(); //itreate and get add the value in list from treeset
			// Get an iterator 
			Iterator itr = set.iterator(); 
			// Display elements 
			while(itr.hasNext()) 
			{ 
				Map.Entry me = (Map.Entry)itr.next(); 
				Object comp_obj=me.getValue();
				if(comp_obj instanceof String)
				{
					if(!noMeasureComp.contains(comp_obj))
					{
						comp_value.add(comp_obj);
					}
				}
				else if(comp_obj instanceof ArrayList)
				{
					ArrayList al=new ArrayList();//if treemap contain component in arraylist itrate and add in another list 
					al=(ArrayList)comp_obj;
					for(int k=0;k<al.size();k++)
					{
						if(!noMeasureComp.contains(al.get(k)))
							comp_value.add(al.get(k));
					}
				}
			}
			//Add the no measure component after the sorting
			for(int j=0;j<noMeasureComp.size();j++)
			{
				comp_value.add(noMeasureComp.get(j));
			}

			//reverse the component in reverse, to sort in decending order
			if(sort_type.equalsIgnoreCase("DESC") || sort_type.equalsIgnoreCase("descending"))
			{
				ArrayList tempList2=new ArrayList();
				for(int k=comp_value.size()-1;k>=0;k--)//for desc
				{
					String temp3=(String)comp_value.get(k);
					if(noMeasureComp!=null && !noMeasureComp.contains(temp3))
						tempList2.add(temp3);
				}
				//after reverse the component list ,add the no mesure comp at the last
				for(int j=0;j<noMeasureComp.size();j++)
				{
					tempList2.add(noMeasureComp.get(j));
				}
				comp_value=tempList2;
				tempList2=null;

			}
			
			/*for(int j=0;j<comp_value.size();j++)
			{
				String comp_value_temp=(String)comp_value.get(j);
				for(int k=0;k<componentList.size();k++)
				{
					EgComponent comp = (EgComponent)componentList.get(k);
					String compName1 = comp.getName();
					StringTokenizer str = new StringTokenizer(compName1, ":"); 
					while(str.hasMoreTokens())
					{ 
						String list_name = str.nextToken(); 
						if(list_name.equalsIgnoreCase(comp_value_temp))
						{
							if(!compList.contains(comp))
							{
								compList.add(comp);
							}
							if(tempList.contains(comp))
							{
								tempList.remove(comp);
							}
						}
						else if(!tempList.contains(comp) && !compList.contains(comp))
						{
							tempList.add(comp);
						}
					}
				}
			}*/

			EgList componentObj=new EgList();
			ArrayList componentNameList=new ArrayList();
			Hashtable componentNamewithObjHT=new Hashtable();
			if(componentList!=null && componentList.size()>0)
			{
				for(int k=0;k<componentList.size();k++)
				{
					EgComponent comp = (EgComponent)componentList.get(k);
					String compName1 = comp.getName();
					String list_name = null;
					if(compName1!=null && compName1.length()>0 && compName1.indexOf(":")>-1)
					{
						list_name = compName1.substring(0,compName1.indexOf(":"));
					}

					if(list_name != null && list_name.trim().length() > 0 && componentNamewithObjHT.containsKey(list_name))
					{
						EgList tempcompObj = (EgList)componentNamewithObjHT.get(list_name);
						tempcompObj.add(comp);
						componentNamewithObjHT.put(list_name,tempcompObj);
						
					}
					else
					{
						EgList compObj = new EgList();
						compObj.add(comp);
						componentNamewithObjHT.put(list_name,compObj);
					}
					componentNameList.add(list_name);
				}
			}
			
			for(int j=0;j<comp_value.size();j++)
			{
				String comp_value_temp=(String)comp_value.get(j);
				if(comp_value_temp!=null  && comp_value_temp.indexOf(":")>-1)
					comp_value_temp = comp_value_temp.substring(0,comp_value_temp.indexOf(":"));
				if(componentNamewithObjHT !=null && componentNamewithObjHT.size() > 0 && componentNamewithObjHT.containsKey(comp_value_temp))
				{
					EgList compObList =(EgList)componentNamewithObjHT.get(comp_value_temp);
					if(compObList!=null && compObList.size()>0 )
					{
						for(int p=0;p<compObList.size();p++)
						{
							EgComponent comp=(EgComponent)compObList.get(p);
							if(!compList.contains(comp))
							{
								compList.add(comp);
							}
						}
						componentNameList.remove(comp_value_temp);
					}
				}
			}

			 //EgList tempList1=new EgList();
			componentList=null;
			componentList=new EgList();
			for(int k=0;k<compList.size();k++)
			{
				EgComponent comp_tem= (EgComponent)compList.get(k);
				componentList.add(comp_tem);
			}
			/*for(int k=0;k<tempList.size();k++)
			{
				EgComponent comp_tem= (EgComponent)tempList.get(k);
				componentList.add(comp_tem);
			}*/

			if(componentNameList!=null && componentNameList.size()>0)
			{
				for(int k=0;k<componentNameList.size();k++)
				{
					String comp_value_temp = (String)componentNameList.get(k);

					if(componentNamewithObjHT !=null && componentNamewithObjHT.size() > 0 && componentNamewithObjHT.containsKey(comp_value_temp))
					{
						EgList compObList =(EgList)componentNamewithObjHT.get(comp_value_temp);
						if(compObList!=null && compObList.size()>0 )
						{
							for(int p=0;p<compObList.size();p++)
							{
								EgComponent comp=(EgComponent)compObList.get(p);

								if(!componentList.contains(comp))
								{
									componentList.add(comp);
								}
							}
						}
					}
				}
			}
			/*
			//reverse the component componentList in reverse to sort in decending order
			if(sort_type.equalsIgnoreCase("descending"))
			{
				for(int k=componentList.size()-1;k>=0;k--)//for desc
				{
					//EgComponent comp_tem= (EgComponent)tempList.get(k);
					tempList1.add(componentList.get(k));
				}
				componentList=tempList1;
			}
			*/
		}
	}
	if(measure_sort!=null && measure_sort.equalsIgnoreCase("-2") )
	{
		if (componentList != null && componentList.size() > 0)
		{
			for(int k=0;k<componentList.size();k++)
			{
				EgComponent comp = (EgComponent)componentList.get(k);
				String compNameStr = comp.getName();
				comNameSort.add(compNameStr);
				comNameSort.add((EgComponent)comp);
				if (comNameSort != null && comNameSort.size() > 0)
				{
					EgSorter esort = new EgSorter(comNameSort, 2);
					comNameSort = esort.sort(1, "String", "asc");
				}
			}
		}
		componentList=null;
		componentList=new EgList();
		if (comNameSort != null && comNameSort.size() > 0)
		{
			for (int i = 0; i < comNameSort.size(); i += 2)
			{
				String compNameLi = (String) comNameSort.get(i);
				EgComponent comObject = (EgComponent) comNameSort.get(i + 1);
				componentList.add(comObject);
			}
		}
	}
	componentTypeOptions.put("componentTypeLabel",mappingInfo.getTextDescription("monitor.common.Component Type"));
	List compStateList=new ArrayList();
	if(selectedState!=null && selectedState.trim().length()>0 )
	{
		if (componentList != null && componentList.size() > 0)
		{
			for(int k=0;k<componentList.size();k++)
			{
				EgComponent compStateLi = (EgComponent)componentList.get(k);
				//String compStateName = selectedState;
				String compStateName = (compStateLi.getState()).getName();
				if(compStateName!=null && compStateName.equalsIgnoreCase(selectedState))
				{
					compStateList.add((EgComponent)compStateLi);
				}
			}
		}
		componentList=null;
		componentList=new EgList();
		if (compStateList != null && compStateList.size() > 0)
		{
			for (int i = 0; i < compStateList.size(); i += 1)
			{
				EgComponent comStateObject = (EgComponent) compStateList.get(i);
				componentList.add(comStateObject);
			}
		}
	}

	ArrayList sortedCompType=new ArrayList();
	if(tempCompList!=null && tempCompList.size()>0)
	{
		EgSorter esort=new EgSorter(tempCompList,2);
		sortedCompType=(ArrayList)esort.sort(2,"String","asc");
	}

	if(componentType != null && componentType.trim().length()>0 && !componentType.equalsIgnoreCase("null") && sortedCompType.contains(componentType) && excludedCompTypeList!=null && excludedCompTypeList.size()>0 && !excludedCompTypeList.contains(componentType))
	{
		componentTypeOptions.put("selectedComponentType",componentType);
	}
	
	if(sortedCompType!=null && sortedCompType.size()>0)
	{
		for(int k=0;k<sortedCompType.size();k+=2)
		{
			String comp_temp=(String)sortedCompType.get(k);
			String selectedValue=sortedCompType.get(0).toString();
			//String temp=(String)sortedComp.get(k);
			String compDispName=(String)sortedCompType.get(k+1);
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
			{
				StringTokenizer nwDevTok2 = new StringTokenizer(network_dev_types.toUpperCase(),",");
				while(nwDevTok2.hasMoreTokens())
				{
					String nw_dev_subject = nwDevTok2.nextToken();
					String networktype[]=iniFilefornet.getVariables(nw_dev_subject);
					if(networktype!=null && networktype.length>0)
					{
						for(int net=0;net<networktype.length;net++)
						{
							String networkgeneric=iniFilefornet.getValue(nw_dev_subject,networktype[net]);
							String selectedValueNet=networktype[0].toString();
							if(networkgeneric!=null && networkgeneric.length()>0)
							{
								if(comp_temp.equalsIgnoreCase(networkgeneric))
								{
									JSONObject option  = new JSONObject();
									option.put("value",comp_temp);
									option.put("name",compDispName);
									selectOptions.add(option);

									if(componentType.equalsIgnoreCase(comp_temp) && !componentTypeOptions.containsKey("selectedComponentType"))
									{
										componentTypeOptions.put("selectedComponentType",comp_temp);
									}
									else
									{
										if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && !excludedCompTypeList.contains(componentType) && !componentTypeOptions.containsKey("selectedComponentType"))
										{
											componentTypeOptions.put("selectedComponentType",selectedValue);
										}
									}
								}
							}
						}
					}
				}
			}
			else
			{
				JSONObject option  = new JSONObject();
				option.put("value",comp_temp);
				option.put("name",compDispName);
				selectOptions.add(option);

				if(componentType.equalsIgnoreCase(comp_temp) && !componentTypeOptions.containsKey("selectedComponentType"))
				{
					componentTypeOptions.put("selectedComponentType",comp_temp);
				}
				else
				{
					if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && !excludedCompTypeList.contains(componentType) && !componentTypeOptions.containsKey("selectedComponentType"))
					{
						componentTypeOptions.put("selectedComponentType",selectedValue);
					}
				}
			}
		}
		componentTypeOptions.put("selectOptions",selectOptions);
	}
	else
	{
		JSONObject option  = new JSONObject();
		option.put("value", "-1");
		option.put("name", mappingInfo.getTextDescription("monitor.common.Not Available"));
		selectOptions.add(option);

		componentTypeOptions.put("selectedComponentType","-1");

		componentTypeOptions.put("selectOptions",selectOptions);
	}
	
	String disp_info=egUI.getValue("TREE_SYSTEM_SETTINGS","DisplayAllComp");
	//String disp_info=egDashConfig.getValue("COMPARISON_DASHBOARD_SETTINGS","DisplayAllComp");
	if(disp_info.equalsIgnoreCase("no"))
	{
		//To remove the component which has no measure
		if(componentList!=null && componentList.size() > 0)
		{
			if(measureData!=null)
			{
				//EgList tempcomponentList=componentList;
				int measure_len=measureList.size();
				for(int k = 0; k< componentList.size(); k++)
				{
					int count_mes=0;
					EgComponent component = (EgComponent)componentList.get(k);
					compName = component.getName();
					String dispCom = component.getDisplayName();
					//int colCnt = 0;
					String s_test="";
					String s_measure="";
					//Iterator iterator3 = measureList.keySet().iterator();
					for(int i=0;i<keyList.size();i++)
					{
						String key_measure = (String)keyList.get(i);
						String unit_Measure = (String)measureList.get(key_measure);
						String []test_Meas = StringUtils.getTokens(key_measure,":");

						if(test_Meas!=null)
						{
							s_test = test_Meas[0];
							s_measure = test_Meas[1];
						}
						String db_Measure =  dbInfo.getColumnForMeasure(s_test,s_measure);
						if(db_Measure!=null && !db_Measure.equals(""))
							s_measure = db_Measure;
						if(s_measure!=null)
						{
							s_measure=s_test+":"+s_measure;
						}
						if(dispCom.indexOf(":") > -1)
							dispCom = dispCom.substring(0,dispCom.indexOf(":"));
						String measure_Value = (String)measureData.get(dispCom +"^"+s_measure);

						if(measure_Value== null || measure_Value.trim().length()==0)
						{
							measure_Value = (String)measureData.get(compName +"^"+s_measure);
						}

						if(measure_Value== null)
						{
							measure_Value="-";
						}
						if(measure_Value.equalsIgnoreCase("-"))
						{
							count_mes++;
						}
						//colCnt++;
					}
					//if total no of measure equal to tot no of empty measure means remove the comp....
					if(count_mes==measure_len)
					{
						componentList.remove(k);
						k--;
					}
				}
			}
		}
	}


	JSONObject countJson= new JSONObject();
	recount=componentList.size();
	pagesizec=recount/pageSize;
	int tem = recount;
	int 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 pageNoReq = request.getParameter("pageNo");
	if(pageNoReq==null || pageNoReq.trim().length()==0 || pageNoReq.equalsIgnoreCase("null"))
		pageNoReq="1";
	int pageStartIndex = 0;
	int pageEndIndex = pageSize;
	int pageNum = 1;
	try
	{
		pageNum = Integer.parseInt(pageNoReq.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;
		}
	}
	catch(Exception ee)
	{
		ee.printStackTrace();
		pageNum=1;
	}

	if(measureList!=null && measureList.size()>0)
	{
		if(componentList !=null && componentList.size() > 0)
		{
			JSONObject columnObj  = new JSONObject();
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
				columnObj.put("text",mappingInfo.getTextDescription("monitor.common.Network Devices"));
			else
				columnObj.put("text",mappingInfo.getTextDescription("monitor.home.Components"));
			String SortForCompName="-2";
			if(measure_sort!=null && measure_sort.equalsIgnoreCase("-1"))
				SortForCompName="-2";
			else if(measure_sort!=null && measure_sort.equalsIgnoreCase("-2"))
				SortForCompName="-1";
			columnObj.put("SortForCompName",SortForCompName);
			String SortTypeForCompName="ASC";
			if(sort_type!=null && sort_type.equalsIgnoreCase("DESC"))
			{
				SortTypeForCompName="ASC";
			}
			else if(sort_type!=null && sort_type.equalsIgnoreCase("ASC"))
			{
				SortTypeForCompName="DESC";
			}
			columnObj.put("SortTypeForCompName",SortTypeForCompName);
			columns.add(columnObj);
			if(sort_type!=null && sort_type.length()>0)
			{
				if(sort_type.equalsIgnoreCase("ascending"))
				{
					imgsrc="/final/monitor/eg_images/arrow_up_black_small.gif";
				}
				else if(sort_type.equalsIgnoreCase("descending"))
				{
					imgsrc="/final/monitor/eg_images/arrow_down_black_small.gif";
				}
			}

			sortByMainOptions.put("sortByLabel",mappingInfo.getTextDescription("monitor.common.Sort By"));
			JSONObject Sortbytypeoption  = new JSONObject();
			Sortbytypeoption.put("value","-1");
			Sortbytypeoption.put("name",mappingInfo.getTextDescription("monitor.common.---State---"));
			sortByOptions.add(Sortbytypeoption);
			Sortbytypeoption  = new JSONObject();
			Sortbytypeoption.put("value","-2");
			Sortbytypeoption.put("name",mappingInfo.getTextDescription("monitor.common.---Component---"));
			sortByOptions.add(Sortbytypeoption);
			if(measure_sort!=null && measure_sort.equalsIgnoreCase("-2"))
				sortByMainOptions.put("sortBySelectedMeasure","-2");
			else if(measure_sort==null)
				sortByMainOptions.put("sortBySelectedMeasure","-1");

			if(measureList!=null && measureList.size() > 0)
			{
				int k=1;
				//Iterator iterator1 = measureList.keySet().iterator();
				String keyVal="";
				for(int i=0;i<keyList.size();i++)
				{
					keyVal = (String)keyList.get(i);
					String testMeas[] = StringUtils.getTokens(keyVal,":");
					if(testMeas!=null)
					{
						compTest = testMeas[0];
						compMeasure = testMeas[1];
						CompDispName = testMeas[2];
					}
					String db_Measure =  dbInfo.getColumnForMeasure(compTest,compMeasure);
					db_Measureandtest=compTest+":"+db_Measure;
					if(measure_sort!=null && measure_sort.trim().length()>0 && measure_sort.equals(db_Measureandtest))
					{
						sortByMainOptions.put("sortBySelectedMeasure",db_Measureandtest);
					}
					Sortbytypeoption  = new JSONObject();
					Sortbytypeoption.put("value",db_Measureandtest);
					Sortbytypeoption.put("name",CompDispName);
					sortByOptions.add(Sortbytypeoption);
					widthOfTheHead="80";
					dbMeasureName =  dbInfo.getColumnForMeasure(compTest,compMeasure);
					if(dbMeasureName.length()==0)
					{
						dbMeasureName=compMeasure;
					}
					if(dbMeasureName!=null)
					{
						dbMeasureName=compTest+":"+dbMeasureName;
					}
					String imgeId="sortImg"+k;

					columnObj  = new JSONObject();
					//columnObj.put("text",CompDispName);
					columnObj.put("text",mappingInfo.getTextDescription("monitor.common."+CompDispName));
					columns.add(columnObj);

					k++;
				}
				
				//Iterator iterator2 = measureList.keySet().iterator();
				for(int i=0;i<keyList.size();i++)
				{
					key = (String)keyList.get(i);
					StringTokenizer tok = new StringTokenizer(key,":");
					int s=0;
					String s_measureFun=null;
					String temp_arr[]=new String[tok.countTokens()];
					while (tok.hasMoreTokens())
					{
						temp_arr[s]=tok.nextToken();
						s++;
					}
					if(s>3)
					{
						String s_test=temp_arr[0];
						String s_measure=temp_arr[1];
						unitMeasure=temp_arr[3];
						String testAndMeasure = s_test+":"+s_measure;
						
						if(!unitMeasure.equalsIgnoreCase("string") && !unitMeasure.equalsIgnoreCase("UniqueCount") && !unitMeasure.equalsIgnoreCase("UniqueUserCount") && !unitMeasure.equalsIgnoreCase("Number"))
						{
							if(unitMeasure.equals("TestMeasureUnit"))
								unitMeasure = tablesInfo.getUnitForMeasure(s_test,s_measure);
							else
							{
								try
								{
									String specify_info=egDashConfig.getValue("TREE_SYSTEM_INFO",s_test);
									if(specify_info!=null && specify_info.trim().length()>0)
									{
										s_measureFun=null;
									}
									else
									{
										s_measureFun=temp_arr[3];
									}
								}
								catch(Exception eee)
								{
									eee.printStackTrace();
									s_measureFun=null;
								}

								if(s_measureFun!=null && (s_measureFun.equalsIgnoreCase("Average") || s_measureFun.equalsIgnoreCase("Avg")))
								{
									s_measureFun = "Avg";
								}
								unitMeasure = tablesInfo.getUnitForMeasure(s_test,s_measure);
							}
						}
						//tablesInfo=null;
					}
					else
					{
						//s_measureFun="Average";
						//s_measureFun="Avg";
						unitMeasure = (String)measureList.get(key);
					}
					
					if(s_measureFun!=null && s_measureFun.trim().length()>0 && !s_measureFun.equalsIgnoreCase("SUM") && !s_measureFun.equalsIgnoreCase("NUMBER"))
					{
						if(unitMeasure != null && unitMeasure.trim().length()>1 && !unitMeasure.equals("(%)"))
							displayUnit = ""+mappingInfo.getTextDescription("monitor.common."+s_measureFun)+" ("+mappingInfo.getTextDescription("monitor.common."+unitMeasure)+")";
						else
							displayUnit = ""+mappingInfo.getTextDescription("monitor.common."+s_measureFun)+" ("+unitMeasure+")";
					}
					else
					{
						if(unitMeasure!=null && (unitMeasure.equalsIgnoreCase("string") || unitMeasure.equalsIgnoreCase("status") || unitMeasure.equalsIgnoreCase("UniqueCount") || unitMeasure.equalsIgnoreCase("UniqueUserCount") || unitMeasure.equalsIgnoreCase("NUMBER")))
						{
							displayUnit = "";
						}
						else
						{
							if(unitMeasure != null && unitMeasure.trim().length()>1 && !unitMeasure.equals("(%)"))
							{
								displayUnit = "("+mappingInfo.getTextDescription("monitor.common."+unitMeasure)+")";
							}							
							else
								displayUnit = "("+unitMeasure+")";
						}
					}

					widthOfTheHead="80";

					if(unitMeasure.equals("%"))
					{
						//displayUnit = unitMeasure;
						widthOfTheHead="100";
					}
					else if(unitMeasure.equals("MB"))
					{
						if(s_measureFun!=null && s_measureFun.trim().length()>0 && !s_measureFun.equalsIgnoreCase("SUM") && !s_measureFun.equalsIgnoreCase("NUMBER"))
						{
							displayUnit = ""+s_measureFun+" ("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
						}
						else
						{
							displayUnit = "("+mappingInfo.getTextDescription("monitor.VirtualDashboard.GB")+")";
						}
					}
					columns.getJSONObject(i+1).put("unit",displayUnit);
				}
			}

			if(componentList!=null && componentList.size() > 0 )
			{
				String currdate = dateInfo.egetDate(false);
				int ff=0;
				int componentList_count=0;
				if(componentList.size()>=pageEndIndex)
				{
					componentList_count=pageEndIndex;
				}
				else if(componentList.size()<pageEndIndex)
				{
					//componentList_count=componentList.size();
					componentList_count=componentList.size();
				}
				int measure_header_len=-1;
				for(int c =pageStartIndex ; c < componentList_count; c++)
				{
					JSONObject measure  = new JSONObject();
					EgComponent component = null;
					try
					{
						component = (EgComponent)componentList.get(c);
					}
					catch(Exception ex)
					{
						ex.printStackTrace();
						ff = 0;
						component = (EgComponent)componentList.get(ff);
					}
					compType = component.getType();
					compName = component.getName();
					compState = (component.getState()).getName();
					dispComp = component.getDisplayName();
					if(selectedNode!=null && selectedNode.indexOf("(")>-1)
					{
						site = selectedNode.substring(0,selectedNode.indexOf("("));
					}
					else
						site = "NULL";
					String treeTitle_New="components";
					if(treeTitle!=null && treeTitle.equalsIgnoreCase("Component"))
						 treeTitle_New="components";
					else if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
						 treeTitle_New="network";

					String trgthost=component.getName();
					if(trgthost!=null && trgthost.indexOf(":")>-1)
						trgthost=trgthost.substring(0,trgthost.indexOf(":"));
					trgthost=trgthost+":NULL";

					String serverName=component.getName();
					String sid="";
					StringTokenizer tokServer=new StringTokenizer(serverName,":");
					int tokens=tokServer.countTokens();
					String sname=tokServer.nextToken();
					String portno=tokServer.nextToken();
					if(tokens==3)
						sid=tokServer.nextToken();

					boolean isHostMaintenance=false;//egM.isItMaintenanceTime(currdate,sname,"","",true);
					boolean isComponentMaintenance=false;//egM.isItMaintenanceTime(currdate,sname,portno,sid,true);
					Hashtable resHostHash=null;
					Hashtable resCompHash=null;

					resHostHash=(Hashtable)egM.getMaintenanceTimePeriod(currdate,sname,"","",true);
					resCompHash=(Hashtable)egM.getMaintenanceTimePeriod(currdate,sname,portno,sid,true);

					if(resHostHash!=null)
					{
						isHostMaintenance = ((Boolean)resHostHash.get("isUnderMaintenance")).booleanValue();
					}

					if(resCompHash!=null)
					{
						isComponentMaintenance = ((Boolean)resCompHash.get("isUnderMaintenance")).booleanValue();
					}

					List  maintenaceTimePeriod=new ArrayList();
					List tempMaintenanceList=null;
					if(isHostMaintenance)
					{
						/*tempMaintenanceList=egM.getMaintenancePeriods(sname,"","",true);
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
							maintenaceTimePeriod.addAll(tempMaintenanceList);
						tempMaintenanceList=egM.getUnplannedMaintenancePeriods(sname,"","",true);
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
							maintenaceTimePeriod.addAll(tempMaintenanceList);*/

						tempMaintenanceList=(List)resHostHash.get("MaintenancePeriods");
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
							maintenaceTimePeriod.addAll(tempMaintenanceList);
					}
					if(isComponentMaintenance)
					{
						/*tempMaintenanceList=egM.getMaintenancePeriods(sname,portno,sid,true);
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
						{
							maintenaceTimePeriod.addAll(tempMaintenanceList);
						}
						tempMaintenanceList=egM.getUnplannedMaintenancePeriods(sname,portno,sid,true);
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
							maintenaceTimePeriod.addAll(tempMaintenanceList);*/

						tempMaintenanceList=(List)resCompHash.get("MaintenancePeriods");
						if(tempMaintenanceList!=null && tempMaintenanceList.size()>0)
							maintenaceTimePeriod.addAll(tempMaintenanceList);
					}

					int noOfLines=maintenaceTimePeriod.size();

					String maintenaceTimePeriodStr="";
					if(isHostMaintenance || isComponentMaintenance)
					{
						maintenaceTimePeriodStr=maintenanceUtil.convertMaintenacevectorToString(maintenaceTimePeriod,user);
					}

					boolean configChanged = ((ht_changeHash.containsKey(component.getName()) || ht_changeHash.containsKey(trgthost)) &&EgInstallInfo.isConfigSupported && hasConfigSupport);
					boolean isTestRelevantForServer = false;
					if(configChanged)
					{
						ArrayList temp_list=(ArrayList) ht_changeHash.get(component.getName());
						if(temp_list==null || temp_list.size()==0)
							temp_list= (ArrayList) ht_changeHash.get(trgthost);

						if(temp_list!=null && temp_list.size()>0)
						{
							for(int k=0;k<temp_list.size();k++)
							{
								String temp_test_name=(String)temp_list.get(k);
								if(temp_test_name!=null && temp_test_name.trim().length()>0)
								{
									isTestRelevantForServer = specsInfo.isTestRelevantForServer(component.getType(),temp_test_name);
								}
								if(isTestRelevantForServer)
									break;
							}
							
							if(isTestRelevantForServer)
								configChanged=true;
							else
								configChanged=false;
						}
						else
							configChanged=false;
					}
					performanceDashboardURL="";
					boolean showPerformanceDashboardForThisType=false;
					String configuredTemplates="";
					if(isShowPerformanceDashboard)
					{
						configuredTemplates=customDashboardInI.getValue("COMPONENT_TYPE_TEMPLATE_MAPPING",compType);
						ArrayList configuredTemplatesList=new ArrayList();
						StringTokenizer stkTemplates=new StringTokenizer(configuredTemplates,",");
						while(stkTemplates.hasMoreTokens())
						{
							String templateName=stkTemplates.nextToken();
							if(templateName!=null && !templateName.startsWith(userId+"_"))
							{
								continue;
							}
							configuredTemplatesList.add(templateName);
						}
						
						if(configuredTemplatesList!=null && !configuredTemplatesList.isEmpty())
						{
							showPerformanceDashboardForThisType=true;
							performanceDashboardURL="/final/monitor/MyDashboard.jsp?comesFrom=myDashboard&action=showMyDashboard&templateOnChange=true&componentDashboard=true&fromHomepage=true&componentsForDashboard=";
						}
					}

					if(filterBy!=null && filterBy.length()>0)
					{
						if(showPerformanceDashboardForThisType)
						{
							url = performanceDashboardURL+EgURLEncoder.encode(compType+":"+compName,"UTF-8");
						}
						else
						{
							url = "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+ "&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&filterBy="+filterBy+"&subFilter="+subFilter+"&componentNameSearch="+componentNameSearch+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
							if(isRumComp || isCitrixComp)
							{
								url= "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+ "&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&filterBy="+subFilter+"&subFilter="+subFilter+"&componentNameSearch="+componentNameSearch+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&filter="+filter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&componentType="+componentType+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
							}
						}
					}
					else
					{
						if(showPerformanceDashboardForThisType)
						{
							url = performanceDashboardURL+EgURLEncoder.encode(compType+":"+compName,"UTF-8");
						}
						else
						{
							url = "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
							if(isRumComp || isCitrixComp)
							{
								url= url+"&filter="+filter+"&filterBy="+subFilter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true";
							}
						}
					}
					if(isServiceBusiViewMetrics!=null && isServiceBusiViewMetrics.trim().length()>0 && isServiceBusiViewMetrics.equalsIgnoreCase("true"))
					{
						url = url + "&isServiceBusiViewMetrics="+isServiceBusiViewMetrics +"&treeFlag="+treeFlag_SBD+"&outsideService="+outsideService_SBD+"&titleText="+titleText_SBD+"&selectNode="+EgURLEncoder.encode(selectNode_SBD,"UTF-8")+"&serviceFromZone="+EgURLEncoder.encode(serviceName,"UTF-8")+"&isEmulTrans="+isEmulTrans_SBD+"&serviceName="+EgURLEncoder.encode(serviceName,"UTF-8")+"&serviceState="+serviceState_SBD+"&isServiceBusiDash="+isServiceBusiDash+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo;
					}
					if(isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true"))
					{
						url = url + "&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
					}
					if(isfromRum!=null && isfromRum.trim().length()>0 && isfromRum.equalsIgnoreCase("true"))
					{
						url = url + "&isfromRum=true&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
					}
					String trBackground="eg_lightlight";
					if(c%2==0)
					{
						trBackground="eg_whitebg";
					}

					measure.put("systemIconClass","state_"+component.getState().getName());
					//measure.put("systemIconTitle",component.getState().getName());
					measure.put("systemIconTitle",mappingInfo.getLabelDescription(component.getState().getName()));
					if(endUserLinkHash != null && endUserLinkHash.containsKey(compType)){
						resconsumIconEnabled=true;
						String getUserType = (String)endUserLinkHash.get(compType);
						String temp_comp_name  = dispComp;
						if(dispComp.indexOf(":") == -1)
							temp_comp_name += ":NULL";
						String end_url="/final/monitor/endUserDashboard.jsp?fromMetricView=true&fromctx=true&access=allusers&userType="+getUserType+"&fromMenu=true&vdiType="+compType+":"+temp_comp_name;
						end_url += "&comptype="+compType+"&treeTitle="+treeTitle_New+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
						//String end_url="/final/monitor/endUserDashboard.jsp?access=allusers&userType="+getUserType+"&fromMenu=true&vdiType="+compType;
						if(filterBy!=null && filterBy.length()>0)
						{	
							if(isRumComp || isCitrixComp)
							{
								if(subFilter != null && subFilter.trim().length()>0)
									end_url = end_url+"&filterBy="+subFilter+"&subFilter="+subFilter;
								else
									end_url = end_url+"&filterBy="+filterBy+"&subFilter="+subFilter;
							}
							else
							{
								end_url = end_url+"&filterBy="+filterBy+"&subFilter="+subFilter;
							}
						}
						if(isServiceBusiViewMetrics!=null && isServiceBusiViewMetrics.trim().length()>0 && isServiceBusiViewMetrics.equalsIgnoreCase("true"))
						{
							end_url = end_url + "&isServiceBusiViewMetrics="+isServiceBusiViewMetrics +"&treeFlag_SBD="+treeFlag_SBD+"&outsideService_SBD="+outsideService_SBD+"&titleText_SBD="+titleText_SBD+"&selectNode_SBD="+EgURLEncoder.encode(selectNode_SBD,"UTF-8")+"&serviceFromZone="+EgURLEncoder.encode(serviceName,"UTF-8")+"&isEmulTrans_SBD="+isEmulTrans_SBD+"&serviceName="+EgURLEncoder.encode(serviceName,"UTF-8")+"&serviceState_SBD="+serviceState_SBD+"&isServiceBusiDash="+isServiceBusiDash;
						}
						if(isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true")){
							end_url = end_url + "&isfromCitrix="+isfromCitrix+"&appliesTo="+appliesTo+"&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
						}
						if(isfromRum!=null && isfromRum.trim().length()>0 && isfromRum.equalsIgnoreCase("true"))
						{
							end_url = end_url + "&isfromRum="+isfromRum+"&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
						}
						if(isRumComp || isCitrixComp)
						{
							end_url= end_url+"&filter="+filter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true";
						}
						measure.put("endUserUrl",end_url);
						if(getUserType.equalsIgnoreCase("VDI"))
							measure.put("endUserText","VM Details");
						else
							measure.put("endUserText","User Details");
					}
					if(resconsumIconEnabled)
						url=url+"&layerModelFromCompPage=true";

					if(isRedirectUrlpresent && msDashboardLinkHash.containsKey(compType))
					{
						String msRedirectUrl = (String)msDashboardLinkHash.get(compType);
						measure.put("layerModelUrl",msRedirectUrl+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&from=metricsView&selectedState="+selectedState);

						if(filterBy!=null && filterBy.length()>0)
						{	
							if(isRumComp || isCitrixComp)
							{
								if(subFilter != null && subFilter.trim().length()>0)
									msRedirectUrl = msRedirectUrl+"&filterBy="+subFilter+"&subFilter="+subFilter;
								else
									msRedirectUrl = msRedirectUrl+"&filterBy="+filterBy+"&subFilter="+subFilter;
							}
							else
							{
								msRedirectUrl = msRedirectUrl+"&filterBy="+filterBy+"&subFilter="+subFilter;
							}
						}
					}
					else
						measure.put("layerModelUrl",url);

					measure.put("systemTitle",dispComp);
					//measure.put("system",StringUtils.egSubString(dispComp,isUserLanguageEnglish,headerLength,15));			// Command by Kaliraj 
					measure.put("system",dispComp);			// Kaliraj 

					if(isHostMaintenance || isComponentMaintenance)
					{
						measure.put("MaintenanceTime",maintenaceTimePeriodStr);
						measure.put("NoOfLines",noOfLines);
					}

					if(configChanged)//  Configuraion Image changes 111
					{
						measure.put("configChange",component.getName()+":"+component.getType());
					}

					colCount = 0;
					//Iterator iterator4 = measureList.keySet().iterator();
					for(int i=0;i<keyList.size();i++)
					{
						key = (String)keyList.get(i);
						StringTokenizer tok = new StringTokenizer(key,":");
						int s=0;
						String s_measureFun=null;
						String temp_arr[]=new String[tok.countTokens()];
						while (tok.hasMoreTokens())
						{
							temp_arr[s]=tok.nextToken();
							s++;
						}

						if(s>3)
						{
							String s_test=temp_arr[0];
							String s_measure=temp_arr[1];
							s_measureFun=temp_arr[3];

							if(!s_measureFun.equalsIgnoreCase("string") && !s_measureFun.equalsIgnoreCase("UniqueCount") && !s_measureFun.equalsIgnoreCase("UniqueUserCount") && !s_measureFun.equalsIgnoreCase("Number"))
							{
								if(s_measureFun.equals("TestMeasureUnit"))
								{
									unitMeasure = tablesInfo.getUnitForMeasure(s_test,s_measure);
								}
								else if(s_measureFun!=null && (s_measureFun.equals("Average") || s_measureFun.equals("Avg")))
								{
									unitMeasure = tablesInfo.getUnitForMeasure(s_test,s_measure);
									if(unitMeasure!=null && unitMeasure.equals("%"))
									{
										unitMeasure="%";
									}
									else
									{
										unitMeasure=s_measureFun;
									}
								}
								else if(s_measureFun!=null && (s_measureFun.equalsIgnoreCase("Sum") || s_measureFun.equalsIgnoreCase("Max") || s_measureFun.equalsIgnoreCase("Min") || s_measureFun.equalsIgnoreCase("NUMBER")))
								{
									unitMeasure = s_measureFun;
								}
								else
								{
									unitMeasure = tablesInfo.getUnitForMeasure(s_test,s_measure);
								}
							}
							else
								unitMeasure = s_measureFun;
							//tablesInfo=null;
						}
						else
						{
							unitMeasure = (String)measureList.get(key);
						}

						testMeasure = StringUtils.getTokens(key,":");
						String org_mea="";
						if(testMeasure!=null)
						{
							stest = testMeasure[0];
							smeasure = testMeasure[1];
							org_mea = smeasure;
							sdispName = testMeasure[2];
						}
						dbMeasure =  dbInfo.getColumnForMeasure(stest,smeasure);
						if(dbMeasure!=null && !dbMeasure.equals(""))
							smeasure = dbMeasure;
						if(smeasure!=null)
						{
							smeasure=stest+":"+smeasure;
						}
						boolean isHostTest = false;
						if(stest != null)
							isHostTest = specsInfo.isTestRelevantForServer("Host_system",stest);
						HashSet Info = new HashSet();
						if(isHostTest)
						{
							String tmpdispComp = dispComp;
							if(tmpdispComp.indexOf(":") > -1)
								tmpdispComp = tmpdispComp.substring(0,tmpdispComp.indexOf(":"));

							Info=(HashSet)measureData.get(tmpdispComp +"^"+smeasure+":INFO");
							measureValue = (String)measureData.get(tmpdispComp +"^"+smeasure);

							if(measureValue == null || measureValue.trim().length()==0)
							{
								Info=(HashSet)measureData.get(compName +"^"+smeasure+":INFO");
								measureValue = (String)measureData.get(compName +"^"+smeasure);
							}
						}
						else
						{
							Info=(HashSet)measureData.get(dispComp +"^"+smeasure+":INFO");
							measureValue = (String)measureData.get(dispComp +"^"+smeasure);

							if(measureValue == null || measureValue.trim().length()==0)
							{
								Info=(HashSet)measureData.get(compName +"^"+smeasure+":INFO");
								measureValue = (String)measureData.get(compName +"^"+smeasure);
							}
						}

						if(measureValue == null || measureValue.trim().length()==0)
						{
							measureValue = "-";
						}
						DecimalFormat df= new DecimalFormat("#0.00");
						double measure_val=0;
						if(measureValue!=null && !measureValue.equalsIgnoreCase("-"))
						{
							if(measureValue!=null && (measureValue.indexOf("Yr")> -1 || measureValue.indexOf("Mth")> -1 || measureValue.indexOf("Day")> -1 ||  measureValue.indexOf("Hr")> -1 || measureValue.indexOf("Min")> -1 || measureValue.indexOf("Sec")> -1 ))
							{
								measureValue=measureValue;
								int tmp_measure_header_len=0;
								if(measureValue.indexOf("Yr")> -1)
								{
									tmp_measure_header_len=(measureValue.length()*9);
								}
								else if(measureValue.indexOf("Mth")> -1)
								{
									tmp_measure_header_len=(measureValue.length()*8);
								}
								else
								{
									tmp_measure_header_len=(measureValue.length()*7);
								}
								
								if(tmp_measure_header_len>measure_header_len)
									measure_header_len=tmp_measure_header_len;
							}
							else
							{
								measure_val= Double.parseDouble(measureValue);
								measureValue=df.format(measure_val);
								String temp=measureValue.substring(measureValue.indexOf(".")+1,measureValue.length());

								if(temp.equals("00"))
								{
									measureValue=measureValue.substring(0,measureValue.indexOf("."));
								}
							}
						}
						if(measureValue!=null && (measureValue.equalsIgnoreCase("0.0") || measureValue.equalsIgnoreCase("0.00")))
						{
							measureValue="0";
						}
						
						String testToUtl="";
						hostNameToken=StringUtils.getTokens(compName,":");
						if(hostNameToken!=null && hostNameToken.length>0)
						{
							hostName = hostNameToken[0];
							hostPort = hostNameToken[1];
						}

						boolean portReleventForTest = specsInfo.isPortRelevantForTest(stest);
						String compNameToUrl=compName;
						if(!portReleventForTest)
						{
							hostPort="NULL";
							//compNameToUrl=hostName+":NULL";
						}
						ArrayList layersForComp = tablesInfo.getLayersForComponent(compType);
						List agents=egExternalInfo.getAgentsFor(stest,compType,hostName);
						if(agents!=null && agents.size()>0)
							msmtHost=(String)agents.get(0);
						else
							msmtHost=hostName;
						String Layer_name_str=tablesInfo.getLayerForTest(stest);
						String layerName="HOST";
						if(Layer_name_str!=null && Layer_name_str.trim().length()>0)
						{
							StringTokenizer tokenLayer=new StringTokenizer(Layer_name_str,",");
							if(tokenLayer!=null)
							{
								while(tokenLayer.hasMoreTokens())
								{
									String l_name=(String)tokenLayer.nextToken();
									if(l_name!=null)
									{
										if(layersForComp!=null && layersForComp.contains(l_name))
										{
											if(tablesInfo.isMeasureInLayer(stest,org_mea,l_name))
											{
												layerName=l_name;
												break;
											}
										}
									}
								}
							}
						}

						boolean isMVD=false;
						if(showPerformanceDashboardForThisType)
						{
							Measureurl = performanceDashboardURL+EgURLEncoder.encode(compType+":"+compNameToUrl,"UTF-8");
						}
						else
						{
							if(filterBy!=null && filterBy.length()>0 && subFilter!=null && subFilter.length()>0)
							{
								if(Info!=null && Info.size()==1)
								{
									String infoFirst=Info.iterator().next().toString();
									//if(infoFirst!=null && infoFirst.indexOf("\\")!=-1)
										//infoFirst = com.egurkha.util.StringUtils.replace(infoFirst, "\\", "\\\\");
									if(infoFirst!=null && infoFirst.trim().length()>0 && (!infoFirst.startsWith("+")) && infoFirst.endsWith("+"))
									{
										testToUtl=stest+"-+";
									}
									else if(infoFirst!=null && infoFirst.trim().length()>0 && (!infoFirst.startsWith("+")) && (!infoFirst.endsWith("+")))
									{
										testToUtl=stest+"-"+infoFirst.substring(infoFirst.indexOf("+"));
									}
									else if(infoFirst!=null && infoFirst.trim().length()>0)
									{
										testToUtl=stest+"-"+infoFirst;
									}
									else
									{
										testToUtl=stest+"-+";
									}

									String iniVar=stest+":"+org_mea+":"+measureValue;
									String iniValue=egUI.getValue("Measure_value_display",iniVar);
									if(iniValue!=null && iniValue.length() > 0)
									{
										measureValue=iniValue;
										isMVD=true;
									}

									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=2&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&filterBy="+EgURLEncoder.encode(filterBy,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									if(isRumComp || isCitrixComp)
									{
										Measureurl= "/final/monitor/EgSiteInfraView.jsp?qctr=2&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&filter="+filter+"&filterBy="+EgURLEncoder.encode(subFilter,"UTF-8")+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									}
									//System.out.println("1 Measureurl--->"+Measureurl);
								}
								else if(Info!=null && Info.size()>1)
								{
									String iniVar=stest+":"+org_mea+":"+measureValue;								
									String iniValue=egUI.getValue("Measure_value_display",iniVar);
									if(iniValue!=null && iniValue.length() > 0)
									{
										measureValue=iniValue;
										isMVD=true;
									}
									testToUtl="null-+";
									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&filterBy="+EgURLEncoder.encode(filterBy,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									if(isRumComp || isCitrixComp)
									{
										Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&filterBy="+EgURLEncoder.encode(subFilter,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&filter="+filter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									}
									//System.out.println("2 Measureurl--->"+Measureurl);
								}
								else
								{
									testToUtl="null-+";
									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&filterBy="+EgURLEncoder.encode(filterBy,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									if(isRumComp || isCitrixComp)
									{
										Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&filterBy="+EgURLEncoder.encode(subFilter,"UTF-8")+"&subFilter="+EgURLEncoder.encode(subFilter,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&filter="+filter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									}
									//System.out.println("3 Measureurl--->"+Measureurl);
								}
							}
							else
							{
								if(Info!=null && Info.size()==1)
								{
									String infoFirst=Info.iterator().next().toString();
									//if(infoFirst!=null && infoFirst.indexOf("\\")!=-1)
										//infoFirst = com.egurkha.util.StringUtils.replace(infoFirst, "\\", "\\\\");

									if(infoFirst!=null && infoFirst.trim().length()>0 && (!infoFirst.startsWith("+")) && infoFirst.endsWith("+"))
									{
										testToUtl=stest+"-+";
									}
									else if(infoFirst!=null && infoFirst.trim().length()>0 && (!infoFirst.startsWith("+")) && (!infoFirst.endsWith("+")))
									{
										testToUtl=stest+"-"+infoFirst.substring(infoFirst.indexOf("+"));
									}
									else if(infoFirst!=null && infoFirst.trim().length()>0)
									{
										testToUtl=stest+"-"+infoFirst;
									}
									else
									{
										testToUtl=stest+"-+";
									}

									String iniVar=stest+":"+org_mea+":"+measureValue;
									String iniValue=egUI.getValue("Measure_value_display",iniVar);
									if(iniValue!=null && iniValue.length() > 0)
									{
										measureValue=iniValue;
										isMVD=true;
									}

									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=2&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;

									if(isRumComp || isCitrixComp)
									{
										Measureurl= Measureurl+"&filter="+filter+"&filterBy="+filterBy+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo;
									}
									//System.out.println("4 Measureurl--->"+Measureurl);
								}
								else if(Info!=null && Info.size()>1)
								{

									String iniVar=stest+":"+org_mea+":"+measureValue;								
									String iniValue=egUI.getValue("Measure_value_display",iniVar);
									if(iniValue!=null && iniValue.length() > 0)
									{
										measureValue=iniValue;
										isMVD=true;
									}

									testToUtl="null-+";
									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTf-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									if(isRumComp || isCitrixComp)
									{
										Measureurl= Measureurl+"&filter="+filter+"&filterBy="+filterBy+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo;
									}
									//System.out.println("5 Measureurl--->"+Measureurl);
								}
								else
								{
									testToUtl="null-+";
									Measureurl="/final/monitor/EgSiteInfraView.jsp?qctr=1&fromalarm=&host="+EgURLEncoder.encode(compNameToUrl,"UTF-8")+"&layer="+EgURLEncoder.encode(layerName,"UTF-8")+"&site="+site+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&test="+EgURLEncoder.encode(testToUtl,"UTF-8")+"&comptype="+EgURLEncoder.encode(compType,"UTF-8")+"&tstate="+compState+"&newWindow=false&prevPage=MainDashBoard&treeTitle="+EgURLEncoder.encode(treeTitle_New,"UTF-8")+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromp=ComparisonDashboard"+"&fromPageView="+EgURLEncoder.encode(fromPageView,"UTF-8")+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
									if(isRumComp || isCitrixComp)
									{
										Measureurl= Measureurl+"&filter="+filter+"&filterBy="+filterBy+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&appliesTo="+appliesTo;
									}
									//System.out.println("6 Measureurl--->"+Measureurl);
								}
							}
						}
						
						String columnWith="180";
						String testName=stest.toLowerCase();
						if(testName!=null && testName.indexOf("uptime")>-1)
						{
							columnWith=String.valueOf(measure_header_len);
							columns.getJSONObject(i+1).put("columnWith", columnWith);
							columns.getJSONObject(i+1).put("textType", "asString");
						}
						else if(isMVD)
						{
							columns.getJSONObject(i+1).put("textType", "asString");
						}
						else
						{
							columns.getJSONObject(i+1).put("textType", "asFloat");
						}

						//columns.getJSONObject(i+1).put("textType", "asFloat");
						columns.getJSONObject(i+1).put("dataIndex",i+"MeasureValue");
						columns.getJSONObject(i+1).put("measureOrgName",smeasure);
						String sortty="DESC";
						if(sort_type!=null && sort_type.equalsIgnoreCase("DESC"))
						{
							sortty="ASC";
						}
						else if(sort_type!=null && sort_type.equalsIgnoreCase("ASC"))
						{
							sortty="DESC";
						}
						columns.getJSONObject(i+1).put("sortType",sortty);
						measure.put(i+"MeasureValue",measureValue);

						if(measureValue!=null && !measureValue.equals("-"))
						{
							if(unitMeasure.equals("%"))
							{
								int columnWidth = 100;
								Long tempValue=new Long(Math.round(Double.parseDouble(measureValue)));
								long fillColorValue=tempValue.longValue();
								long tempValue2 = (fillColorValue*100)/columnWidth;
								measure.put(i+"MeasureValueWidth",tempValue2);
							}
							if(isServiceBusiViewMetrics!=null && isServiceBusiViewMetrics.trim().length()>0 && isServiceBusiViewMetrics.equalsIgnoreCase("true"))
							{
								Measureurl = Measureurl +"&isServiceBusiViewMetrics="+isServiceBusiViewMetrics+"&treeFlag="+treeFlag_SBD+"&outsideService="+outsideService_SBD+"&titleText="+titleText_SBD+"&selectNode="+EgURLEncoder.encode(selectNode_SBD,"UTF-8")+"&serviceFromZone="+EgURLEncoder.encode(serviceName,"UTF-8")+"&isEmulTrans="+isEmulTrans_SBD+"&serviceName="+EgURLEncoder.encode(serviceName,"UTF-8")+"&serviceState="+serviceState_SBD+"&isServiceBusiDash="+isServiceBusiDash;
							}
							if(isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true"))
							{
								Measureurl = Measureurl + "&isfromCitrix=true&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange+"&componentType="+componentType;
							}
							if(isfromRum!=null && isfromRum.trim().length()>0 && isfromRum.equalsIgnoreCase("true"))
							{
								Measureurl = Measureurl + "&isfromRum=true&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange+"&componentType="+componentType;
							}
							/*if(isRedirectUrlpresent && msDashboardLinkHash.containsKey(compType))
							{
								String msRedirectUrl = (String)msDashboardLinkHash.get(compType);
								measure.put(i+"MeasureValueUrl",msRedirectUrl+"&host="+EgURLEncoder.encode(compName,"UTF-8"));
							}
							else*/
								measure.put(i+"MeasureValueUrl",Measureurl);
						}
						colCount++;
					}
					measures.add(measure);
					ff++;
				}
			}
			JSONObject labelObj= new JSONObject();
			labelObj.put("monitor.serviceDashboard.noDataMsg",mappingInfo.getTextDescription("monitor.common.No data found"));
			labelObj.put("monitor.serviceDashboard.systemTitle",mappingInfo.getTextDescription("monitor.serviceDashboard.Key Performance Indicators for Service")+" : "+selectedParam);
			json.put("columns",columns);
			json.put("measures",measures);
			json.put("screenLabels",labelObj);
			json.put("componentTypeOptions",componentTypeOptions);
			json.put("countJson",countJson);
			sortByMainOptions.put("sortByOptions",sortByOptions);
			json.put("sortByMainOptions",sortByMainOptions);
			json.put("filterByOptions", filterByOptions);
			json.put("subFilterOptions", subFilterOptions);
			json.put("pageParams", pageParams);
			response.getWriter().write(json.toString());
		}
		else
		{
			JSONObject labelObj= new JSONObject();
			labelObj.put("monitor.serviceDashboard.noDataMsg",mappingInfo.getTextDescription("monitor.common.No data found"));
			labelObj.put("monitor.serviceDashboard.systemTitle",mappingInfo.getTextDescription("monitor.serviceDashboard.Key Performance Indicators for Service")+" : "+selectedParam);
			json.put("columns",columns);
			json.put("measures",measures);
			json.put("screenLabels",labelObj);
			json.put("componentTypeOptions",componentTypeOptions);
			json.put("countJson",countJson);
			sortByMainOptions.put("sortByOptions",sortByOptions);
			json.put("sortByMainOptions",sortByMainOptions);
			json.put("filterByOptions", filterByOptions);
			json.put("subFilterOptions", subFilterOptions);
			json.put("pageParams", pageParams);
			json.put("error",mappingInfo.getTextDescription("monitor.serviceDashboard.No components found/No metrics configured"));
			response.getWriter().write(json.toString());
		}
		/*else
		{
			JSONObject labelObj= new JSONObject();
			labelObj.put("monitor.serviceDashboard.systemTitle",mappingInfo.getTextDescription("monitor.serviceDashboard.Key Performance Indicators for service")+" : "+selectedParam);
			sortByMainOptions.put("sortByOptions",sortByOptions);
			json.put("filterByOptions", filterByOptions);
			json.put("subFilterOptions", subFilterOptions);
			json.put("pageParams", pageParams);
			json.put("screenLabels",labelObj);
			json.put("componentTypeOptions",componentTypeOptions);
			json.put("error",mappingInfo.getTextDescription("monitor.serviceDashboard.No metrics configured"));
			
			response.getWriter().write(json.toString());
		}*/
	}
	else
	{
		boolean needErrorMsg=true;
		if(componentList !=null && componentList.size() > 0)
		{
			needErrorMsg=false;
			JSONObject columnObj  = new JSONObject();
			EgComponent component = null;
			int componentList_count=0;
			int ff=0;
			if(componentList.size()>=pageEndIndex)
			{
				componentList_count=pageEndIndex;
			}
			else if(componentList.size()<pageEndIndex)
			{
				componentList_count=componentList.size();
			}
			for(int c =pageStartIndex ; c < componentList_count; c++)
			{
				try
				{
					component = (EgComponent)componentList.get(c);
				}
				catch(Exception ex)
				{
					ex.printStackTrace();
					ff = 0;
					component = (EgComponent)componentList.get(ff);
				}
				
				dispComp = component.getDisplayName();
				if(selectedNode!=null && selectedNode.indexOf("(")>-1)
				{
					site = selectedNode.substring(0,selectedNode.indexOf("("));
				}
				else
					site = "NULL";
				compType = component.getType();
				compName = component.getName();
				JSONObject measure  = new JSONObject();
				if(endUserLinkHash != null && endUserLinkHash.containsKey(compType))
					resconsumIconEnabled=true;

				measure.put("systemIconClass","state_"+component.getState().getName());
				measure.put("systemIconTitle",mappingInfo.getLabelDescription(component.getState().getName()));
				measure.put("systemTitle",dispComp);
				measure.put("system",dispComp);
				String trgthost=component.getName();
				if(trgthost!=null && trgthost.indexOf(":")>-1)
					trgthost=trgthost.substring(0,trgthost.indexOf(":"));
				trgthost=trgthost+":NULL";
				boolean configChanged = ((ht_changeHash.containsKey(component.getName()) || ht_changeHash.containsKey(trgthost)) &&EgInstallInfo.isConfigSupported && hasConfigSupport);
				boolean isTestRelevantForServer = false;
				if(configChanged)
				{
					ArrayList temp_list=(ArrayList) ht_changeHash.get(component.getName());
					if(temp_list==null || temp_list.size()==0)
						temp_list= (ArrayList) ht_changeHash.get(trgthost);

					if(temp_list!=null && temp_list.size()>0)
					{
						for(int k=0;k<temp_list.size();k++)
						{
							String temp_test_name=(String)temp_list.get(k);
							if(temp_test_name!=null && temp_test_name.trim().length()>0)
							{
								isTestRelevantForServer = specsInfo.isTestRelevantForServer(component.getType(),temp_test_name);
							}
							if(isTestRelevantForServer)
								break;
						}
						
						if(isTestRelevantForServer)
							configChanged=true;
						else
							configChanged=false;
					}
					else
						configChanged=false;
				}
				if(configChanged)//  Configuraion Image changes 111
				{
					measure.put("configChange",component.getName()+":"+component.getType());
				}
				String treeTitle_New="components";
				if(treeTitle!=null && treeTitle.equalsIgnoreCase("Component"))
					 treeTitle_New="components";
				else if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
					 treeTitle_New="network";
				boolean showPerformanceDashboardForThisType=false;
				String configuredTemplates="";
				if(isShowPerformanceDashboard)
				{
					configuredTemplates=customDashboardInI.getValue("COMPONENT_TYPE_TEMPLATE_MAPPING",compType);
					ArrayList configuredTemplatesList=new ArrayList();
					StringTokenizer stkTemplates=new StringTokenizer(configuredTemplates,",");
					while(stkTemplates.hasMoreTokens())
					{
						String templateName=stkTemplates.nextToken();
						if(templateName!=null && !templateName.startsWith(userId+"_"))
						{
							continue;
						}
						configuredTemplatesList.add(templateName);
					}
					
					if(configuredTemplatesList!=null && !configuredTemplatesList.isEmpty())
					{
						showPerformanceDashboardForThisType=true;
						performanceDashboardURL="/final/monitor/MyDashboard.jsp?comesFrom=myDashboard&action=showMyDashboard&templateOnChange=true&componentDashboard=true&fromHomepage=true&componentsForDashboard=";
					}
				}
				if(filterBy!=null && filterBy.length()>0)
				{
					if(showPerformanceDashboardForThisType)
					{
						url = performanceDashboardURL+EgURLEncoder.encode(compType+":"+compName,"UTF-8");
					}
					else
					{
						url = "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+ "&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&filterBy="+filterBy+"&subFilter="+subFilter+"&componentNameSearch="+componentNameSearch+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
						
						if(isRumComp || isCitrixComp)
						{
							url= "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+ "&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&filterBy="+subFilter+"&subFilter="+subFilter+"&componentNameSearch="+componentNameSearch+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&filter="+filter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true&componentType="+componentType+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
						}
					}
				}
				else
				{
					if(showPerformanceDashboardForThisType)
					{
						url = performanceDashboardURL+EgURLEncoder.encode(compType+":"+compName,"UTF-8");
					}
					else
					{
						url = "/final/servlet/com.eg.EgDashboardController?from=list&fromp=ComparisonDashboard&site="+EgURLEncoder.encode(site,"UTF-8")+"&qctr=0&comptype="+compType+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&tab=LayerModel&toDashBoardLayer=true&treeTitle="+treeTitle_New+"&componentNameSearch="+EgURLEncoder.encode(componentNameSearch,"UTF-8")+"&fromPageView="+fromPageView+"&selectedState="+selectedState+"&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&action="+action+"&fromHomepage="+fromHomepage+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone;
						if(isRumComp || isCitrixComp)
						{
							url= url+"&filter="+filter+"&filterBy="+subFilter+"&selectedRum="+selectedRum+"&isFromServiceMenu="+isFromServiceMenu+"&isFromZoneMain="+isFromZoneMain+"&isFromZoneMenu="+isFromZoneMenu+"&isFromServiceGroup="+isFromServiceGroup+"&serviceComponent=true";
						}
					}
				}
				if(isServiceBusiViewMetrics!=null && isServiceBusiViewMetrics.trim().length()>0 && isServiceBusiViewMetrics.equalsIgnoreCase("true"))
				{
					url = url + "&isServiceBusiViewMetrics="+isServiceBusiViewMetrics +"&treeFlag="+treeFlag_SBD+"&outsideService="+outsideService_SBD+"&titleText="+titleText_SBD+"&selectNode="+EgURLEncoder.encode(selectNode_SBD,"UTF-8")+"&serviceFromZone="+EgURLEncoder.encode(serviceName,"UTF-8")+"&isEmulTrans="+isEmulTrans_SBD+"&serviceName="+EgURLEncoder.encode(serviceName,"UTF-8")+"&serviceState="+serviceState_SBD+"&isServiceBusiDash="+isServiceBusiDash+"&isfromCitrix="+isfromCitrix+"&isfromRum="+isfromRum+"&appliesTo="+appliesTo;
				}
				if(isfromCitrix!=null && isfromCitrix.trim().length()>0 && isfromCitrix.equalsIgnoreCase("true"))
				{
					url = url + "&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
				}
				if(isfromRum!=null && isfromRum.trim().length()>0 && isfromRum.equalsIgnoreCase("true"))
				{
					url = url + "&isfromRum=true&dashboard_mapping="+dashboard_mapping+"&dashboard_name="+dashboard_name+"&user_name="+user_name+"&view_name="+view_name+"&iniName="+iniName+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange;
				}
				if(resconsumIconEnabled)
					url=url+"&layerModelFromCompPage=true";

				if(isRedirectUrlpresent && msDashboardLinkHash.containsKey(compType))
				{
					String msRedirectUrl = (String)msDashboardLinkHash.get(compType);
					measure.put("layerModelUrl",msRedirectUrl+"&host="+EgURLEncoder.encode(compName,"UTF-8")+"&from=metricsView&filter="+filter+"&filterBy="+subFilter+"&selectedState="+selectedState);
				}
				else
					measure.put("layerModelUrl",url);

				measure.put("0MeasureValue","No metrics configured");
				measures.add(measure);			
				json.put("measures",measures);
			}
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
				columnObj.put("text",mappingInfo.getTextDescription("monitor.common.Network Devices"));
			else
				columnObj.put("text",mappingInfo.getTextDescription("monitor.home.Components"));
			String SortForCompName="-2";
			if(measure_sort!=null && measure_sort.equalsIgnoreCase("-1"))
				SortForCompName="-2";
			else if(measure_sort!=null && measure_sort.equalsIgnoreCase("-2"))
				SortForCompName="-1";
			columnObj.put("SortForCompName",SortForCompName);
			String SortTypeForCompName="ASC";
			if(sort_type!=null && sort_type.equalsIgnoreCase("DESC"))
			{
				SortTypeForCompName="ASC";
			}
			else if(sort_type!=null && sort_type.equalsIgnoreCase("ASC"))
			{
				SortTypeForCompName="DESC";
			}
			columnObj.put("SortTypeForCompName",SortTypeForCompName);

			columns.add(columnObj);
			columnObj  = new JSONObject();
			//columnObj.put("text",mappingInfo.getTextDescription("monitor.common.Measures Status"));
			columnObj.put("text","");
			columnObj.put("dataIndex","0MeasureValue");
			columns.add(columnObj);
			json.put("columns",columns);
			
		}
		JSONObject labelObj= new JSONObject();
		labelObj.put("monitor.serviceDashboard.systemTitle",mappingInfo.getTextDescription("monitor.serviceDashboard.Key Performance Indicators for Service")+" : "+selectedParam);
		
		json.put("screenLabels",labelObj);
		json.put("componentTypeOptions",componentTypeOptions);
		json.put("countJson",countJson);
		if(componentList !=null && componentList.size() > 0)
		{
			sortByMainOptions.put("sortByLabel",mappingInfo.getTextDescription("monitor.common.Sort By"));
			JSONObject Sortbytypeoption  = new JSONObject();
			Sortbytypeoption.put("value","-1");
			Sortbytypeoption.put("name",mappingInfo.getTextDescription("monitor.common.---State---"));
			sortByOptions.add(Sortbytypeoption);
			Sortbytypeoption  = new JSONObject();
			Sortbytypeoption.put("value","-2");
			Sortbytypeoption.put("name",mappingInfo.getTextDescription("monitor.common.---Component---"));
			sortByOptions.add(Sortbytypeoption);
			if(measure_sort!=null && measure_sort.equalsIgnoreCase("-2"))
				sortByMainOptions.put("sortBySelectedMeasure","-2");
			else if(measure_sort==null)
				sortByMainOptions.put("sortBySelectedMeasure","-1");

			sortByMainOptions.put("sortByOptions",sortByOptions);

		}
		else
			sortByMainOptions.put("sortByOptions",sortByOptions);

		json.put("sortByMainOptions",sortByMainOptions);
		json.put("filterByOptions", filterByOptions);
		json.put("subFilterOptions", subFilterOptions);
		json.put("pageParams", pageParams);
		if(needErrorMsg)
		{
			if(isAllAggComp)
			{
				json.put("error",mappingInfo.getTextDescription("monitor.serviceDashboard.Aggregate components not supported"));
			}
			else
			{
				json.put("error",mappingInfo.getTextDescription("monitor.serviceDashboard.No components found/No metrics configured"));
			}
		}
		response.getWriter().write(json.toString());
	}
}
catch(Throwable exp)
{
	System.out.println("Exception in comparisonDashboard Component Page..");
	exp.printStackTrace();
}


try
{
	String treeTitle = request.getParameter("treeTitle");
	treeTitle=(treeTitle==null || treeTitle.trim().length()==0)?"Component":treeTitle;
	String fromPageView = request.getParameter("fromPageView");
	fromPageView=(fromPageView==null || fromPageView.trim().length()==0)?"Menu":fromPageView;
	String viewPageTitle=request.getParameter("viewPageTitle");
	viewPageTitle=(viewPageTitle==null || viewPageTitle.equalsIgnoreCase("undefined") || viewPageTitle.trim().length()==0)?"":viewPageTitle;
	String action=request.getParameter("action");
	action=(action==null || action.equalsIgnoreCase("undefined") || action.trim().length()==0)?"":action;
	String fromHomepage=request.getParameter("fromHomepage");
	fromHomepage=(fromHomepage==null || fromHomepage.equalsIgnoreCase("undefined") || fromHomepage.trim().length()==0)?"":fromHomepage;
	String userName=request.getParameter("userName");
	userName=(userName==null || userName.equalsIgnoreCase("undefined") || userName.trim().length()==0)?"":userName;
	String componentType=request.getParameter("componentType");
	componentType=(componentType==null || componentType.equalsIgnoreCase("undefined") || componentType.trim().length()==0)?"":componentType;
	String filterBy = request.getParameter("filterBy");
	filterBy=(filterBy==null || filterBy.equalsIgnoreCase("undefined") || filterBy.trim().length()==0)?treeTitle:filterBy;
	String subFilter = request.getParameter("subFilter");
	subFilter=(subFilter==null || subFilter.equalsIgnoreCase("undefined") || subFilter.trim().length()==0)?"":subFilter;
	String selectedState=request.getParameter("selectedState");
	selectedState=(selectedState==null  || selectedState.equalsIgnoreCase("undefined") || selectedState.trim().length()==0)?"":selectedState;
	String isServiceBusiDash=request.getParameter("isServiceBusiDash");
	String isfromCitrix=request.getParameter("isfromCitrix");
	String isfromRum=request.getParameter("isfromRum");
	String dashboard_mapping = request.getParameter("dashboard_mapping");
	String dashboard_name = request.getParameter("dashboard_name");
	String user_name = request.getParameter("user_name");
	String view_name = request.getParameter("view_name");
	String iniName = request.getParameter("iniName");
	String appliesTo = request.getParameter("appliesTo");
	String isFromZone = request.getParameter("isFromZone");
	String iszoneName = request.getParameter("iszoneName");
	String parentZone = request.getParameter("parentZone");
	String fromServiceHomePage = request.getParameter("fromServiceHomePage");
	String fromSerComboChange = request.getParameter("fromSerComboChange");
	String treeFlag_SBD = request.getParameter("treeFlag_SBD");
	String titleText_SBD = request.getParameter("titleText_SBD");
	String selectNode_SBD = request.getParameter("selectNode_SBD");
	String isEmulTrans_SBD = request.getParameter("isEmulTrans_SBD");
	String outsideService_SBD = request.getParameter("outsideService_SBD");
	String serviceName = request.getParameter("serviceName");
	String serviceState_SBD = request.getParameter("serviceState_SBD");
		
	String qString=request.getQueryString();
	if(isfromRum!= null && isfromRum.trim().length() > 0 && isfromRum.equalsIgnoreCase("true"))
		isfromCitrix = "true";
	if(isfromCitrix == null || isfromCitrix.trim().length() == 0 || !isfromCitrix.equalsIgnoreCase("true"))
	{
		if(qString!=null)
		{
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
			{
				if(componentType!=null && componentType.length()>0)
				{
					session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&menuName=network&searchIndComps=checked&isFromMenu=true&view=metric&viewId=network&viewPageTitle=Network Devices&viewTreeTitle=Network&componentType="+componentType);
				}
				else
				{
					session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&menuName=network&searchIndComps=checked&isFromMenu=true&view=metric&viewId=network&viewPageTitle=Network Devices&viewTreeTitle=Network");
				}
			}
			else
			{
				if(fromPageView!=null && !fromPageView.equalsIgnoreCase("undefined") && !fromPageView.equalsIgnoreCase("null") && !fromPageView.equalsIgnoreCase(""))
				{
					if(isServiceBusiDash != null && isServiceBusiDash.equalsIgnoreCase("true"))
					{
						String tempURL1="&selectNode_SBD="+EgURLEncoder.encode(selectNode_SBD,"UTF-8")+"&treeFlag_SBD="+treeFlag_SBD+"&outsideService_SBD="+outsideService_SBD+"&titleText_SBD="+titleText_SBD+"&isEmulTrans_SBD="+isEmulTrans_SBD+"&serviceState_SBD="+serviceState_SBD+"&serviceName="+serviceName;
						session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&fromAcessPage=bussinessDashboard&from=bussinessDashboard&action=component&searchIndComps=checked&isFromMenu=false&view=metric&viewId=components&viewPageTitle=Components&viewTreeTitle=Component&filterBy="+filterBy+"&subFilter="+subFilter+"&componentType="+componentType+"&isServiceBusiDash=true"+tempURL1);
					}
					else
					{
						String fromMenu="";
						if(fromPageView.equalsIgnoreCase("zoneDashboard"))
							fromMenu="&isFromMenu=false";
						session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=componentList&action="+action+"&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+viewPageTitle+"&viewTreeTitle=Component&componentType="+componentType+"&fromPageView="+fromPageView+"&filterBy="+filterBy+"&subFilter="+subFilter+"&zoneName="+subFilter+"&fromHomepage="+fromHomepage+"&userName="+userName+"&stateName="+selectedState+"&selectedState="+selectedState+fromMenu);
					
					}
				}
				else
				{
					session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=componentList&action=component&searchIndComps=checked&isFromMenu=true&view=metric&viewId=components&viewPageTitle=Components&viewTreeTitle=Component");
				}
				
			}
		}
		else
		{
			if(treeTitle!=null && treeTitle.equalsIgnoreCase("Network"))
			{
				session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&menuName=network&searchIndComps=checked&isFromMenu=true&view=metric&viewId=network&viewPageTitle=Network Devices&viewTreeTitle=Network");
			}
			else
			{
				session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&isFromMenu=true&view=metric&viewId=components&viewPageTitle=Components&viewTreeTitle=Component");
			}
		}
	}
	else if(isfromCitrix != null && isfromCitrix.trim().length() > 0 && isfromCitrix.equalsIgnoreCase("true")){
		if(isfromRum!= null && isfromRum.trim().length() > 0 && isfromRum.equalsIgnoreCase("true"))
		{
			session.setAttribute("monitorLastSession","/final/monitor/rumAppFlow.jsp?iniName=eg_rumdashboard&userBased=true&fromMenu=true&showConfig=true&user_name="+user_name+"&dashboard_name=RUM_Dashboard&appliesTo="+appliesTo+"&isBackFromRUM=false&filter=Service&filterBy="+subFilter+"&view_name="+view_name+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone);
		}
		else
		{
			String url ="";
			if(fromServiceHomePage!= null && fromServiceHomePage.trim().length() > 0 && fromServiceHomePage.equalsIgnoreCase("true") && !fromServiceHomePage.equalsIgnoreCase("NULL"))
			{
				url ="/final/monitor/citrixDashboard.jsp?iniName="+iniName+"&action=loadViewData&user_name="+user_name+"&fromMenu=true&showConfig=true&fromUED=true&dashboard_name="+dashboard_name+"&view_name="+view_name+"&componentType="+compType+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone+"&filter=Service&filterBy="+serviceName; 
			}
			else
			{
				url ="/final/monitor/citrixDashboard.jsp?iniName="+iniName+"&action=loadViewData&user_name="+user_name+"&fromMenu=true&showConfig=true&fromUED=true&dashboard_name="+dashboard_name+"&view_name="+view_name+"&componentType="+compType+"&fromServiceHomePage="+fromServiceHomePage+"&fromSerComboChange="+fromSerComboChange+"&isFromZone="+isFromZone+"&iszoneName="+iszoneName+"&parentZone="+parentZone+"&dashboard_mapping="+dashboard_mapping+"&filter=Service&filterBy="+serviceName; 
			}

			session.setAttribute("monitorLastSession",url);	
		}
	}
}
catch(Exception exp)
{
	System.out.println("Exception in comparisonDashboard Component Page..");
	exp.printStackTrace();
}
%>
