<%@ include file = "EgMonitorTracker.jsp" %>
<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %> 
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.egurkha.ini.IniUI" %>
<%@ page import="com.eg.EgStateManager" %>
<%@ page import="com.eg.EgServicesInfo" %>
<%@ page import="com.egurkha.monitor.*" %>
<%@ page import="com.egurkha.monitor.alarms.AlarmPriorities" %>
<%@ page import="com.eg.*" %>
<%@ page import = "egurkha.*" %>
<%@ page import="com.eg.EgStateManager" %>
<%@ page import="com.eg.EgURLEncoder"	%>
<%@ page import="com.egurkha.*"%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="com.egurkha.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.egurkha.monitor.Dashboard"	%>
<%@ page import="com.egurkha.monitor.DashboardData"%>
<%@ page import="com.egurkha.monitor.DashboardResult"%>
<%@ page import="com.egurkha.monitor.*"	%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="net.sf.json.*"%>
<%@ page import = "com.eg.EgMappingInfo"%>
<%@ page import="java.sql.*"%>					
<%@ page import="com.eg.IniFile"%>

<%@ page import="com.fasterxml.jackson.databind.ObjectMapper"%>
<%@ page import="com.fasterxml.jackson.databind.node.ArrayNode"%>
<%@ page import="com.fasterxml.jackson.databind.node.ObjectNode"%>
<%@ page import="com.fasterxml.jackson.databind.JsonNode"%>

<%
try
{
	String thisLanguage="";
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);
	response.setContentType("application/json");

	String iscurrentTab = request.getParameter("currentTab");
	//iscurrentTab=(iscurrentTab==null||iscurrentTab.trim().length()==0)?"details":iscurrentTab;
	String isaggregateTab = request.getParameter("aggregateTab");
	String isopenNode = request.getParameter("openNode");
	String isTreeFlag = request.getParameter("treeFlag");
	String fromHomepage = request.getParameter("fromHomepage");
	fromHomepage = (fromHomepage!=null && !fromHomepage.equalsIgnoreCase("") && !fromHomepage.equalsIgnoreCase("null") && !fromHomepage.equalsIgnoreCase("undefined"))?fromHomepage:"";
	String iszoneName = request.getParameter("zoneName");
	String fromZoneMenu = request.getParameter("fromZoneMenu");
	boolean isFromZoneMenu= false;
	if(fromZoneMenu != null && fromZoneMenu.trim().length()>0 && (fromZoneMenu.equalsIgnoreCase("true") || fromZoneMenu.equalsIgnoreCase("yes")))
	{
		isFromZoneMenu = true;
	}
	String isselectNode = request.getParameter("selectNode");
	if(isselectNode != null)
	{
		isselectNode = com.egurkha.util.StringUtils.replace(isselectNode,"$cap$","^");
		isselectNode = com.egurkha.util.StringUtils.replace(isselectNode,"$pipe$","|");
	}

	String isselectedParam = request.getParameter("selectedParam");
	//String parentZoneVal = request.getParameter("parentZone");
	//parentZoneVal = (parentZoneVal!=null && !parentZoneVal.equalsIgnoreCase("") && !parentZoneVal.equalsIgnoreCase("null") && !parentZoneVal.equalsIgnoreCase("undefined"))?parentZoneVal:"";
	//String parentZone = (parentZoneVal.length()>0)?parentZoneVal:iszoneName;
	String parentZone = request.getParameter("parentZone");
	parentZone = (parentZone==null && parentZone.equalsIgnoreCase("") && parentZone.equalsIgnoreCase("null") && parentZone.equalsIgnoreCase("undefined"))?"":parentZone;
	String selectedState =  request.getParameter("selectedState");
	String selectedHealthName =  request.getParameter("selectedHealthName");
	String fromPageView = request.getParameter("fromPageView");
	fromPageView=(fromPageView==null || fromPageView.trim().length()==0 || fromPageView.equalsIgnoreCase("null") ||  fromPageView.equalsIgnoreCase("undefined"))?"Zone":fromPageView;
	
	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());
	IniUI ui = (IniUI)com.egurkha.ini.IniUI.getInstance();
	try
	{
		thisLanguage = ui.getDefaultLanguage();
		if (user!=null)
		{
			String userLang = user.getLanguage();
			if (userLang!=null && !userLang.equalsIgnoreCase("NULL"))
			{
				thisLanguage=userLang;
			}
		}
	}
	catch(Exception e)
	{
		System.out.println(e);
	}
	com.eg.IniFile egUi = new com.eg.IniFile(EgInstallInfo.getInstallDir() +"/manager/config/eg_ui.ini");
	com.eg.IniFile iniFileforComp = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_dashboardConfig.ini", false);
	String isListView = egUi.getValue("MONITOR_DASHBOARD","ListView");
	isListView=(isListView==null || isListView.trim().length()==0)?"Yes":isListView;
	//EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	EgAggregateInfo aggregateInfo = new EgAggregateInfo("manager");
	AlarmPriorities ap = AlarmPriorities.getInstance();
	
	ZoneDashboardData d = (ZoneDashboardData) session.getAttribute("zoneDashboardData");
	ZoneDashboardResult r = (ZoneDashboardResult) session.getAttribute("zoneDashboardResult");

	long zonesTotal = r.zonesHealth.getTotal();
	long servicesTotal = r.servicesHealth.getTotal();
	long segmentsTotal = r.segmentsHealth.getTotal();
	long independentComponentsTotal = r.independentComponentsHealth.getTotal();
	long dashboardaggregateComponentsTotal = r.aggregateComponentsHealth.getTotal();

	String[] states = {"HIGH","INTERMEDIATE","LOW","UNKNOWN","GOOD"};
	int index = -1;
	for (int i=0;i<states.length;i++) 
	{
		if (selectedState != null &&  selectedState.trim().length()>0 && states[i].equals(selectedState)) 
		{
			index = i;
			break;
		}
	}

	ArrayList componentStatusList = r.componentStatusList;
	ArrayList aggComponentStatusList = r.aggComponentStatusList;
	ArrayList zoneStatusList = r.zoneStatusList;
	ArrayList serviceStatusList = r.serviceStatusList;
	ArrayList segmentStatusList = r.segmentStatusList;
	
	ArrayList dialList = new ArrayList();

	List aggegateComp = null;
	List keyList = null;

	String startValue = "0";
	long maxCount=0L;

	ObjectMapper mapper = new ObjectMapper();
	ObjectNode json  = mapper.createObjectNode();
	ObjectNode healthViewContent = mapper.createObjectNode();
	ArrayNode  componentslist = null,zones = null,services = null,segments = null,aggregates = null;
	ObjectNode component = null;
	
	int blockCount = 0;
	
	boolean isInfrastructureAvailable = false;
	
	if(( componentStatusList!= null && componentStatusList.size() > 0 )|| ( aggComponentStatusList!=null && aggComponentStatusList.size() >0 )|| (zoneStatusList!=null &&  zoneStatusList.size() >0) || (serviceStatusList!=null && serviceStatusList.size() >0) || (segmentStatusList!=null && segmentStatusList.size() >0) )
	{
		isInfrastructureAvailable=true;
	}
	if(isInfrastructureAvailable)
	{
		String Show_InfrastructureHealth = ui.getValue("MONITOR_DASHBOARD","Show_InfrastructureHealth");
		if(Show_InfrastructureHealth==null || Show_InfrastructureHealth.trim().length()==0)
		{
			Show_InfrastructureHealth = "Zones,Services,ServiceGroups,Segments,Aggregates,Components";
		}
		StringTokenizer st = new StringTokenizer(Show_InfrastructureHealth,",");
		componentslist = mapper.createArrayNode();
		while(st.hasMoreTokens())
		{
			String tokens = st.nextToken();
			if(tokens!=null && tokens.equalsIgnoreCase("zones"))
			{
				if((zoneStatusList!=null && zoneStatusList.size() >0 )&& zonesTotal>0)
				{
					String xmlData_zone = r.xmlData_zone;
				String highChartJsonZonesDataValue = r.highChartJsonZonesData;
				JSONObject highChartJsonZonesData = (JSONObject) JSONSerializer.toJSON(highChartJsonZonesDataValue);
					blockCount++;
					if(xmlData_zone!=null)
					{
						
						component = mapper.createObjectNode();
						component.put("xmlData",xmlData_zone);
						component.put("total",String.valueOf(zonesTotal));
						component.put("text",mappingInfo.getTextDescription("monitor.home.Zones"));
						dialList.add("Zones");
					if(highChartJsonZonesData!=null)
					{
						component.put("highChartData",mapper.valueToTree(highChartJsonZonesData));
					}
						component.put("id","zones");
						componentslist.add(component);
					}
				}
			}

			/*if(mBean.toShowServiceGroups())
			{
				if((serviceGroupStatusList!=null && serviceGroupStatusList.size() >0 )&& dashboardserviceGroupTotal>0)
				{
					String xmlData_servGroup = "";//(String)mBean.getXmlForelementStatus(serviceGroupStatusList);

					if(xmlData_servGroup!=null)
					{
							blockCount++;
							component = mapper.createObjectNode();
							component.put("xmlData",xmlData_servGroup);
							component.put("total",dashboardserviceGroupTotal);
							component.put("text",mappingInfo.getTextDescription("monitor.home.Service Groups"));
							component.put("id","serviceGroups");
							componentslist.add(component);
					}
				}
			}*/
			else if(tokens!=null && tokens.equalsIgnoreCase("services"))
			{
				if((serviceStatusList!=null && serviceStatusList.size() >0) && servicesTotal>0)
				{
					String xmlData_serv = r.xmlData_serv;
				String highChartJsonServicesDataValue = r.highChartJsonServicesData;
				JSONObject highChartJsonServicesData = (JSONObject) JSONSerializer.toJSON(highChartJsonServicesDataValue);
					blockCount++;
					if(xmlData_serv!=null)
					{
						component = mapper.createObjectNode();
						component.put("xmlData",xmlData_serv);
						component.put("total",String.valueOf(servicesTotal));
						component.put("text",mappingInfo.getTextDescription("monitor.home.Services"));
						dialList.add("Services");
					if(highChartJsonServicesData!=null)
					{
						component.put("highChartData",mapper.valueToTree(highChartJsonServicesData));
					}
						component.put("id","services");
						componentslist.add(component);
					}
				}
			}
			else if(tokens!=null && tokens.equalsIgnoreCase("segments"))
			{
				if((segmentStatusList!=null && segmentStatusList.size() >0 )&& segmentsTotal>0)
				{
					String xmlData_seg = r.xmlData_seg;
				String highChartJsonSegmentsDataValue = r.highChartJsonSegmentsData;
				JSONObject highChartJsonSegmentsData = (JSONObject) JSONSerializer.toJSON(highChartJsonSegmentsDataValue);
					blockCount++;
					if(xmlData_seg!=null)
					{
						component = mapper.createObjectNode();
						component.put("xmlData",xmlData_seg);
						component.put("total",String.valueOf(segmentsTotal));
						component.put("text",mappingInfo.getTextDescription("monitor.home.Segments"));
						dialList.add("Segments");
					if(highChartJsonSegmentsData!=null)
					{
						component.put("highChartData",mapper.valueToTree(highChartJsonSegmentsData));
					}
						component.put("id","segments");
						componentslist.add(component);
					}
				}
			}
			else if(tokens!=null && tokens.equalsIgnoreCase("aggregates"))
			{
				if(!(dashboardaggregateComponentsTotal==0))
				{
					if(aggComponentStatusList!=null && aggComponentStatusList.size() >0)
					{
						String xmlData_Agg = r.xmlData_Agg;
					String highChartJsonAggsDataValue = r.highChartJsonAggsData;
					JSONObject highChartJsonAggsData = (JSONObject) JSONSerializer.toJSON(highChartJsonAggsDataValue);
						blockCount++;
						if(xmlData_Agg!=null)
						{
							component = mapper.createObjectNode();
							component.put("xmlData",xmlData_Agg);
							component.put("total",String.valueOf(dashboardaggregateComponentsTotal));
							component.put("text",mappingInfo.getTextDescription("monitor.home.Aggregates"));
							dialList.add("Aggregates");
						if(highChartJsonAggsData!=null)
						{
							component.put("highChartData",mapper.valueToTree(highChartJsonAggsData));
						}
							component.put("id","aggregates");
							componentslist.add(component);
						}
					}
				}
			}
			else if(tokens!=null && tokens.equalsIgnoreCase("components"))
			{
				if(!(independentComponentsTotal==0))
				{
					if(componentStatusList!=null && componentStatusList.size() >0)
					{
						String xmlData_comp = r.xmlData_comp;
						String highChartJsonCompDataValue = r.highChartJsonCompData;
						JSONObject highChartJsonCompData = (JSONObject) JSONSerializer.toJSON(highChartJsonCompDataValue);
						
						blockCount++;
						if(xmlData_comp!=null)
						{
							component = mapper.createObjectNode();
							component.put("xmlData",xmlData_comp);
							component.put("total",String.valueOf(independentComponentsTotal));
							component.put("text",mappingInfo.getTextDescription("monitor.home.Components"));
							dialList.add("Components");
							if(highChartJsonCompData!=null)
							{
								component.put("highChartData",mapper.valueToTree(highChartJsonCompData));
							}
							component.put("id","components");
							componentslist.add(component);
						}
					}
				}
			}
		}
		healthViewContent.put("componentslist",componentslist);
	}

	boolean isShowFullBar=false;
	String strShowFullBar = ui.getValue("MONITOR_DASHBOARD","Show_ComponentsAtAGlance_FullBar");
	if(strShowFullBar==null || strShowFullBar.trim().length()==0)
		strShowFullBar="true";

	if(strShowFullBar!=null && (strShowFullBar.equalsIgnoreCase("true") || strShowFullBar.equalsIgnoreCase("yes")))
	{
		isShowFullBar=true;
	}
	
	Map backgroundColor = r.backgroundColor;
	Hashtable serversWithTypesAndStates = r.serversWithTypesAndStates;
	Hashtable serverTypesAndComps = r.serverTypesAndComps;

	List tmp_v_zone = r.zoneList;
	List tmp_v_site = r.serviceList;
	List tmp_v_segment = r.segmentList;
	aggegateComp = r.aggregateList;
	//keyList = r.zoneComponentsList; //--- zone components list
	keyList = r.zoneComponentsTypeList; // -- zone components type list
	List v_site = new ArrayList();
	List v_segment = new ArrayList();
	List v_zone = new ArrayList();
		
	if(tmp_v_site!=null && tmp_v_site.size()>0)
	{
		EgList egServiceList = new EgList();
		CompositeComparator compObj = new CompositeComparator();
		for (int sl=0; sl < tmp_v_site.size(); sl++)
		{
			String orgServiceName = (String) tmp_v_site.get(sl);
			String tmpServiceName = orgServiceName;
			if(tmpServiceName!=null && tmpServiceName.indexOf("(Site)") > -1)
			{
				tmpServiceName = tmpServiceName.substring(0,tmpServiceName.indexOf("(Site)"));
			}

			if(tmpServiceName!=null && tmpServiceName.trim().length()>0)
			{
				String name = "Service:"+tmpServiceName+":NULL";
				String state = (String)EgStateZone.getState(name);
				EgService tmpService = new EgService(orgServiceName, State.getState(state));
				if(tmpService!=null) 
					egServiceList.add(tmpService);
			}
		}
		compObj.add(new StateComparatorDes());
		compObj.add(new NameComparatorAsc());
		Collections.sort(egServiceList,compObj);

		if(egServiceList!=null && egServiceList.size()>0)
		{
			for(int s=0;s<egServiceList.size();s++)
			{
				EgService service1 = (EgService) egServiceList.get(s);
				String service_name=(String)service1.getName();
				if(service_name!=null && v_site!=null && !v_site.contains(service_name))
					v_site.add(service_name);
			}
		}
	}

	if(tmp_v_segment!=null && tmp_v_segment.size()>0)
	{
		EgList egSegmentList = new EgList();
		CompositeComparator compObj = new CompositeComparator();

		for (int sl=0; sl < tmp_v_segment.size(); sl++)
		{
			String tmpSegmentName = (String) tmp_v_segment.get(sl);
			if(tmpSegmentName!=null && tmpSegmentName.trim().length()>0)
			{
				String name = "Segment:"+tmpSegmentName+":NULL";
				String state = (String)EgStateZone.getState(name);
				EgSegment tmpSegment = new EgSegment(tmpSegmentName, State.getState(state));
				if(tmpSegment!=null) 
					egSegmentList.add(tmpSegment);
			}
		}

		compObj.add(new StateComparatorDes());
		compObj.add(new NameComparatorAsc());
		Collections.sort(egSegmentList,compObj);

		if(egSegmentList!=null && egSegmentList.size()>0)
		{
			for(int s=0;s<egSegmentList.size();s++)
			{
				EgSegment segment1 = (EgSegment) egSegmentList.get(s);
				String segment_name = (String)segment1.getName();
				if(segment_name!=null && v_segment!=null && !v_segment.contains(segment_name))
					v_segment.add(segment_name);
			}
		}
	}

	if(tmp_v_zone!=null && tmp_v_zone.size()>0)
	{
		EgList egZoneList = new EgList();
		CompositeComparator compObj = new CompositeComparator();
		for (int sl=0; sl < tmp_v_zone.size(); sl++)
		{
			String tmpZoneName = (String) tmp_v_zone.get(sl);
			if(tmpZoneName!=null && tmpZoneName.trim().length()>0)
			{
				String name = "Zone:"+tmpZoneName+":NULL";
				String state = (String)EgStateZone.getState(name);
				EgZone tmpZone = new EgZone(tmpZoneName, State.getState(state));
				if(tmpZone!=null) 
					egZoneList.add(tmpZone);
			}
		}

		compObj.add(new StateComparatorDes());
		compObj.add(new NameComparatorAsc());
		Collections.sort(egZoneList,compObj);
		
		if(egZoneList!=null && egZoneList.size()>0)
		{
			for(int s=0;s<egZoneList.size();s++)
			{
				EgZone zone1 = (EgZone)egZoneList.get(s);
				String zone_name = (String)zone1.getName();
				if(zone_name!=null && v_zone!=null && !v_zone.contains(zone_name))
					v_zone.add(zone_name);
			}
		}
	}

	String selectedInfraStructure = "";

	IniFile iniValue = new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_topology.ini");
	IniFile groupIniValue = new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_group.ini");
	if(v_zone!=null && v_zone.size()>0)
	{
		selectedInfraStructure = "zones";
		zones = mapper.createArrayNode();
		ObjectNode zone;
		int displayHeadLength=40;
		//Collections.sort(v_zone);
		for(int z =0 ;z<v_zone.size();z++)
		{
			String zonename = (String)v_zone.get(z);
			String name="Zone:"+zonename+":NULL";
			String state = (String)EgStateZone.getState(name);
			//String cssClass = "zone_"+state;
			String tempZoneName = zonename;
			String zone_image=(String)groupIniValue.getValue("ZONE_DISPLAY_IMAGE",tempZoneName);
			if(zone_image.indexOf("Small")!=-1)
			{
				zone_image=zone_image.replace("Small","48");
				if(zone_image.equals("serviceOthers48"))
				{
					zone_image="zone_GRAY";
				}
			}
			String cssClass = zone_image;

			ArrayList aggregateArray = aggregateInfo.getAggregateComponentsOfElement("zone",zonename);

			boolean aggregateTab =false;
			if(aggregateArray != null && aggregateArray.size() > 0)
				aggregateTab = true;

			//String href= "/final/monitor/zoneDash.jsp?treeFlag=null&outsideZone=true&titleText=zone&selectNode=Zone^"+EgURLEncoder.encode(zonename,"UTF-8")+"&zoneFromZone="+EgURLEncoder.encode(zonename,"UTF-8")+"&aggregateTab="+aggregateTab;
			
			String href = "/final/monitor/zoneDash.jsp?from=ZoneDashboard&selectNode=Zone$cap$"+EgURLEncoder.encode(zonename,"UTF-8")+"&selectedParam="+EgURLEncoder.encode(zonename,"UTF-8")+"&currentTab=details&monCmd=zoneDashboard&zoneName="+EgURLEncoder.encode(zonename,"UTF-8")+"&treeOpen=false&fromHomepage="+fromHomepage+"&aggregateTab="+aggregateTab+"&fromZoneMenu="+fromZoneMenu;
			
			if(parentZone!=null && parentZone.length()>0)
				href = href+"&parentZone="+parentZone;
			
			String displayName = zonename;
			
			zone = mapper.createObjectNode();
			zone.put("name",zonename);
			zone.put("state",state);
			zone.put("cssClass",cssClass);
			zone.put("href",href);
			zone.put("displayName",displayName);
					
			if(selectedState!= null && selectedState.trim().length()>0 && selectedHealthName!=null && selectedHealthName.equalsIgnoreCase("Zones"))
			{
				if(state!=null && selectedState.equals(state))
				{
								zones.add(zone);
							}
				else
				{
					continue;
				}
			}
			else
			{
				zones.add(zone);
			}
		}
		healthViewContent.put("zones",zones);
	}
	if(v_site !=null && v_site.size()>0)
	{
		EgTopoInfo topoInfo = new EgTopoInfo("manager");
		DashboardModel dashModel = new DashboardModel();
		com.eg.IniFile commonDashSaveIni = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_citrixdashboard.ini", true);
		if(selectedInfraStructure!=null && selectedInfraStructure.equals(""))
		{
			selectedInfraStructure = "services";
		}
		services = mapper.createArrayNode();
		ObjectNode service;

		String server_types = iniFileforComp.getValue("InfraDashboard_service_redirectURL","componenetTypes");

		ArrayList serverList = new ArrayList();
		if(server_types != null && server_types.trim().length() > 0)
		{
			StringTokenizer st1 = new StringTokenizer(server_types, ",");
			while (st1.hasMoreTokens())
			{
				serverList.add(st1.nextToken().trim());
			}
		}
	
		ArrayList simulationTypes = new ArrayList();
		String[] s_types = iniFileforComp.getVariables("SIMULATION_SUPPORT");
		String serviceDashboardType = iniFileforComp.getValue("SERVICE_DASHBOARD_TYPE","Citrix_dashboard_view");
		if(s_types != null && s_types.length > 0){
			for(int k=0;k<s_types.length;k++){
				String type = s_types[k];
				if(type != null && type.length() > 0)
					simulationTypes.add(type);
			}
		}
		boolean toSave = false;

		EgDbAdapterUI egDb=EgDbAdapterTypeUI.getObject();
		String s_conn = null;
		Hashtable transactionHash= new Hashtable();				
		try
		{
			if(EgInstallInfo.isSuperManager)
			{
				ArrayList managerIDs = EgElementInfo.getInstance().getManagerIDs("zone",iszoneName);
				if(managerIDs != null && !managerIDs.isEmpty())
				{
					SmSessionData smsData = new SmSessionData(session.getId(),managerIDs);
					EgThreadLocal egtl = new EgThreadLocal();
					egtl.set(smsData);
				}
			}
			s_conn = egDb.setConnection();
			transactionHash= egDb.SelectAllEgTrans();
		}
		catch(Exception e)
		{
			System.out.println("Exception while adding TransactionList to EgService object in zoneInfrastructureHealthView.jsp : "+e);
		}
		finally
		{
			egDb.releaseConnection(false);
			EgDbAdapterTypeUI.releaseObject(egDb);
		}
		ArrayList dashComps = com.egurkha.util.StringUtils.egTokenizer((iniFileforComp.getValue("InfraDashboard_service_redirectURL","componenetTypes")),",",false,true,true);
		Vector compVec = new Vector();
		for(int s=0;s < v_site.size();s++)
		{
			boolean isSite=false;
			String sitename = (String)v_site.get(s);
			String hrefForSite = sitename;
			if(hrefForSite.indexOf("(Site)") > -1)
			{
				hrefForSite = hrefForSite.substring(0,hrefForSite.indexOf("(Site)"));
				isSite = true;
			}
			String siteCheck = iniValue.getValue("SERVICE",hrefForSite);
			if(siteCheck != null && siteCheck.equalsIgnoreCase("site"))
				isSite = true;
			String tempServiceName = sitename;
			if(tempServiceName.indexOf("(Site)") > -1)
			{
				tempServiceName = tempServiceName.substring(0,tempServiceName.indexOf("(Site)"));
			}
			String service_image=(String)iniValue.getValue("SERVICE_DISPLAY_IMAGE",tempServiceName);
			if(service_image.indexOf("Small")!=-1)
			{
				service_image=service_image.replace("Small","48");
			}
			//<! Changes Start here ---- Kaliraj >

			/*EgList transactionList = new EgList();
			if(isSite)
			{
				EgDbAdapterUI egDb;
				egDb=EgDbAdapterTypeUI.getObject();
				String s_conn = null;
				ResultSet rs=null;
			
				try
				{
					s_conn = egDb.setConnection();
					rs = egDb.SelectEgAddMonTrans(hrefForSite.trim());

					while(rs.next())
					{
						transactionList.add(rs.getString("trans_name") +"~~#~~"+ rs.getString("user_id"));
					}

					rs.close();
				}
				catch(Exception e)
				{
					System.out.println("Exception while adding TransactionList to EgService object : "+e);
				}
				finally
				{
					if(rs!=null)
					{
						rs.close();
						rs=null;
					}
					egDb.releaseConnection(false);
					EgDbAdapterTypeUI.releaseObject(egDb);
				}
			}*/

			boolean hasTransactions = false;
			boolean hasEmulatedTransactions = false;
			boolean hasLogonSimulations = false;
			boolean hasRUM = false;
			boolean hasCitrix = false;

			//if(transactionList != null && transactionList.size() > 0)
			if(transactionHash != null && transactionHash.containsKey(hrefForSite))
			{
				hasTransactions = true;
			}
			
			compVec = topoInfo.getAssociatesForSite(hrefForSite);
			int dashCompCnt = 0;

			boolean isServiceRedirectOthers = false;
			String dashboard_name = "";
			String comp_type_rum = "";
			String comp_type_rum_first ="";
			List rumcomp_arr = new ArrayList();
			for(int k=0; k<compVec.size(); k++)
			{
				String comp =(String) compVec.get(k);
				if(comp!=null && (comp.indexOf("Emulated")>-1 || comp.indexOf("Emulation")>-1))
				{
					hasEmulatedTransactions = true;
				}
				if(simulationTypes != null && simulationTypes.size() > 0 && comp != null && comp.indexOf(":") > 0 && simulationTypes.contains(comp.substring(0,comp.indexOf(":"))))
				{
					hasLogonSimulations = true;
				}
				if(comp.indexOf("Real_user_monitor") > -1){
					hasRUM = true;
					comp_type_rum = comp.substring(comp.indexOf(":")+1);
					rumcomp_arr.add(comp_type_rum);
				}
				String comp_type_alone = comp.substring(0,comp.indexOf(":"));
				comp_type_alone = comp_type_alone.trim();
				if(dashComps != null && dashComps.contains(comp_type_alone)){
					hasCitrix = true;
					dashCompCnt++;
				}
				
				if(serverList != null && serverList.size () > 0 && serverList.contains(comp_type_alone))
				{
					dashboard_name = iniFileforComp.getValue("InfraDashboard_service_redirectURL",comp_type_alone);
					if(dashboard_name != null && dashboard_name.trim().length() > 0)
						isServiceRedirectOthers = true;
				}
			}
			String currentTab = "";
			if(isSite && hasTransactions)
				currentTab = "transactions";
			else if(hasLogonSimulations)
				currentTab = "logon";
			else
				currentTab = "topology";

			ArrayList aggregateArray = aggregateInfo.getAggregateComponentsOfElement("service",hrefForSite);

			boolean aggregateTab =false;
			if(aggregateArray != null && aggregateArray.size() > 0)
			aggregateTab = true;

			String name = "Service:"+hrefForSite+":NULL";
			String state = (String)EgStateZone.getState(name);
			//String cssClass = "service_"+state;
			String cssClass = service_image;
			
			String href =	"/final/monitor/serviceDashboard.jsp?action=service&treeFlag=treeFlag&treeTitle=services&outsideService=true&selectNode=Service$cap$&selectedParam="+EgURLEncoder.encode(hrefForSite,"UTF-8")+"&currentTab="+currentTab+"&isSite="+isSite+"&aggregateTab="+aggregateTab+"&hasTransactions="+hasTransactions+"&hasEmulatedTransactions=false&treeOpen=false&openNode=Services&iszoneName="+EgURLEncoder.encode(iszoneName,"UTF-8")+"&iscurrentTab="+iscurrentTab+"&isaggregateTab ="+isaggregateTab+"&isopenNode="+isopenNode+"&istreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&hasLogonSimulations="+hasLogonSimulations;

			if(parentZone!=null && parentZone.length()>0)
				href = href+"&parentZone="+EgURLEncoder.encode(parentZone,"UTF-8");
			com.eg.IniFile ctx_ini = new com.eg.IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_citrixdashboard.ini", false);
			String temp_user = user.getLoginID();
			temp_user = (temp_user == null || temp_user.trim().length() == 0)?"admin":temp_user;

			String userBased = ctx_ini.getValue("DASHBOARD_SETTINGS","User_Based");
			userBased = (userBased == null || userBased.trim().length() == 0)?"true":userBased;
			ArrayList dashboardNames = null;
			if(userBased != null && userBased.equalsIgnoreCase("true"))
				dashboardNames = com.egurkha.util.StringUtils.egTokenizer((ctx_ini.getValue("User_Dashboard_List",temp_user+":Dashboard_Names")),",",false,true,true);
			if(dashboardNames == null || dashboardNames.size() == 0)
				dashboardNames = com.egurkha.util.StringUtils.egTokenizer((ctx_ini.getValue("Dashboard_List","Dashboard_Names")),",",false,true,true);

			String tmpdashboard_name = ctx_ini.getValue("Dashboard_List",temp_user+":Service"+":"+hrefForSite+":DefaultDashboard");
			if(tmpdashboard_name == null || tmpdashboard_name.trim().length() == 0){
				if(dashCompCnt > 1){
					tmpdashboard_name = dashModel.getDashboardName("Service",hrefForSite,ctx_ini,user,dashboardNames);
					dashboard_name = tmpdashboard_name;
				}
				commonDashSaveIni.setValue("Dashboard_List",temp_user+":Service"+":"+hrefForSite+":DefaultDashboard",dashboard_name);
				toSave = true;
			}
			else
				dashboard_name = tmpdashboard_name;

			if(isServiceRedirectOthers)
			{
				if(dashboard_name.indexOf("?") != -1)
					href = dashboard_name;
				else
				{
					if(dashboardNames.contains(dashboard_name))
					{
						String temp_dashboard_name = null;
						String getDashboards[] = ctx_ini.getVariables(temp_user+":"+dashboard_name+":Mapping");						
						if(getDashboards != null && getDashboards.length > 0)
						{
							for(int l=0;l<getDashboards.length;l++)
							{
								String dash_keys = getDashboards[l];
								if(dash_keys == null || dash_keys.trim().length() ==0)
									continue;

								
								if(dash_keys.equalsIgnoreCase("DefaultView"))
									continue;
								
								String dash_value = ctx_ini.getValue(temp_user+":"+dashboard_name+":Mapping",dash_keys);

								if(!dash_value.toLowerCase().startsWith("service:"))
									continue;
								
								if(dash_value.indexOf(":") > -1 && dash_value.indexOf("#~#") > -1)
									dash_value = dash_value.substring(dash_value.indexOf(":")+1,dash_value.indexOf("#~#"));
								
								
								if(dash_value!= null && dash_value.trim().length() > 0 && dash_value.equalsIgnoreCase(hrefForSite))
								{
									temp_dashboard_name = dash_keys;
									break;
								}
							}
						}
						if(serviceDashboardType != null && serviceDashboardType.trim().length()>0 && (serviceDashboardType.equalsIgnoreCase("yes") || serviceDashboardType.equalsIgnoreCase("true")))
						{
							if(hasRUM)
							{	
								StringBuffer  rum_url = new StringBuffer();
								rum_url.append("/final/monitor/rumAppFlow.jsp?");
								rum_url.append("iniName=eg_rumdashboard&action=loadViewData&user_name=");
								rum_url.append(temp_user);
								rum_url.append("&userBased="+userBased+"&fromMenu=true&showConfig=true&");
								
								if(temp_dashboard_name == null || temp_dashboard_name.trim().length() == 0)
									rum_url.append("filter=Service&filterBy="+hrefForSite);
								else
								{
									rum_url.append("dashboard_mapping="+temp_dashboard_name);
									rum_url.append("&filter=Service&filterBy="+hrefForSite);
								}
								
								rum_url.append("&dashboard_name=RUM_Dashboard");
								rum_url.append("&hasCitrix="+hasCitrix);
								rum_url.append("&hasTransactions="+hasTransactions);
								rum_url.append("&hasEmulatedTransactions="+hasEmulatedTransactions);
								rum_url.append("&hasLogonSimulations="+hasLogonSimulations);
								rum_url.append("&hasRUM="+hasRUM);
								for(int p=0;p<rumcomp_arr.size();p++){
									comp_type_rum_first = (String)rumcomp_arr.get(0);
								}
								rum_url.append("&appliesTo="+comp_type_rum_first);
								rum_url.append("&isBackFromRUM=false");									
								rum_url.append("&isFromZone=true");									
								rum_url.append("&iszoneName="+iszoneName);	
								rum_url.append("&parentZone="+parentZone);	
								rum_url.append("&isopenNode="+isopenNode);	
								rum_url.append("&isTreeFlag="+isTreeFlag);	
								rum_url.append("&isFromZoneMenu="+isFromZoneMenu);	
								rum_url.append("&aggregateTab="+aggregateTab);	

								href = rum_url.toString();
							}
							else
							{
								StringBuffer  citrix_url = new StringBuffer();
								citrix_url.append("/final/monitor/citrixDashboard.jsp?");
								citrix_url.append("iniName=eg_citrixdashboard&action=loadViewData&user_name=");
								citrix_url.append(temp_user);
								citrix_url.append("&userBased="+userBased+"&fromMenu=true&showConfig=true&fromUED=false&");
								
								if(temp_dashboard_name == null || temp_dashboard_name.trim().length() == 0)
									citrix_url.append("filter=Service&filterBy="+hrefForSite);
								else
								{
									citrix_url.append("dashboard_mapping="+temp_dashboard_name);
									citrix_url.append("&filter=Service&filterBy="+hrefForSite);
								}

								citrix_url.append("&dashboard_name="+dashboard_name);								
								citrix_url.append("&filterName=");
								citrix_url.append("&filterViewName=");
								citrix_url.append("&hasCitrix="+hasCitrix);
								citrix_url.append("&hasTransactions="+hasTransactions);
								citrix_url.append("&hasEmulatedTransactions="+hasEmulatedTransactions);
								citrix_url.append("&hasLogonSimulations="+hasLogonSimulations);
								citrix_url.append("&fromServiceHomePage=true");
								citrix_url.append("&fromSerComboChange=true");
								citrix_url.append("&appliesTo=Service:"+hrefForSite);
								citrix_url.append("&isFromZone=true");
								citrix_url.append("&iszoneName="+iszoneName);	
								citrix_url.append("&parentZone="+parentZone);
								citrix_url.append("&isopenNode="+isopenNode);	
								citrix_url.append("&isTreeFlag="+isTreeFlag);
								citrix_url.append("&isFromZoneMenu="+isFromZoneMenu);
								citrix_url.append("&aggregateTab="+aggregateTab);
								
								href = citrix_url.toString();
							}
						}
					}
				}
			}
			else
			{
				String temp_dashboard_name = null;
				String getDashboards[] = ctx_ini.getVariables(temp_user+":"+dashboard_name+":Mapping");				

				if(getDashboards != null && getDashboards.length > 0)
				{
					for(int l=0;l<getDashboards.length;l++)
					{
						String dash_keys = getDashboards[l];
						if(dash_keys == null || dash_keys.trim().length() ==0)
							continue;

						if(dash_keys.equalsIgnoreCase("DefaultView"))
							continue;

						String dash_value = ctx_ini.getValue(temp_user+":"+dashboard_name+":Mapping",dash_keys);
						if(dash_value!= null && dash_value.trim().length() > 0 && dash_value.indexOf(hrefForSite) != -1)
						{
							temp_dashboard_name = dash_keys;
							break;
						}
					}
				}
				if(serviceDashboardType != null && serviceDashboardType.trim().length()>0 && (serviceDashboardType.equalsIgnoreCase("yes") || serviceDashboardType.equalsIgnoreCase("true")))
				{
					if(hasRUM)
					{	
						StringBuffer  rum_url = new StringBuffer();
						rum_url.append("/final/monitor/rumAppFlow.jsp?");
						rum_url.append("iniName=eg_rumdashboard&action=loadViewData&user_name=");
						rum_url.append(temp_user);
						rum_url.append("&userBased="+userBased+"&fromMenu=true&showConfig=true&");
						
						if(temp_dashboard_name == null || temp_dashboard_name.trim().length() == 0)
							rum_url.append("filter=Service&filterBy="+hrefForSite);
						else
						{
							rum_url.append("dashboard_mapping="+temp_dashboard_name);
							rum_url.append("&filter=Service&filterBy="+hrefForSite);
						}
						
						rum_url.append("&dashboard_name=RUM_Dashboard");
						rum_url.append("&hasCitrix="+hasCitrix);
						rum_url.append("&hasTransactions="+hasTransactions);
						rum_url.append("&hasEmulatedTransactions="+hasEmulatedTransactions);
						rum_url.append("&hasLogonSimulations="+hasLogonSimulations);
						rum_url.append("&hasRUM="+hasRUM);
						for(int p=0;p<rumcomp_arr.size();p++){
							comp_type_rum_first = (String)rumcomp_arr.get(0);
						}
						rum_url.append("&appliesTo="+comp_type_rum_first);
						rum_url.append("&isBackFromRUM=false");
						rum_url.append("&isFromZone=true");									
						rum_url.append("&iszoneName="+iszoneName);	
						rum_url.append("&parentZone="+parentZone);
						rum_url.append("&isopenNode="+isopenNode);	
						rum_url.append("&isTreeFlag="+isTreeFlag);	
						rum_url.append("&isFromZoneMenu="+isFromZoneMenu);	
						rum_url.append("&aggregateTab="+aggregateTab);	
						
						href = rum_url.toString();
					}
					else
					{
						StringBuffer  citrix_url = new StringBuffer();
						citrix_url.append("/final/monitor/citrixDashboard.jsp?");
						citrix_url.append("iniName=eg_citrixdashboard&action=loadViewData&user_name=");
						citrix_url.append(temp_user);
						citrix_url.append("&userBased="+userBased+"&fromMenu=true&showConfig=true&fromUED=false&");
						
						if(temp_dashboard_name == null || temp_dashboard_name.trim().length() == 0)
							citrix_url.append("filter=Service&filterBy="+hrefForSite);
						else
						{
							citrix_url.append("dashboard_mapping="+temp_dashboard_name);
							citrix_url.append("&filter=Service&filterBy="+hrefForSite);
						}

						citrix_url.append("&dashboard_name="+dashboard_name);					
						citrix_url.append("&filterName=");
						citrix_url.append("&filterViewName=");
						citrix_url.append("&hasCitrix="+hasCitrix);
						citrix_url.append("&hasTransactions="+hasTransactions);
						citrix_url.append("&hasEmulatedTransactions="+hasEmulatedTransactions);
						citrix_url.append("&hasLogonSimulations="+hasLogonSimulations);
						citrix_url.append("&fromServiceHomePage=true");
						citrix_url.append("&fromSerComboChange=true");
						citrix_url.append("&appliesTo=Service:"+hrefForSite);
						citrix_url.append("&isFromZone=true");
						citrix_url.append("&iszoneName="+iszoneName);	
						citrix_url.append("&parentZone="+parentZone);
						citrix_url.append("&isopenNode="+isopenNode);	
						citrix_url.append("&isTreeFlag="+isTreeFlag);
						citrix_url.append("&isFromZoneMenu="+isFromZoneMenu);
						citrix_url.append("&aggregateTab="+aggregateTab);

						
						href = citrix_url.toString();
					}
				}
			}			

			String displayName = sitename;
			displayName = ( displayName.indexOf("(Site)") > -1 )?displayName.substring(0,displayName.indexOf("(Site)")):displayName;
			service = mapper.createObjectNode();
			service.put("name",sitename);
			service.put("state",state);
			service.put("cssClass",cssClass);
			service.put("href",href);
			service.put("displayName",displayName);
			if(selectedState!= null && selectedState.trim().length()>0 && selectedHealthName!=null && selectedHealthName.equalsIgnoreCase("Services"))
			{
				if(state!=null && selectedState.equals(state))
				{
								services.add(service);
				}
				else
				{
					continue;
				}
			}
			else
			{
				services.add(service);
			}
		}
		healthViewContent.put("services",services);
		if(toSave)
			commonDashSaveIni.saveFile();
	}

	if(v_segment!=null && v_segment.size()>0)
	{
		if(selectedInfraStructure!=null && selectedInfraStructure.equals(""))
		{
			selectedInfraStructure = "segments";
		}
		
		segments = mapper.createArrayNode();
		ObjectNode segment;
		
		for(int sg=0;sg < v_segment.size();sg++)
		{
			String segmentname=(String)v_segment.get(sg);
			String state=(String)EgStateZone.getState("Segment:"+segmentname+":NULL");
			//String cssClass = "segment_"+state;
			String tempSegmentName = segmentname;
			String segment_image=(String)iniValue.getValue("SEGMENT_DISPLAY_IMAGE",tempSegmentName);
			if(segment_image.indexOf("Small")!=-1)
			{
				segment_image=segment_image.replace("Small","48");
				if(segment_image.equals("serviceOthers48"))
				{
					segment_image="segment_GRAY";
				}
			}
			String cssClass = segment_image;

			ArrayList aggregateArray = aggregateInfo.getAggregateComponentsOfElement("segment",segmentname);

			boolean aggregateTab =false;
			if(aggregateArray != null && aggregateArray.size() > 0)
				aggregateTab = true;

		
			String href = "/final/monitor/segmentDashboard.jsp?selectNode="+EgURLEncoder.encode(segmentname,"UTF-8")+"&selectedParam="+EgURLEncoder.encode(segmentname,"UTF-8")+"&currentTab=topology&segment="+EgURLEncoder.encode(segmentname,"UTF-8")+"&aggregateTab="+aggregateTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&istreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iszoneName="+iszoneName+"&isselectNode="+isselectNode+"&isselectedParam="+isselectedParam;

			if(parentZone!=null && parentZone.length()>0)
				href = href+"&parentZone="+parentZone;

			String displayName= segmentname;
			
			segment = mapper.createObjectNode();
			segment.put("name",segmentname);
			segment.put("state",state);
			segment.put("cssClass",cssClass);
			segment.put("href",href);
			segment.put("displayName",displayName);
			if(selectedState!= null && selectedState.trim().length()>0 && selectedHealthName!=null && selectedHealthName.equalsIgnoreCase("Segments"))
			{
				if(state!=null && selectedState.equals(state))
				{
					segments.add(segment);
				}
				else
				{
					continue;
				}
			}
			else
			{
				segments.add(segment);
			}
		}
		healthViewContent.put("segments",segments);
	}

	if(aggegateComp!=null && aggegateComp.size()>0)
	{
		if(selectedInfraStructure!=null && selectedInfraStructure.equals(""))
		{
			selectedInfraStructure = "aggregates";
		}

		ArrayList recorder = new ArrayList();
	
		aggregates = mapper.createArrayNode();
		ObjectNode aggregate;
		
		boolean hasUnique=false;
		boolean changelink=false;
		String ser1="";
		String href="";
		for(int n=0; n < aggegateComp.size(); n++)
		{
			String serverType = aggegateComp.get(n).toString();
			if(serverType.indexOf(":") > -1)
				serverType  = serverType.substring(0,serverType.indexOf(":"));
			if(!recorder.contains(serverType))
			{
				recorder.add(serverType);
			}
			else
			{
				continue;
			}

			Health health = (Health) serversWithTypesAndStates.get(serverType);
			changelink=false;
			if(health!=null && health.getTotal()==1)
			{
				changelink=true;
			}

			if(selectedState!= null && selectedState.trim().length()>0 && selectedHealthName!=null && selectedHealthName.equalsIgnoreCase("Aggregates"))
			{
				aggregate = mapper.createObjectNode();
				long size = 0L;
				HashSet uniqueState = new HashSet();
				int lastCountInteger  = 0;
				int sameColorCount = 0;
				long thisCount = health.getValue(State.getState(selectedState));
				if(thisCount!=0)
				{
					sameColorCount++;
					lastCountInteger = 0;
				}
				else
					continue;

				size+=thisCount;
				maxCount = Math.max(maxCount, size);
				int tableWidth = (int)((health.getTotal()*100)/(int)maxCount);
				tableWidth = tableWidth<1?1:tableWidth;

				if(changelink)
				{
					ser1=null;
					ArrayList sname=new ArrayList();
					if(r.serverTypesAndComps!=null)
					{
						sname=(ArrayList)r.serverTypesAndComps.get(serverType);
						if(sname!=null && sname.size()==1)
						{
							ser1=(String)sname.get(0);
						}
					}

					if(ser1!=null && ser1.trim().length()>0)
					{
						href="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
					}
					else
					{
						href="../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchStateString=All States&action=componentType&searchIndComps=checked&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&menuName=agg&who=fromServerTypes&zoneName="+r.zoneName+"&fromHomepage="+fromHomepage;
						if(parentZone!=null && parentZone.length()>0)
							href = href+"&parentZone="+parentZone;
					}
				}
				else
				{
					href="../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchStateString=All States&action=componentType&searchIndComps=checked&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&menuName=agg&who=fromServerTypes&zoneName="+r.zoneName+"&fromHomepage="+fromHomepage;
					if(parentZone!=null && parentZone.length()>0)
						href = href+"&parentZone="+parentZone;
				}
				aggregate.put("compType",mappingInfo.getComponentTypeDescription(serverType));
				aggregate.put("href",href);
				aggregate.put("count",String.valueOf(health.getTotal()));
				aggregate.put("tdWidth",String.valueOf(tableWidth));

				int k=0;
				long divWidth=0;
				ArrayNode divArray = mapper.createArrayNode();
				ObjectNode stateDivObj = mapper.createObjectNode();
				size = health.getValue(State.getState(selectedState));
				if(size==0)
					continue;

				long tdWidth = (long) size*100/(long)thisCount;
				divWidth = tdWidth + divWidth;
				if(lastCountInteger==0)
				{
					long tmpWidth = 100 - divWidth;
					tdWidth = tdWidth + tmpWidth;
				}
				String curve = "";
				if(health.getTotal()==1)
				{
					curve="innerLeftRight12";
				}
				else
				{
					if(k==0 && sameColorCount!=1)
					{
						curve="innerLeft12";
					}
					else if(sameColorCount==1)
					{
						curve="innerLeftRight12";
					}
					else if(lastCountInteger==0)
					{
						curve="innerRight12";
					}
					k++;
				}

				stateDivObj.put("tdWidth", String.valueOf(tdWidth));
				stateDivObj.put("backgroundColor",(String)backgroundColor.get(index+"id"));
				stateDivObj.put("curve",curve);
				String curvehref="";
				String sizehref="";
				if(changelink)
				{
					if(ser1!=null && ser1.trim().length()>0)
					{
						curvehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
						stateDivObj.put("curveHref",curvehref);
						sizehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
						stateDivObj.put("sizeHref",sizehref);
					}
					else
					{
						curvehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentTypeState&menuName=agg&zoneName="+r.zoneName+"&searchIndComps=true&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage;
						if(parentZone!=null && parentZone.length()>0)
							curvehref = curvehref+"&parentZone="+parentZone;
						stateDivObj.put("curveHref",curvehref);
						sizehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchIndComps=true&menuName=agg&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(index+"state")+"&who=fromServerTypes&fromHomepage="+fromHomepage;
						if(parentZone!=null && parentZone.length()>0)
							sizehref = sizehref+"&parentZone="+parentZone;
						stateDivObj.put("sizeHref",sizehref);
					}
				}
				else
				{
					curvehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentTypeState&menuName=agg&zoneName="+r.zoneName+"&searchIndComps=true&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage;
					if(parentZone!=null && parentZone.length()>0)
						curvehref = curvehref+"&parentZone="+parentZone;
					stateDivObj.put("curveHref",curvehref);
					sizehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchIndComps=true&menuName=agg&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(index+"state")+"&who=fromServerTypes&fromHomepage="+fromHomepage;
					if(parentZone!=null && parentZone.length()>0)
						sizehref = sizehref+"&parentZone="+parentZone;
					stateDivObj.put("sizeHref",sizehref);
				}
				stateDivObj.put("size",String.valueOf(size));
				divArray.add(stateDivObj);
				k++;
				aggregate.put("barchart", divArray);
			}
			else
			{
				if(changelink)
				{
					if(ser1!=null && ser1.trim().length()>0)
					{
						href="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
					}
					else
					{
						href="../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchStateString=All States&action=componentType&searchIndComps=checked&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&menuName=agg&who=fromServerTypes&zoneName="+r.zoneName+"&fromHomepage="+fromHomepage;
						if(parentZone!=null && parentZone.length()>0)
							href = href+"&parentZone="+parentZone;
					}
				}
				else
				{
					href="../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchStateString=All States&action=componentType&searchIndComps=checked&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&menuName=agg&who=fromServerTypes&zoneName="+r.zoneName+"&fromHomepage="+fromHomepage;
					if(parentZone!=null && parentZone.length()>0)
						href = href+"&parentZone="+parentZone;
				}

				aggregate = mapper.createObjectNode();
				aggregate.put("compType",mappingInfo.getComponentTypeDescription(serverType));
				aggregate.put("href",href);
				aggregate.put("count",String.valueOf(health.getTotal()));

				if(isShowFullBar)
				{
					maxCount=0L;
				}

				long size = 0L;
				HashSet uniqueState = new HashSet();
				int lastCountInteger  = 0;
				int sameColorCount = 0;
				for (int b=0; b < states.length; b++)
				{
					long thisCount = health.getValue(State.getState(states[b]));
					if(thisCount!=0)
					{
						sameColorCount++;
						lastCountInteger = b;
					}
					size+=thisCount;
				}
				maxCount = Math.max(maxCount, size);
				int tableWidth = (int)((health.getTotal()*100)/(int)maxCount);
				tableWidth = tableWidth<1?1:tableWidth;

				aggregate.put("tdWidth",String.valueOf(tableWidth));
				long maxStateValue = 0L;
				long divWidth=0;
				Hashtable statesValueHash = new Hashtable();
				if(isShowFullBar)
				{
					for(int j=0;j < states.length;j++)
					{
						size = health.getValue(State.getState(states[j]));
						if(size==0)
						{
							continue;
						}

						long tdWidth = (long) size*100/(long)health.getTotal();
						
						if(size>=1) 
						{
							//tdWidth = (tdWidth<4)?2:tdWidth;
							if (tdWidth < 2)
								tdWidth = 2;
						}
						String maxState = (String)statesValueHash.get("MaxState");
						if(maxState==null || maxState.trim().length()==0)
							maxState = states[j];

						Long tmpMaxStateValue = (Long)statesValueHash.get(maxState);
						if(tmpMaxStateValue==null)
							tmpMaxStateValue = new Long(0);

						maxStateValue = Math.max(tmpMaxStateValue.longValue(), tdWidth);
						maxState = (maxStateValue == tmpMaxStateValue.longValue())?maxState:states[j];
						statesValueHash.put("MaxState",maxState);
						statesValueHash.put("MaxStateValue",new Long(maxStateValue));

						divWidth = tdWidth + divWidth;

						if(divWidth > 100)
						{
							if(maxStateValue == tdWidth)
							{
								maxStateValue = maxStateValue - 2;
								statesValueHash.put(maxState,new Long(maxStateValue));
								divWidth = divWidth - 2;
							}
							else
							{
								maxStateValue = maxStateValue - tdWidth;
								statesValueHash.put(maxState,new Long(maxStateValue));
								statesValueHash.put(states[j],new Long(tdWidth));
								divWidth = divWidth - tdWidth;
							}
						}
						else
						{
							statesValueHash.put(states[j],new Long(tdWidth));
						}
						if(j==lastCountInteger )
						{
							long tmpWidth = 100 - divWidth;
							//tdWidth = tdWidth + tmpWidth;
							maxStateValue = maxStateValue + tmpWidth;
							statesValueHash.put(maxState,new Long(maxStateValue));
						}
					}
				}

				int k=0;
				long divWidthOld=0;
				ArrayNode divArray = mapper.createArrayNode();
				for(int j=0;j < states.length;j++)	
				{
					ObjectNode stateDivObj = mapper.createObjectNode();
					size = health.getValue(State.getState(states[j]));
					if(size==0)
						continue;
					/*long tdWidth = (long) size*100/(long)health.getTotal();
					divWidth = tdWidth + divWidth;
					if(j==lastCountInteger )
					{
						long tmpWidth = 100 - divWidth;
						tdWidth = tdWidth + tmpWidth;
					}*/
					Long tdWidth = new Long(0);
					if(isShowFullBar)
					{
						tdWidth = (Long)statesValueHash.get(states[j]);
					}
					else
					{
						long tdWidthTmp = (long) size*100/(long)health.getTotal();
						divWidthOld = tdWidthTmp + divWidthOld;
						
						if(j==lastCountInteger )
						{
							long tmpWidth = 100 - divWidthOld;
							tdWidthTmp = tdWidthTmp + tmpWidth;
						}

						tdWidth = new Long(tdWidthTmp);
					}
					String curve = "";
					if(health.getTotal()==1)
					{
						curve="innerLeftRight12";
					}
					else
					{
						if(k==0 && sameColorCount!=1)
						{
							curve="innerLeft12";
						}
						else if(sameColorCount==1)
						{
							curve="innerLeftRight12";
						}
						else if(lastCountInteger==j)
						{
							curve="innerRight12";
						}
						k++;
					}
					stateDivObj.put("tdWidth", String.valueOf(tdWidth));
					stateDivObj.put("backgroundColor",(String)backgroundColor.get(j+"id"));
					stateDivObj.put("curve",curve);
					String curvehref="";
					String sizehref="";
					if(changelink)
					{
						if(ser1!=null && ser1.trim().length()>0)
						{
							curvehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
							stateDivObj.put("curveHref",curvehref);
							sizehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
							stateDivObj.put("sizeHref",sizehref);
						}
						else
						{
							curvehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentTypeState&menuName=agg&zoneName="+r.zoneName+"&searchIndComps=true&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;
							if(parentZone!=null && parentZone.length()>0)
								curvehref = curvehref+"&parentZone="+parentZone;
							stateDivObj.put("curveHref",curvehref);
							sizehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchIndComps=true&menuName=agg&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(j+"state")+"&who=fromServerTypes&fromHomepage="+fromHomepage;
							if(parentZone!=null && parentZone.length()>0)
								sizehref = sizehref+"&parentZone="+parentZone;
							stateDivObj.put("sizeHref",sizehref);
						}
					}
					else
					{
						if(size==1)
						{
							String ser2=null;
							String temp_ser = null;
							ArrayList sname2=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname2=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname2!=null )
								{
									for(int l=0;l<sname2.size();l++)
									{
										ser2=(String)sname2.get(l);
										String al_state = ap.getAlarmPriority(Server.getServerName(serverType+":"+ser2), serverType,"NULL");
										if(backgroundColor.get(j+"state").equals(al_state))
										{
											temp_ser = ser2;
											break;
										}
									}
								}
							}

							if(temp_ser!=null && temp_ser.trim().length()>0)
							{
								curvehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(temp_ser,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
								stateDivObj.put("curveHref",curvehref);
								sizehref="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&fromPage=componentList&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(temp_ser,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
								stateDivObj.put("sizeHref",sizehref);
							}
						}
						else
						{
							curvehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentTypeState&menuName=agg&zoneName="+r.zoneName+"&searchIndComps=true&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;
							
							if(parentZone!=null && parentZone.length()>0)
								curvehref = curvehref+"&parentZone="+parentZone;

							stateDivObj.put("curveHref",curvehref);
							
							sizehref = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&searchIndComps=true&menuName=agg&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&stateName="+backgroundColor.get(j+"state")+"&who=fromServerTypes&fromHomepage="+fromHomepage;

							if(parentZone!=null && parentZone.length()>0)
								sizehref = sizehref+"&parentZone="+parentZone;

							stateDivObj.put("sizeHref",sizehref);
						}
					}
					stateDivObj.put("size",String.valueOf(size));
					divArray.add(stateDivObj);
					k++;
				}
				aggregate.put("barchart", divArray);
			}
			aggregates.add(aggregate);
		}
		healthViewContent.put("aggregates",aggregates);
	}

	if(keyList!=null && keyList.size()>0)
	{
		ArrayList recorder = new ArrayList();
		//if(selectedInfraStructure!=null && selectedInfraStructure.equals(""))
		//{
			//selectedInfraStructure = "components";
		//}
		
		if(dialList.size()>1)
			selectedInfraStructure = "components";
		else if(dialList.size()==1 && dialList.contains("Aggregates"))
			selectedInfraStructure = "aggregates";
		else
			selectedInfraStructure = "components";

		ArrayNode components = mapper.createArrayNode();
		ObjectNode componentObj;
		
		boolean hasUnique=false;
		boolean changelink=false;
		String ser1="";
		String tempUrl="";
		for(int n=0; n < keyList.size(); n++)
		{
			String serverType = keyList.get(n).toString();
			Health health = (Health) serversWithTypesAndStates.get(serverType);
			changelink=false;
			if(health!=null && health.getTotal()==1)
			{
				changelink=true;
			}

			if(serverType.startsWith("Agg_"))
			{
				continue;
			}

			if(serverType.indexOf(":") > -1)
				serverType = serverType.substring(0,serverType.indexOf(":"));
			if(!recorder.contains(serverType))
			{
				recorder.add(serverType);
			}
			else
			{
				continue;
			}

			if(selectedState!= null && selectedState.trim().length()>0 && selectedHealthName!=null && selectedHealthName.equalsIgnoreCase("Components"))
			{
				componentObj = mapper.createObjectNode();
				long size = 0L;
				int lastCountInteger  = 0;
				int sameColorCount = 0;
				long thisCount = health.getValue(State.getState(selectedState));
				if(thisCount!=0)
				{
					sameColorCount++;
					lastCountInteger = 0;
				}
				else
					continue;
				size+=thisCount;
				maxCount = Math.max(maxCount, size);
				int tableWidth = (int)((thisCount*100)/(int)maxCount);
				tableWidth = tableWidth<1?1:tableWidth;
				componentObj.put("compType",mappingInfo.getComponentTypeDescription(serverType));
				String redirectOtherURL= iniFileforComp.getValue("InfraDashboard_compType_redirectURL",serverType);
				boolean redirectToOthers = false;
				if(redirectOtherURL != null && redirectOtherURL.trim().length() > 0)
					redirectToOthers = true;

				String excludedCompType=iniFileforComp.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);
						}
					}
				}

				//if(redirectToOthers  && health.getTotal() > 1){
				if(redirectToOthers){
					tempUrl=redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8");
					//componentObj.put("href",redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8"));
				}else{
					if(isListView!=null && (isListView.equalsIgnoreCase("Yes") || isListView.equalsIgnoreCase("true")))
					{
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}
							if(ser1!=null && ser1.trim().length()>0)
							{
								tempUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
							}
							else
							{
								tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage;
								if(parentZone!=null && parentZone.length()>0)
									tempUrl = tempUrl+"&parentZone="+parentZone;
							}
						}
						else
						{
							String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;
						
							tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";
						
							if(parentZone!=null && parentZone.length()>0)
								tempUrl = tempUrl+"&parentZone="+parentZone;

						}
					}
					else if(isListView!=null && (isListView.equalsIgnoreCase("No") || isListView.equalsIgnoreCase("false")))
					{
						//tempUrl = "/final/monitor/comparisonDashboard.jsp?treeTitle=components&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName;
						
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}

							if(ser1!=null && ser1.trim().length()>0)
							{
								tempUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
							}
							else
							{
								tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage;
						
								if(parentZone!=null && parentZone.length()>0)
									tempUrl = tempUrl+"&parentZone="+parentZone;
							}
						}
						else
						{
							if(serverType!=null && serverType.length()>0)
							{
								String compVal=iniFileforComp.getValue("TREE_APPLICATION",serverType);
								if(compVal!=null && compVal.length()>0)
								{
									if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && excludedCompTypeList.contains(serverType))
									{
										String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;
						
										tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";
						
										if(parentZone!=null && parentZone.length()>0)
											tempUrl = tempUrl+"&parentZone="+parentZone;
									}
									else
									{
										String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;

										tempUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
										
										if(parentZone!=null && parentZone.length()>0)
											tempUrl = tempUrl+"&parentZone="+parentZone;
									}
								}
								else
								{
									String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;
						
									tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";
						
									if(parentZone!=null && parentZone.length()>0)
										tempUrl = tempUrl+"&parentZone="+parentZone;
								}
							}
						}
						
						//String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;

						//tempUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
					}
				}
				if(isFromZoneMenu)
					tempUrl = tempUrl+"&isFromZoneMenu="+isFromZoneMenu;

				componentObj.put("href",tempUrl);
				componentObj.put("count",String.valueOf(thisCount));
				componentObj.put("tdWidth",String.valueOf("100"));
				int k=0;
				long divWidth=0;
				ArrayNode divArray = mapper.createArrayNode();
				ObjectNode stateDivObj = mapper.createObjectNode();
				size = health.getValue(State.getState(selectedState));
				if(size==0)
				{
					continue;
				}
				String curve = "";
				if(health.getTotal()==1)
				{
					curve="innerLeftRight12";
				}
				else
				{
					if(k==0 && sameColorCount!=1)
					{
						curve="innerLeft12";
					}
					else if(sameColorCount==1)
					{
						curve="innerLeftRight12";
					}
					else if(lastCountInteger==0)
					{
						curve="innerRight12";
					}
					k++;
				}
									
				long tdWidth = (long) size*100/(long)thisCount;
				divWidth = tdWidth + divWidth;
				if(lastCountInteger == 0)
				{
					long tmpWidth = 100 - divWidth;
					tdWidth = tdWidth + tmpWidth;
				}
				stateDivObj.put("tdWidth",String.valueOf(tdWidth));
				stateDivObj.put("backgroundColor",(String)backgroundColor.get(index+"id"));
				stateDivObj.put("curve",curve);
				String tempCurveUrl="";
				String tempSizeUrl="";

				if(redirectToOthers){
					stateDivObj.put("curveHref",redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8")+"&selectedState="+backgroundColor.get(index+"state"));
					stateDivObj.put("sizeHref",redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8")+"&selectedState="+backgroundColor.get(index+"state"));
					
				}else{
					if(isListView!=null && (isListView.equalsIgnoreCase("Yes") || isListView.equalsIgnoreCase("true")))
					{
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}

							if(ser1!=null && ser1.trim().length()>0)
							{
								tempCurveUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true&isFromZoneMenu="+isFromZoneMenu;
								stateDivObj.put("curveHref",tempCurveUrl);
								tempSizeUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true&isFromZoneMenu="+isFromZoneMenu;
								stateDivObj.put("sizeHref",tempSizeUrl);
							}
							else
							{
								tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
								if(parentZone!=null && parentZone.length()>0)
									tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;
								stateDivObj.put("curveHref",tempCurveUrl);
								tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
								if(parentZone!=null && parentZone.length()>0)
									tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
								stateDivObj.put("sizeHref",tempSizeUrl);
							}
						}
						else
						{
							/*tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage;
							if(parentZone!=null && parentZone.length()>0)
								tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;
							stateDivObj.put("curveHref",tempCurveUrl);
							tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage;
							if(parentZone!=null && parentZone.length()>0)
								tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
							stateDivObj.put("sizeHref",tempSizeUrl);*/

							String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(index+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
							tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

							if(parentZone!=null && parentZone.length()>0)
								tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

							stateDivObj.put("curveHref",tempCurveUrl);

							tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

							if(parentZone!=null && parentZone.length()>0)
								tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
								stateDivObj.put("sizeHref",tempSizeUrl);
						}
					}
					else if(isListView!=null && (isListView.equalsIgnoreCase("No") || isListView.equalsIgnoreCase("false")))
					{
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}
							if(ser1!=null && ser1.trim().length()>0)
							{
								tempCurveUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
								stateDivObj.put("curveHref",tempCurveUrl);
								tempSizeUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
								stateDivObj.put("sizeHref",tempSizeUrl);
							}
							else
							{
								tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
								if(parentZone!=null && parentZone.length()>0)
									tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;
								stateDivObj.put("curveHref",tempCurveUrl);
								tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
								if(parentZone!=null && parentZone.length()>0)
									tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
								stateDivObj.put("sizeHref",tempSizeUrl);
							}
						}
						else
						{
							if(serverType!=null && serverType.length()>0)
							{
								String compVal=iniFileforComp.getValue("TREE_APPLICATION",serverType);
								if(compVal!=null && compVal.length()>0)
								{
									if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && excludedCompTypeList.contains(serverType))
									{
										String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(index+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
										tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

										if(parentZone!=null && parentZone.length()>0)
											tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

										stateDivObj.put("curveHref",tempCurveUrl);

										tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

										if(parentZone!=null && parentZone.length()>0)
											tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
										stateDivObj.put("sizeHref",tempSizeUrl);
									}
									else
									{
										String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(index+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
										tempCurveUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
							
										if(parentZone!=null && parentZone.length()>0)
											tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;
										stateDivObj.put("curveHref",tempCurveUrl);
							
										tempSizeUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;

										if(parentZone!=null && parentZone.length()>0)
											tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
										stateDivObj.put("sizeHref",tempSizeUrl);
									}
								}
								else
								{
									String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(index+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
									tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

									if(parentZone!=null && parentZone.length()>0)
										tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

									stateDivObj.put("curveHref",tempCurveUrl);

									tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(index+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;

									if(parentZone!=null && parentZone.length()>0)
										tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
									stateDivObj.put("sizeHref",tempSizeUrl);
								}
							}
						}
						
						/*String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(index+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
						
						tempCurveUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
						
						stateDivObj.put("curveHref",tempCurveUrl);
						
						tempSizeUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(index+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
						
						stateDivObj.put("sizeHref",tempSizeUrl);*/
					}
				}

				stateDivObj.put("size",String.valueOf(size));
				divArray.add(stateDivObj);
				componentObj.put("barchart", divArray);
			}
			else
			{
				componentObj = mapper.createObjectNode();
				componentObj.put("compType",mappingInfo.getComponentTypeDescription(serverType));
				String viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" COMPONENTS FOR THE ZONE : "+r.zoneName;

				String redirectOtherURL= iniFileforComp.getValue("InfraDashboard_compType_redirectURL",serverType);
				boolean redirectToOthers = false;
				if(redirectOtherURL != null && redirectOtherURL.trim().length() > 0)
					redirectToOthers = true;
				
				String excludedCompType=iniFileforComp.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);
						}
					}
				}

				//if(redirectToOthers  && health.getTotal() > 1){
				if(redirectToOthers){
					tempUrl=redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(r.zoneName,"UTF-8");
				
					if(tempUrl.indexOf("&fromHomepage=true")>-1)
					{
						tempUrl=tempUrl.replace("&fromHomepage=true","&fromHomepage="+fromHomepage);
					}
					tempUrl+="&isFromZoneMenu="+isFromZoneMenu;
					
				}else{
					if(isListView!=null && (isListView.equalsIgnoreCase("Yes") || isListView.equalsIgnoreCase("true")))
					{
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}
							if(ser1!=null && ser1.trim().length()>0)
							{
								tempUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
							}
							else
							{
								tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&isFromZoneMenu="+isFromZoneMenu;

								if(parentZone!=null && parentZone.length()>0)
									tempUrl = tempUrl+"&parentZone="+parentZone;
							}
						}
						else
						{
							/*tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage;

							if(parentZone!=null && parentZone.length()>0)
								tempUrl = tempUrl+"&parentZone="+parentZone;*/

							tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;
							
							if(parentZone!=null && parentZone.length()>0)
								tempUrl = tempUrl+"&parentZone="+parentZone;
						}
					}
					else
					{
						if(changelink)
						{
							ser1=null;
							ArrayList sname=new ArrayList();
							if(r.serverTypesAndComps!=null)
							{
								sname=(ArrayList)r.serverTypesAndComps.get(serverType);
								if(sname!=null && sname.size()==1)
								{
									ser1=(String)sname.get(0);
								}
							}
							if(ser1!=null && ser1.trim().length()>0)
							{
								tempUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage="+fromHomepage;
							}
							else
							{
								tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&isFromZoneMenu="+isFromZoneMenu;

								if(parentZone!=null && parentZone.length()>0)
									tempUrl = tempUrl+"&parentZone="+parentZone;
							}
						}
						else
						{
							if(serverType!=null && serverType.length()>0)
							{
								String compVal=iniFileforComp.getValue("TREE_APPLICATION",serverType);
								if(compVal!=null && compVal.length()>0)
								{
									if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && excludedCompTypeList.contains(serverType))
									{
										tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;
							
										if(parentZone!=null && parentZone.length()>0)
											tempUrl = tempUrl+"&parentZone="+parentZone;
									}
									else
									{
										tempUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage+"&isFromZoneMenu="+isFromZoneMenu;
										if(parentZone!=null && parentZone.length()>0)
											tempUrl = tempUrl+"&parentZone="+parentZone;
									}
								}
								else
								{
									tempUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&action=componentType&searchIndComps=true&zoneName="+r.zoneName+"&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&isTreeFlag="+isTreeFlag+"&fromHomepage="+fromHomepage+"&iscurrentTab="+iscurrentTab+"&isaggregateTab="+isaggregateTab+"&isopenNode="+isopenNode+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&isFromZoneMenu="+isFromZoneMenu;
							
									if(parentZone!=null && parentZone.length()>0)
										tempUrl = tempUrl+"&parentZone="+parentZone;
								}
							}
						}
						
						//tempUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
					}
				}
				if(tempUrl != null && tempUrl.length()>0)
				{
					if(tempUrl.indexOf("&parentZone=")<0)
					{
						if(parentZone!=null && parentZone.length()>0)
							tempUrl = tempUrl+"&parentZone="+parentZone;
					}
					if(tempUrl.indexOf("&zoneName=")<0)
					{
						if(r.zoneName!=null && r.zoneName.length()>0)
							tempUrl = tempUrl+"&zoneName="+r.zoneName;
					}
				}
				componentObj.put("href",tempUrl);
				componentObj.put("count",String.valueOf(health.getTotal()));

				if(isShowFullBar)
				{
					maxCount=0L;
				}

				long size = 0L;
				int lastCountInteger  = 0;
				int sameColorCount = 0;
				for (int b=0; b < states.length; b++)
				{
					long thisCount = health.getValue((State.getState(states[b])));
					if(thisCount!=0)
					{
						sameColorCount++;
						lastCountInteger = b;
					}
					size+=thisCount;
				}
				
				maxCount = Math.max(maxCount, size);
				int tableWidth = (int)((health.getTotal()*100)/(int)maxCount);
				tableWidth = tableWidth<1?1:tableWidth;

				componentObj.put("tdWidth",String.valueOf(tableWidth));
				long divWidth=0;
				long maxStateValue = 0L;
				Hashtable statesValueHash = new Hashtable();
				if(isShowFullBar)
				{
					for(int j=0;j < states.length;j++)
					{
						size = health.getValue(State.getState(states[j]));
						if(size==0)
						{
							continue;
						}

						long tdWidth = (long) size*100/(long)health.getTotal();
						
						if(size>=1) 
						{
							//tdWidth = (tdWidth<4)?2:tdWidth;
							if (tdWidth < 2)
								tdWidth = 2;
						}
						String maxState = (String)statesValueHash.get("MaxState");
						if(maxState==null || maxState.trim().length()==0)
							maxState = states[j];

						Long tmpMaxStateValue = (Long)statesValueHash.get(maxState);
						if(tmpMaxStateValue==null)
							tmpMaxStateValue = new Long(0);

						maxStateValue = Math.max(tmpMaxStateValue.longValue(), tdWidth);
						maxState = (maxStateValue == tmpMaxStateValue.longValue())?maxState:states[j];
						statesValueHash.put("MaxState",maxState);
						statesValueHash.put("MaxStateValue",new Long(maxStateValue));

						divWidth = tdWidth + divWidth;

						if(divWidth > 100)
						{
							if(maxStateValue == tdWidth)
							{
								maxStateValue = maxStateValue - 2;
								statesValueHash.put(maxState,new Long(maxStateValue));
								divWidth = divWidth - 2;
							}
							else
							{
								maxStateValue = maxStateValue - tdWidth;
								statesValueHash.put(maxState,new Long(maxStateValue));
								statesValueHash.put(states[j],new Long(tdWidth));
								divWidth = divWidth - tdWidth;
							}
						}
						else
						{
							statesValueHash.put(states[j],new Long(tdWidth));
						}
						if(j==lastCountInteger )
						{
							long tmpWidth = 100 - divWidth;
							//tdWidth = tdWidth + tmpWidth;
							maxStateValue = maxStateValue + tmpWidth;
							statesValueHash.put(maxState,new Long(maxStateValue));
						}
					}
				}

				int k=0;
				long divWidthOld=0;
				ArrayNode divArray = mapper.createArrayNode();
				for(int j=0;j < states.length;j++)
				{
					ObjectNode stateDivObj = mapper.createObjectNode();
					size = health.getValue(State.getState(states[j]));
					if(size==0)
					{
						continue;
					}

					Long tdWidth = new Long(0);
					if(isShowFullBar)
					{
						tdWidth = (Long)statesValueHash.get(states[j]);
					}
					else
					{
						long tdWidthTmp = (long) size*100/(long)health.getTotal();
						divWidthOld = tdWidthTmp + divWidthOld;
						
						if(j==lastCountInteger )
						{
							long tmpWidth = 100 - divWidthOld;
							tdWidthTmp = tdWidthTmp + tmpWidth;
						}

						tdWidth = new Long(tdWidthTmp);
					}
					String curve = "";
					if(health.getTotal()==1)
					{
						curve="innerLeftRight12";
					}
					else
					{
						if(k==0 && sameColorCount!=1)
						{
							curve="innerLeft12";
						}
						else if(sameColorCount==1)
						{
							curve="innerLeftRight12";
						}
						else if(lastCountInteger==j)
						{
							curve="innerRight12";
						}
						k++;
					}

					/*long tdWidth = (long) size*100/(long)health.getTotal();
					divWidth = tdWidth + divWidth;
					
					if(j==lastCountInteger )
					{
						long tmpWidth = 100 - divWidth;
						tdWidth = tdWidth + tmpWidth;
						
					}*/
					//stateDivObj.put("tdWidth",String.valueOf(tdWidth));
					stateDivObj.put("tdWidth",tdWidth);
					stateDivObj.put("backgroundColor",(String)backgroundColor.get(j+"id"));
					stateDivObj.put("curve",curve);
					String tempCurveUrl="";
					String tempSizeUrl="";
					
					if(redirectToOthers){
						stateDivObj.put("curveHref",redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8")+"&selectedState="+backgroundColor.get(j+"state"));
						stateDivObj.put("sizeHref",redirectOtherURL+"&isFromZoneInfra=true&zoneName="+EgURLEncoder.encode(parentZone,"UTF-8")+"&selectedState="+backgroundColor.get(j+"state"));
						
					}else{
						if(isListView!=null && (isListView.equalsIgnoreCase("Yes") || isListView.equalsIgnoreCase("true")))
						{
							if(changelink)
							{
								ser1=null;
								ArrayList sname=new ArrayList();
								if(r.serverTypesAndComps!=null)
								{
									sname=(ArrayList)r.serverTypesAndComps.get(serverType);
				
									if(sname!=null && sname.size()==1)
									{
										ser1=(String)sname.get(0);
									}
								}
								if(ser1!=null && ser1.trim().length()>0)
								{
									tempCurveUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
									stateDivObj.put("curveHref",tempCurveUrl);
									tempSizeUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
									stateDivObj.put("sizeHref",tempSizeUrl);
								}
								else
								{
									tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

									if(parentZone!=null && parentZone.length()>0)
									tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

									stateDivObj.put("curveHref",tempCurveUrl);

									tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

									if(parentZone!=null && parentZone.length()>0)
										tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

									stateDivObj.put("sizeHref",tempSizeUrl);
								}
							}
							else
							{
								/*tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

								if(parentZone!=null && parentZone.length()>0)
								tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

								stateDivObj.put("curveHref",tempCurveUrl);

								tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

								if(parentZone!=null && parentZone.length()>0)
									tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

								stateDivObj.put("sizeHref",tempSizeUrl);*/

								viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(j+"state")) +" STATE FOR THE ZONE : "+r.zoneName;

								if(size==1)
								{
									String ser2=null;
									String temp_ser = null;
									ArrayList sname2=new ArrayList();
									if(r.serverTypesAndComps!=null)
									{
										sname2=(ArrayList)r.serverTypesAndComps.get(serverType);
										if(sname2!=null )
										{
											for(int l=0;l<sname2.size();l++)
											{
												ser2=(String)sname2.get(l);
												String al_state = ap.getAlarmPriority(Server.getServerName(serverType+":"+ser2), serverType,"NULL");
												if(backgroundColor.get(j+"state").equals(al_state))
												{
													temp_ser = ser2;
													break;
												}
											}
										}
									}

									if(ser2!=null && ser2.trim().length()>0)
									{
										tempCurveUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser2,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
										stateDivObj.put("curveHref",tempCurveUrl);
										tempSizeUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser2,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
										stateDivObj.put("sizeHref",tempSizeUrl);
									}
								}
								else
								{
									tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

									if(parentZone!=null && parentZone.length()>0)
										tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

									stateDivObj.put("curveHref",tempCurveUrl);

									tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

									if(parentZone!=null && parentZone.length()>0)
										tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

									stateDivObj.put("sizeHref",tempSizeUrl);
								}
							}
						}
						else
						{
							if(changelink)
							{
								ser1=null;
								ArrayList sname=new ArrayList();
								if(r.serverTypesAndComps!=null)
								{
									sname=(ArrayList)r.serverTypesAndComps.get(serverType);
									if(sname!=null && sname.size()==1)
									{
										ser1=(String)sname.get(0);
									}
								}
								if(ser1!=null && ser1.trim().length()>0)
								{
									tempCurveUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
									stateDivObj.put("curveHref",tempCurveUrl);
									tempSizeUrl="/final/servlet/com.eg.EgDashboardController?from=list&site=NULL&qctr=0&newWindow=false&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true";
									stateDivObj.put("sizeHref",tempSizeUrl);
								}
								else
								{
									tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

									if(parentZone!=null && parentZone.length()>0)
									tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

									stateDivObj.put("curveHref",tempCurveUrl);

									tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage;

									if(parentZone!=null && parentZone.length()>0)
										tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

									stateDivObj.put("sizeHref",tempSizeUrl);
								}
							}
							else
							{
								if(serverType!=null && serverType.length()>0)
								{
									String compVal=iniFileforComp.getValue("TREE_APPLICATION",serverType);
									if(compVal!=null && compVal.length()>0)
									{
										if(excludedCompTypeList!=null && excludedCompTypeList.size()>0 && excludedCompTypeList.contains(serverType))
										{
											viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(j+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
											tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

											if(parentZone!=null && parentZone.length()>0)
												tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

											stateDivObj.put("curveHref",tempCurveUrl);

											tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

											if(parentZone!=null && parentZone.length()>0)
												tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

											stateDivObj.put("sizeHref",tempSizeUrl);
										}
										else
										{
											if(size == 1)
											{
												ser1=null;

												String temp_ser = null;
												ArrayList sname=new ArrayList();
												if(r.serverTypesAndComps!=null)
												{
													sname=(ArrayList)r.serverTypesAndComps.get(serverType);
													if(sname!=null )
													{
														for(int l=0;l<sname.size();l++)
														{
															ser1=(String)sname.get(l);
															String al_state = ap.getAlarmPriority(Server.getServerName(serverType+":"+ser1), serverType,"NULL");
															if(backgroundColor.get(j+"state").equals(al_state))
															{
																temp_ser = ser1;
																break;
															}
														}
													}
												}
												if(temp_ser != null)
												{
													stateDivObj.put("curveHref","/final/servlet/com.eg.EgDashboardController?site=NULL&from=list&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true");
													stateDivObj.put("sizeHref","/final/servlet/com.eg.EgDashboardController?site=NULL&from=list&comptype="+EgURLEncoder.encode(serverType,"UTF-8")+"&host="+EgURLEncoder.encode(ser1,"UTF-8")+"&tab=LayerModel&fromHomepage=true");
												}
											}
											else
											{
												viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(j+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
						
												tempCurveUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
												if(parentZone!=null && parentZone.length()>0)
													tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;
							
												stateDivObj.put("curveHref",tempCurveUrl);
							
												tempSizeUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
												if(parentZone!=null && parentZone.length()>0)
													tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;
							
												stateDivObj.put("sizeHref",tempSizeUrl);
											}
										}
									}
									else
									{
										viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(j+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
							
										tempCurveUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

										if(parentZone!=null && parentZone.length()>0)
											tempCurveUrl = tempCurveUrl+"&parentZone="+parentZone;

										stateDivObj.put("curveHref",tempCurveUrl);

										tempSizeUrl = "../servlet/com.eg.EgMonitorController?monCmd=componentList&from=ZoneDashboard&zoneName="+r.zoneName+"&action=componentTypeState&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&searchIndComps=true&stateName="+backgroundColor.get(j+"state")+"&fromHomepage="+fromHomepage+"&fromPageView="+fromPageView+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component";

										if(parentZone!=null && parentZone.length()>0)
											tempSizeUrl = tempSizeUrl+"&parentZone="+parentZone;

										stateDivObj.put("sizeHref",tempSizeUrl);
									}
								}
							}

							/*viewPageTitle=(String)mappingInfo.getComponentTypeDescription(serverType)+" "+"COMPONENTS IN "+ (String)mappingInfo.getLabelDescription((String)backgroundColor.get(j+"state")) +" STATE FOR THE ZONE : "+r.zoneName;
						
							tempCurveUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
							
							stateDivObj.put("curveHref",tempCurveUrl);
							
							tempSizeUrl = "/final/servlet/com.eg.EgMonitorController?monCmd=componentList&from=TreeMenu&action=component&searchIndComps=checked&view=metric&viewId=components&viewPageTitle="+EgURLEncoder.encode(viewPageTitle,"UTF-8")+"&viewTreeTitle=Component&componentType="+EgURLEncoder.encode(serverType,"UTF-8")+"&filterBy=zone&subFilter="+r.zoneName+"&selectedState="+backgroundColor.get(j+"state")+"&fromPageView="+fromPageView+"&fromHomepage="+fromHomepage;
							
							stateDivObj.put("sizeHref",tempSizeUrl);*/
						}
					}
					stateDivObj.put("size",String.valueOf(size));
					divArray.add(stateDivObj);
					componentObj.put("barchart", divArray);
				}
			}
			components.add(componentObj);
		}
		healthViewContent.put("components",components);
	}

	ObjectNode labelObj= mapper.createObjectNode();
	labelObj.put("Component Type",mappingInfo.getTextDescription("monitor.home.Component Type"));
	labelObj.put("Count",mappingInfo.getTextDescription("monitor.home.Count"));
	labelObj.put("Status",mappingInfo.getTextDescription("monitor.home.Status"));
	labelObj.put("Infrastructure Health",mappingInfo.getTextDescription("monitor.home.Infrastructure Health"));
	labelObj.put("Event Analysis",mappingInfo.getTextDescription("monitor.home.Event Analysis"));
	
	json.put("healthView",healthViewContent);
	json.put("screenLabels",labelObj);
	if(selectedInfraStructure != null && !selectedInfraStructure.equals("undefined") && selectedInfraStructure.trim().length()>0)
	{
		json.put("selectedInfraStructure",selectedInfraStructure);
	}
	else
	{
		json.put("selectedInfraStructure","components");
	}

	response.getWriter().write(json.toString());
}
catch(Throwable e)
{
	e.printStackTrace();
}
%>


