<%
/**
 *	File name		: eGBTMd3Topology.jsp
 *	Purpose			: This page shows the call graph of a web request in HTML Table Tree view
 *	Version			: eG 6.1
 *	Creation Date	: 24-Aug-2015
 *	Author			: Mr.Balraj
 */
%>
<%@ include file = "EgMonitorTracker.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import = "java.sql.*"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.math.*"%>
<%@ page import = "net.sf.json.*" %>
<%@ page import = "java.text.*" %>
<%@ page import = "com.egurkha.util.StringUtils"%> 
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.eg.EgSpecsInfo"%>
<%@ page import = "com.eg.EgDiscInfo"%>
<%@ page import = "com.eg.IniFile"%>
<%@ page import = "com.eg.EgDbInfo"%>
<%@ page import = "com.eg.EgDbaseInfo"%>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "java.io.*" %>
<%@ page import = "com.eg.eGComponentCategory" %>
<%@ page import = "com.egurkha.BTMHelper"%>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.EgAPMInfo" %>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import = "egurkha.EgDbAdapterUI" %>
<%@ page import = "com.eg.EgDbAdapterTypeUI" %>

<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%
	response.setContentType("text/html;charset=UTF-8");
	String comesFrom = request.getParameter("from");
	
	if(comesFrom!=null && comesFrom.equalsIgnoreCase("mydashboard"))
	{
		String myDashboardTheme = request.getParameter("myDashboardTheme");
		if(!com.egurkha.util.StringUtils.isNull(myDashboardTheme) && !myDashboardTheme.equalsIgnoreCase(monitor_Skin))
		{
			monitor_Skin=myDashboardTheme;
		}
	}
	String isReporterRequest = request.getParameter("isReporterRequest");
	if(isReporterRequest == null || isReporterRequest.trim().equals("")){
		isReporterRequest = "no";
	}
%>
<%!

	EgAPMInfo apm = new EgAPMInfo("manager");
	DecimalFormat scaleDecimalFormat = new DecimalFormat("#");
	DecimalFormat percentFormat = new DecimalFormat("#.##");
	eGComponentCategory egCompCategory = eGComponentCategory.getInstance(); 
	//EgDbaseInfo egDbaseInfo = new EgDbaseInfo("manager");

	String USER_EXPERIENCE_SLOW = "SLOW";
	String USER_EXPERIENCE_STALLED = "STALLED";
	String USER_EXPERIENCE_ERROR = "ERROR";
	String USER_EXPERIENCE_HEALTHY = "HEALTHY";
	String healthy_Urls_Count = "Healthy_percentage";
	String slow_Urls_Count = "Slow_percentage";
	String error_Urls_Count = "Error_percentage";
	String stalled_Urls_Count = "Stalled_percentage";
	String userExpTooltipTitle = "Summary for";
	String pointCutException = "EXCEPTION";
	String pointCutHTTP = "HTTP";
	String pointCutEJB = "EJB";
	String pointCutWebService = "WEBSERVICE";
	String pointCutJMS = "JMS";
	String pointCutSAP = "SAP JCO";
	String pointCutSQL = "SQL";
	String pointCutMONGO = "MONGODB";
	String pointCutREDIS = "REDIS";
	String pointCutCustom = "Custom";
	String pointCutRuntime = "RUNTIME";
	String pointCutJmsEntry = "JMS_ENTRY";
	String checkTempQueue = "TEMP-QUEUE";
	String checkTempTopic = "TEMP-TOPIC";
	String deepDive = "Deep-dive (Server)";
	String endUserExperience = "End user response time";
	String lbl_Normal = "NORMAL";
	String lbl_milliseconds = "ms";
	String lbl_Web = "Web";
	String lbl_Thread = "Thread";
	String lbl_Total_Execution_Time = "Total Execution Time";
	String frontEnd = "Front End";
	String network = "Network";
	String backEnd = "Back End";
	String lbl_txnProcessingTime = "Transaction Processing Time";

	// Json Data
	String lbl_skin = "skin";
	String lbl_paper = "paper";
	String lbl_title = "title";
	String lbl_compName = "componentName";
	String lbl_compThreshold = "compThreshold";
	String lbl_slowThreshold = "slowThreshold";
	String lbl_stalledThreshold = "stalledThreshold";
	String lbl_nodeText = "nodeText";
	String lbl_nodeValue = "nodeValue";
	String lbl_nodeTime = "nodeTime";
	String lbl_nodePercent = "nodePercent";
	String lbl_isAsync = "isAsync";
	String lbl_asyncValue = "asyncValue";
	String lbl_asyncTime = "asyncTime";
	String lbl_None = "None";
	String lbl_lineValue = "lineValue";
	String lbl_callCounter = "callCounter";
	String lbl_asynclineTime = "asynclineTime";
	String lbl_lineExperience = "lineExperience";
	String lbl_drillDownLink = "drillDownLink";
	String lbl_drillDownUrlToGo = "drillDownUrl";
	String lbl_drillDownGuid = "guid";
	String lbl_drillDownNodeOrder = "nodeOrder";
	String lbl_drillDownImg = "drillDownImg";
	String lbl_lineCall = "lineCall";
	String lbl_lineTime = "lineTime";
	String lbl_linePercent = "linePercent";
	String lbl_arrow = "arrow";
	String lbl_source = "source";
	String lbl_target = "target";
	String lbl_nodeExperience = "nodeExperience";
	String lbl_displayName = "displayName";
	String lbl_isStartJvm = "isStartJvm";
	String lbl_serverType = "serverType";
	String lbl_User = "User";
	String lbl_Experience = "Experience";
	String lbl_Type = "Type";
	String lbl_Component = "Component";
	String lbl_Diagnosis = "Diagnosis";
	String lbl_blocks = "blocks";
	String lbl_nodes = "nodes";
	String lbl_links = "links";
	String lbl_byServer = "byServer";
	String lbl_byTier = "byTier";
	String lbl_userTooltip = "userTooltip";
	String lbl_headerDetails = "headerDetails";
	String lbl_userNode = "USER";
	String lbl_stringTrue = "true";
	String lbl_stringFalse = "false";
	String lbl_Others = "USER";
	String lbl_NoneLc = "none";
	String lbl_tabRUM = "tabRUM";
	String lbl_tabBTM = "tabBTM";
	String lbl_tabName = "tabName";
	String lbl_transactionExperience = "transactionExperience";
	String lbl_tabData = "tabData";
	String lbl_disabled = "disabled";
	String lbl_headerText = "headerText";
	String lbl_device = "device";
	String lbl_browser = "browser";
	String lbl_location = "location";
	String lbl_requestTime = "requestTime";
	String lbl_isDataPresent = "isDataPresent";
	String lbl_userDevice = "userDevice";
	String lbl_blockChart = "blockChart";
	String lbl_nodeChart = "nodechart";
	String lbl_isPartialTopology = "isPartialTopology";
	String lbl_incompleteDataText = "incompleteDataText";
	String lbl_parentNode = "parentNode";
	String lbl_highlight = "highlight";
	String lbl_activeNode = "activeNode";
	String lbl_txnSnapshotToShow = "txnSnapshotToShow";
	String lbl_User_Name = "UserName";

	String clrJava = "#b15530";
	String clrDb = "#43896a";
	String clrExternalCall = "#204c51";
	
	String imgJavaServers = "JAVAAPP_SERVERS";

	String seperatorHyphen = "-";
	String seperatorTilt = "~";

	public boolean isParentNodeJms(String nodeOrder)
	{
		boolean res = false ; 
		if(nodeOrder.lastIndexOf("[") > -1){
			res = true;
		}
		return res ; 
	}

	public void updateStatusCodeTable(String statusCode,String connString , Hashtable httpUrlStatusCodeTable)
	{
		int status_code = 0;
		try
		{
			status_code = Integer.parseInt(statusCode);
			if(status_code >=400)
			{
				Integer code = (Integer)httpUrlStatusCodeTable.get("status_code");
				if(code!=null)
				{
					if(status_code > code)
					{
						httpUrlStatusCodeTable.put("status_code",status_code);
					}
				}else
				{
					httpUrlStatusCodeTable.put("status_code",status_code);
				}
			}
		}catch(Exception e)
		{
			System.out.println("Exception occured while parsing the URL status code ... ");
		}
		if(httpUrlStatusCodeTable.containsKey(connString))
		{
			String tmpStatus =(String)httpUrlStatusCodeTable.get(connString);

			if(tmpStatus.equals("-"))
			{
				String user_exp = BTMHelper.getLineExpInfo(status_code);
				httpUrlStatusCodeTable.put(connString, user_exp);
			}
		}else
		{
			String user_exp = BTMHelper.getLineExpInfo(status_code);
			httpUrlStatusCodeTable.put(connString, user_exp);
		}
	}

	public String getLineExperience(long slowUrlThresh,long stalledUrlThresh,long time)
	{
		String valueToBeReturned = USER_EXPERIENCE_HEALTHY ; 
		if(slowUrlThresh == -1L && stalledUrlThresh == -1L){
			valueToBeReturned = USER_EXPERIENCE_HEALTHY ;
		}
		else if (stalledUrlThresh == -1L){
				if(time >= slowUrlThresh){
					valueToBeReturned = USER_EXPERIENCE_SLOW ; 
				}
		}
		else{
			if(time >= stalledUrlThresh)
			{
				valueToBeReturned = USER_EXPERIENCE_STALLED ; 
			}
			else if(time >= slowUrlThresh)
			{
				valueToBeReturned = USER_EXPERIENCE_SLOW ; 
			}
		}
		return valueToBeReturned;
	}

	private String getDBString(String dbServerType, ArrayList RACIpPortList , String extHost , String dbName , String allColumns,EgDiscInfo discInfo)
	{
		String result = null;
		ArrayList dbServerList = discInfo.getAllEntries(dbServerType);
		if(dbServerList != null || dbServerList.size() > 0)
		{
			for(int i=0;i<RACIpPortList.size();i++){
				String racIpString = (String) RACIpPortList.get(i);
				int colon_index = racIpString.lastIndexOf(":");
				if(colon_index > 0){
					String racIp = racIpString.substring(0 , colon_index);
					String racPort = racIpString.substring(colon_index+1);
					result = getDBManagedComp(dbServerType,racIp,racPort,dbName,dbServerList);
					if(result!=null){
						return BTMHelper.decodeUrlString(result);
					}
				}
			}
		}
		if(allColumns!=null && allColumns.length() > 0)
		{
			ArrayList allColumnList = StringUtils.egTokenizer(allColumns,",");
			if(allColumnList!=null && allColumnList.size() > 0 )
			{
				for(int j = 0 ; j < allColumnList.size() ; j++)
				{
					String serverType = (String)allColumnList.get(j);
					for(int i=0;i<RACIpPortList.size();i++){
						String racIpString = (String) RACIpPortList.get(i);
						int colon_index = racIpString.lastIndexOf(":");
						if(colon_index > 0){
							String racIp = racIpString.substring(0 , colon_index);
							String racPort = racIpString.substring(colon_index+1);
							dbServerList = discInfo.getAllEntries(serverType);
							if(dbServerList != null || dbServerList.size() > 0)
							{
		
								result = getDBManagedComp(serverType,racIp,racPort,dbName,dbServerList);
								if(result!=null)
								{
									return BTMHelper.decodeUrlString(result);
								}
							}
						}
					}
				}
			}
		}
		
		if(result == null)
			result = "DATABASECALL-"+dbServerType + "*"+extHost;
		return result;
	}


	public Hashtable prepareParentChildNodes(ArrayList nodeIdList,Hashtable conNodeTable)
	{
		Hashtable mainTable = new Hashtable();
		Hashtable parentChildNodeTable = new Hashtable();
		Hashtable parentChildMappingTable  = new Hashtable();
		int minHttpNodeLength = 0 ; 
		for(int i = 0 ; i < nodeIdList.size() ; i++)
		{
			String nodeIds = (String)nodeIdList.get(i);
			if(nodeIds.lastIndexOf(".") > -1)
			{
				int len  =  nodeIds.lastIndexOf(".") ; 
				if(minHttpNodeLength==0 || minHttpNodeLength>len)
				{
					minHttpNodeLength = len ; 
				}
			}
		}
		for(int i = 0 ; i < nodeIdList.size() ; i++)
		{
			String nodeId  = (String)nodeIdList.get(i);
			String childNodeId = null ; 
			boolean calculateHttpTime = true ; 
			boolean start = true ; 
			if(nodeId.lastIndexOf(".") > -1 )
			{
				 childNodeId = nodeId.substring(0,nodeId.lastIndexOf("."));
			}
			if(nodeIdList!=null && childNodeId!=null)
			{
				if( nodeIdList.contains(childNodeId))
				{
					calculateHttpTime = false ; 
				}else
				{
					int nidLength = childNodeId.lastIndexOf(".") ; 
					
					if(nidLength >  minHttpNodeLength)
					{
						while(start)
						{
							if(childNodeId.lastIndexOf(".") > -1 )
							{
								 childNodeId = childNodeId.substring(0,childNodeId.lastIndexOf("."));
								 if(nodeIdList.contains(childNodeId))
								{
									 calculateHttpTime = false ; 
									 start = false ; 
								}
								nidLength = childNodeId.lastIndexOf(".") ;
								if(nidLength < minHttpNodeLength)
								{
									start = false ; 
								}
							}else
							{
								 start = false ;
							}
						}
					}
				}
			}
			if(!calculateHttpTime)
			{
				if(nodeId!=null && !nodeId.equals("-"))
				{
					String key = (String)conNodeTable.get(childNodeId);
					if(parentChildMappingTable.containsKey(key))
					{
						ArrayList childList = (ArrayList)parentChildMappingTable.get(key);
						String value = (String)conNodeTable.get(nodeId);
						if(key!=null && !key.equals(value)  )
						{
							if(!childList.contains(value))
								childList.add(value);
							parentChildMappingTable.put(key,childList);
						}

					}else
					{
						ArrayList childList = new ArrayList();
						String value = (String)conNodeTable.get(nodeId);
						if(!key.equals(value))
						{
							childList.add(value);
							parentChildMappingTable.put(key,childList);
						}
						
					}
				}
			}
			parentChildNodeTable.put(nodeId,calculateHttpTime);
		}

		mainTable.put("parentChildMappingTable",parentChildMappingTable);
		mainTable.put("parentChildNodeTable",parentChildNodeTable);
		return mainTable;
	}

	public  String getUnKnownDetails(Hashtable guidNodeHostTable,String egGuid,String connectedNodeOrder,EgDiscInfo discInfo)
	{
		String result = null ; //methodType+"-"+extSchema+""+extHost+":"+extPort;
		if(connectedNodeOrder != null && connectedNodeOrder.length()>0)
		{
			if(!connectedNodeOrder.equals("-"))
			{
				if(guidNodeHostTable != null)
				{
					if(guidNodeHostTable.containsKey(egGuid+"#"+connectedNodeOrder))
					{
						ArrayList temp = (ArrayList)guidNodeHostTable.get(egGuid+"#"+connectedNodeOrder);
						if(temp!=null && temp.size() >= 2 )
						{
							String compName = (String) temp.get(0);
							String port = (String) temp.get(1);
							String compType = (String) discInfo.getServerTypesForComponentNamePort(compName+":"+port);
							result = compType+"_M:"+compName+":"+port+"#";
						}
					}
				}
			}
		}
		return result ; 
	}

	public int getTargetForUnknownNode(ArrayList webOrderList , String nodeOrder , String drilldownGuid, Hashtable topologyBuildSource , Hashtable connMapNickToOrder , Hashtable guidNodeHostTable){
		int target = -1;
		if(webOrderList == null || webOrderList.size()  == 0){
			return target;
		}

		boolean foundNxtNode = false;
		try
		{
			for (int n=0;n<webOrderList.size()-1;n++){
				String webNodeOrder = (String) webOrderList.get(n);
				if(webNodeOrder.equals(nodeOrder)){
					// get the next Node Order , this unKnownNode might be connected with that.
					String nextNodeOrder = (String) webOrderList.get(n+1);
					//System.out.println(" [Found] -  nextNodeOrder :"+nextNodeOrder);
					String nxtTrgtString = drilldownGuid+"#"+nextNodeOrder;
					ArrayList nextNodeTargetList = (ArrayList) guidNodeHostTable.get(nxtTrgtString);
					//System.out.println(" nextNodeTargetList :"+nextNodeTargetList);
					if(nextNodeTargetList!=null && nextNodeTargetList.size() == 2){
						StringBuilder builder = new StringBuilder();
						builder.append(nextNodeTargetList.get(0).toString());
						builder.append(":");
						builder.append(nextNodeTargetList.get(1).toString());
						String nxtNodeString = builder.toString();
						//System.out.println(" nxtNodeString :"+nxtNodeString);
						// Next node order
						ArrayList nxtNodeRequestDetails = (ArrayList) topologyBuildSource.get(nxtNodeString);
						if(nxtNodeRequestDetails == null || nxtNodeRequestDetails.size() == 0){
							continue;
						}
						//System.out.println(" nxtNodeRequestDetails.size() :"+nxtNodeRequestDetails.size());
						for(int r=0;r<nxtNodeRequestDetails.size();r++){
							HashMap nxtJvmDetails = (HashMap) nxtNodeRequestDetails.get(r);
							if(nxtJvmDetails!=null && nxtJvmDetails.containsValue(nextNodeOrder)){
								//Is the NextNode JMS-Entry?
								String jmsEntryStringValue = (String)nxtJvmDetails.get("isJmsEntry");
								if(jmsEntryStringValue!=null && jmsEntryStringValue.equals("true")){
									HashMap jmsEntryMap = (HashMap) nxtJvmDetails.get("JMS_Entry_Queues");
									if(jmsEntryMap == null || jmsEntryMap.size() == 0){
										continue;
									}
									Set jmsEntryKeys = jmsEntryMap.keySet();
									Iterator jmsItr = jmsEntryKeys.iterator();
									while(jmsItr.hasNext()){
										String jmsKey = (String) jmsItr.next();
										Object targetObj = connMapNickToOrder.get(jmsKey);
										if(targetObj == null){
											continue;
										}
										target = (Integer) targetObj;
										foundNxtNode = true;
										break;
									}
								}
								else{
									target = (Integer)connMapNickToOrder.get(nxtNodeString);
									foundNxtNode = true;
									break;
								}
							}
						}
					}
				}
				if(foundNxtNode){
					break;
				}
			}
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return target;
	}

	public String getRenamedDisplayName(String key, String testName)
	{
		String otherPointCut = key.substring(0,key.indexOf(':'));
		boolean isOtherPointCut = apm.isPointCutInIni(testName,otherPointCut);

		if(key != null && key.length()>0)
		{
			if(key.startsWith("DATABASECALL-"))
			{
				if(key.indexOf("*")>-1)
				{
					key = key.substring(key.indexOf(":")+1);
					if(key.indexOf("_")>-1)
						key = key.substring(key.indexOf("_")+1);
				}
			}
			else if(key.startsWith("HTTP-") || key.startsWith("WEBSERVICE-"))
			{
				key = key.substring(key.indexOf("-")+1);
			}
			else if(key.indexOf("queue:")>-1 || key.indexOf("topic:")>-1)
			{
				key = key.substring(key.lastIndexOf("/")+1);
			}
			else if(key.startsWith("Custom_") )
			{
				key = key.substring(key.indexOf(":")+1);
			}
			else if(key.startsWith("EJB") )
			{
				key = key.substring(key.indexOf(":")+1);
			}
			else if (isOtherPointCut)
			{
				key = key.substring(key.indexOf(":")+1);
			}
			else 
			{
				if(key.indexOf("_M:")>-1)
					key = key.substring(key.indexOf("_M:")+3);
			}
		}
		return key;
	}

	public String getParentFromThreadNodeOrder(String nodeOrder)
	{
		String parentNode = nodeOrder;
		if(nodeOrder != null && nodeOrder.indexOf(".A")>-1)
		{
			nodeOrder = nodeOrder.substring(0,nodeOrder.lastIndexOf("."));
			if(nodeOrder.endsWith(".A"))
				parentNode = nodeOrder.substring(0, nodeOrder.lastIndexOf(".A"));
		}
		return parentNode;
	}

	public boolean isParentThreadRequestType(String nodeOrder)
	{
		boolean result = false;
		String parentNode;
		if(nodeOrder != null && nodeOrder.indexOf(".1")>-1)
		{
			if(nodeOrder.endsWith(".A.1"))
				parentNode = nodeOrder.substring(0, nodeOrder.lastIndexOf(".A.1"));
			else
				parentNode = nodeOrder.substring(0, nodeOrder.lastIndexOf(".1"));

			result = isThreadRequestType(parentNode);
		}
		return result;
	}

	public boolean isThreadRequestType(String nodeOrder)
	{
		boolean result = false;
		if(nodeOrder != null && nodeOrder.indexOf(".A")>-1)
		{ 
			String temp = nodeOrder.substring(0,nodeOrder.lastIndexOf("."));
			if(temp.endsWith(".A"))
				result = true;
		}
		return result;
	}
	
	public String compareExperience(String previousState,String currentState)
	{
		int state1 = 0;
		int state2 = 0;
		if(previousState.equalsIgnoreCase(USER_EXPERIENCE_ERROR))
			state1 = 20;
		else if(previousState.equalsIgnoreCase(USER_EXPERIENCE_STALLED))
			state1 = 15;
		else if(previousState.equalsIgnoreCase(USER_EXPERIENCE_SLOW))
			state1 = 10;
		else if(previousState.equalsIgnoreCase(USER_EXPERIENCE_HEALTHY))
			state1 = 5;
		
		if(currentState.equalsIgnoreCase(USER_EXPERIENCE_ERROR))
			state2 = 20;
		if(currentState.equalsIgnoreCase(USER_EXPERIENCE_STALLED))
			state2 = 15;
		else if(currentState.equalsIgnoreCase(USER_EXPERIENCE_SLOW))
			state2 = 10;
		else if(currentState.equalsIgnoreCase(USER_EXPERIENCE_HEALTHY))
			state2 = 5;

		int result = 0;
		if(state1>state2)
			result = state1;
		else
			result = state2;

		if(result == 20)
			return USER_EXPERIENCE_ERROR;
		else if(result == 15)
			return USER_EXPERIENCE_STALLED;
		else if(result == 10)
			return USER_EXPERIENCE_SLOW;
		else if(result == 5)
			return USER_EXPERIENCE_HEALTHY;

		return USER_EXPERIENCE_ERROR;
	}

	// Check whether the managed component is database component or not
	public boolean isDbManagedComponent(String type)
	{
		boolean isDBComp = false;
		String categoryType= egCompCategory.getCategoryforCompType(type);
		if(categoryType.equalsIgnoreCase("DATABASE_SERVERS"))
			isDBComp = true;

		return isDBComp;
	}

	// Tooltip chart data preparation for Java, Database Queries and External calls
	public ArrayList dataByBlock(Hashtable nodeDataHolder, String monSkin)
	{
		String[] blockClrListLight = {"#3c8869","#1b4b51", "#b5582c", "#afc8e9","#fc7e00","#b276b2","#81bef7", "#115fa6", "#a61120","#ffd13e", "#770d72","#887c65", "#f25454", "#60bd68","#a4ac91"};
		String[] blockClrListDark = {"#9ae9b3","#f5c372", "#27afa7", "#fc7e00","#b276b2","#afc8e9","#81bef7", "#115fa6", "#a61120","#ffd13e", "#770d72","#887c65", "#f25454", "#60bd68","#a4ac91"};

		ArrayList tempArray = new ArrayList();
		JSONObject tmpObj = new JSONObject();
		JSONObject tmpObj2 = new JSONObject();
		if(nodeDataHolder != null && nodeDataHolder.size()>0)
		{
			Set keySet = nodeDataHolder.keySet();
			Iterator it = keySet.iterator();
			int count = 0;
			while(it.hasNext())
			{
				String key = (String) it.next();
				if(count >= (blockClrListLight.length-1))
					count = 0;

				tmpObj.put("name",key);
				if(monSkin.equals("Dark"))
					tmpObj.put("color",blockClrListDark[count]);
				else
					tmpObj.put("color",blockClrListLight[count]);
				
				tmpObj.put("y",nodeDataHolder.get(key));
				tmpObj2.put("enabled",true);
				tmpObj2.put("formatter","function(){return ((this.point.percentage > 0.9 ? Highcharts.numberFormat(this.point.percentage, 0) + \" % \" : null) );}");
				tmpObj.put("dataLabels",tmpObj2);
				tempArray.add(tmpObj);
				tmpObj = new JSONObject();
				count++;
			}
		}
		return tempArray;
	}

	// Tooltip chart data preparation for all btm enabled nodes.
	public ArrayList dataByNodes(Hashtable nodeDataHolder, String monSkin)
	{
		String[] nodeClrListLight = {"#fdba74","#926ac0", "#2479b6", "#afc8e9","#fc7e00","#60bd68","#b276b2", "#81bef7", "#a61120","#ffd13e", "#770d72","#887c65", "#a4ac91", "#f25454","#115fa6"};
		String[] nodeClrListDark = {"#d6b57e","#98d980", "#8399b0", "#b1b9a0","#c4b3d0","#115fa6","#a4ac91", "#b276b2", "#81bef7","#a61120", "#ffd13e","#770d72", "#887c65", "#f25454","#60bd68"};

		ArrayList tempArray = new ArrayList();
		JSONObject tmpObj = new JSONObject();
		JSONObject tmpObj2 = new JSONObject();
		if(nodeDataHolder != null && nodeDataHolder.size()>0)
		{
			Set keySet = nodeDataHolder.keySet();
			Iterator it = keySet.iterator();
			int count = 0;
			while(it.hasNext())
			{
				if(count >= (nodeClrListLight.length-1))
					count = 0;

				String key = (String) it.next();
				tmpObj.put("name",key);
				if(monSkin.equals("Dark"))
					tmpObj.put("color",nodeClrListDark[count]);
				else
					tmpObj.put("color",nodeClrListLight[count]);
				tmpObj.put("y",nodeDataHolder.get(key));
				tmpObj2.put("enabled",true);
				tmpObj2.put("formatter","function(){return ((this.point.percentage > 0.9 ? Highcharts.numberFormat(this.point.percentage, 0) + \" % \" : null) );}");
				tmpObj.put("dataLabels",tmpObj2);
				tempArray.add(tmpObj);
				tmpObj = new JSONObject();
				count++;
			}
		}
		return tempArray;
	}

	// Chart Json Data preparation for user experience tooltip
	public JSONObject nodeDataChartJsonBuild(String monSkin, Hashtable nodeDataHolder, String chartType)
	{
		JSONObject rootJson = new JSONObject();

		JSONObject tmpObj = new JSONObject();
		JSONObject tmpObj2 = new JSONObject();
		JSONObject tmpObj3 = new JSONObject();
		JSONObject tmpObj4 = new JSONObject();
		JSONObject tmpObj5 = new JSONObject();
		ArrayList tempArray = new ArrayList();
		ArrayList tempArray2 = new ArrayList();
		
		tmpObj.put("backgroundColor","transparent");
		tmpObj.put("plotBorderWidth",null);
		tmpObj.put("plotShadow",false);
		
		tmpObj2.put("load","function () {this.legend.allItems.legendGroup.attr({ translateX: 100});}");
		rootJson.put("chart",tmpObj);
		tmpObj = new JSONObject();
		tmpObj2 = new JSONObject();
		tempArray = new ArrayList();

		tmpObj.put("formatter","function(){return (this.point.name.length>26?this.point.name.slice(0, 26)+'.. ':this.point.name) + \": <b>\" + this.y + \" ms </b>(\" + Highcharts.numberFormat(this.percentage, 2) + \" %) \";}");
		rootJson.put("tooltip",tmpObj);
		tmpObj = new JSONObject();

		tmpObj2.put("fontSize","10px");
		tmpObj2.put("fontWeight","none");
		if(monSkin.equals("Dark"))
			tmpObj2.put("color","#dcdbdb");
		tmpObj2.put("font","LucidaGrandeRegular !important");
		tmpObj3.put("enabled",true);
		tmpObj3.put("distance",5);
		tmpObj3.put("connectorWidth",1);
		tmpObj3.put("style",tmpObj2);
		tmpObj4.put("dataLabels",tmpObj3);
		tmpObj2 = new JSONObject();
		tmpObj3 = new JSONObject();
		tmpObj2.put("legendItemClick","function(){this.select();chart.tooltip.refresh(this); return false;}");
		tmpObj3.put("events",tmpObj2);
		tmpObj4.put("point",tmpObj3);
		tmpObj4.put("startAngle",0);
		tmpObj4.put("endAngle",360);
		tmpObj4.put("minSize",160);
		if(monSkin.equals("Dark"))
			tmpObj4.put("borderColor","#636363");
		tmpObj5.put("pie",tmpObj4);
		rootJson.put("plotOptions",tmpObj5);
		tmpObj = new JSONObject();
		tmpObj2 = new JSONObject();
		tmpObj3 = new JSONObject();
		tmpObj4 = new JSONObject();
		tmpObj5 = new JSONObject();

		if(nodeDataHolder != null && nodeDataHolder.size() > 0)
		{
			tmpObj.put("type","pie");
			tmpObj.put("name","Execution Time");
			tmpObj.put("innerSize","58%");
			tmpObj.put("showInLegend",true); 
			tmpObj.put("allowPointSelect",false);
			tmpObj.put("cursor","pointer");
			
			if(chartType != null && chartType.equalsIgnoreCase(lbl_blockChart))
				tempArray = dataByBlock(nodeDataHolder,monSkin);
			else if(chartType.equalsIgnoreCase(lbl_nodeChart))
				tempArray = dataByNodes(nodeDataHolder,monSkin);

			tmpObj.put("data",tempArray);
			tempArray2.add(tmpObj);

			rootJson.put("series",tempArray2);
			tmpObj = new JSONObject();
			tmpObj2 = new JSONObject();
			tmpObj3 = new JSONObject();
			tmpObj4 = new JSONObject();
			tempArray = new ArrayList();

			tmpObj.put("enabled",false);
			rootJson.put("exporting",tmpObj);
			rootJson.put("credits",tmpObj);
			tmpObj = new JSONObject();

			tmpObj.put("text","");
			rootJson.put("title",tmpObj);
			tmpObj = new JSONObject();

			tmpObj.put("align","right");
			tmpObj.put("layout","vertical");
			tmpObj.put("borderWidth",0);
			tmpObj.put("x",0);

			tmpObj.put("itemWidth",115);
			tmpObj.put("maxHeight","100%");
			//tmpObj.put("itemDistance",10);
			tmpObj.put("itemMarginTop",4);
			tmpObj.put("itemMarginBottom",4);
			tmpObj.put("verticalAlign","middle");
			tmpObj.put("symbolHeight",8);
			tmpObj.put("symbolWidth",8);
			tmpObj.put("symbolRadius",8); 
			tmpObj.put("symbolPadding",10); 
			tmpObj2.put("fontSize","10px");
			tmpObj2.put("fontWeight","none");
			if(monSkin.equalsIgnoreCase("Dark"))
			{
				tmpObj2.put("color","#dcdbdb");
				tmpObj.put("itemHoverStyle",tmpObj2);
			}
			tmpObj2.put("font","LucidaGrandeRegular !important");
			
			tmpObj.put("itemStyle",tmpObj2);
			tmpObj.put("labelFormatter","function() { return this.name.length>16?this.name.slice(0, 16)+'..':this.name}");
			rootJson.put("legend",tmpObj);
			tmpObj = new JSONObject();
			tmpObj2 = new JSONObject();
		}
		return rootJson;
	}

	// Rum Main Data Prepaaration by executing query are doing here
	public Hashtable getRumMeasures(String rumQuery) 
	{ 
		ResultSet rs = null;
		Hashtable resultRumList = new Hashtable();
		EgDbAdapterUI egDb = EgDbAdapterTypeUI.getObject();
		try
		{
			String s_status = egDb.setConnection();
			if(s_status.equals("CONNECTED")){
				rs = egDb.dbselect(rumQuery);
			}
			ResultSetMetaData metaData = rs.getMetaData();
			int noOfColumns = metaData.getColumnCount();
			while(rs.next()){
				for (int i = 1; i <=noOfColumns ; i++ ) 
				{
					String columnName = metaData.getColumnName(i);
					resultRumList.put(columnName,rs.getString(i));
				}
			}
		}
		catch (Exception e){
		e.printStackTrace();
		}
		finally{
			egDb.releaseConnection(false);
			EgDbAdapterTypeUI.releaseObject(egDb);
		}
		return resultRumList;
	}

	// RUM Json Data Preparation
	public JSONObject userRumJsonBuild(Hashtable rumDataTable)
	{
		JSONObject rumJsonData = new JSONObject();
		if(rumDataTable != null && rumDataTable.size() > 0)
		{
			JSONObject userexpTooltipRUMDatas = new JSONObject();
			rumJsonData.put(lbl_isDataPresent,"Yes");
			rumJsonData.put(lbl_tabName,endUserExperience);
			String rumUserExperience = (String) rumDataTable.get("RUM_USER_EXP");
			rumJsonData.put(lbl_transactionExperience, rumUserExperience.toUpperCase());

			double pageLoadTime = 0.0;
			double frontEndTime = 0.0;
			double serverConnectionTime = 0.0;
			double responseAvailableTime = 0.0;
			double slowUrlThreshold = 0.0;
			try
			{
				pageLoadTime = Double.parseDouble((String)rumDataTable.get("PAGE_LOAD_TIME"));
				frontEndTime = Double.parseDouble((String)rumDataTable.get("FRONT_END_TIME"));
				serverConnectionTime = Double.parseDouble((String)rumDataTable.get("SERVER_CONNECTION_TIME"));
				responseAvailableTime = Double.parseDouble((String)rumDataTable.get("RESPONSE_AVAILABLE_TIME"));
				slowUrlThreshold = Double.parseDouble((String)rumDataTable.get("SLOW_URL_THRESHOLD"));
			}
			catch(Exception e)
			{
				System.err.println("Exception in eGBTMd3Topology.jsp : "+e.getMessage());
				//e.printStackTrace();
			}

			userexpTooltipRUMDatas.put(lbl_txnProcessingTime,scaleDecimalFormat.format(pageLoadTime)+" "+lbl_milliseconds);
			userexpTooltipRUMDatas.put(frontEnd, scaleDecimalFormat.format(frontEndTime)+" "+lbl_milliseconds);
			userexpTooltipRUMDatas.put(network, scaleDecimalFormat.format(serverConnectionTime)+" "+lbl_milliseconds);
			userexpTooltipRUMDatas.put(backEnd, scaleDecimalFormat.format(responseAvailableTime)+" "+lbl_milliseconds);
			String device = (String) rumDataTable.get("DEVICE");
			userexpTooltipRUMDatas.put(lbl_device, device);
			userexpTooltipRUMDatas.put(lbl_browser, (String) rumDataTable.get("BROWSER"));
			userexpTooltipRUMDatas.put(lbl_requestTime, (String) rumDataTable.get("REQUEST_DATE")+" "+(String) rumDataTable.get("REQUEST_TIME_ZONE"));
			userexpTooltipRUMDatas.put(lbl_slowThreshold, scaleDecimalFormat.format(slowUrlThreshold)+" "+lbl_milliseconds);

			// code starts - Location string for RUM 
			String city = (String) rumDataTable.get("CITY");
			String region = (String) rumDataTable.get("REGION");
			String country = (String) rumDataTable.get("COUNTRY");
			StringBuffer sbf = new StringBuffer();
			if(city != null && region != null && country != null)
			{
				if(city.equals("Unknown") && region.equals("Unknown") && region.equals("Unknown"))
				{
					sbf.append("Unknown");
				}
				else
				{
					if(!city.equals("Unknown"))
						sbf.append(city).append(",");

					if(!region.equals("Unknown"))
						sbf.append(region).append(",");

					if(!country.equals("Unknown"))
						sbf.append(country).append(",");
				}
			}
			String location = sbf.toString();
			if(location != null && location.endsWith(","))
				location = location.substring(0,location.lastIndexOf(","));

			userexpTooltipRUMDatas.put(lbl_location, location);
			// code ends - Location string for RUM 

			rumJsonData.put(lbl_tabData,userexpTooltipRUMDatas);

			//userexpTooltipDatas.put(lbl_tabRUM, rumJsonData);
		}
		else{
			rumJsonData.put(lbl_tabName,endUserExperience);
			rumJsonData.put(lbl_transactionExperience,lbl_None);
			rumJsonData.put(lbl_isDataPresent,"No");
			//userexpTooltipDatas.put(lbl_tabRUM, rumJsonData);
		}
		return rumJsonData;
	}

	// BTM Json Data Preparation
	public JSONObject topologyDagreJsonBuild(String monSkin, Hashtable topologyBuildSource, Hashtable connMapOrderToNick, Hashtable connMapNickToOrder, Double responseTime, String overAllExperience, String timeString, EgMappingInfo mappingInfo, Hashtable rumDataTable, String requestUrl, String apmType, String testName, Hashtable webTempCallCount,Hashtable httpUrlStatusCodeTable,Set jmsConList,String userName, ArrayList webOrderList , Hashtable guidNodeHostTable)
	{
		String headerMessageHealthy = mappingInfo.getTextDescription("monitor.apmtopology.headerMessageHealthy");
		String lbl_Database_Queries =  mappingInfo.getTextDescription("monitor.apmtopology.plural.SQL");
		String lbl_External_Calls = mappingInfo.getTextDescription("monitor.apmtopology.plural.RemoteService");
		String lbl_Java = mappingInfo.getTextDescription("monitor.apmtopology."+apmType+"");
		String lbl_User_Experience= mappingInfo.getTextDescription("monitor.apmtopology.User Experience");
		String lbl_Execution_Time= mappingInfo.getTextDescription("monitor.apmtopology.Execution Time");
		String lbl_Error_Segment = mappingInfo.getTextDescription("monitor.apmtopology.Error Segment");
		String lbl_Stalled_Segment = mappingInfo.getTextDescription("monitor.apmtopology.Stalled Segment");
		String lbl_Slow_Segment = mappingInfo.getTextDescription("monitor.apmtopology.Slow Segment");
		String lbl_Healthy_Segment = mappingInfo.getTextDescription("monitor.apmtopology.Healthy Segment");
		String incompleteDataText = mappingInfo.getTextDescription("monitor.apmtopology.Incomplete Data");
		String lbl_Code = mappingInfo.getTextDescription("monitor.apmtopology.Code");
		String entireFlowText = mappingInfo.getTextDescription("monitor.apmtopology.Topology above represents the complete request flow");

		Hashtable compAdded = new Hashtable();
		Hashtable nodeDataHolder = new Hashtable();
		Hashtable blockDataHolder = new Hashtable();
		Hashtable overallMsg = new Hashtable();

		/*System.out.println("[topologyDagreJsonBuild] - topologyBuildSource :"+topologyBuildSource);
		System.out.println("[topologyDagreJsonBuild] - connMapOrderToNick  :"+connMapOrderToNick);
		System.out.println("[topologyDagreJsonBuild] - connMapNickToOrder  :"+connMapNickToOrder);
		System.out.println("[topologyDagreJsonBuild] - responseTime        :"+responseTime);
		System.out.println("[topologyDagreJsonBuild] - overAllExperience   :"+overAllExperience);
		System.out.println("[topologyDagreJsonBuild] - timeString          :"+timeString);
		System.out.println("[topologyDagreJsonBuild] - rumDataTable        :"+rumDataTable);
		System.out.println("[topologyDagreJsonBuild] - requestUrl          :"+requestUrl);
		System.out.println("[topologyDagreJsonBuild] - apmType             :"+apmType);
		System.out.println("[topologyDagreJsonBuild] - testName            :"+testName);
		System.out.println("[topologyDagreJsonBuild] - webTempCallCount    :"+webTempCallCount);
		System.out.println("[topologyDagreJsonBuild] - httpUrlStatusCodeTable  :"+httpUrlStatusCodeTable);
		System.out.println("[topologyDagreJsonBuild] - jmsConList          :"+jmsConList);
		System.out.println("[topologyDagreJsonBuild] - userName            :"+userName);*/
		
		timeString = StringUtils.encodeSecurityChar(timeString); 
		/*
			TimeString contains special symbol . Tomcat rejects the special symbols in query param So we have to encode the value to provide in query string 
		*/
		timeString = BTMHelper.getEncodedURI(timeString);
		ArrayList technologiesInvolved = new ArrayList();

		JSONObject rootJson = new JSONObject();
		JSONObject jsonHolder = new JSONObject();
		JSONObject tabBTMData = new JSONObject();
		JSONObject paperDataObj = new JSONObject();
		JSONObject userexpTooltipDatas = new JSONObject();
		JSONObject userexpTooltipBTMDatas = new JSONObject();
		JSONObject blockDataObj = new JSONObject();
		JSONObject totalHeaderDataObj = new JSONObject();
		JSONObject headerSegmentObj = new JSONObject();
		JSONObject tmpNodeObj = new JSONObject();

		JSONArray nodeDatas = new JSONArray();
		JSONArray headerBlockData = new JSONArray();
		JSONArray totalHeaderDataArr = new JSONArray();
		JSONArray linkDatas = new JSONArray();
		//JSONArray userToolTipData = new JSONArray();
		Hashtable connectionDetailsHolder = new Hashtable();
		connectionDetailsHolder.put(0,0);
		connectionDetailsHolder.put(1,0);

		long javaTime = 0L;
		long dbTime = 0L;
		long externalCallsTime = 0L;
		long firstNodeSlowThreshold = 0L;
		long firstNodeStalledThreshold = 0L;
		boolean overallAsyncPresence = false;
		String strOtherPointCutName = "";
		boolean isOtherPointCut = false;
		boolean overallUnknownNodePresence = false;
		boolean txnSnapshotToShow = false;
		boolean isNegativeTimedisclaimerToShow = false ; 


		paperDataObj.put(lbl_skin,monSkin);
		int charLen = apm. getMaxLength();
		paperDataObj.put("displayCount",charLen);
		rootJson.put(lbl_paper,paperDataObj);
		
		userexpTooltipBTMDatas.put(lbl_tabName,deepDive);
		userexpTooltipBTMDatas.put(lbl_transactionExperience,overAllExperience.toUpperCase());
		tabBTMData.put(lbl_txnProcessingTime,scaleDecimalFormat.format(responseTime)+" "+lbl_milliseconds);

		
		totalHeaderDataObj.put(lbl_User_Experience,overAllExperience);
		totalHeaderDataObj.put(lbl_Execution_Time,scaleDecimalFormat.format(responseTime)+" "+lbl_milliseconds);

		ArrayList targetHolder = new ArrayList();
		targetHolder.add(0);
		targetHolder.add(1);

		if(topologyBuildSource != null && topologyBuildSource.size()>0)
		{
			if(connMapOrderToNick != null && connMapOrderToNick.size()>0)
			{
				for(int i=0;i<connMapOrderToNick.size();i++)
				{
					long compInOutboundTime = 0L;
					String thisNode = (String) connMapOrderToNick.get(i);

					// For Managed node json data preparation
					if(topologyBuildSource.containsKey(thisNode))
					{
						JSONObject jvmDataObj = new JSONObject();

						JSONArray gridData = new JSONArray();
						JSONArray linegridData = new JSONArray();

						Hashtable cumLineTimeTable = new Hashtable();
						Hashtable cumLineDataTable = new Hashtable();
						Hashtable cumLineValueTable = new Hashtable();

						ArrayList lineModalWindowNodeDetails = new ArrayList();

						long cumulativeNodeTime = 0L;
						long cumulativeAsyncNodeTime = -1L;
						long cumulativeLineTime = 0L;
						long cumulativeAsyncLineTime = 0L;
						double cumulativeNodePercent = 0.0;
						double cumulativeLinePercent = 0.0;
						boolean modalWindowPresence = false;
						String cumNodeExperience = null;
						boolean cumHighlightResult = false;
						boolean isJmsEntryPresent = false ; 

						ArrayList multiRequestDetails = (ArrayList) topologyBuildSource.get(thisNode);
						int multiRequestDetailsSize = multiRequestDetails.size();
						if(multiRequestDetailsSize>1)
							modalWindowPresence = true;

						for(int m=0;m<multiRequestDetailsSize;m++)
						{
							JSONObject tmpNodeModalWindowObj = new JSONObject(); // IMW - Data for Node
							JSONObject tmpLineModalWindowObj = new JSONObject(); // IMW - Data for Line

							boolean isAsynchPresent = false;
							HashMap hmasyncLineValue = null;

							HashMap thisJvmDetails = (HashMap) multiRequestDetails.get(m);

							String compName = (String) thisJvmDetails.get(lbl_compName);
							String nodeOrder = (String) thisJvmDetails.get(lbl_drillDownNodeOrder);
							String parentNode = (String) thisJvmDetails.get(lbl_parentNode);
							String requestType = (String) thisJvmDetails.get("requestType");
							String drillDownImgState = (String) thisJvmDetails.get(lbl_drillDownImg);
							String jvmNodeDrillDownUrlToGo = (String) thisJvmDetails.get(lbl_drillDownUrlToGo);
							String startJvm = (String) thisJvmDetails.get(lbl_isStartJvm);
							String reqTime = (String) thisJvmDetails.get(lbl_requestTime);
							String drilldownGuid = (String) thisJvmDetails.get(lbl_drillDownGuid);
							String totalResponseTime = (String) thisJvmDetails.get("totalResponseTime");
							long slowurlThreshold = (Long) thisJvmDetails.get(lbl_compThreshold);
							long StalledTransactionTime = (Long) thisJvmDetails.get(lbl_stalledThreshold);
							ArrayList nodeValueList = (ArrayList) thisJvmDetails.get(lbl_nodeValue);
							String isAsynch = (String) thisJvmDetails.get(lbl_isAsync);
							String nodeType = (String) thisJvmDetails.get("nodeType");
							String toHighlight = (String) thisJvmDetails.get(lbl_highlight);
							String jmsEntryNode = (String) thisJvmDetails.get("isJmsEntry") ;
							boolean isAsyncTimeToShowForJMS = false;
							boolean jmsEntryNodeFlag = false;
							HashMap jmsEntryQueues = (HashMap) thisJvmDetails.get("JMS_Entry_Queues");
							if(jmsEntryNode!=null && jmsEntryNode.equals("true"))
							{
								isAsyncTimeToShowForJMS = (Boolean)thisJvmDetails.get("isAsyncTimeToShow");
								isJmsEntryPresent = true ; 

								if(!nodeOrder.equals("1"))
								{
									jmsEntryNodeFlag = true ; 
								}
							}
							else
							{
								jmsEntryNodeFlag = isParentNodeJms(nodeOrder);
							}
							// JSON Data PreParation - Start JVM - Starts

							if(startJvm.equals(lbl_stringTrue))
								jvmDataObj.put(lbl_isStartJvm, true);
							else
								jvmDataObj.put(lbl_isStartJvm, false);
							// JSON Data PreParation - Start JVM - Ends

							// JSON Data PreParation - Start JVM - Starts
							if(toHighlight.equals(lbl_stringTrue))
								cumHighlightResult = true;

							jvmDataObj.put(lbl_highlight, cumHighlightResult);
							// JSON Data PreParation - Start JVM - Starts

							boolean isThreadReq = false;
							if(requestType != null && requestType.equalsIgnoreCase("Thread"))
							{
								isThreadReq = true;
								tmpNodeModalWindowObj.put("Call_Type","Asynchronous");
								tmpLineModalWindowObj.put("Call_Type","Asynchronous");
							}else if(isAsyncTimeToShowForJMS){
								tmpNodeModalWindowObj.put("Call_Type","Asynchronous");
								tmpLineModalWindowObj.put("Call_Type","Asynchronous");
							}
							else
							{
								tmpNodeModalWindowObj.put("Call_Type","Synchronous");
								tmpLineModalWindowObj.put("Call_Type","Synchronous");
							}
							if(drillDownImgState != null)
							{
								tmpNodeModalWindowObj.put("User_Exp",drillDownImgState.toLowerCase());
								tmpLineModalWindowObj.put("User_Exp",drillDownImgState.toLowerCase());
							}

							//boolean isParentThreadReq = (boolean) isParentThreadRequestType(nodeOrder);

							boolean isThreadRoot = false;
							if(nodeOrder != null && nodeOrder.indexOf(".A")>-1)
								isThreadRoot = true;

							//if(compAdded != null && compAdded.containsKey(compName))
								//continue;
							//else
								//compAdded.put(compName,i);

							// JSON Data Preparation - Component Name - Starts
							boolean isUnknownNode = false;
							if(compName.indexOf("UNKNOWN_NODE")>-1)
							{
								isUnknownNode = true;
								overallUnknownNodePresence = true;
							}

							if(nodeOrder.equals("1") && !isUnknownNode)
									txnSnapshotToShow = true;

							if(compName != null && compName.indexOf(":NULL")>-1)
								jvmDataObj.put(lbl_compName, compName.substring(0,compName.indexOf(":NULL")));
							else if(isUnknownNode)
								jvmDataObj.put(lbl_compName, "");
							else
								jvmDataObj.put(lbl_compName, compName);
							// JSON Data PreParation - Component - Ends
							if(nodeType != null)
							{
								lbl_Java = mappingInfo.getTextDescription("monitor.apmtopology."+nodeType+"");
								if(!technologiesInvolved.contains(lbl_Java))
									technologiesInvolved.add(lbl_Java);
							}
							if(isUnknownNode)
							{
								jvmDataObj.put(lbl_activeNode,false);
								jvmDataObj.put(lbl_nodeText,lbl_None);
							}
							else
							{
								jvmDataObj.put(lbl_activeNode, true); 
								jvmDataObj.put(lbl_nodeText, lbl_Java); 
							}

							
							Long totRespTime = 0L;
							try
							{
								totRespTime = Long.parseLong(totalResponseTime);
							}
							catch(Exception trtexc){}
							tmpNodeModalWindowObj.put("Start_Time",reqTime);
							if(parentNode != null && parentNode.indexOf("UNKNOWN_NODE_") > -1)
								tmpNodeModalWindowObj.put("Called_From","-");
							else
								tmpNodeModalWindowObj.put("Called_From",parentNode);
							tmpNodeModalWindowObj.put("Exit_Calls","-");
							tmpNodeModalWindowObj.put("Execution_Time", totRespTime);
							tmpNodeModalWindowObj.put("GUID", drilldownGuid);
							tmpNodeModalWindowObj.put("Node_Order",nodeOrder);

							tmpLineModalWindowObj.put("Start_Time",reqTime);
							if(parentNode != null && parentNode.indexOf("UNKNOWN_NODE_") > -1)
								tmpLineModalWindowObj.put("Called_From","-");
							else
								tmpLineModalWindowObj.put("Called_From",parentNode);
							tmpLineModalWindowObj.put("Exit_Calls","-");
							tmpLineModalWindowObj.put("Execution_Time", totRespTime);
							tmpLineModalWindowObj.put("GUID", drilldownGuid);
							tmpLineModalWindowObj.put("Node_Order",nodeOrder);

							
							
							// JSON Data PreParation - Node Percentage - Starts
							long selfTime = 0L;
							if(nodeValueList != null && nodeValueList.size()>0)
							{
								try
								{
									long nodeTimeMillis = Long.parseLong(nodeValueList.get(0).toString());
									if(!isThreadReq && !isAsyncTimeToShowForJMS)
									{
										cumulativeNodeTime = cumulativeNodeTime + nodeTimeMillis;
										if(!isThreadRoot && !jmsEntryNodeFlag)
										{
											cumulativeNodePercent = cumulativeNodePercent + Double.parseDouble(nodeValueList.get(1).toString());
											javaTime += nodeTimeMillis;
										}
									}
									else
									{
										if(cumulativeAsyncNodeTime > 0){
											cumulativeAsyncNodeTime = cumulativeAsyncNodeTime + nodeTimeMillis;
										}
										else{
											cumulativeAsyncNodeTime = nodeTimeMillis;
										}
									}
								}
								catch(Exception e){}
								
								/*if(cumulativeNodeTime>0)
									jvmDataObj.put(lbl_nodeTime, cumulativeNodeTime + " " + lbl_milliseconds);
								else
									jvmDataObj.put(lbl_nodeTime, "");*/

								if(cumulativeAsyncNodeTime > -1 && !isUnknownNode)
									jvmDataObj.put(lbl_asyncTime, cumulativeAsyncNodeTime + " "+lbl_milliseconds);
								else
									jvmDataObj.put(lbl_asyncTime,lbl_None);

								/*if(cumulativeNodePercent>0)
									jvmDataObj.put(lbl_nodePercent, "("+percentFormat.format(cumulativeNodePercent)+ "%)");
								else
									jvmDataObj.put(lbl_nodePercent, "");*/

								if(isUnknownNode)
									jvmDataObj.put(lbl_nodeTime, lbl_None);
								else
									jvmDataObj.put(lbl_nodeTime, cumulativeNodeTime + " " + lbl_milliseconds);
									
								jvmDataObj.put(lbl_nodePercent, "("+percentFormat.format(cumulativeNodePercent)+ "%)");
								if(jmsEntryNodeFlag)
									jvmDataObj.put(lbl_nodePercent,"");

								try
								{
									if(isThreadReq)
									{
										if(nodeValueList != null && nodeValueList.size()>2)
											selfTime = Long.parseLong(nodeValueList.get(2).toString());
										else
											selfTime = Long.parseLong(nodeValueList.get(0).toString());
									}
									else
									{
										selfTime = Long.parseLong(nodeValueList.get(0).toString());
									}
								}
								catch(Exception slfTimeExc){}
								tmpNodeModalWindowObj.put("Self_Time",selfTime);
								tmpLineModalWindowObj.put("Self_Time",selfTime);
							}
							// JSON Data PreParation - Node Percentage - Ends

							if(jvmNodeDrillDownUrlToGo.equals(lbl_None))
							{
								tmpNodeModalWindowObj.put("Drilldown_URL", jvmNodeDrillDownUrlToGo);
							}
							else
							{
								if(drillDownImgState.equalsIgnoreCase(USER_EXPERIENCE_ERROR))
									tmpNodeModalWindowObj.put("Drilldown_URL", jvmNodeDrillDownUrlToGo+"&redirectPage=ERROR"+"&timeString="+selfTime);
								else
									tmpNodeModalWindowObj.put("Drilldown_URL", jvmNodeDrillDownUrlToGo+"&redirectPage=CALLGRAPH"+"&timeString="+selfTime);
							}

							gridData.add(tmpNodeModalWindowObj);  // Data for IMW Grid for Node - Added

							// JSON Data PreParation - Async time and Is Async Check - Starts
							if(isAsynch.equals(lbl_stringTrue) && !isUnknownNode)
							{
								overallAsyncPresence = true;
								modalWindowPresence = true;
								hmasyncLineValue = (HashMap) thisJvmDetails.get(lbl_asyncValue);
								isAsynchPresent = true;
								jvmDataObj.put(lbl_isAsync, true);

								// It shows total execution time of all threads above the node - Async Time
								//if(nodeValueList != null && nodeValueList.size()>2)
									//jvmDataObj.put(lbl_asyncTime, nodeValueList.get(2) + " "+lbl_milliseconds);

							}
							else
							{
								jvmDataObj.put(lbl_isAsync, false);
								jvmDataObj.put(lbl_asyncTime, lbl_None);
							}
							// JSON Data PreParation - Async time and Is Async Check - Ends
							
							// Line Value data preparation for web request starts here
							HashMap hmLineValue = (HashMap) thisJvmDetails.get(lbl_lineValue);
							Hashtable callCounterHolder = (Hashtable) thisJvmDetails.get("lbl_callCounterHolder");
							Hashtable callCounter = (Hashtable) callCounterHolder.get(compName);
							ArrayList thisLineModalWindowDetails = new ArrayList();
							if(hmLineValue != null && hmLineValue.size()>0)
							{
								Iterator itr = hmLineValue.keySet().iterator();
								while(itr.hasNext())
								{									
									String key = (String) itr.next();
									if(key!=null && key.startsWith("-")){
										continue;
									}
									String tempKey = key;
									strOtherPointCutName = tempKey.substring(0,tempKey.indexOf(':'));
									isOtherPointCut = apm.isPointCutInIni(testName,strOtherPointCutName);

									if(!tempKey.startsWith("Custom_")&& !tempKey.startsWith("HTTP-") && !tempKey.startsWith("WEBSERVICE-") && !tempKey.startsWith("DATABASECALL-") && !(tempKey.indexOf("queue=*=")>-1) && !(tempKey.indexOf("topic=*=")>-1) && !tempKey.startsWith("ABAP") && !(tempKey.indexOf(checkTempQueue)>-1) && !(tempKey.indexOf(checkTempTopic)>-1) && !isOtherPointCut && !(tempKey.startsWith("EJB")) && !(tempKey.startsWith("EHCACHE")))
									{
										tempKey = tempKey.substring(tempKey.indexOf(":")+1);
									}
									if(tempKey != null && tempKey.endsWith("_M"))
									{
										tempKey = tempKey.substring(tempKey.indexOf(":")+1);
									}
									// Source and target is for connecting from and to node.
									int source = (Integer) connMapNickToOrder.get(compName);
									int target = (Integer) connMapNickToOrder.get(tempKey);

									if(/*(jmsConList.contains(tempKey) || nodeOrder.equals("1")) &&*/ isJmsEntryPresent && (tempKey.indexOf("queue=*=")>-1  ||  tempKey.indexOf("topic=*=")>-1)) 
									{
										if(jmsEntryQueues.containsKey(tempKey)){
											source = (Integer) connMapNickToOrder.get(tempKey);
											target = (Integer) connMapNickToOrder.get(compName);
										}
									}

									// BugFix on 17-Apr-2020 : Below code reduces the visiblity of nodes on multi-node env, so commented
									/*if(!isJmsEntryPresent && !connectionDetailsHolder.containsKey(source)) 
									{ 
										continue ;
									}*/
									connectionDetailsHolder.put(target,source);
									String sourceTargetMappedKey = source+"#"+target;
									ArrayList allCallDetails = (ArrayList) hmLineValue.get(key);
									int allCallDetailsSize = allCallDetails.size();
									for(int c=0;c<allCallDetailsSize;c++)
									{
										JSONObject connLineObj = new JSONObject(); // Connected Line Details Data Object

										ArrayList callDetails = (ArrayList) allCallDetails.get(c);
										// JSON Data Preparation - Async Line Time Calculation (Web involves Async)- Starts
										if(isAsynchPresent)
										{
											if(hmasyncLineValue != null && hmasyncLineValue.containsKey(key))
											{
												ArrayList allAsyncCallDetails = (ArrayList) hmasyncLineValue.get(key);
												int allAsyncCallDetailsSize = allAsyncCallDetails.size();
												for(int s=0;s<allAsyncCallDetailsSize;s++)
												{
													ArrayList asynccallDetails = (ArrayList)allAsyncCallDetails.get(s);
													hmasyncLineValue.remove(key);
													if(asynccallDetails != null && asynccallDetails.size()>0)
													{
														connLineObj.put(lbl_asynclineTime, "(async) "+asynccallDetails.get(1) + " ms");
													}
												}
											}
										}
										// JSON Data Preparation - Async Line Time Calculation (Web involves Async)- Ends
										String extCallType = (String) callDetails.get(0);
										Hashtable countDetailsTable = (Hashtable) callCounter.get(extCallType);
										long outBoundTime = Long.parseLong(callDetails.get(1).toString());
										//cumulativeLineTime += outBoundTime; 

										double percent = Double.parseDouble(callDetails.get(2).toString());
										//if(!isThreadRoot)
											//cumulativeLinePercent += percent;
										
										if(!isThreadRoot)
											compInOutboundTime += outBoundTime;

										long connectedEndCallTime = Long.parseLong(callDetails.get(1).toString());
										if(jmsEntryNodeFlag)
										{
											connectedEndCallTime = 0 ; 
										}
										
										// JSON Data Preparation - Line Experience Message - Starts
										String LineExpMsg = "";
										if(!isUnknownNode)
										{	
											if(connectedEndCallTime > slowurlThreshold)
											{
												if(connectedEndCallTime > StalledTransactionTime)
												{
													LineExpMsg = USER_EXPERIENCE_STALLED;
												}
												else
												{
													LineExpMsg = USER_EXPERIENCE_SLOW;
												}
											}
										}
										// JSON Data Preparation - Line Experience Message- Ends

										if(isUnknownNode)
										{
											connLineObj.put(lbl_drillDownUrlToGo, lbl_None);
											connLineObj.put(lbl_drillDownNodeOrder, lbl_None);
										}
										else
										{
											String connLineDrillDownUrlToGo = (String) thisJvmDetails.get(lbl_drillDownUrlToGo);
											if(connLineDrillDownUrlToGo != null && connLineDrillDownUrlToGo.length()>0)
											{
												connLineObj.put(lbl_drillDownGuid, (String) thisJvmDetails.get(lbl_drillDownGuid));
												connLineObj.put(lbl_drillDownNodeOrder, nodeOrder);

												if(!connLineDrillDownUrlToGo.equals(lbl_None))
												{
													String urlGoString = connLineDrillDownUrlToGo+"&redirectPage="+extCallType+"&timeString="+selfTime;
													connLineObj.put(lbl_drillDownUrlToGo, urlGoString);
													tmpLineModalWindowObj.put("Drilldown_URL",urlGoString);
												}
												else
												{
													connLineObj.put(lbl_drillDownUrlToGo, connLineDrillDownUrlToGo);
													tmpLineModalWindowObj.put("Drilldown_URL", connLineDrillDownUrlToGo);
												}
											}
										}
										
										// JSON Data - Tier Breakup calculation - Starts
										if(!isThreadRoot)
										{
											if(key.startsWith("DATABASECALL-"))
											{
												dbTime += connectedEndCallTime;
											}
											else
											{
												if(key.indexOf("_M:")>-1)
												{
													// MS_sql_server_M:SQL_246:1433
													String type = key.substring(0,key.indexOf("_M:"));
													boolean isDbComp = isDbManagedComponent(type);
													if(isDbComp)
														dbTime += connectedEndCallTime;
													else
														externalCallsTime += connectedEndCallTime;
												}
												else
												{
													externalCallsTime += connectedEndCallTime;
												}
											}
										}
										// JSON Data - Tier Breakup calculation - Ends

										// Code Starts for adding the Sync and Async Time and for adding only sync percentage - Starts
										boolean lineAsyncPresent = false;
										if(cumLineTimeTable.containsKey(sourceTargetMappedKey))
										{
											
											double[] currentList = (double[]) cumLineTimeTable.get(sourceTargetMappedKey);
											if(isThreadReq)
											{
												lineAsyncPresent = true;

												double accumulatedlineTime = currentList[2];
												if(outBoundTime<0 && accumulatedlineTime<0)
												{
													accumulatedlineTime = outBoundTime ; 
												}
												else if(outBoundTime>=0)
												{
													if(accumulatedlineTime<0)
														accumulatedlineTime = 0 ;
													accumulatedlineTime += outBoundTime;
												}
												currentList[2] = accumulatedlineTime;
											}
											else
											{
												double accumulatedlineTime = currentList[0] ; //(Long) currentList.remove(0);
												if(outBoundTime<0 && accumulatedlineTime<0)
												{
													accumulatedlineTime = outBoundTime ; 
												}
												else if(outBoundTime>=0)
												{
													if(accumulatedlineTime<0)
														accumulatedlineTime = 0 ;
													accumulatedlineTime += outBoundTime;
												}
												currentList[0] = accumulatedlineTime;

												double accumulatedlinePercent = currentList[1]; 
												if(!isThreadRoot)
													accumulatedlinePercent += percent;
												currentList[1] = accumulatedlinePercent;
											}
											if (!isOtherPointCut)
											{
												linegridData = (JSONArray) cumLineDataTable.get(sourceTargetMappedKey);
												if(!lineModalWindowNodeDetails.contains(nodeOrder))
													linegridData.add(tmpLineModalWindowObj);
											}
											connLineObj.put("modalWindowGridData", linegridData);
										}
										else
										{
											double[] details = new double[3];
											if(isThreadReq)
											{
												lineAsyncPresent = true;
												details[0] = -155.0D;
												details[1] = 0.0D;
												details[2] = (double)outBoundTime;
											}
											else
											{
												details[0] = (double)outBoundTime;
												if(!isThreadRoot){
													details[1] = percent;
												}
												else{
													details[1] = 0.0D;
												}
												details[2] = -155.0D;
											}
											cumLineTimeTable.put(source+"#"+target,details);
											if (!isOtherPointCut)
											{
												linegridData = new JSONArray();

												lineModalWindowNodeDetails.add(nodeOrder);
												linegridData.add(tmpLineModalWindowObj);
											}
											connLineObj.put("modalWindowGridData", linegridData);
											cumLineDataTable.put(sourceTargetMappedKey,linegridData);
										}
										// Code Starts for adding the Sync and Async Time and for adding only sync percentage - Ends

										double[] cumulativeTimingList = (double[])cumLineTimeTable.get(sourceTargetMappedKey);
										cumulativeLineTime = (long) cumulativeTimingList[0];
										cumulativeLinePercent =  cumulativeTimingList[1];
										cumulativeAsyncLineTime = (long) cumulativeTimingList[2];

										if(!targetHolder.contains(target))
											targetHolder.add(target);
				
										// JSON Data Preparation - Line Experience - Starts
										
										if(!isUnknownNode)
										{	
											String lineExp = null ;
											long tmpTime = ( cumulativeLineTime >= cumulativeAsyncLineTime )?cumulativeLineTime : cumulativeAsyncLineTime ; 
											lineExp = getLineExperience(slowurlThreshold,StalledTransactionTime,tmpTime);
											connLineObj.put(lbl_lineExperience,lineExp);
										}
										else
										{
											connLineObj.put(lbl_lineExperience,lbl_None);
										}
										// JSON Data Preparation - Line Experience - Ends
										
										if(extCallType.equals(pointCutHTTP) || extCallType.equals(pointCutWebService))
										{
											String tmp =(String)httpUrlStatusCodeTable.get(key);
											if(tmp!=null && tmp.equals(USER_EXPERIENCE_ERROR))
											{
												connLineObj.put(lbl_lineExperience,USER_EXPERIENCE_ERROR);
											}
										}
										// Code for adding Call Count, Call type, Sync & Async Time, Source , Target to JSON - Starts
										String connectedCallResult = tempKey;
										int callCounts = 1;
										String msgString ="";
										if(countDetailsTable != null && countDetailsTable.size()>0)
										{
											ArrayList countDetails = (ArrayList) countDetailsTable.get(connectedCallResult);
											if(countDetails != null && countDetails.size()>0){
												callCounts = (Integer) countDetails.get(0);
												msgString = (String) countDetails.get(2);
											}
										}

										String tmpCallType = extCallType;

										if(tmpCallType.startsWith("Custom_")){
										
											tmpCallType =tmpCallType.substring(tmpCallType.indexOf("_")+1);
										}
										if(callCounts > 1)
										{
											if(extCallType.startsWith(pointCutCustom))
												connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology."+tmpCallType)+" ("+callCounts+")");
											else
												connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology.plural."+tmpCallType)+" ("+callCounts+")");
										}
										else
										{
											if(isUnknownNode)
												connLineObj.put(lbl_lineCall,lbl_None);
											else
												connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology."+tmpCallType));
										}
					
										/*if(cumulativeLineTime>0)
											connLineObj.put(lbl_lineTime, cumulativeLineTime + " "+lbl_milliseconds);
										else
											connLineObj.put(lbl_lineTime, lbl_None);*/


										if(cumulativeAsyncLineTime>=0 && !isUnknownNode)
										{
											connLineObj.put(lbl_asynclineTime, "(async) "+cumulativeAsyncLineTime + " ms");
										}
										else
										{
											connLineObj.put(lbl_asynclineTime, lbl_None);
											if(cumulativeAsyncLineTime < 0 && cumulativeAsyncLineTime != -155 && (cumulativeLineTime>0 || cumulativeLineTime == -155))
											{
												isNegativeTimedisclaimerToShow = true ;
												connLineObj.put(lbl_asynclineTime,"*");
											}
										}
										if(cumulativeLineTime>=0 && !isUnknownNode)
										{
											connLineObj.put(lbl_lineTime,cumulativeLineTime + " ms");
										}
										else{
											connLineObj.put(lbl_lineTime, lbl_None);
											if(cumulativeLineTime<0 && cumulativeLineTime != -155  ){
												isNegativeTimedisclaimerToShow = true ; 
												connLineObj.put(lbl_lineTime,"*");
											}
										}
											
										if(cumulativeLinePercent>0 && !isUnknownNode && !jmsEntryNodeFlag )
											connLineObj.put(lbl_linePercent, "("+percentFormat.format(cumulativeLinePercent)+ "%)");
										else
											connLineObj.put(lbl_linePercent, lbl_None);


										connLineObj.put(lbl_arrow,true);
										connLineObj.put(lbl_source,source);
										connLineObj.put(lbl_target,target);
										// Code for adding Call Count, Call type, Sync & Async Time, Source , Target to JSON - Ends
										cumLineValueTable.put(source+"#"+target,connLineObj); // Link date (connected line) has been added

										// Transaction snapshot Overall Message computation - Starts
										if(LineExpMsg.length()>0 && !overallMsg.containsKey(pointCutException) && !isJmsEntryPresent)
										{
											if(overallMsg.containsKey(LineExpMsg))
											{
												overallMsg.put(LineExpMsg, "Slowness found in multiple stages of processing");
											}
											else
											{
												if(LineExpMsg.equals(USER_EXPERIENCE_SLOW) || LineExpMsg.equals(USER_EXPERIENCE_STALLED))
												{
													String tempTarget = getRenamedDisplayName(key, testName);
													String mappingName = mappingInfo.getTextDescription("monitor.apmtopology."+extCallType);
													StringBuffer expBufferString = new StringBuffer();
													expBufferString.append(mappingName).append(" execution");
													if(tempTarget!=null && tempTarget.length() > 0){
														expBufferString.append(" on ").append(tempTarget);
													}
													expBufferString.append(" took ").append(callDetails.get(1)).append(" ");
													expBufferString.append(lbl_milliseconds).append(".");
													overallMsg.put(LineExpMsg, expBufferString.toString());
												}
												else if(LineExpMsg.equals(pointCutException))
												{
													overallMsg.put(LineExpMsg, msgString+" execution on "+compName);
												}
												else
												{
													overallMsg.put(LineExpMsg, headerMessageHealthy);
												}
											}
										}
										if((tempKey.indexOf("queue=*=")>-1  || tempKey.indexOf("topic=*=")>-1)){
											String asyncLineString = "(async) "+cumulativeLineTime + " "+lbl_milliseconds;
											if(isJmsEntryPresent && jmsEntryQueues.containsKey(tempKey)){
												asyncLineString = "";
												connLineObj.put(lbl_lineExperience,lbl_None);
											}
											connLineObj.put(lbl_asynclineTime, asyncLineString);
											connLineObj.put(lbl_lineTime, lbl_None);
											connLineObj.put(lbl_linePercent, lbl_None);
										}
										// Transaction snapshot Overall Message computation - Ends
									}
								}
							}
							else{
								// Node 1 ----> queue (JMS_ENTRY) -----> Node 2 , When Node 1 is UnKnown below code used.
								if(isUnknownNode){
									int source = (Integer) connMapNickToOrder.get(compName);
									int target = getTargetForUnknownNode(webOrderList , nodeOrder , drilldownGuid , topologyBuildSource , connMapNickToOrder , guidNodeHostTable);

									if(target > -1 ){
										connectionDetailsHolder.put(target,source);
										JSONObject connLineObj = new JSONObject();
										connLineObj.put(lbl_arrow,true);
										connLineObj.put(lbl_source,source);
										connLineObj.put(lbl_target,target);
										connLineObj.put(lbl_lineTime,lbl_None);
										connLineObj.put(lbl_linePercent,lbl_None);
										connLineObj.put(lbl_asynclineTime,lbl_None);
										linkDatas.add(connLineObj);
									}
								}
							}
							 // Line Value data preparation for web request ends here
								
							 // Line Value data preparation for async request starts here
							if(isAsynch != null && isAsynch.equals(lbl_stringTrue))
							{
								
								HashMap hmAsyncLineValue = (HashMap) thisJvmDetails.get(lbl_asyncValue);
								if(hmAsyncLineValue != null && hmAsyncLineValue.size()>0)
								{
									Iterator itr = hmAsyncLineValue.keySet().iterator();
									
									while(itr.hasNext())
									{
										String key = (String) itr.next();
										ArrayList allCallDetails = (ArrayList) hmAsyncLineValue.get(key);
										int allCallDetailsSize = allCallDetails.size();

										for(int c=0;c<allCallDetailsSize;c++)
										{
											JSONObject connLineObj = new JSONObject();
											ArrayList callDetails = (ArrayList) allCallDetails.get(c);
											String extCallType = (String) callDetails.get(0);
											Hashtable countDetailsTable = (Hashtable) callCounter.get(extCallType);
											long outBoundTime = Long.parseLong(callDetails.get(1).toString());
											//compInOutboundTime += outBoundTime;
											long connectedEndCallTime = Long.parseLong(callDetails.get(1).toString());
											if(jmsEntryNodeFlag)
											{
												connectedEndCallTime = 0 ; 
											}
											
											String LineExpMsg = "";
											if(isUnknownNode)
											{
												connLineObj.put(lbl_lineExperience, lbl_None);
												connLineObj.put(lbl_drillDownUrlToGo, lbl_None);
											}
											else
											{
												// JSON Data Preparation - Line Experience - Starts
												LineExpMsg = getLineExperience(slowurlThreshold,StalledTransactionTime,connectedEndCallTime);
												// JSON Data Preparation - Line Experience - Ends

												// JSON Data Preparation -URL to go - Starts
												String connLineDrillDownUrlToGo = (String) thisJvmDetails.get(lbl_drillDownUrlToGo);
												if(connLineDrillDownUrlToGo != null && connLineDrillDownUrlToGo.length()>0)
												{
													connLineObj.put(lbl_drillDownGuid, (String) thisJvmDetails.get(lbl_drillDownGuid));
													connLineObj.put(lbl_drillDownNodeOrder, nodeOrder);

													if(connLineDrillDownUrlToGo.equals(lbl_None))
													{
														connLineObj.put(lbl_drillDownUrlToGo, connLineDrillDownUrlToGo);
														tmpLineModalWindowObj.put("Drilldown_URL",connLineDrillDownUrlToGo);
													}
													else
													{
														String urlGoString = connLineDrillDownUrlToGo+"&redirectPage="+extCallType+"&timeString="+selfTime;
														connLineObj.put(lbl_drillDownUrlToGo, urlGoString);
														tmpLineModalWindowObj.put("Drilldown_URL",urlGoString);
													}
												}
												// JSON Data Preparation -URL to go  - Ends
											}

											String tempKey = key;
											strOtherPointCutName = tempKey.substring(0,tempKey.indexOf(':'));
											isOtherPointCut = apm.isPointCutInIni(testName,strOtherPointCutName);
											if(!tempKey.startsWith("Custom_") && !tempKey.startsWith("HTTP-") && !tempKey.startsWith("WEBSERVICE-") && !tempKey.startsWith("DATABASECALL-") && !(tempKey.indexOf("topic=*=")>-1) && !(tempKey.indexOf("queue=*=")>-1) && !tempKey.startsWith("ABAP") && !(tempKey.indexOf(checkTempQueue)>-1) && !(tempKey.indexOf(checkTempTopic)>-1) && !isOtherPointCut && !(tempKey.startsWith("EJB")) && !(tempKey.startsWith("EHCACHE")))
											{
												tempKey = tempKey.substring(tempKey.indexOf(":")+1);
											}
											if(tempKey != null && tempKey.endsWith("_M"))
											{
												tempKey = tempKey.substring(tempKey.indexOf(":")+1);
											}
											
											int source = (Integer) connMapNickToOrder.get(compName);
											int target = (Integer) connMapNickToOrder.get(tempKey);
											
											if(!targetHolder.contains(target))
												targetHolder.add(target);
											//connectionDetailsHolder.put(connMapNickToOrder.get(tempKey),compName);
											
											// Code for adding Call Count, Call type, Sync & Async Time, Source , Target to JSON - Starts
											String connectedCallResult = tempKey;
											int callCounts = 1;
											String msgString ="";
											if(countDetailsTable != null && countDetailsTable.size()>0)
											{
												ArrayList countDetails = (ArrayList) countDetailsTable.get(connectedCallResult);
												if(countDetails != null && countDetails.size()>0){
													callCounts = (Integer) countDetails.get(0);
													msgString = (String) countDetails.get(2);
												}
											}

											if(callCounts > 1)
											{
												connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology.plural."+extCallType)+" ("+callCounts+")");
											}
											else
											{
												//connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology."+extCallType));
												if(isUnknownNode)
													connLineObj.put(lbl_lineCall,lbl_None);
												else
													connLineObj.put(lbl_lineCall, mappingInfo.getTextDescription("monitor.apmtopology."+extCallType));
											}
											//connLineObj.put(lbl_lineTime, callDetails.get(1) + " "+lbl_milliseconds+" (async)");

											if(isUnknownNode)
												connLineObj.put(lbl_lineTime, lbl_None);
											else
												connLineObj.put(lbl_lineTime, " (async) "+callDetails.get(1) + " "+lbl_milliseconds);

											connLineObj.put(lbl_linePercent, "");
											connLineObj.put(lbl_arrow,true);
											
											connLineObj.put(lbl_source,source);
											connLineObj.put(lbl_target,target);
											// Code for adding Call Count, Call type, Sync & Async Time, Source , Target to JSON - Starts

											if(!isOtherPointCut)
												linegridData.add(tmpLineModalWindowObj);
											connLineObj.put("modalWindowGridData", linegridData);
	
											//linkDatas.add(connLineObj);
											cumLineValueTable.put(source+"#"+target,connLineObj);

											// Transaction snapshot Overall Message computation - Starts
											if(LineExpMsg.length()>0 && !overallMsg.containsKey(pointCutException))
											{
												if(overallMsg.containsKey(LineExpMsg))
												{
													overallMsg.put(LineExpMsg, "Slowness found in multiple stages of processing");
												}
												else
												{
													if(LineExpMsg.equals(USER_EXPERIENCE_SLOW) || LineExpMsg.equals(USER_EXPERIENCE_STALLED))
													{
														String tempTarget = getRenamedDisplayName(key, testName);
														overallMsg.put(LineExpMsg, mappingInfo.getTextDescription("monitor.apmtopology."+extCallType)+" execution on "+tempTarget+" took "+callDetails.get(1)+" "+lbl_milliseconds+".");
													}
													else if(LineExpMsg.equals(pointCutException))
													{
														overallMsg.put(LineExpMsg, msgString+" execution on "+compName);
													}
													else
													{
														overallMsg.put(LineExpMsg, headerMessageHealthy);
													} 
												}
											}
											// Transaction snapshot Overall Message computation - Ends
										}
									}
								}
							}
							// Line Value data preparation for async request ends here 
							
							// Json Data for USER
							if(compName.equals(lbl_User))
							{
								JSONObject connLineObjUser = new JSONObject();
								connLineObjUser.put(lbl_source,0);
								connLineObjUser.put(lbl_target,1);
								connLineObjUser.put(lbl_arrow,true);
								connLineObjUser.put(lbl_lineTime,lbl_None);
								connLineObjUser.put(lbl_linePercent,lbl_None);
								connLineObjUser.put(lbl_asynclineTime,lbl_None);
								linkDatas.add(connLineObjUser);
								//linkDataHolder.put("0#1",connLineObjUser);
								jvmDataObj.put(lbl_nodeText,lbl_None);
								jvmDataObj.put(lbl_User_Name,userName);
								jvmDataObj.put(lbl_nodeTime,lbl_None);
								jvmDataObj.put(lbl_nodePercent,lbl_None);
								jvmDataObj.put(lbl_nodeExperience,overAllExperience.toUpperCase());
								jvmDataObj.put(lbl_lineExperience,lbl_None);
								jvmDataObj.put(lbl_userDevice,(String) thisJvmDetails.get(lbl_userDevice));
							}

							// JSON Data - Calculation for Node Experience State and Overall Topology Message - Starts
							String nodeExperienceState = drillDownImgState;
							if(nodeValueList != null && nodeValueList.size()>0)
							{
								long nodeSelfTime = Long.parseLong(nodeValueList.get(0).toString());
								if(!isThreadRoot)
									compInOutboundTime += nodeSelfTime;
								
								if(!nodeExperienceState.equals(USER_EXPERIENCE_ERROR) && !nodeExperienceState.equals(lbl_Normal))
								{
									if(slowurlThreshold == -1L && StalledTransactionTime == -1L ){
										nodeExperienceState = USER_EXPERIENCE_HEALTHY;
									}
									else{
										if(nodeSelfTime>slowurlThreshold){
											if(nodeSelfTime>StalledTransactionTime)
												nodeExperienceState = USER_EXPERIENCE_STALLED;
											else
												nodeExperienceState = USER_EXPERIENCE_SLOW;
										}
										else
										{
											nodeExperienceState = USER_EXPERIENCE_HEALTHY;
										}
									}
								}
								
								if(cumNodeExperience == null)
									cumNodeExperience = nodeExperienceState;

								if(cumNodeExperience != null)
								{
									nodeExperienceState = compareExperience(cumNodeExperience,nodeExperienceState);
									cumNodeExperience = nodeExperienceState;
								}
								//jvmDataObj.put(lbl_nodeExperience, nodeExperienceState);

								if(isUnknownNode)
									jvmDataObj.put(lbl_nodeExperience, lbl_None);
								else
									jvmDataObj.put(lbl_nodeExperience, nodeExperienceState);

								if(nodeExperienceState.length()>0 && !overallMsg.containsKey(USER_EXPERIENCE_ERROR))
								{
									if(overallMsg.containsKey(nodeExperienceState))
									{
										overallMsg.put(nodeExperienceState, "Slowness found in multiple stages of processing");
									}
									else
									{
										if(nodeExperienceState.equals(USER_EXPERIENCE_SLOW) || nodeExperienceState.equals(USER_EXPERIENCE_STALLED))
										{
											if(compName != null && compName.indexOf(":NULL")>-1)
												overallMsg.put(nodeExperienceState, mappingInfo.getTextDescription("monitor.apmtopology."+apmType)+" execution on "+compName.substring(0,compName.indexOf(":NULL"))+" took "+nodeValueList.get(0)+" "+lbl_milliseconds+".");
											else
												overallMsg.put(nodeExperienceState, mappingInfo.getTextDescription("monitor.apmtopology."+apmType)+" execution on "+compName+" took "+nodeValueList.get(0)+" "+lbl_milliseconds+".");
										}
										else if(nodeExperienceState.equals(USER_EXPERIENCE_ERROR))
										{
											if(callCounter != null)
											{
												Hashtable temp = (Hashtable) callCounter.get(pointCutException);
												if(temp != null && temp.size()>0)
												{
													ArrayList exceptionDetails = (ArrayList) temp.get(pointCutException);
													String tempExpString = (String) exceptionDetails.get(1);
													if(tempExpString.indexOf(":")>-1)
														tempExpString = tempExpString.substring(0,tempExpString.indexOf(":"));
						
													tempExpString = tempExpString.substring(tempExpString.lastIndexOf(".")+1);
													overallMsg.put(nodeExperienceState, tempExpString+" on "+compName);
												}
											}
										}
										else
										{
											overallMsg.put(nodeExperienceState, headerMessageHealthy);
										}
									}
								}
							}
							// JSON Data - Calculation for Node Experience State and Overall Topology Message - Starts

							// JSON Data - Calculation for Drilldown URL to go,Display Name, Server Type, Modal Window Presence - Starts
							if(isUnknownNode)
							{
								jvmDataObj.put(lbl_drillDownUrlToGo, lbl_None);
							}
							else
							{
								if(jvmNodeDrillDownUrlToGo != null && jvmNodeDrillDownUrlToGo.length()>0)
								{
									jvmDataObj.put(lbl_drillDownGuid, (String) thisJvmDetails.get(lbl_drillDownGuid));
									jvmDataObj.put(lbl_drillDownNodeOrder, nodeOrder);

									if(nodeOrder != null && nodeOrder.equals("1"))
									{
										firstNodeSlowThreshold = slowurlThreshold;
										firstNodeStalledThreshold = StalledTransactionTime;
									}

									String urlGoString ="";
									if(jvmNodeDrillDownUrlToGo.equals(lbl_None)){
										urlGoString = jvmNodeDrillDownUrlToGo;
									}
									else{
										String redirectPage = "CALLGRAPH";
										if(drillDownImgState.equalsIgnoreCase(USER_EXPERIENCE_ERROR)){
											redirectPage = "ERROR";
										}
										urlGoString = jvmNodeDrillDownUrlToGo+"&redirectPage="+redirectPage+"&timeString="+selfTime;
									}
									jvmDataObj.put(lbl_drillDownUrlToGo, urlGoString);
								}
							}
							jvmDataObj.put(lbl_displayName, (String) thisJvmDetails.get(lbl_displayName));
							jvmDataObj.put(lbl_serverType, (String) thisJvmDetails.get(lbl_serverType));

							if(!compName.equals(lbl_User) && !isUnknownNode && !isJmsEntryPresent)
							{
								if(compInOutboundTime>0)
								{
									if(compName != null && compName.indexOf(":NULL")>-1)
										nodeDataHolder.put(compName.substring(0,compName.indexOf(":NULL")),compInOutboundTime);
									else
										nodeDataHolder.put(compName,compInOutboundTime);
								}
							}

							if(modalWindowPresence)
								jvmDataObj.put("isModalWindowToShow", true);
							else
								jvmDataObj.put("isModalWindowToShow", false);

							// JSON Data - Calculation for Drilldown URL to go,Display Name, Server Type, Modal Window Presence - Starts
						}
						jvmDataObj.put("modalWindowGridData", gridData);
						tmpNodeObj.put(i,jvmDataObj);

						// IMW - Grid data preparation for links (On Clicking line) - Starts
						Iterator cumlineValIterator = cumLineValueTable.keySet().iterator();
						while(cumlineValIterator.hasNext())
						{
							String sourceTargetKey = (String) cumlineValIterator.next();
							JSONObject connLineObj = (JSONObject) cumLineValueTable.get(sourceTargetKey);
							JSONArray entireLineDetails = (JSONArray) connLineObj.get("modalWindowGridData");
							if(entireLineDetails != null)
							{
								int entireLineDetailsSize = (Integer) entireLineDetails.size();
								if(entireLineDetailsSize>1)
								{
									connLineObj.put("isModalWindowToShow", true);
									linkDatas.add(cumLineValueTable.get(sourceTargetKey));
								}
								else
								{
									connLineObj.put("isModalWindowToShow", false);
									linkDatas.add(cumLineValueTable.get(sourceTargetKey));
								}
							}
						}
						// IMW - Grid data preparation for links (On Clicking line) - Ends
					}
					else
					{
						// For exit / end call data preparation
						strOtherPointCutName = thisNode.substring(0,thisNode.indexOf(':'));
						isOtherPointCut = apm.isPointCutInIni(testName,strOtherPointCutName);

						String image = "";
						String componName = null;
						JSONObject unmanageDataObj = new JSONObject();
						if(thisNode.startsWith("HTTP-"))
						{
							image =  pointCutHTTP;
							if(thisNode.indexOf("HTTP-") > -1)
							{
								componName = thisNode.substring(thisNode.indexOf("HTTP-")+5);
							}
							unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology.Remote Service"));
						}
						else if(thisNode.startsWith("WEBSERVICE-"))
						{
							image =  "WEB_SERVICE";
							if(thisNode.indexOf("WEBSERVICE-")>-1)
							{
								componName = thisNode.substring(thisNode.indexOf("WEBSERVICE-")+11);
							}
							unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology.Remote Service"));
						}
						else if(thisNode.startsWith("DATABASECALL-"))
						{
							image =  "DATABASE_SERVER";
							componName = "";
							int db_Idx = thisNode.indexOf("DATABASECALL-")+13 ; 
							int star_Idx = thisNode.indexOf("*") ; 
							String server = thisNode.substring(db_Idx);
							if( star_Idx > - 1 )
							{
								server = thisNode.substring(db_Idx,star_Idx);
								//Bug fix - When JDBC URL contains "_", topology showing db name after "_"
								if(server!=null){
									String tempDbdetails = thisNode.substring(star_Idx+1);
									if(server.equals("-")){
										server = tempDbdetails;
									}
									else{
										int temp_idx = tempDbdetails.indexOf("_") ; 
										int temp_star_idx = tempDbdetails.indexOf("*") ;
										if(temp_idx > - 1 )
										{
											componName=tempDbdetails.substring(temp_idx+1);
											if(componName.length() == 0)
											{
												componName=tempDbdetails.substring(temp_star_idx+1,temp_idx);
											}
										}
										else
										{
											componName=tempDbdetails.substring(temp_star_idx+1);
										}
									}
								}
							}
							server = server.startsWith("jdbc:")? server : mappingInfo.getComponentTypeDescription(server);
							image = server.equalsIgnoreCase(pointCutREDIS) ? pointCutREDIS : server.equalsIgnoreCase("Mongo Database") ? "MONGODB" : "DATABASE_SERVER" ;
							unmanageDataObj.put(lbl_displayName, server);
						}
						else if(thisNode.startsWith("ABAP"))
						{
							image = "JCOSAP";
							componName = thisNode;
							unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology.Remote Service"));
						}
						else if(thisNode.indexOf("queue=*=")>-1 || thisNode.indexOf("topic=*=")>-1 || thisNode.indexOf(checkTempQueue)>-1 || thisNode.indexOf(checkTempTopic)>-1)
						{
							image =  "JMS_TOPIC";
							if(thisNode.indexOf("queue=*=")>-1 || thisNode.indexOf(checkTempQueue)>-1){
								image =  "QUEUE";
							}

							String queueOrTopicName = thisNode;
							int colon_index = thisNode.indexOf(":");
							if(colon_index > -1)
								queueOrTopicName = thisNode.substring(colon_index + 1);
							else if(thisNode.indexOf(checkTempQueue)> -1 )
								queueOrTopicName = checkTempQueue;
							else if(thisNode.indexOf(checkTempTopic)> -1 )
								queueOrTopicName = checkTempTopic;
							componName = queueOrTopicName;
							String provider = thisNode.substring(thisNode.indexOf("=*=")+3,colon_index);
							//When Provider is "-" change provider as queueOrTopicName & componName as emptyString
							if(provider!=null && provider.equals("-")){
								provider = queueOrTopicName;
								componName = "";
							}
							unmanageDataObj.put(lbl_displayName, provider);
						}
						else if(thisNode.startsWith("Custom_"))
						{
							image = "CUSTOM";
							componName = thisNode.substring(thisNode.indexOf(":")+1);
						}
						else if(thisNode.startsWith("EJB"))
						{
							int temp = thisNode.indexOf(":");
							//image = "HTTP";
							if (temp>-1) {
								image = apm.getPointCutImageName(thisNode.substring(0, temp));
								componName = thisNode.substring(temp+1);
							}
							//unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology.Remote Service"));
						}else if(thisNode.startsWith("EHCACHE"))
						{
							image =  "CACHE";
							componName="";
							unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology.EHCACHE"));
						}
						else if(isOtherPointCut)
						{
							String whiteSpaceSep = " ";
							image = apm.getPointCutImageName(strOtherPointCutName);
							String compTypeEndStr = "Backends";
							//image = "CUSTOM";

							int backEndCounts = 1;
							Hashtable exitPCCountDetails = null;

							if (strOtherPointCutName.equalsIgnoreCase("rmi") || strOtherPointCutName.equalsIgnoreCase("LDAP"))
							{
								exitPCCountDetails = (Hashtable)webTempCallCount.get(strOtherPointCutName);
								if (exitPCCountDetails != null){
									backEndCounts = exitPCCountDetails.size();
									if (backEndCounts > 1)
									{
										componName = "";
										unmanageDataObj.put(lbl_displayName, backEndCounts + whiteSpaceSep + mappingInfo.getTextDescription("monitor.apmtopology."+ strOtherPointCutName + whiteSpaceSep + compTypeEndStr));
									}
									else
									{
										Iterator tempItr = exitPCCountDetails.keySet().iterator();
										while(tempItr.hasNext())
										{
											String url = (String)tempItr.next();
											componName = url;
											unmanageDataObj.put(lbl_displayName, lbl_None);
										}
									}
								}
							}
							else if (strOtherPointCutName.equalsIgnoreCase("email"))
							{
								exitPCCountDetails = (Hashtable)webTempCallCount.get(strOtherPointCutName);
								componName = "";
								if (exitPCCountDetails != null){
									backEndCounts = exitPCCountDetails.size();
									if (backEndCounts > 1) // Have both send and sendMessage
									{
										unmanageDataObj.put(lbl_displayName, "2" + whiteSpaceSep + mappingInfo.getTextDescription("monitor.apmtopology."+ strOtherPointCutName + whiteSpaceSep + compTypeEndStr));
									}
									else
									{
										Iterator tempItr = exitPCCountDetails.keySet().iterator();
										while(tempItr.hasNext())
										{
											String mailMethodName = (String)tempItr.next();
											unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology."+strOtherPointCutName + whiteSpaceSep + mailMethodName.toUpperCase()));
										}
									}
								}
							}
							else{
								unmanageDataObj.put(lbl_displayName, mappingInfo.getTextDescription("monitor.apmtopology."+ strOtherPointCutName));
							}
						}
						else
						{
							EgDiscInfo discInfo = new EgDiscInfo("manager");
							componName = thisNode;
							String compType=discInfo.getServerTypesForComponentNamePort(thisNode);
							image = apm.getIcon(compType);
							if(image ==null || image.trim().length() == 0) {
								image = egCompCategory.getCategoryforCompType(compType);
							}
							if(image.equalsIgnoreCase(lbl_Others))
								image = "CUSTOM";
							unmanageDataObj.put(lbl_displayName, mappingInfo.getComponentTypeDescription(compType));
						}

						// To avoid duplicating the same exit call again and again in the topology
						if(compAdded != null && compAdded.containsKey(thisNode))
							continue;
						else
							compAdded.put(thisNode,i);

						// End call Json Data
						unmanageDataObj.put(lbl_compName, componName);
						unmanageDataObj.put(lbl_nodeText, lbl_None);
						unmanageDataObj.put(lbl_nodeTime, lbl_None);
						unmanageDataObj.put(lbl_nodePercent, lbl_None);
						unmanageDataObj.put(lbl_isAsync, false);
						unmanageDataObj.put(lbl_asyncTime, lbl_None);
						unmanageDataObj.put(lbl_nodeExperience, lbl_None);
						unmanageDataObj.put(lbl_isStartJvm, false);
						unmanageDataObj.put(lbl_serverType, image);
						unmanageDataObj.put(lbl_drillDownGuid, lbl_None);
						unmanageDataObj.put(lbl_drillDownNodeOrder, lbl_None);
						unmanageDataObj.put(lbl_drillDownUrlToGo, lbl_None);
						unmanageDataObj.put(lbl_activeNode, lbl_None);
						tmpNodeObj.put(i,unmanageDataObj);
					}
				}
			}
			nodeDatas.add(tmpNodeObj);

			// data for time split for Java, Database and External calls in in user tool tip and header 
			if(javaTime<0)
				javaTime = 0;
			if(dbTime<0)
				dbTime = 0;
			if(externalCallsTime<0)
				externalCallsTime = 0;

			if(technologiesInvolved.size()>1)
				blockDataObj.put(lbl_Code,javaTime+" "+lbl_milliseconds);
			else
				blockDataObj.put(lbl_Java,javaTime+" "+lbl_milliseconds);

			blockDataObj.put(lbl_Database_Queries,dbTime+" "+lbl_milliseconds);
			blockDataObj.put(lbl_External_Calls,externalCallsTime+" "+lbl_milliseconds);

			if(javaTime > 0)
			{
				if(technologiesInvolved.size()>1)
					blockDataHolder.put(lbl_Code,javaTime);
				else
					blockDataHolder.put(lbl_Java,javaTime);
			}
			if(dbTime > 0)
				blockDataHolder.put(lbl_Database_Queries,dbTime);
			if(externalCallsTime > 0)
				blockDataHolder.put(lbl_External_Calls,externalCallsTime);

			// Header user experience calculation
			if(overallMsg != null && overallMsg.size()>0)
			{
				if(overallMsg.containsKey(USER_EXPERIENCE_ERROR))
				{
					Integer http_Url_statusCode = (Integer)httpUrlStatusCodeTable.get("status_code");
					String err_msg = (String) overallMsg.get(USER_EXPERIENCE_ERROR);
					if(err_msg.startsWith("Multiple"))
					{
						totalHeaderDataObj.put(lbl_Error_Segment,"Errors found in multiple stages of processing");
					}else if(http_Url_statusCode!=null)
					{
						totalHeaderDataObj.put(lbl_Error_Segment,err_msg+" Status Code : "+http_Url_statusCode);
					}else
					{
						totalHeaderDataObj.put(lbl_Error_Segment,err_msg);
					}
					
				}
				else if(overallMsg.containsKey(USER_EXPERIENCE_STALLED))
				{
					totalHeaderDataObj.put(lbl_Stalled_Segment,(String) overallMsg.get(USER_EXPERIENCE_STALLED));
				}
				else if(overallMsg.containsKey(USER_EXPERIENCE_SLOW))
				{
					totalHeaderDataObj.put(lbl_Slow_Segment,(String) overallMsg.get(USER_EXPERIENCE_SLOW));
				}
				else
				{
					if(overAllExperience.equalsIgnoreCase(USER_EXPERIENCE_HEALTHY))
					{
						totalHeaderDataObj.put(lbl_Healthy_Segment,headerMessageHealthy);
					}
					else if(overAllExperience.equalsIgnoreCase(USER_EXPERIENCE_SLOW))
					{
						if((responseTime<firstNodeSlowThreshold) && overallAsyncPresence)
							totalHeaderDataObj.put(lbl_Slow_Segment,"The web request is healthy. However, the Async activity associated with this web request has exceeded the slow threshold.");
						else
							totalHeaderDataObj.put(lbl_Slow_Segment,"Total response time exceeded the slow threshold of "+firstNodeSlowThreshold+" ms (however, each individual component was within threshold)");
					}
					else if(overAllExperience.equalsIgnoreCase(USER_EXPERIENCE_STALLED))
					{
						if((responseTime<firstNodeStalledThreshold) && overallAsyncPresence)
							totalHeaderDataObj.put(lbl_Stalled_Segment,"The web request is healthy.However, the Async activity associated with this web request has exceeded the stalled threshold.");
						else
							totalHeaderDataObj.put(lbl_Stalled_Segment,"Total response time exceeded the stalled threshold of "+firstNodeStalledThreshold+" ms (however, each individual component was within threshold)");
					}
				}
			}
			headerBlockData.add(blockDataObj);
			JSONObject blockDataChartJson = nodeDataChartJsonBuild(monSkin,blockDataHolder,lbl_blockChart);
			tabBTMData.put(lbl_byTier,blockDataChartJson);
			totalHeaderDataObj.put(lbl_blocks,headerBlockData);
		}

		// code starts for removing the unconnected nodes in the topology - Now Alert window replaces this.
		boolean isPartialTopology = false;
		if(nodeDatas != null)
		{
			JSONObject nodeObj = (JSONObject) nodeDatas.get(0);
			if(nodeObj != null)
			{
				Iterator keys = nodeObj.keys();
				while( keys.hasNext() ) {
					int key = Integer.parseInt((String)keys.next());
					if(!targetHolder.contains(key))
					{
						isPartialTopology = true;
						break;
					}
				}
			}
		}
		rootJson.put(lbl_isPartialTopology,isPartialTopology);
		rootJson.put(lbl_txnSnapshotToShow,txnSnapshotToShow);
		if(isPartialTopology)
		{
			rootJson.put(lbl_incompleteDataText,incompleteDataText);
			rootJson.put("incompleteDataTextTitle","Incomplete Data");
			rootJson.put("incompleteDataDetails","This may be a partial topology because of incomplete data");
		}
		else if(overallAsyncPresence || overallUnknownNodePresence)
		{
			rootJson.put(lbl_incompleteDataText,"Note");
			

			/*if(overallAsyncPresence && overallUnknownNodePresence)
			{
				rootJson.put("incompleteDataTextTitle","When Processing time is too small:");
				rootJson.put("incompleteDataDetails","Some of the tiers involved may not be shown in the topology. <br><br> Processing time for some of the tiers may not be available. <br><br> Execution time shown in topology is an add up of Web and Thread Calls. Execution time for serial time is applicable only for Transaction snapshot, Tier Breakup and Server Breakup.");
			}*/
			if(overallUnknownNodePresence)
			{
				rootJson.put("incompleteDataTextTitle","When Processing time is too small:");
				rootJson.put("incompleteDataDetails","Some of the tiers involved may not be shown in the topology <br><br> Processing time for some of the tiers may not be available.");
			}
			else
			{
				rootJson.put("incompleteDataTextTitle","");
				rootJson.put("incompleteDataDetails","Execution time shown in topology is sum of Web and Thread Calls. Execution time for serial time is applicable only for Transaction snapshot, Tier Breakup and Server Breakup.");
			}
		}
		else
		{
			//rootJson.put(lbl_incompleteDataText,lbl_None);
			rootJson.put(lbl_incompleteDataText,"Note");

			rootJson.put("incompleteDataTextTitle","");
			rootJson.put("incompleteDataDetails","Request topology shown here is the representative of some of the tiers accessed by the request.");
		}
		if(isNegativeTimedisclaimerToShow)
		{
			rootJson.put("NegativeTimeInTopology","* Timing may not shown in all nodes , This is because timing is insignificant or could not be determined ... ");
		}else
		{
			rootJson.put("NegativeTimeInTopology","none");
		}
		// code starts for removing the unconnected nodes in the topology - Now Alert window replaces this.

		ArrayList nodesToRemove = new ArrayList();
		if(nodeDatas != null)
		{
			JSONObject nodeObj = (JSONObject) nodeDatas.get(0);
			if(nodeObj != null)
			{
				Iterator keys = nodeObj.keys();
				while( keys.hasNext() ) {
					String key = (String)keys.next();
					if(!connectionDetailsHolder.containsKey(Integer.parseInt(key)))
					{
						if(nodeObj.has(key))
						{
							nodesToRemove.add(key);
						}
					}
				}
			}
			for(int i=0;i<nodesToRemove.size();i++)
			{
				String key = (String) nodesToRemove.get(i);
				nodeObj.remove(key);
			}
		}
		// code ends for removing the unconnected nodes in the topology

		rootJson.put(lbl_nodes,nodeDatas);
		rootJson.put(lbl_links,linkDatas);

		totalHeaderDataArr.add(totalHeaderDataObj);
		rootJson.put(lbl_headerDetails,totalHeaderDataArr);

		JSONObject nodeDataChartJson = nodeDataChartJsonBuild(monSkin,nodeDataHolder,lbl_nodeChart);

		tabBTMData.put(lbl_byServer,nodeDataChartJson);
		tabBTMData.put(lbl_slowThreshold,firstNodeSlowThreshold+" "+lbl_milliseconds);
		tabBTMData.put(lbl_stalledThreshold,firstNodeStalledThreshold+" "+lbl_milliseconds);
		userexpTooltipBTMDatas.put(lbl_tabData,tabBTMData);
		// RUM data json object
		JSONObject userexpTooltipRUMDatas =  userRumJsonBuild(rumDataTable);
		// Final RUM and BTM Json data
		userexpTooltipDatas.put(lbl_headerText,userExpTooltipTitle + requestUrl);
		userexpTooltipDatas.put(lbl_tabRUM, userexpTooltipRUMDatas);
		userexpTooltipDatas.put(lbl_tabBTM, userexpTooltipBTMDatas);
		rootJson.put(lbl_userTooltip,userexpTooltipDatas);

		//return jsonHolder;
		return rootJson;
	}

	public ArrayList getBusinessTransactionEnabledServers(String testName)
	{
		ArrayList businessTransServerList = new ArrayList();
		EgDiscInfo disc=new EgDiscInfo("manager");
		EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
		String serverTypes[]=disc.getServerTypes();
		for(int k=0;k<serverTypes.length;k++)
		{
			String serverType = serverTypes[k];
			ArrayList result = apm.getAllApmTests();
			if(result != null && result.size()>0)
			{
				for(int i=0;i<result.size();i++)
				{
					String test = (String) result.get(i);
					boolean flag = specsInfo.isTestRelevantForServer(serverType,test);
					if(flag){
						businessTransServerList.add(serverType);
					}
				}
			}
		}
		return businessTransServerList;
	}

	// connection string data preparation for database
	private String getDBString(String dbServerType , String extHost , String extPort , String dbName,String allColumns)
	{
		String result = null;
		boolean found = false ;
		EgDiscInfo discInfo = new EgDiscInfo("manager");
		ArrayList dbServerList = null; 
		if(allColumns!=null && allColumns.length() > 0)
		{
			ArrayList allColumnList = StringUtils.egTokenizer(allColumns,",");
			if(allColumnList!=null && allColumnList.size() > 0 )
			{
				for(int i = 0 ; i < allColumnList.size() ; i++)
				{
					String serverType = (String)allColumnList.get(i);
					dbServerList = discInfo.getAllEntries(serverType);
					if(dbServerList != null || dbServerList.size() > 0)
					{
						result = getDBManagedComp(serverType,extHost,extPort,dbName,dbServerList);
						if(result!=null)
						{
							return BTMHelper.decodeUrlString(result);
						}
					}
				}
			}
		}
		dbServerList = discInfo.getAllEntries(dbServerType);
		if(dbServerList != null || dbServerList.size() > 0)
		{
			result = getDBManagedComp(dbServerType,extHost,extPort,dbName,dbServerList);
			if(result!=null)
			{
				return BTMHelper.decodeUrlString(result);
			}
		}
		if(result == null)
		{
				result = (dbServerType.equals("Redis_server") || dbServerType.equals("Mongo_server"))?"DATABASECALL-"+dbServerType + "*"+extHost+":"+extPort:"DATABASECALL-"+dbServerType + "*"+extHost+":"+extPort+"_"+dbName;
		}
		result =  BTMHelper.decodeUrlString(result);
		return result;
	}


	private String getDBManagedComp(String dbServerType , String extHost , String extPort , String dbName,ArrayList dbServerList)
	{
		String result = null ;
		for(int k=0;k<dbServerList.size();k++)
		{
			String line = (String) dbServerList.get(k);
			if(line.startsWith("#"))
				continue;
			String rhsPart = line.substring(line.indexOf("=")+1);
			StringTokenizer st = new StringTokenizer(rhsPart , ",");
			int count = st.countTokens();
			String compType = st.nextToken();
			String hostIp = st.nextToken();
			String nickName = st.nextToken();
			String portNo = st.nextToken();
			String isPassive = st.nextToken();
			String sid = null;
			if(count == 6){
				sid = st.nextToken();
			}
			boolean found = false;
			if(extHost.equalsIgnoreCase(hostIp) && extPort.equalsIgnoreCase(portNo))
			{
				if(sid!=null && sid.equalsIgnoreCase(dbName)){
					result = compType+"_M:"+nickName+":"+portNo+":"+dbName;
					found = true;
				}
				else{
					result = compType+"_M:"+nickName+":"+portNo;
					found = true;
				}
			}
			if(found) 
				break;
		}
		return result;
	}

	// connection string data preparation for SAP
	private String getSAPString(String ashost, String systemNo)
	{
		String result = "ABAP:"+ashost+":"+systemNo;
		ArrayList sapList = new ArrayList();
		EgDiscInfo discInfo = new EgDiscInfo("manager");
		ArrayList allManagedIp = discInfo.getAllManagedIps();
		
		Vector allManagedCompType = discInfo.getAllManagedComponents();
		for(int i=0;i<allManagedCompType.size();i++)
		{
			String temp = (String) allManagedCompType.get(i);
			
			if(temp.indexOf("SAP_R3_server") > -1 && temp.indexOf(ashost) > -1)
			{
				sapList.add(temp);
			}
		}
		if(sapList != null && sapList.size()>0)
		{
			EgAgentInfo agentInfo = new EgAgentInfo("manager");
			EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
			ArrayList enabledTests = specsInfo.getEnabledTests("SAP_R3_server",false);
			for(int i=0;i<enabledTests.size();i++)
			{
				String testName = (String) enabledTests.get(i);
				for(int j=0;j<sapList.size();j++)
				{
					String singleServerData = (String) sapList.get(j);
					StringTokenizer stk = new StringTokenizer(singleServerData, ",");
					stk.nextToken();
					stk.nextToken();
					String nick = stk.nextToken();
					String port = stk.nextToken();

					String var = testName+"::"+nick+":"+port;
					String value = agentInfo.getValueForVar(var);
					if(value != null && value.length()>0)
					{
						if(value.indexOf("-host "+ashost)>-1 && value.indexOf("-sysno "+systemNo)>-1)
						{
							result = "SAP_R3_server_M:"+nick+":"+port;
							break;
						}
					}
				}
			}
		}
		return result;
	}

	// connection string data preparation for HTTP and Webservice


	// Data preparation  for web and thread call seperately
	private Hashtable getStatisticsData(Hashtable externalDataTable , String egGuid , ArrayList webOrderList , ArrayList threadOrderList ,String keySep , String fieldSep, String testName)
	{
		Hashtable resultTable = new Hashtable();
		Hashtable webStatisticsTable = new Hashtable();
		Hashtable threadStatisticsTable = new Hashtable();
		boolean isOtherPointCut = false;

		for(int k=0;k<webOrderList.size();k++)
		{
			String webNodeOrder = (String) webOrderList.get(k);
			String keyString = egGuid+"#"+webNodeOrder+"#"+lbl_Web;
			Hashtable innerTable = (Hashtable) externalDataTable.get(keyString);
			if(innerTable == null)
				continue;

			Set nodeSet = innerTable.keySet();
			Iterator nodeItr = nodeSet.iterator();
			Hashtable innerStatTable = new Hashtable();
			while(nodeItr.hasNext())
			{
				String nodeId = (String) nodeItr.next();
				ArrayList nodeInfoList = (ArrayList) innerTable.get(nodeId);
				String methodType = (String) nodeInfoList.get(1);
				String childPointcut = apm.changeChildPointcutTime(methodType);
				if (childPointcut != null && childPointcut.length() > 0)
					methodType = childPointcut;
				isOtherPointCut = apm.isPointCutInIni(testName,methodType);
				
				boolean isJms = false;
				boolean isHttp = false;
				boolean isCustom = false;
				boolean isWebService = false;
				boolean isJmsEntry = false ;
				boolean isEHCache = false;

				if(methodType.equals(pointCutJMS)){
					isJms = true;
				}
				else if(methodType.equals(pointCutHTTP)){
					isHttp =true;
				}else if(methodType.equals(pointCutJmsEntry)){
					isJmsEntry =true;
				}
				else if(methodType.equals(pointCutWebService))
				{
					isWebService = true;
				}
				else if(methodType.startsWith(pointCutCustom))
				{
					isCustom = true;
				}else if(methodType.startsWith("EHCACHE"))
				{
					isEHCache = true;
				}
				String extHost = (String) nodeInfoList.get(2);
				String extPort = (String) nodeInfoList.get(3);
				String extInfo = (String) nodeInfoList.get(4);
				String extInstance = (String) nodeInfoList.get(5);

				StringBuffer keyBuffer = new StringBuffer();
				keyBuffer.append(methodType).append(keySep);
				keyBuffer.append(extHost).append(keySep);
				keyBuffer.append(extPort).append(keySep);
				keyBuffer.append(extInfo).append(keySep);
				if(isHttp || isWebService){
					
					String connectedNodeOrder = (String) nodeInfoList.get(9);
					keyBuffer.append(connectedNodeOrder).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(10)).append(keySep);
					keyBuffer.append(nodeId);
				}else if(isJms){
					String connectedNodeOrder = (String) nodeInfoList.get(9);
					keyBuffer.append(extInstance).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(8)).append(keySep);
					keyBuffer.append(connectedNodeOrder);
				}else if(isJmsEntry){
					keyBuffer.append(extInstance).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(8));

				}else if(isEHCache){
					String cacheMethod = (String) nodeInfoList.get(6);
					keyBuffer.append(cacheMethod);
				}
				else{
					keyBuffer.append(extInstance);
				}

				BigDecimal responseString = (BigDecimal) nodeInfoList.get(7);
				double response_double = responseString.doubleValue();

				/*if(isJms && false){
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}*/

				if(isCustom)
				{
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}
				else if(isOtherPointCut)
				{
					String extDetailsURL = (String) nodeInfoList.get(6);
					if (extDetailsURL.indexOf(':')>-1)
						extDetailsURL = extDetailsURL.substring(0,extDetailsURL.indexOf(":"));
					keyBuffer.append(keySep).append(extDetailsURL);
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}
				else if(methodType.startsWith(pointCutEJB))
				{
					String extDetailsURL = (String) nodeInfoList.get(6);
					keyBuffer.append(keySep).append(extDetailsURL);
				}

				String innerStatKey = keyBuffer.toString();

				if(innerStatTable.containsKey(innerStatKey)){
					Double oldValue = (Double) innerStatTable.get(innerStatKey);
					double old_value = oldValue.doubleValue();
					double new_value = old_value + response_double;
					innerStatTable.put(innerStatKey , new Double(new_value));
				}
				else{
					innerStatTable.put(innerStatKey , new Double(response_double));
				}
			}
			webStatisticsTable.put(keyString , innerStatTable);
		}

		for(int k=0;k<threadOrderList.size();k++)
		{
			String threadNodeOrder = (String) threadOrderList.get(k);
			String keyString = egGuid+"#"+threadNodeOrder+"#"+lbl_Thread;
			Hashtable innerTable = (Hashtable) externalDataTable.get(keyString);
			Hashtable httpConnectionNodeTable = new Hashtable();
			ArrayList httpNodeOrderList = new ArrayList();
			if(innerTable == null)
				continue;
			Set nodeSet = innerTable.keySet();
			Iterator nodeItr = nodeSet.iterator();
			Hashtable innerStatTable = new Hashtable();
			while(nodeItr.hasNext())
			{
				String nodeId = (String) nodeItr.next();
				ArrayList nodeInfoList = (ArrayList) innerTable.get(nodeId);
				String methodType = (String) nodeInfoList.get(1);
				String childPointcut = apm.changeChildPointcutTime(methodType);
				if (childPointcut != null && childPointcut.length() > 0)
					methodType = childPointcut;
				isOtherPointCut = apm.isPointCutInIni(testName,methodType);

				boolean isJms = false;
				boolean isHttp = false;
				boolean isCustom = false;
				boolean isWebService = false;
				boolean isJmsEntry = false ;
				boolean isEHCache = false;
				if(methodType.equals(pointCutJMS)){
					isJms = true;
				}else if(methodType.equals(pointCutJmsEntry)){
					isJmsEntry =true;
				}
				else if(methodType.equals(pointCutHTTP)){
					isHttp =true;
				}
				else if(methodType.equals(pointCutWebService))
				{
					isWebService = true;
				}
				else if(methodType.startsWith(pointCutCustom))
				{
					isCustom = true;
				}else if(methodType.startsWith("EHCACHE"))
				{
					isEHCache = true;
				}
				String extHost = (String) nodeInfoList.get(2);
				String extPort = (String) nodeInfoList.get(3);
				String extInfo = (String) nodeInfoList.get(4);
				String extInstance = (String) nodeInfoList.get(5);

				StringBuffer keyBuffer = new StringBuffer();
				keyBuffer.append(methodType).append(keySep);
				keyBuffer.append(extHost).append(keySep);
				keyBuffer.append(extPort).append(keySep);
				keyBuffer.append(extInfo).append(keySep);
				//keyBuffer.append(extInstance);
				if(isHttp || isWebService){
					String connectedNodeOrder = (String) nodeInfoList.get(9);
					keyBuffer.append(connectedNodeOrder).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(10)).append(keySep);
					keyBuffer.append(nodeId);
				}else if(isJms){
					String connectedNodeOrder = (String) nodeInfoList.get(9);
					keyBuffer.append(extInstance).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(8)).append(keySep);
					keyBuffer.append(connectedNodeOrder);
				}else if(isJmsEntry){
					keyBuffer.append(extInstance).append(keySep);
					keyBuffer.append((String) nodeInfoList.get(8));

				}else if(isEHCache){
					String cacheMethod = (String) nodeInfoList.get(6);
					keyBuffer.append(cacheMethod);
				}
				else{
					keyBuffer.append(extInstance);
				}

				BigDecimal responseString = (BigDecimal) nodeInfoList.get(7);
				double response_double = responseString.doubleValue();

				/*if(isJms){
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}*/

				if(isCustom)
				{
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}
				else if(isOtherPointCut)
				{
					String extDetailsURL = (String) nodeInfoList.get(6);
					if (extDetailsURL.indexOf(':')>-1)
						extDetailsURL = extDetailsURL.substring(0,extDetailsURL.indexOf(":"));
					keyBuffer.append(keySep).append(extDetailsURL);
					String extDetails = (String) nodeInfoList.get(8);
					keyBuffer.append(keySep).append(extDetails);
				}
				else if(methodType.startsWith(pointCutEJB))
				{
					String extDetailsURL = (String) nodeInfoList.get(6);
					keyBuffer.append(keySep).append(extDetailsURL);
				}

				String innerStatKey = keyBuffer.toString();

				if(innerStatTable.containsKey(innerStatKey)){
					Double oldValue = (Double) innerStatTable.get(innerStatKey);
					double old_value = oldValue.doubleValue();
					double new_value = old_value + response_double;
					innerStatTable.put(innerStatKey , new Double(new_value));
				}
				else{
					innerStatTable.put(innerStatKey , new Double(response_double));
				}
			}
			threadStatisticsTable.put(keyString , innerStatTable);
		}
		resultTable.put(lbl_Web,webStatisticsTable);
		resultTable.put(lbl_Thread,threadStatisticsTable);
		return resultTable;
	}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<!-- added -->
<!--link rel="stylesheet" href="/final/styles/jquery-ui.min.css"-->

<!-- added -->
<script>
	var isMyDashboard='<%=comesFrom%>';
	
	if(isMyDashboard!=null && isMyDashboard=="myDashboard")
	{
		var strSkin='<%=monitor_Skin%>';
		if(strSkin!=null && strSkin=='Dark')
		{
			document.write('<link rel="stylesheet" href="/final/resources/css/ext-eg.css"  media="all"/>');
			document.write('<link rel="stylesheet" href="/final/styles/eGDarkTheme.css" media="all" />');
			document.write('<link rel="stylesheet" href="/final/styles/eGDarkThemeIcons.css"  media="all" />');
		}
		else
		{
			document.write('<link rel="stylesheet" href="/final/resources/css/ext-eg.css"  media="all"/>');
			document.write('<link rel="stylesheet" href="/final/styles/eGLightTheme.css" media="all" />');
			document.write('<link rel="stylesheet" href="/final/styles/eGLightThemeIcons.css"  media="all" />');
		}
	}
	else
	{	
		document.write('<egui:skin ui="monitor"/>');
	}
</script>
<script type="text/javascript" src="/final/extjs/ext-all.js"></script>
<!--<script  src="/final/jquery/jquery.js"></script>-->
<!--Old Jquery refering in the name of highchart_export.js -->
<script language="JavaScript1.2" src="/final/jquery/highchart_export.js"></script>
<script language="JavaScript1.2" src="/final/Highcharts/js/highstock.js"></script>
<script type="text/javascript" src="/final/Highcharts/js/modules/exporting.js"></script>
<!-- d3 comes in -->
<script src="/final/jquery/jquery-ui.js"></script>
<script  src="/final/scripts/d3.min.js"></script>
<script  src="/final/scripts/dagre-d3.js"></script>

<!--<link rel="stylesheet" href="/final/styles/jquery.qtip.css">
<script  src="/final/scripts/jquery.qtip.js"></script>-->
<!--<script  src="/final/scripts/BTMTopology.js"></script>-->

<!--end d3 -->


<script>
	var comCatagoryArray = new Array();
	var icCatagoryArray = new Array();
	var isReporterRequest  = '<%=isReporterRequest%>';
	
</script>
<style>
.x-tip.yellowTip .x-tip-body, 
.x-tip.yellowTip .x-form-invalid-tip-body {
    word-break: break-all !important;
    white-space: nowrap !important;
}
.qtipwidth{width:auto !important}
</style>
<title></title>
</head>
<%
	try
	{
		String conPath = request.getContextPath();
		//String contextPath = request.getContextPath()+"/images/component_icons/";
		//String contextSkinPath = request.getContextPath()+"/images/"+monitor_Skin+"/";
		String skinBTM = monitor_Skin;
		String btmIconPath = request.getContextPath()+"/images/component_icons/"; 
		String contextPath = request.getContextPath()+"/images/"+monitor_Skin+"/component_icons/";
		String contextSkinPath = request.getContextPath()+"/images/"+monitor_Skin+"/";
		String serverImagePath = contextPath ;
		String ICImagePath	=	request.getContextPath()+"/images/"+monitor_Skin+"/ic_images/";
		String userImagePath = request.getContextPath()+"/images/"+monitor_Skin+"/component_icons/";
		//String groupImagePath = request.getContextPath()+"/images/"+monitor_Skin+"/component_icons/";
		String groupImagePath = request.getContextPath()+"/images/component_icons/";
		
		String bgColor = "";
		String animationLineColor="";
		String animationObjColor="";
		String timelineObjColor="";
		String compNameColor="";
		String fontFamily="LucidaGrandeRegular";
		String mouseOverTextColor="";
		IniFile egUi = new IniFile(EgInstallInfo.getInstallDir()+ "/manager/config/eg_ui.ini");
		String iniValue = egUi.getValue("TOPOLOGY_OPTIONS","Background");
		if(iniValue!=null && iniValue.equalsIgnoreCase("dark")){
			bgColor=egUi.getValue("TOPOLOGY_DARK_BACKGROUND","BgColor");
			//animationLineColor=egUi.getValue("TOPOLOGY_DARK_BACKGROUND","AnimationLineColor");
			animationLineColor="#aaaaaa";
			//animationObjColor=egUi.getValue("TOPOLOGY_DARK_BACKGROUND","AnimationObjColor");
			animationObjColor="#529ad1";
			timelineObjColor="#fff";
			compNameColor=egUi.getValue("TOPOLOGY_DARK_BACKGROUND","ComponentNameColor");
			mouseOverTextColor=egUi.getValue("TOPOLOGY_DARK_BACKGROUND","MouseOverTextColor");
		}
		else{
			bgColor=egUi.getValue("TOPOLOGY_LIGHT_BACKGROUND","BgColor");
			//animationLineColor=egUi.getValue("TOPOLOGY_LIGHT_BACKGROUND","AnimationLineColor");
			animationLineColor="#aaaaaa";
			timelineObjColor="#2a292a";
			//animationObjColor=egUi.getValue("TOPOLOGY_LIGHT_BACKGROUND","AnimationObjColor");
			animationObjColor="#2a292a";
			compNameColor=egUi.getValue("TOPOLOGY_LIGHT_BACKGROUND","ComponentNameColor");
			mouseOverTextColor=egUi.getValue("TOPOLOGY_LIGHT_BACKGROUND","MouseOverTextColor");
		}
%>
	<body  bgcolor="<%//=bgColor%>" onclick="topologyParentCall()" onload="topologyTitleChange()"> 
<%
		EgDiscInfo discInfo=new EgDiscInfo("manager");
		JSONObject jsonResult = new JSONObject();

		String egGuid = request.getParameter("EG_GUID");
		String userName="User";
		String testName = request.getParameter("testName");
		String fromNodeOrder = request.getParameter("fromNodeOrder");
		fromNodeOrder = StringUtils.decodeSecurityChar(fromNodeOrder);
		String overAllExperience = request.getParameter("overallExperience");
		String requestUrl = "";
		String fromNodeRequestUrl = "";
		String apmType = apm.getAPMType(testName);
		Hashtable jvmTimeList = new Hashtable() ; 
		//boolean isAPMJavaBasedTest = apm.isAPMTypeJava(testName);

		EgDbaseInfo egDbaseInfo = new EgDbaseInfo("manager");
		String btmExpQueryresult = BTMHelper.getBTMExpQuery(egGuid);
		ArrayList testDetailsForRequest = BTMHelper.getTestDetailsForRequest(btmExpQueryresult);
		ArrayList otherDetails = null;
		ArrayList testDetails = null;
		/* jmsConList will maintain JMS connection string . Using this will decide whether JMS present in database or not to swap the JMS Entry. */
		Set<String> jmsConList = new HashSet();
		if(testDetailsForRequest != null && testDetailsForRequest.size()>0)
		{
			otherDetails = (ArrayList) testDetailsForRequest.get(0);
			testDetails = (ArrayList) testDetailsForRequest.get(1);
			overAllExperience = (String) otherDetails.get(0);
		}
		request.getSession().setAttribute("enabledTests",testDetails);
		// This block is for adding business and Kbusiness test by default to solve upgrade issue.
		if(testDetails != null && testDetails.size() == 0)
		{
			if(egDbaseInfo.isTableExistInDB("BusinessTransTest_DDD"))
				testDetails.add("BusinessTransTest_DDD");

			if(egDbaseInfo.isTableExistInDB("KBusinessTransTest_DDD"))
				testDetails.add("KBusinessTransTest_DDD");
		}

		String query = BTMHelper.topologyQuery(egGuid, egDbaseInfo, testDetails);
		String extQuery = "select REQUEST_DATE, EG_GUID, REQUEST_TYPE, NODE_ORDER, DETAILS from EXTERNAL_SERVICE_DETAILS where EG_GUID = '"+egGuid+"'  ORDER BY NODE_ORDER asc";
		ArrayList transactionEnabledServers = getBusinessTransactionEnabledServers(testName);
		//System.out.println(" [eGBTMd3Topology.jsp] - query :"+query);
		//System.out.println(" [eGBTMd3Topology.jsp] - extQuery :"+extQuery);

		boolean foundBtmCallDetailsTable = egDbaseInfo.isDefaultTableExistInDB("BTM_SQL_DETAILS");
		boolean foundBtmHashDetailsTable = egDbaseInfo.isDefaultTableExistInDB("BTM_SQL_QUERIES");
		if(foundBtmCallDetailsTable && foundBtmHashDetailsTable) {
			StringBuilder builder = new StringBuilder();

			builder.append("select * from EXTERNAL_SERVICE_DETAILS A LEFT JOIN BTM_SQL_DETAILS B ON A.EXT_HASH = B.EXT_HASH LEFT JOIN BTM_SQL_QUERIES C ON B.QUERY_HASH = C.QUERY_HASH  where A.EG_GUID='");
			builder.append(egGuid).append("'");
			extQuery = builder.toString();
		}

		ArrayList requestDataList = BTMHelper.getRequestMapDetails(query, extQuery, egGuid, overAllExperience,transactionEnabledServers,discInfo);
		//System.out.println(" [eGBTMd3Topology.jsp] - requestDataList :"+requestDataList);
		//Hashtable externalDataTable = BTMHelper.getExternalDetails(extQuery);
		Hashtable externalDataTable = new Hashtable();
		Hashtable httpUrlStatusCodeTable = new Hashtable();
		Hashtable httpParentChildNodeMappingTable = new Hashtable();
		Hashtable urlMappingTable = new Hashtable() ;
		Hashtable nodeIdTable = new Hashtable() ;
		Hashtable conNodeTable = new Hashtable() ;
		Hashtable conTimeTable = new Hashtable() ;
		Hashtable httpNodeDetailsTable = new Hashtable() ;
		

		//RUM Query execution
		String rumQuery = "SELECT FRONT_END_TIME , RESPONSE_AVAILABLE_TIME , SERVER_CONNECTION_TIME , PAGE_LOAD_TIME , RUM_USER_EXP , DEVICE , BROWSER , COUNTRY , REGION , CITY , REQUEST_DATE , REQUEST_TIME_ZONE, SLOW_URL_THRESHOLD FROM RUM_DETAILS WHERE GUID ='"+egGuid+"'";
		
		//Hashtable rumDataTable = getRumMeasures(rumQuery);

		// RUM Details will be disabled
		Hashtable rumDataTable = new Hashtable();

		String userDeviceFromRUM = (String) rumDataTable.get("DEVICE");
		if(userDeviceFromRUM == null)
			userDeviceFromRUM = lbl_None;

		// Logic Begins
		ArrayList orderList = null;
		ArrayList webOrderList = null;
		ArrayList threadOrderList = null;
		if(requestDataList!=null && requestDataList.size() == 11)
		{
			orderList = (ArrayList) requestDataList.get(2);
			webOrderList = (ArrayList)orderList.get(0);
			threadOrderList = (ArrayList)orderList.get(1);
			externalDataTable = (Hashtable) requestDataList.get(5);
			urlMappingTable  = (Hashtable) requestDataList.get(6);
			nodeIdTable = (Hashtable) requestDataList.get(7);
			conNodeTable = (Hashtable) requestDataList.get(8);
			conTimeTable = (Hashtable) requestDataList.get(9);
			httpNodeDetailsTable = (Hashtable) requestDataList.get(10);

			/*System.out.println(" [eGBTMd3Topology.jsp] - orderList         :"+orderList);
			System.out.println(" [eGBTMd3Topology.jsp] - webOrderList      :"+webOrderList);
			System.out.println(" [eGBTMd3Topology.jsp] - threadOrderList   :"+threadOrderList);
			System.out.println(" [eGBTMd3Topology.jsp] - externalDataTable :"+externalDataTable);
			System.out.println(" [eGBTMd3Topology.jsp] - urlMappingTable   :"+urlMappingTable);
			System.out.println(" [eGBTMd3Topology.jsp] - nodeIdTable       :"+nodeIdTable);
			System.out.println(" [eGBTMd3Topology.jsp] - conNodeTable      :"+conNodeTable);
			System.out.println(" [eGBTMd3Topology.jsp] - conTimeTable      :"+conTimeTable);
			System.out.println(" [eGBTMd3Topology.jsp] - httpNodeDetailsTable :"+httpNodeDetailsTable);*/
		}

		Hashtable jmsTable = new Hashtable();
		for(int i=0 ; i < orderList.size() ; i++)
		{
			ArrayList al = (ArrayList)orderList.get(i);
			for(int k=0 ; k< al.size() ; k++)
			{
				String input = (String)al.get(k);
				if(input.lastIndexOf("[")>-1){
					String  orgNodeOrder= input.substring(0,input.lastIndexOf("[")-1);
					if(jmsTable.containsKey(orgNodeOrder))
					{
						ArrayList al1 = (ArrayList)jmsTable.get(orgNodeOrder);
						al1.add(input);
						jmsTable.put(orgNodeOrder, al1);
					}else{
						ArrayList a = new ArrayList();
						a.add(input);
						jmsTable.put(orgNodeOrder,a );
					}
				}
			}
		}

		boolean isAsyncPresent = false;
		if(threadOrderList!=null && threadOrderList.size() > 0)
			isAsyncPresent = true;

		boolean isWebOrderListEmpty = false;
		if(webOrderList!=null && webOrderList.size() > 0)
			isWebOrderListEmpty = false;
		else
			isWebOrderListEmpty = true;

		String keySep ="~*~";
		String fieldSep = "~!~";
		Hashtable statisticsTable = getStatisticsData(externalDataTable , egGuid , webOrderList , threadOrderList , keySep ,fieldSep, testName);
		//System.out.println(" [eGBTMd3Topology.jsp] - statisticsTable :"+statisticsTable);
		ArrayList positionHelperList = new ArrayList();
		ArrayList completeList = new ArrayList();
		Hashtable stateAndMappingName = new Hashtable();
		//String measureName = null;
		String transName = null;
		String requestTime = null;
		String fromNodeRequestTime = "-";
		//String nodeOrderString=null;
		double responseTime = -1.0D;
		String managerTimeFormat = null;
		String fromNodeTimeFormat = "-";
		String targetServerTimeZone = null;
		String fromNodeTargetServerTimeZone = "-";
		//String overAllExperience = null;
		String fromNodeCompNamePort = "-";

		ArrayList nodeList4d3  = new ArrayList();
		Hashtable nodeConnectionsMappingTable = new Hashtable();
		
		if(requestDataList!=null && requestDataList.size() == 11)
		{
			Hashtable requestTable = (Hashtable)requestDataList.get(0);
			Hashtable guidNodeHostTable = (Hashtable)requestDataList.get(1);
			Hashtable asyncGuidTable = (Hashtable)requestDataList.get(3);

			//System.out.println(" [eGBTMd3Topology.jsp] - requestTable      :"+requestTable);
			//System.out.println(" [eGBTMd3Topology.jsp] - guidNodeHostTable :"+guidNodeHostTable);
			//System.out.println(" [eGBTMd3Topology.jsp] - asyncGuidTable    :"+asyncGuidTable);

			//overAllExperience = (String) requestDataList.get(4);
			if(overAllExperience != null)
			{
				if(overAllExperience.equals("Error"))
					overAllExperience = mappingInfo.getTextDescription("monitor.apmtopology.Error");
				else if(overAllExperience.equals("Stalled"))
					overAllExperience = mappingInfo.getTextDescription("monitor.apmtopology.Stalled");
				else if(overAllExperience.equals("Slow"))
					overAllExperience = mappingInfo.getTextDescription("monitor.apmtopology.Slow");
				else if(overAllExperience.equals("Healthy"))
					overAllExperience = mappingInfo.getTextDescription("monitor.apmtopology.Healthy");
			}

			Hashtable webStatistics = (Hashtable) statisticsTable.get(lbl_Web);
			Hashtable threadStatistics = (Hashtable) statisticsTable.get(lbl_Thread);
			Hashtable webNodeAsyncSummary =  new Hashtable();
			Hashtable asyncResposeTimeTable = new Hashtable(); 
			if(isAsyncPresent)
			{
				
				Hashtable webAsyncTable = new Hashtable();
				// Match Async - Web
				if(isWebOrderListEmpty){
					webAsyncTable.put("1" , threadOrderList); // All thread details belongs to Root
				}
				else
				{
					for(int y=0;y<threadOrderList.size();y++)
					{
						String threadNodeOrder = (String) threadOrderList.get(y);
						int lastAIndex = threadNodeOrder.lastIndexOf(".A");
						if(lastAIndex > 0)
						{
							String webNodeString = threadNodeOrder.substring(0, lastAIndex);
							if(webAsyncTable.containsKey(webNodeString)){
								ArrayList asynNodeList = (ArrayList) webAsyncTable.get(webNodeString);
								asynNodeList.add(threadNodeOrder);
								webAsyncTable.put(webNodeString , asynNodeList);
							}
							else
							{
								ArrayList asynNodeList = new ArrayList();
								asynNodeList.add(threadNodeOrder);
								webAsyncTable.put(webNodeString , asynNodeList);
							}
						}
					}
				}

				Set webAsyncSet = webAsyncTable.keySet();
				Iterator webAsyncItr = webAsyncSet.iterator();
				while(webAsyncItr.hasNext())
				{
					Hashtable sumTable = new Hashtable();
					String webAsyncKey = (String) webAsyncItr.next();
					ArrayList threadNodeOrderList = (ArrayList) webAsyncTable.get(webAsyncKey);
					double asyncTotalResponseTime = 0.0D;
					for(int y=0;y<threadNodeOrderList.size();y++)
					{
						String threadNodeOrder = (String) threadNodeOrderList.get(y);
						String keyString =  egGuid+"#"+threadNodeOrder+"#"+lbl_Thread;
						Hashtable innerHash = (Hashtable) threadStatistics.get(keyString);
						if(innerHash != null)
						{
							Set innerSet = innerHash.keySet();
							Iterator innerItr = innerSet.iterator();
							while(innerItr.hasNext())
							{
								String innerKey = (String) innerItr.next();
								Double innerValue = (Double) innerHash.get(innerKey);
								if(sumTable.containsKey(innerKey))
								{
									Double doubleObj = (Double) sumTable.get(innerKey);
									double doubleVal = doubleObj.doubleValue();
									doubleVal += innerValue.doubleValue();
									sumTable.put(innerKey , new Double(doubleVal));
								}
								else
								{
									sumTable.put(innerKey , innerValue);
								}
							}
						}
						// asyncResposeTimeTable Calculation
						String thirdTableKey = egGuid+"#"+threadNodeOrder;
						ArrayList thirdArrayList = (ArrayList) requestTable.get(thirdTableKey);
						if(thirdArrayList!=null && thirdArrayList.size() > 0){
							BigDecimal asyResTime = (BigDecimal)thirdArrayList.get(11);
							if(asyResTime!=null){
								double asyResTimedouble = asyResTime.doubleValue();
								asyncTotalResponseTime = asyncTotalResponseTime + asyResTimedouble;
							}
						}
					}
					webNodeAsyncSummary.put(webAsyncKey , sumTable);
					asyncResposeTimeTable.put(webAsyncKey , new Double(asyncTotalResponseTime));
				}
			}

			String uiFile = "eg_ui.ini";
			String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
			IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
			String currentDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");

			StringBuffer nodeOrderBuffer = new StringBuffer();

			if(requestTable!=null){
				String rootGuidKey = egGuid+"#1";
				ArrayList dataList = (ArrayList) requestTable.get(rootGuidKey);

				if(dataList == null)
				{
		%>
					<div class="clr" style="border:0px solid red;height:400px">
						<table height="100%" width="100%" border="0" class="white_bg">
							<tr>
								<td align="center" valign="middle" class="commonErrorMsgText" > 
									<img src="/final/images/clear.png" align="center" border="0" class="iconInformation"/><br>
									<egui:intnl text='monitor.layermodel.No sufficient data found in the database for this transaction!'/>
								</td>
							</tr>
						</table>
					</div>
		<%
					return;
				}

				transName = (String) dataList.get(4); 
				if(transName!=null && transName.startsWith("+"))
					transName = transName.substring(1);

				Object reqTime = dataList.get(7);
				requestTime = reqTime.toString();
				BigDecimal responseTimeObj = (BigDecimal)dataList.get(11);
				responseTime = responseTimeObj.doubleValue();
				targetServerTimeZone = (String) dataList.get(8);
				requestUrl= (String) dataList.get(9);
				String entryNodeGuidKey = egGuid+"#"+fromNodeOrder;
				ArrayList fromNodeDataList = (ArrayList) requestTable.get(entryNodeGuidKey);
				if(fromNodeDataList != null)
				{
					fromNodeCompNamePort = fromNodeDataList.get(0)+":"+fromNodeDataList.get(1);
					fromNodeTargetServerTimeZone = (String) fromNodeDataList.get(8);
					fromNodeRequestUrl= (String) fromNodeDataList.get(9);
					fromNodeRequestTime = (fromNodeDataList.get(7)).toString();
				}
			}
			managerTimeFormat = DateUtil.changeDateFormat(requestTime,"yyyy-MM-dd HH:mm:ss",currentDateFormat+" HH:mm:ss") +" "+targetServerTimeZone;
			fromNodeTimeFormat = DateUtil.changeDateFormat(fromNodeRequestTime,"yyyy-MM-dd HH:mm:ss",currentDateFormat+" HH:mm:ss") +" "+fromNodeTargetServerTimeZone;
			Hashtable connMapOrderToNick = new Hashtable();
			Hashtable connMapNickToOrder = new Hashtable();
			Hashtable rearrangeHt = new Hashtable();
			Hashtable callCounterHolder = new Hashtable();

			StringBuffer timeString = new StringBuffer();
			
			//----------- Used For Other PC Calls Count-start-----------
			Hashtable webTempCallCount = new Hashtable();
			//----------- Used For Other PC Calls Count - end-----------

			// Json Data for USER node 
			

			// For async calls
			/*if(isWebOrderListEmpty)
			{
				System.out.println("isWebOrderListEmpty ..... "+isWebOrderListEmpty);
				HashMap jsonMap = new HashMap();
				String keyName = egGuid+"#1";
				ArrayList hostPortList = (ArrayList) guidNodeHostTable.get(keyName);
				ArrayList dataList = (ArrayList) requestTable.get(keyName);
				String trgtHost = (String) hostPortList.get(0);
				String portNo = (String) hostPortList.get(1);
				String jvmComp = trgtHost+":"+portNo;
				String compType=discInfo.getServerTypesForComponentNamePort(jvmComp);
				String compDisplayName = mappingInfo.getComponentTypeDescription(compType);
				String fullName = compType+":"+jvmComp;
				String jvmCompState = dataList.get(2).toString();
				if(jvmCompState.equals(slow_Urls_Count))
					jvmCompState = USER_EXPERIENCE_SLOW;
				else if(jvmCompState.equals(error_Urls_Count))
					jvmCompState = USER_EXPERIENCE_ERROR;
				else if(jvmCompState.equals(healthy_Urls_Count))
					jvmCompState = USER_EXPERIENCE_HEALTHY;
				else if(jvmCompState.equals(stalled_Urls_Count))
					jvmCompState = USER_EXPERIENCE_STALLED;

				jsonMap.put(lbl_serverType,egCompCategory.getCategoryforCompType(compType));
				//jsonMap.put(lbl_serverType,imgJavaServers);
				jsonMap.put(lbl_displayName,compDisplayName);
				jsonMap.put(lbl_compName,jvmComp);
				jsonMap.put(lbl_drillDownImg, jvmCompState);
				jsonMap.put(lbl_isStartJvm, lbl_stringTrue);
				jsonMap.put(lbl_lineValue, "");

				nodeOrderBuffer.append(fullName).append("#1").append("!*!");
				stateAndMappingName.put(fullName, jvmCompState+"#"+compDisplayName);
				StringBuffer jvmDataBuffer = new StringBuffer();
				jvmDataBuffer.append("{"+scaleDecimalFormat.format(responseTime) +" "+lbl_milliseconds+" ("+percentFormat.format(100.0)+" %)" );
				if(isAsyncPresent){
					jsonMap.put(lbl_isAsync, lbl_stringTrue);
					Double asyncResTime = (Double) asyncResposeTimeTable.get("1");
					jvmDataBuffer.append(" \\n "+scaleDecimalFormat.format(asyncResTime)+" "+lbl_milliseconds+" (async)").append(" } ");

					ArrayList nodeDataList = new ArrayList();
					nodeDataList.add(scaleDecimalFormat.format(asyncResTime));
					jsonMap.put(lbl_nodeValue, nodeDataList);

					Hashtable asyncExternalTable = (Hashtable) webNodeAsyncSummary.get("1");

					StringBuffer rhsBuffer = new StringBuffer();
					StringBuffer helperBuffer = new StringBuffer();
					HashMap asyncLineData = new HashMap();
					if(asyncExternalTable!=null && asyncExternalTable.size() > 0)
					{
						Set extKeys = asyncExternalTable.keySet();
						Iterator extItr = extKeys.iterator();
						while(extItr.hasNext())
						{
							String extKey = (String) extItr.next();

							Double resposeTimeObj = (Double) asyncExternalTable.get(extKey);
							double response_double = resposeTimeObj.doubleValue();

							ArrayList extList = StringUtils.egTokenizer(extKey,keySep);
							String methodType = (String) extList.get(0);
							String extHost = (String) extList.get(1);
							String extPort = (String) extList.get(2);
							String dataString = "["+methodType+"\\t"+scaleDecimalFormat.format(response_double) +" "+lbl_milliseconds+" (async)"+"]";

							ArrayList asyncDataList = new ArrayList();
							asyncDataList.add(methodType);
							asyncDataList.add(scaleDecimalFormat.format(response_double));

							if(methodType.equals(pointCutHTTP) || methodType.equals(pointCutWebService))
							{
								//Check for HTTP Host & port is managed in eG Manager
								//System.out.println("___________ >>> [ BTMTopo ] - http : "+extList);
								String extUrl = (String) extList.get(3);
								String extSchema = extUrl.substring(0,extUrl.indexOf("://")+3);
								String connectedNodeOrder = (String) extList.get(4);
								String connString = getHttpOrWebServiceString(transactionEnabledServers , extHost , extPort , methodType, extSchema, connectedNodeOrder, guidNodeHostTable, egGuid);
								//String connString = getHttpOrWebServiceString(transactionEnabledServers , extHost , extPort , methodType, extSchema);
								//String connString = getHttpOrWebServiceString(transactionEnabledServers , extHost , extPort , methodType);
								if(connString.endsWith("#"))	// ends with "#" means , comp. is managed in eG Manager
								{
									String managedCompType = connString.substring(0,connString.indexOf(":"));
									connString = connString.substring(0,connString.lastIndexOf("#"));
									String nickWithPort = connString.substring(connString.indexOf(":")+1);
								}
								rhsBuffer.append(connString).append(dataString).append(fieldSep);
								helperBuffer.append(connString).append(fieldSep);
								asyncLineData.put(connString , asyncDataList);
							}
							else if(methodType.equals(pointCutSQL))
							{
								String dbServerType = (String) extList.get(3);
								String dbName = (String) extList.get(4);
								// Check for DB Server is Managed or Not in eG Manager
								String connString = getDBString(dbServerType , extHost , extPort , dbName);

								String dbTypeString = connString.substring(0,connString.indexOf(":"));
								if(dbTypeString.endsWith("_M"))	// ends with "#" means , comp. is managed in eG Manager
								{
									String managedDBType = dbTypeString.substring(0,dbTypeString.indexOf("_M"));
									String nickWithPort = connString.substring(connString.indexOf(":")+1);
								}
								rhsBuffer.append(connString).append(dataString).append(fieldSep);
								helperBuffer.append(connString).append(fieldSep);
								asyncLineData.put(connString , asyncDataList);
							}
							else if(methodType.equals(pointCutJMS))
							{
								String jmsProvider = (String) extList.get(3);
								String queueOrTopic = (String) extList.get(4);
								//String detailsString = (String) extList.get(5);
								//String connString = jmsProvider + "::"+queueOrTopic+"::"+detailsString;
								String connString = jmsProvider + "::"+queueOrTopic;
								rhsBuffer.append(connString).append(dataString).append(fieldSep);
								helperBuffer.append(connString).append(fieldSep);
								asyncLineData.put(connString , asyncDataList);
							}
							else if(methodType.equals(pointCutSAP))
							{
								String ashost = (String) extList.get(1);
								String idWithNo = (String) extList.get(2);
								String systemId = idWithNo.substring(0, idWithNo.indexOf("#"));
								String connString = getSAPString(ashost,systemId);
								rhsBuffer.append(connString).append(dataString).append(fieldSep);
								helperBuffer.append(connString).append(fieldSep);
								asyncLineData.put(connString , asyncDataList);
							}
							else if(methodType.startsWith(pointCutCustom))
							{
								//System.out.println("CUSTOM POINT CUT ELSE IF..."+extList);
								String customPointCutName = (String) extList.get(0);
								String customPointCutString = (String) extList.get(5);
								String connString = customPointCutName + ":" + customPointCutString;
								//System.out.println("[getCustomString] "+pointCutCustom+" >> "+lineDataList);
								
								asyncLineData.put(connString , asyncDataList);
							}
						}
					}
					jsonMap.put(lbl_asyncValue, asyncLineData);

					if(rhsBuffer!=null && rhsBuffer.length() > 0)
					{
						String rhsLine = rhsBuffer.toString();
						if(rhsLine.endsWith(fieldSep))
							rhsLine = rhsLine.substring(0,rhsLine.length() - 3);
						String completeLine = fullName+jvmDataBuffer.toString()+"<==>"+rhsLine;
						completeList.add(completeLine);
					}
					else{
						String completeLine = fullName+jvmDataBuffer.toString();
						completeList.add(completeLine);
					}

					if(helperBuffer!=null && helperBuffer.length() > 0)
					{
						String rhsLine = helperBuffer.toString();
						if(rhsLine.endsWith(fieldSep))
							rhsLine = rhsLine.substring(0,rhsLine.length() - 3);
						positionHelperList.add(fullName+"<==>"+rhsLine);
					}
					else{
						positionHelperList.add(fullName);
					}
				}
				else
				{
					jsonMap.put(lbl_isAsync, lbl_stringFalse);
					jvmDataBuffer.append(" } ");
					String completeLine = fullName+jvmDataBuffer.toString();
					completeList.add(completeLine);
					positionHelperList.add(fullName);

					ArrayList nodeDataList = new ArrayList();
					nodeDataList.add(scaleDecimalFormat.format(responseTime));
					nodeDataList.add(percentFormat.format(100.0));

					jsonMap.put(lbl_nodeValue, nodeDataList);
				}
			}
			else*/
			//{
				//rootJvmResponseTime Calculation - Used for % calculation
				ArrayList rootJvmSummaryList = (ArrayList) requestTable.get(egGuid+"#1");
				BigDecimal rootJvmRes = (BigDecimal)rootJvmSummaryList.get(11);
				double rootJvmTotalResponseTime = rootJvmRes.doubleValue();

				for(int j=0;j<orderList.size();j++)
				{
					ArrayList reqList = (ArrayList) orderList.get(j);
					for(int k=0;k<reqList.size();k++)
					{
						String webThreadNodeOrder = (String) reqList.get(k);
						String keyName = egGuid+"#"+webThreadNodeOrder;
						ArrayList dataList = (ArrayList) requestTable.get(keyName);
						if(dataList!=null && dataList.size()>=31 && webThreadNodeOrder.equals("1"))
						{
							String tmpUsrName =dataList.get(30).toString();
							if(!tmpUsrName.equals("-")){
								userName = tmpUsrName;
							}
						}
						ArrayList hostPortList = (ArrayList) guidNodeHostTable.get(keyName);
						if(hostPortList!=null && hostPortList.size() != 2)
							continue;

						String trgtHost = (String) hostPortList.get(0);
						String portNo = (String) hostPortList.get(1);

						HashMap jsonMap = new HashMap();
						if(j == 0)
						{
							jsonMap.put("requestType","Web");

							if(webThreadNodeOrder.equals(fromNodeOrder))
								jsonMap.put(lbl_highlight,lbl_stringTrue);
							else
								jsonMap.put(lbl_highlight,lbl_stringFalse);
						}
						else
						{
							jsonMap.put("requestType","Thread");

							String parentThread = getParentFromThreadNodeOrder(webThreadNodeOrder);

							if(parentThread.equals(fromNodeOrder))
								jsonMap.put(lbl_highlight,lbl_stringTrue);
							else
								jsonMap.put(lbl_highlight,lbl_stringFalse);
						}

						

						String reqTime = dataList.get(7).toString();
						String zone = (String)dataList.get(8);
						jsonMap.put(lbl_requestTime,DateUtil.changeDateFormat(reqTime,"yyyy-MM-dd HH:mm:ss",currentDateFormat+" HH:mm:ss") +" "+zone);

						BigDecimal totalRes = (BigDecimal)dataList.get(11);
						double totalResponseTime = totalRes.doubleValue();
						jsonMap.put("totalResponseTime",scaleDecimalFormat.format(totalResponseTime));

						String jvmComp = trgtHost+":"+portNo;
						String compType=discInfo.getServerTypesForComponentNamePort(jvmComp);
						String compDisplayName = mappingInfo.getComponentTypeDescription(compType);
						
						if(trgtHost.indexOf("UNKNOWN_NODE")>-1)
						{
							compDisplayName = "";
							jsonMap.put(lbl_serverType,imgJavaServers);
						}
						else
						{
							String iconName = apm.getIcon(compType);
							if(iconName == null || iconName.trim().length() == 0){
								iconName = egCompCategory.getCategoryforCompType(compType);
							}
							jsonMap.put(lbl_serverType,iconName);
						}

						String fullName = compType+":"+jvmComp;
						//jsonMap.put(lbl_serverType,egCompCategory.getCategoryforCompType(compType));
						//jsonMap.put(lbl_serverType,imgJavaServers);
						jsonMap.put(lbl_displayName,compDisplayName);
						jsonMap.put(lbl_compName,jvmComp);

						BigDecimal thisThreshold = (BigDecimal)dataList.get(23);
						//int thisThreshInt = Integer.valueOf(thisThreshold.intValue());
						long thisThreshInt =thisThreshold.longValue();
						jsonMap.put(lbl_compThreshold,thisThreshInt);

						BigDecimal thisStalledThreshold = (BigDecimal)dataList.get(24);
						//int thisStalledThreshInt = Integer.valueOf(thisStalledThreshold.intValue());
						long thisStalledThreshInt =thisStalledThreshold.longValue();
						jsonMap.put(lbl_stalledThreshold,thisStalledThreshInt);

						String nodeTestName = (String) dataList.get(26);
						jsonMap.put("nodeType",apm.getAPMType(nodeTestName));

						String jvmCompState = dataList.get(2).toString();
						if(jvmCompState.equals(slow_Urls_Count))
							jvmCompState = USER_EXPERIENCE_SLOW;
						else if(jvmCompState.equals(error_Urls_Count))
							jvmCompState = USER_EXPERIENCE_ERROR;
						else if(jvmCompState.equals(healthy_Urls_Count))
							jvmCompState = USER_EXPERIENCE_HEALTHY;
						else if(jvmCompState.equals(stalled_Urls_Count))
							jvmCompState = USER_EXPERIENCE_STALLED;
						
						jsonMap.put(lbl_drillDownImg, jvmCompState);

						int dotIndex = webThreadNodeOrder.lastIndexOf(".");
						if(dotIndex < 0){
							jsonMap.put(lbl_isStartJvm, lbl_stringTrue);
							jsonMap.put(lbl_parentNode,"This Node");
						}
						else{
							jsonMap.put(lbl_isStartJvm, lbl_stringFalse);
							String parent = webThreadNodeOrder.substring(0, dotIndex); 
							if(j == 1){
								parent = webThreadNodeOrder;
							}
							else{
								int errorPageIndex = parent.indexOf(".E");
								if(errorPageIndex > 0){
									parent = parent.substring(0,errorPageIndex);
								}
								else {
									if(webThreadNodeOrder.endsWith("]")){
										// It is JMS_Entry, So Parent should be "This Node".
										parent = webThreadNodeOrder;
									}
								}
							}

							String keyString = egGuid+"#"+parent;
							ArrayList nickPort = (ArrayList) guidNodeHostTable.get(keyString);
							jsonMap.put(lbl_parentNode,"-");
							if(nickPort != null && nickPort.size()>0){
								String nickString = (String) nickPort.get(0)+":"+(String) nickPort.get(1);
								String resultString = jvmComp.equals(nickString) ? "This Node" : nickString;
								jsonMap.put(lbl_parentNode,resultString);
							}
						}

						/*
							Node Order contains special symbol . Tomcat rejects the special symbols in query param So we have to encode the value to provide in query string 
						*/
						String tmpNodeOrder = StringUtils.encodeSecurityChar(webThreadNodeOrder); 
						tmpNodeOrder = BTMHelper.getEncodedURI(tmpNodeOrder);
						// Add code for Creating Link
						String urlToGo =  "eGBTMBase.jsp?EG_GUID="+egGuid+"&TRGT_HOST="+trgtHost+"&PORT_NO="+portNo+"&nodeOrder="+tmpNodeOrder+"&testName="+nodeTestName+"&overallExperience="+overAllExperience+"&isReporterRequest="+isReporterRequest;
						String temp = keyName+","+urlToGo;
						List userCompDetails = (List) u_ser.getServers(true);
						if(trgtHost.indexOf("UNKNOWN_NODE")>-1)
						{
							jsonMap.put(lbl_drillDownGuid, egGuid);
							jsonMap.put(lbl_drillDownNodeOrder, webThreadNodeOrder);
							jsonMap.put(lbl_drillDownUrlToGo, lbl_None);
						}
						else
						{
							// Preventing drilldown when transaction time is 0 ms
							if(totalResponseTime > 0)
							{
								jsonMap.put(lbl_drillDownGuid, egGuid);
								jsonMap.put(lbl_drillDownNodeOrder, webThreadNodeOrder);
								jsonMap.put(lbl_drillDownUrlToGo, urlToGo);
							}
							else
							{
								jsonMap.put(lbl_drillDownGuid, lbl_None);
								jsonMap.put(lbl_drillDownNodeOrder, lbl_None);
								jsonMap.put(lbl_drillDownUrlToGo, lbl_None);
							}
						}

						// Code end for  Creating Link
						nodeOrderBuffer.append(fullName).append("#").append(webThreadNodeOrder).append("!*!");
						stateAndMappingName.put(fullName, jvmCompState+"#"+compDisplayName);


						// code for Calls counts here 
						Hashtable callCounter = new Hashtable();
						Hashtable allExtCallsFromThisNode = new Hashtable();
						if(j == 0){
							allExtCallsFromThisNode = (Hashtable) externalDataTable.get(keyName+"#"+lbl_Web);
						}
						else{
							allExtCallsFromThisNode = (Hashtable) externalDataTable.get(keyName+"#"+lbl_Thread);
						}

						if(allExtCallsFromThisNode != null && allExtCallsFromThisNode.size()>0)
						{
							Set thisNodeExtCallsNodeOrders = allExtCallsFromThisNode.keySet();
							Iterator extCallsCountItr = thisNodeExtCallsNodeOrders.iterator();
							int dataCount = 1;
							while(extCallsCountItr.hasNext())
							{
								int redisQueryCount = 0 ;
								String extCallNodeKey = (String) extCallsCountItr.next();
								ArrayList callDetails = (ArrayList) allExtCallsFromThisNode.get(extCallNodeKey);
								String callType = (String) callDetails.get(1);
								String toComp = callDetails.get(2)+":"+callDetails.get(3);
								if(callType.equals(pointCutHTTP) || callType.equals(pointCutWebService))
								{
									String extHost = (String)callDetails.get(2);
									String extUrl = (String) callDetails.get(4);
									String extPort = (String)callDetails.get(3);
									String extSchema = extUrl.substring(0,extUrl.indexOf("://")+3);
									String connectedNodeOrder = (String) callDetails.get(9);
									String tmp = getUnKnownDetails(guidNodeHostTable,egGuid,connectedNodeOrder,discInfo);
									if( tmp!=null && (extHost.indexOf("UNKNOWN_NODE")>-1 || tmp.indexOf("UNKNOWN_NODE")>-1))
									{
											toComp = tmp; 
									}else
									{
											toComp = (String)urlMappingTable.get(callType+"-"+extUrl);
									}
									if(toComp == null)
									{
										toComp = callType+"-"+extSchema+""+extHost+":"+extPort;
									}
									if(toComp.endsWith("#"))	// ends with "#" means , comp. is managed in eG Manager
									{
										toComp = toComp.substring(toComp.indexOf("_M:")+3,toComp.lastIndexOf("#"));
									}
								}
								else if(callType.equals(pointCutSQL))
								{
									String dbtype = (String)callDetails.get(4);
									String extHost = (String)callDetails.get(2);
									String extPort = (String)callDetails.get(3);
									String dbName = (String)callDetails.get(5);
									dbName = dbName.equals("-") ? "" : dbName ; 
									if(extHost.startsWith("jdbc:")){
										toComp = dbtype.equals("UNKNOWN") ? "DATABASECALL-"+extHost : "DATABASECALL-"+dbtype + "*"+extHost;
									}
									else 
									{
										if(extHost.indexOf(",") > 0){
											ArrayList RACIpPortList = StringUtils.egTokenizer(extHost,",");
											String allColumnString = apm.getValue("CLUSTER_DB",dbtype);
											toComp = getDBString(dbtype , RACIpPortList, extHost, dbName , allColumnString,discInfo);
										}
										else{
											String allColumnString = apm.getValue("DB_MAPPINGS",dbtype);
											toComp = getDBString(dbtype , extHost , extPort , dbName,allColumnString);
										}
										if(!toComp.startsWith("DATABASECALL-") && toComp.indexOf("_M:")>-1)
											toComp = toComp.substring(toComp.indexOf("_M:")+3);
									}
								}else if(callType.equals(pointCutREDIS))
								{
									
									String extHost = (String)callDetails.get(2);
									String extPort = (String)callDetails.get(3);
									String dbtype = (String)callDetails.get(4);
									String dbName = (String)callDetails.get(5);
									String dataString = (String)callDetails.get(6);
									ArrayList valueTokens = StringUtils.egTokenizer(dataString,"[C]");
									 
									for(int i = 0 ; i < valueTokens.size() ; i += 2)
									{
										String tmpCommand = (String)valueTokens.get(i+1);
										ArrayList tmpTokens = StringUtils.egTokenizer(tmpCommand,",");
										redisQueryCount= redisQueryCount + tmpTokens.size();
									}
									String allColumnString = apm.getValue("DB_MAPPINGS",dbtype);
									toComp = getDBString(dbtype , extHost , extPort , dbName,allColumnString);
					
									if(!toComp.startsWith("DATABASECALL-") && toComp.indexOf("_M:")>-1)
											toComp = toComp.substring(toComp.indexOf("_M:")+3);
								}
								else if(callType.equals(pointCutException))
								{
									toComp = callType;
								}
								else if(callType.equals(pointCutSAP))
								{
									String asHost = (String) callDetails.get(2);
									String idWithNo = (String) callDetails.get(3);
									String systemId = idWithNo.substring(0, idWithNo.indexOf("#"));
									toComp = getSAPString(asHost,systemId);
									toComp = toComp.substring(toComp.indexOf(":")+1);
								}
								else if(callType.equals(pointCutJMS) || callType.equals(pointCutJmsEntry)) 
								{
									String messagingType = (String) callDetails.get(8);
									if(messagingType.equalsIgnoreCase("Publisher") || messagingType.equalsIgnoreCase("Subscriber"))
									{
										messagingType = "topic" ; 
									}else
									{
										messagingType = "queue" ; 
									}
									toComp = messagingType+"=*="+callDetails.get(4)+":"+callDetails.get(5);
								}
								else if(callType.startsWith(pointCutCustom))
								{
									toComp = callDetails.get(1)+":"+callDetails.get(8);
								}
								else if(callType.startsWith(pointCutEJB))
								{
									String pointCutTargetUrl = (String) callDetails.get(6);
									toComp = callDetails.get(1)+":"+pointCutTargetUrl;
								}else if(callType.startsWith("EHCACHE"))
								{
									toComp = callType+":"+"-";
								}
								else //callType = RMI|JavaMail|...
								{
									//In order to identify the Backend counts, Renamed EMAIL_CHILD & LDAP_CHILD  to EMAIL_CHILD & LDAP_CHILD correspondingly.
									//This made no effect on Call counts. As we are forming the call count by toComp
									String childPointcut = apm.changeChildPointcutTime(callType);
									if (childPointcut != null && childPointcut.length() > 0)
										callType = childPointcut;
										
									String pointCutTargetUrl = (String) callDetails.get(6);
									toComp = callDetails.get(1)+":"+callDetails.get(8);

									Hashtable otherPCCountMapping;
									if (webTempCallCount.containsKey(callType)){
										otherPCCountMapping = (Hashtable) webTempCallCount.get(callType);
										if (otherPCCountMapping != null) {
											if (otherPCCountMapping.containsKey(pointCutTargetUrl)) {
												dataCount = ((Integer)otherPCCountMapping.get(pointCutTargetUrl)).intValue();
												dataCount++;
												otherPCCountMapping.put(pointCutTargetUrl, dataCount);
											} else{
												dataCount = 1;
												otherPCCountMapping.put(pointCutTargetUrl, dataCount);
											}
											webTempCallCount.put(callType,otherPCCountMapping);
										}
									} else{
										dataCount = 1;
										otherPCCountMapping = new Hashtable();
										otherPCCountMapping.put(pointCutTargetUrl, dataCount);
										webTempCallCount.put(callType,otherPCCountMapping);
									}
								}

								if(callCounterHolder.containsKey(jvmComp))
									callCounter = (Hashtable) callCounterHolder.get(jvmComp);
								int toAdd = callType.equals(pointCutREDIS)?redisQueryCount:1 ;
								if(callCounter.containsKey(callType))
								{
									Hashtable detailResultHolder = (Hashtable) callCounter.get(callType);
									if(detailResultHolder.containsKey(toComp))
									{
										ArrayList resultArrayList = (ArrayList) detailResultHolder.get(toComp);
										if(resultArrayList != null && resultArrayList.size()>0)
										{
											int count = (Integer) resultArrayList.remove(0);
											if(extCallNodeKey.startsWith("FASTQUERY")||extCallNodeKey.startsWith("SLOWEXCCEDQUERY")||extCallNodeKey.startsWith("ERROREXCCEDQUERY"))
											{
												toAdd = Integer.parseInt((String)callDetails.get(8));
											}
											count += toAdd;

											
											resultArrayList.add(0,count);

											String msg = (String) resultArrayList.remove(1);
											/*if(callType.equals(pointCutException))
											{
												//resultArrayList.add(1, msg);
											}
											else
											{*/
												resultArrayList.add(1,"Multiple "+callType );
											//}


										}
									}
									else
									{
										ArrayList detailArrList = new ArrayList();
										//detailArrList.add(1);
										if(extCallNodeKey.startsWith("FASTQUERY")||extCallNodeKey.startsWith("SLOWEXCCEDQUERY")||extCallNodeKey.startsWith("ERROREXCCEDQUERY"))
										{
											int count = Integer.parseInt((String)callDetails.get(8));
											detailArrList.add(count);
										}
										else
										{
											detailArrList.add(toAdd);
										}
										detailArrList.add((String) callDetails.get(6));
										detailArrList.add(jvmComp);
										detailResultHolder.put(toComp,detailArrList);
									}
								}
								else
								{
									ArrayList detailArrList = new ArrayList();
									
									if(extCallNodeKey.startsWith("FASTQUERY")||extCallNodeKey.startsWith("SLOWEXCCEDQUERY")||extCallNodeKey.startsWith("ERROREXCCEDQUERY"))
									{
										int count = Integer.parseInt((String)callDetails.get(8));
										detailArrList.add(count);
									}
									else
									{
										detailArrList.add(toAdd);
									}
									detailArrList.add((String) callDetails.get(6));
									detailArrList.add(jvmComp);

									Hashtable toSend = new Hashtable();
									toSend.put(toComp,detailArrList);
									callCounter.put(callType, toSend);
								}
								callCounterHolder.put(jvmComp,callCounter);
							}
						}
						jsonMap.put("lbl_callCounterHolder", callCounterHolder);
						// code for Call counts ends here 

						//Hashtable extDataTable = (Hashtable) webStatistics.get(keyName+"#"+lbl_Web);
						Hashtable extDataTable = new Hashtable(); 
						String webThreadKey = null ; 
						
						int minHttpNodeLength = 0 ; 
						if(j == 0)
						{
							webThreadKey = keyName+"#"+lbl_Web;
							extDataTable = (Hashtable) webStatistics.get(webThreadKey);
						}
						else
						{
							webThreadKey = keyName+"#"+lbl_Thread;
							extDataTable = (Hashtable) threadStatistics.get(webThreadKey);
						}

						ArrayList nodeIdList = (ArrayList)nodeIdTable.get(webThreadKey);
						Hashtable conNodeIdTable = (Hashtable)conNodeTable.get(webThreadKey);
						Hashtable conHttpTimeTable = (Hashtable)conTimeTable.get(webThreadKey);
						Hashtable httpNodeDetailTable = (Hashtable)httpNodeDetailsTable.get(webThreadKey);
						Hashtable parentChildNodeTable = null ;
						Hashtable parentChildMappingTable = null ;
						 

						if(nodeIdList!=null)
						{
							Hashtable ht = prepareParentChildNodes(nodeIdList,conNodeIdTable);
							parentChildMappingTable = (Hashtable)ht.get("parentChildMappingTable");
							parentChildNodeTable = (Hashtable)ht.get("parentChildNodeTable");
						}
						if(parentChildNodeTable!=null)
						{
							String  tmp= keyName.substring(keyName.lastIndexOf("#")+1);
							httpParentChildNodeMappingTable.put(tmp,parentChildNodeTable);
						}
						int ext_size = 0;
						double totalTime = 0.0D;
						StringBuffer rhsBuffer = new StringBuffer();
						StringBuffer helperBuffer = new StringBuffer();
						if(extDataTable!=null){
							ext_size = extDataTable.size();
						}
						HashMap lineData = new HashMap();
						HashMap jmsEntryQueues = new HashMap(); // Contains JMS_Entry queue, from which msg produced or consumed.
						double externalCallsTime = 0.0D;
						if(ext_size > 0){
							Set extKeys = extDataTable.keySet();
							Iterator extItr = extKeys.iterator();
							while(extItr.hasNext())
							{
								String extKey = (String) extItr.next();
								String nodeId  = extKey.substring(extKey.lastIndexOf("~*~")+3);
								boolean calculateHttpTime = true ;
								double response_double = 0.0;
								double percentage = 0.0;
								if(parentChildNodeTable!=null && parentChildNodeTable.containsKey(nodeId))
								{
									calculateHttpTime = (Boolean)parentChildNodeTable.get(nodeId) ;
								}

								ArrayList extList = StringUtils.egTokenizer(extKey,keySep);

								String methodType = (String) extList.get(0);
								Double resposeTimeObj = (Double) extDataTable.get(extKey);
								
								if(methodType.equals(pointCutHTTP) )
								{
									String connectedNodeOrder = (String) extList.get(4);
									if(httpNodeDetailTable!=null || connectedNodeOrder.equals("-"))
									{
										ArrayList infoList = (ArrayList)httpNodeDetailTable.get(connectedNodeOrder);
										if(infoList!=null)
										{
											for(int i = 0 ; i< infoList.size() ; i++ )
											{
												String parentChildnodeIds = (String)infoList.get(i);
												BigDecimal responseString = (BigDecimal) conHttpTimeTable.get(parentChildnodeIds);
												boolean calcHttpTime = false; 
												if(parentChildNodeTable!=null && parentChildNodeTable.containsKey(parentChildnodeIds))
												{
													calcHttpTime = (Boolean)parentChildNodeTable.get(parentChildnodeIds) ;
												}
												if(calcHttpTime)
												{
													
													response_double += responseString.doubleValue();
													try
													{
														 if(calcHttpTime && rootJvmTotalResponseTime > 0 )
														{
															percentage = (response_double / rootJvmTotalResponseTime) * 100;
														}
													}
													catch(Exception ex){}
													if(Double.isNaN(percentage) || Double.isInfinite(percentage))
													{
														percentage = 0.0;
													}
												}
											}
											Hashtable innerTable = (Hashtable) externalDataTable.get(webThreadKey);
											ArrayList al = (ArrayList)innerTable.get(nodeId);
											al.set(7,response_double);
										}
									}else
									{
										response_double = resposeTimeObj.doubleValue();
										try
										{
											 if(rootJvmTotalResponseTime > 0 )
											{
												percentage = (response_double / rootJvmTotalResponseTime) * 100;
											}
										}
										catch(Exception ex){}
										if(Double.isNaN(percentage) || Double.isInfinite(percentage))
										{
											percentage = 0.0;
										}
									}

								}else
								{
									response_double = resposeTimeObj.doubleValue();
									try
									{
										 if(rootJvmTotalResponseTime > 0 )
										{
											percentage = (response_double / rootJvmTotalResponseTime) * 100;
										}
									}
									catch(Exception ex){}
									if(Double.isNaN(percentage) || Double.isInfinite(percentage))
									{
										percentage = 0.0;
									}
								}

								if(!methodType.equals(pointCutException))
								{
									//totalTime = 0.0D;
									totalTime = totalTime + response_double;
								}
								String extHost = (String) extList.get(1);
								String extPort = (String) extList.get(2);
								ArrayList lineDataList = new ArrayList();

								String double_data = scaleDecimalFormat.format(response_double);
								String double_percentage = percentFormat.format(percentage);

								String dataString = "["+methodType+"\\t"+double_data +" "+lbl_milliseconds+"  ("+double_percentage+" %)" +"]";
								lineDataList.add(methodType);
								lineDataList.add(double_data);
								lineDataList.add(double_percentage);
								lineDataList.add(extList.get(4));

								if(methodType.equals(pointCutHTTP) || methodType.equals(pointCutWebService))
								{
									//Check for HTTP Host & port is managed in eG Manager
									String extUrl = (String) extList.get(3);
									String extSchema = extUrl.substring(0,extUrl.indexOf("://")+3);
									String connectedNodeOrder = (String) extList.get(4);
									String connString  = null; 
									String tmp = getUnKnownDetails(guidNodeHostTable,egGuid,connectedNodeOrder,discInfo);
									if( tmp!=null && (extHost.indexOf("UNKNOWN_NODE")>-1 || tmp.indexOf("UNKNOWN_NODE")>-1))
									{
											connString = tmp;
									}else
									{
										connString = (String)urlMappingTable.get(methodType+"-"+extUrl);
									}
									if(connString == null)
									{
										connString = methodType+"-"+extSchema+""+extHost+":"+extPort;
									}	
									if(connString.endsWith("#"))	// ends with "#" means , comp. is managed in eG Manager
									{
										connString = connString.substring(0,connString.lastIndexOf("#"));
									}
									rhsBuffer.append(connString).append(dataString).append(fieldSep);
									helperBuffer.append(connString).append(fieldSep);
									//lineData.put(connString , lineDataList);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}
									String statusCode = (String) extList.get(5);
									updateStatusCodeTable(statusCode,connString,httpUrlStatusCodeTable);
								}
								else if(methodType.equals(pointCutSQL) || methodType.equals(pointCutMONGO))
								{
									String dbServerType = (String) extList.get(3);
									String dbName = (String) extList.get(4);
									dbName = dbName.equals("-") ? "" : dbName ; 
									// Check for DB Server is Managed or Not in eG Manager
									String connString = null;
									
									if(extHost.startsWith("jdbc:")){
										connString = dbServerType.equals("UNKNOWN") ? "DATABASECALL-"+extHost : "DATABASECALL-"+dbServerType + "*"+extHost;
									}
									else 
									{
										if(extHost.indexOf(",") > 0){
											String allColumnString = apm.getValue("CLUSTER_DB",dbServerType);
											ArrayList RACIpPortList = StringUtils.egTokenizer(extHost,",");
											connString = getDBString(dbServerType , RACIpPortList, extHost, dbName , allColumnString,discInfo);
										}
										else{
											String allColumnString = apm.getValue("DB_MAPPINGS",dbServerType);
											connString = getDBString(dbServerType , extHost , extPort , dbName,allColumnString);
										}
									}
									rhsBuffer.append(connString).append(dataString).append(fieldSep);
									helperBuffer.append(connString).append(fieldSep);
									//lineData.put(connString , lineDataList);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}
								}else if(methodType.equals(pointCutREDIS))
								{
									 
									String dbName = (String) extList.get(4);
									String dbtype = (String)extList.get(3);
									String allColumnString = apm.getValue("DB_MAPPINGS",dbtype);
									String connString = getDBString(dbtype , extHost , extPort , dbName,allColumnString);
									rhsBuffer.append(connString).append(dataString).append(fieldSep);
									helperBuffer.append(connString).append(fieldSep);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
										
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}

								}
								else if(methodType.equals(pointCutJMS) || methodType.equals(pointCutJmsEntry))
								{
									String jmsProvider = (String) extList.get(3);
									String queueOrTopic = (String) extList.get(4);
									String messagingType = (String) extList.get(5);
									if(messagingType.equalsIgnoreCase("Publisher") || messagingType.equalsIgnoreCase("Subscriber"))
									{
										messagingType = "topic" ; 
									}else
									{
										messagingType = "queue" ; 
									}
									String connString = messagingType+"=*="+jmsProvider+":"+queueOrTopic;
									rhsBuffer.append(connString).append(dataString).append(fieldSep);
									helperBuffer.append(connString).append(fieldSep);
									//lineData.put(connString , lineDataList);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}

									if(methodType.equals(pointCutJmsEntry)){
										boolean isAsyncTimeToShow = BTMHelper.isAsyncTimeToShow(keyName,guidNodeHostTable);
										jsonMap.put("egGuid", keyName);
										jsonMap.put("isAsyncTimeToShow", isAsyncTimeToShow);
										jsonMap.put("isJmsEntry", lbl_stringTrue);
										jmsEntryQueues.put(connString, "true");
									}
									else{
										jmsConList.add(connString);
									}
								}
								else if(methodType.equals(pointCutSAP))
								{
									String ashost = (String) extList.get(1);
									String idWithNo = (String) extList.get(2);
									String systemId = idWithNo.substring(0, idWithNo.indexOf("#"));
									String connString = getSAPString(ashost,systemId);
									rhsBuffer.append(connString).append(dataString).append(fieldSep);
									helperBuffer.append(connString).append(fieldSep);
									//lineData.put(connString , lineDataList);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}
								}
								else if(methodType.startsWith(pointCutCustom))
								{
									String customPointCutName = (String) extList.get(0);
									String customPointCutString = (String) extList.get(5);
									String connString = customPointCutName + ":" + customPointCutString;
									//lineData.put(connString , lineDataList);
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}
								}else if(methodType.startsWith("EHCACHE"))
								{
									String connString = methodType + ":" +"-";
									if(lineData.containsKey(connString))
									{
										ArrayList addedList = (ArrayList) lineData.get(connString);
										addedList.add(lineDataList);
									}
									else
									{
										ArrayList newList = new ArrayList();
										newList.add(lineDataList);
										lineData.put(connString , newList);
									}
								}
								else if(methodType.startsWith(pointCutEJB))
								{
									if(!methodType.equals(pointCutException))
									{
										String pointCutTargetUrl = (String) extList.get(5);
										String connString = extList.get(0) + ":" + extList.get(5);
										if(lineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) lineData.get(connString);
											addedList.add(lineDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(lineDataList);
											lineData.put(connString , newList);
										}
									}
								}
								else // methodType = RMI|JavaMail|...
								{
									if(!methodType.equals(pointCutException))
									{
										String pointCutName = (String) extList.get(0);	
										String pointCutProtocolName = (String) extList.get(6);
										
										String connString = pointCutName + ":" + pointCutProtocolName;
										//lineData.put(connString , lineDataList);
										if(lineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) lineData.get(connString);
											addedList.add(lineDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(lineDataList);
											lineData.put(connString , newList);
										}
									}
								}
							}
						}
						jsonMap.put(lbl_lineValue, lineData);
						jsonMap.put("JMS_Entry_Queues", jmsEntryQueues);
						/*parentChildMappingTable - Contains parent child mapping of Node specific to this Node */
						jsonMap.put("NodeMappingData", parentChildMappingTable);
						double jvmTime = totalResponseTime - totalTime;
						if(jvmTime<0)
							jvmTime = 0;
						jvmTimeList.put(webThreadNodeOrder,jvmTime);

						double jvmPercent = 0.0;
						try
						{
							 jvmPercent = ((jvmTime / rootJvmTotalResponseTime) * 100.0D);
						}
						catch(Exception ex){}
						if(Double.isNaN(jvmPercent) || Double.isInfinite(jvmPercent))
						{
							jvmPercent = 0.0;
						}
						StringBuffer jvmDataBuffer = new StringBuffer();
						boolean thisNodeIsAsync = false;
						if(asyncResposeTimeTable!=null && asyncResposeTimeTable.containsKey(webThreadNodeOrder)){
							thisNodeIsAsync = true;
						}
						HashMap userDetails = new HashMap();
						userDetails.put(lbl_compName,lbl_User);
						userDetails.put(lbl_nodeValue,null);
						userDetails.put(lbl_isAsync,lbl_stringFalse);
						userDetails.put(lbl_nodeExperience,lbl_NoneLc);
						userDetails.put(lbl_isStartJvm,lbl_stringFalse);
						userDetails.put(lbl_highlight,lbl_stringFalse);
						userDetails.put(lbl_displayName,userName);
						userDetails.put(lbl_serverType, lbl_Others);
						long userDefaultSlowThresh  = 4000;
						userDetails.put(lbl_compThreshold, userDefaultSlowThresh);
						long userDefaultStalledThresh  = 60000;
						userDetails.put(lbl_stalledThreshold, userDefaultStalledThresh);
						userDetails.put(lbl_lineValue, null);
						userDetails.put(lbl_drillDownGuid, lbl_None);
						userDetails.put(lbl_drillDownNodeOrder, lbl_None);
						userDetails.put(lbl_drillDownUrlToGo, lbl_None);
						userDetails.put(lbl_userDevice, userDeviceFromRUM);
						userDetails.put("lbl_callCounterHolder", new Hashtable());
						userDetails.put("nodeType", null);

						
						//Intermediate modal window code starts
						ArrayList userDetailsArray = new ArrayList();
						userDetailsArray.add(userDetails);
						rearrangeHt.put(lbl_userNode,userDetailsArray);
						//Intermediate modal window code ends
						
						// If async call present, then the details are calculating here
						if(isAsyncPresent && thisNodeIsAsync)
						{
							jsonMap.put(lbl_isAsync, lbl_stringTrue);
							Double asyncResTime = (Double) asyncResposeTimeTable.get(webThreadNodeOrder);

							String node_jvm_time = scaleDecimalFormat.format(jvmTime);
							String node_jvm_percentage = percentFormat.format(jvmPercent);
							String node_async_time = scaleDecimalFormat.format(asyncResTime);

							jvmDataBuffer.append("{"+node_jvm_time +" "+lbl_milliseconds+"  ("+node_jvm_percentage+" %)");
							jvmDataBuffer.append(" \\n "+node_async_time+" "+lbl_milliseconds+" (async)").append(" } ");

							ArrayList nodeDataList = new ArrayList();
							nodeDataList.add(node_jvm_time);
							nodeDataList.add(node_jvm_percentage);
							nodeDataList.add(node_async_time);

							jsonMap.put(lbl_nodeValue, nodeDataList);
							Hashtable summaryDetails = (Hashtable) requestDataList.get(0);
							ArrayList summaryData = (ArrayList) summaryDetails.get(keyName);
							if(summaryData != null && summaryData.size()>0)
							{
								String toRemove = (String) summaryData.get(2);
								if(toRemove.equals(slow_Urls_Count) || toRemove.equals(stalled_Urls_Count))
								{
									summaryData.remove(2);
									if(Integer.parseInt(node_jvm_time) > thisThreshInt)
									{
										if(Integer.parseInt(node_jvm_time) > thisStalledThreshInt)
											summaryData.add(2,stalled_Urls_Count);
										else
											summaryData.add(2,slow_Urls_Count);
									}
									else
									{
										summaryData.add(2,healthy_Urls_Count);
									}
								}
							}
							
							Hashtable asyncExternalTable = (Hashtable) webNodeAsyncSummary.get(webThreadNodeOrder);
							HashMap asyncLineData = new HashMap();
							if(asyncExternalTable!=null && asyncExternalTable.size() > 0)
							{
								Set extKeys = asyncExternalTable.keySet();
								Iterator extItr = extKeys.iterator();
								while(extItr.hasNext())
								{
									String extKey = (String) extItr.next();

									Double resposeTimeObj = (Double) asyncExternalTable.get(extKey);
									double response_double = resposeTimeObj.doubleValue();

									ArrayList extList = StringUtils.egTokenizer(extKey,keySep);
									String methodType = (String) extList.get(0);
									String extHost = (String) extList.get(1);
									String extPort = (String) extList.get(2);

									ArrayList asyncDataList = new ArrayList();
									String async_double = scaleDecimalFormat.format(response_double);
									asyncDataList.add(methodType);
									asyncDataList.add(async_double);
									asyncDataList.add("");
									String dataString = "["+methodType+"\\t"+async_double +" "+lbl_milliseconds+"  (async)"+"]";
									if(methodType.equals(pointCutHTTP) || methodType.equals(pointCutWebService))
									{
										//Check for HTTP Host & port is managed in eG Manager
										String extUrl = (String) extList.get(3);
										String extSchema = extUrl.substring(0,extUrl.indexOf("://")+3);
										String connectedNodeOrder = (String) extList.get(4);
										String connString = null ;
										String tmp = getUnKnownDetails(guidNodeHostTable,egGuid,connectedNodeOrder,discInfo);
										if( tmp!=null && (extHost.indexOf("UNKNOWN_NODE")>-1 || tmp.indexOf("UNKNOWN_NODE")>-1))
										{
											connString = tmp ; 
										}else
										{
											connString = (String)urlMappingTable.get(methodType+"-"+extUrl);
										}
										if(connString == null)
										{
											connString = methodType+"-"+extSchema+""+extHost+":"+extPort;
										}	
										if(connString.endsWith("#"))	// ends with "#" means , comp. is managed in eG Manager
										{
											connString = connString.substring(0,connString.lastIndexOf("#"));
										}
										rhsBuffer.append(connString).append(dataString).append(fieldSep);
										helperBuffer.append(connString).append(fieldSep);
										//asyncLineData.put(connString , asyncDataList);
										if(asyncLineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) asyncLineData.get(connString);
											addedList.add(asyncDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(asyncDataList);
											asyncLineData.put(connString , newList);
										}
										String statusCode = (String) extList.get(5);
										updateStatusCodeTable(statusCode,connString,httpUrlStatusCodeTable);
									}
									else if(methodType.equals(pointCutSQL) || methodType.equals(pointCutMONGO))
									{
										String dbServerType = (String) extList.get(3);
										String dbName = (String) extList.get(4);
										dbName = dbName.equals("-") ? "" : dbName ; 
										// Check for DB Server is Managed or Not in eG Manager
										String connString = null;

										if(extHost.startsWith("jdbc:")){
											connString = dbServerType.equals("UNKNOWN") ? "DATABASECALL-"+extHost : "DATABASECALL-"+dbServerType + "*"+extHost ;
										}
										else 
										{
											if(extHost.indexOf(",") > 0){
												String allColumnString = apm.getValue("CLUSTER_DB",dbServerType);
												ArrayList RACIpPortList = StringUtils.egTokenizer(extHost,",");
												connString = getDBString(dbServerType , RACIpPortList, extHost, dbName , allColumnString,discInfo);
											}
											else{
												String allColumnString = apm.getValue("DB_MAPPINGS",dbServerType);
												connString = getDBString(dbServerType , extHost , extPort , dbName,allColumnString);
											}
										}
										rhsBuffer.append(connString).append(dataString).append(fieldSep);
										helperBuffer.append(connString).append(fieldSep);
										//asyncLineData.put(connString , asyncDataList);
										if(asyncLineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) asyncLineData.get(connString);
											addedList.add(asyncDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(asyncDataList);
											asyncLineData.put(connString , newList);
										}
									}
									else if(methodType.equals(pointCutJMS))
									{
										String jmsProvider = (String) extList.get(3);
										String queueOrTopic = (String) extList.get(4);
										String messagingType = (String) extList.get(5);
										if(messagingType.equalsIgnoreCase("Publisher") || messagingType.equalsIgnoreCase("Subscriber"))
										{
											messagingType = "topic" ; 
										}else
										{
											messagingType = "queue" ; 
										}
										String connString = messagingType+"=*="+jmsProvider +":"+queueOrTopic	;
										rhsBuffer.append(connString).append(dataString).append(fieldSep);
										helperBuffer.append(connString).append(fieldSep);
										//asyncLineData.put(connString , asyncDataList);
										if(asyncLineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) asyncLineData.get(connString);
											addedList.add(asyncDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(asyncDataList);
											asyncLineData.put(connString , newList);
										}
									}
									else if(methodType.equals(pointCutSAP))
									{
										String ashost = (String) extList.get(1);
										String idWithNo = (String) extList.get(2);
										String systemId = idWithNo.substring(0, idWithNo.indexOf("#"));
										String connString = getSAPString(ashost,systemId);
										rhsBuffer.append(connString).append(dataString).append(fieldSep);
										helperBuffer.append(connString).append(fieldSep);
										//asyncLineData.put(connString , asyncDataList);
										if(asyncLineData.containsKey(connString))
										{
											ArrayList addedList = (ArrayList) asyncLineData.get(connString);
											addedList.add(asyncDataList);
										}
										else
										{
											ArrayList newList = new ArrayList();
											newList.add(asyncDataList);
											asyncLineData.put(connString , newList);
										}
									}
									else if(methodType.equals(pointCutEJB))
									{
										if(!methodType.equals(pointCutException))
										{
											String pointCutTargetUrl = (String) extList.get(5);
											String connString = extList.get(0) + ":" + extList.get(5);
											if(asyncLineData.containsKey(connString))
											{
												ArrayList addedList = (ArrayList) asyncLineData.get(connString);
												addedList.add(asyncDataList);
											}
											else
											{
												ArrayList newList = new ArrayList();
												newList.add(asyncDataList);
												asyncLineData.put(connString , newList);
											}
										}
									}
									else // callType = RMI|JavaMail|...
									{
										if(!methodType.equals(pointCutException))
										{
											String pointCutName = (String) extList.get(0);
											String pointCutTargetUrl = (String) extList.get(5);
											String pointCutProtocolName = (String) extList.get(6);
											String connString = pointCutName + ":" + pointCutProtocolName;
											if(asyncLineData.containsKey(connString))
											{
												ArrayList addedList = (ArrayList) asyncLineData.get(connString);
												addedList.add(asyncDataList);
											}
											else
											{
												ArrayList newList = new ArrayList();
												newList.add(asyncDataList);
												asyncLineData.put(connString , newList);
											}
										}
									}
								}
							}
							jsonMap.put(lbl_asyncValue, asyncLineData);

							timeString.append(webThreadNodeOrder).append(seperatorHyphen).append(node_jvm_time).append(seperatorTilt);
						}
						else
						{
							if(j==1)
								jsonMap.put(lbl_isAsync, lbl_stringTrue);
							else
								jsonMap.put(lbl_isAsync, lbl_stringFalse);

							String node_jvm_time = scaleDecimalFormat.format(jvmTime);
							String node_jvm_percentage = percentFormat.format(jvmPercent);

							jvmDataBuffer.append("{"+node_jvm_time +" "+lbl_milliseconds+"  ("+node_jvm_percentage+" %)");
							jvmDataBuffer.append(" } ");
							
							ArrayList nodeDataList = new ArrayList();
							nodeDataList.add(node_jvm_time);
							nodeDataList.add(node_jvm_percentage);

							jsonMap.put(lbl_nodeValue, nodeDataList);
							Hashtable summaryDetails = (Hashtable) requestDataList.get(0);
							ArrayList summaryData = (ArrayList) summaryDetails.get(keyName);
							if(summaryData != null && summaryData.size()>0)
							{
								String toRemove = (String) summaryData.get(2);
								if(toRemove.equals(slow_Urls_Count))
								{
									summaryData.remove(2);
									if(Integer.parseInt(node_jvm_time) > thisThreshInt)
									{
										if(Integer.parseInt(node_jvm_time) > thisStalledThreshInt)
											summaryData.add(2,stalled_Urls_Count);
										else
											summaryData.add(2,slow_Urls_Count);
									}
									else
									{
										summaryData.add(2,healthy_Urls_Count);
									}
								}
							}
							timeString.append(webThreadNodeOrder).append(seperatorHyphen).append(node_jvm_time).append(seperatorTilt);
						}
						if(rhsBuffer!=null && rhsBuffer.length() > 0)
						{
							String rhsLine = rhsBuffer.toString();
							if(rhsLine.endsWith(fieldSep))
								rhsLine = rhsLine.substring(0,rhsLine.length() - 3);
							String completeLine = fullName+jvmDataBuffer.toString()+"<==>"+rhsLine;
							completeList.add(completeLine);
						}
						else{
							String completeLine = fullName+jvmDataBuffer.toString();
							completeList.add(completeLine);
						}

						nodeList4d3.add(jsonMap);
						if(helperBuffer!=null && helperBuffer.length() > 0)
						{
							String rhsLine = helperBuffer.toString();
							if(rhsLine.endsWith(fieldSep))
								rhsLine = rhsLine.substring(0,rhsLine.length() - 3);
							positionHelperList.add(fullName+"<==>"+rhsLine);
						}
						else{
							positionHelperList.add(fullName);
						}

						ArrayList nodeDetailsArray = null;
						if(rearrangeHt.containsKey(jvmComp))
						{
							nodeDetailsArray = (ArrayList) rearrangeHt.get(jvmComp);
							nodeDetailsArray.add(jsonMap);
						}
						else
						{
							nodeDetailsArray = new ArrayList();
							nodeDetailsArray.add(jsonMap);
							rearrangeHt.put(jvmComp,nodeDetailsArray);
						}
					}
				}
				
				if(nodeList4d3 != null && nodeList4d3.size()>0)
				{
					for(int n=0;n<nodeList4d3.size();n++)
					{
						HashMap singleComp = (HashMap) nodeList4d3.get(n);
						HashMap singleCompLineValue = (HashMap) singleComp.get(lbl_lineValue);
						Hashtable nodeMappingData = (Hashtable)singleComp.get("NodeMappingData");
						boolean isAsync = Boolean.valueOf(singleComp.get(lbl_isAsync).toString());
						String compName = (String) singleComp.get(lbl_compName);
						
						long compThreshold =  (Long) singleComp.get(lbl_compThreshold);
						String isStart = (String) singleComp.get(lbl_isStartJvm);
						String jmsEntryNode = (String) singleComp.get("isJmsEntry") ;
						String nodeOrderString = (String) singleComp.get("nodeOrder") ;
						HashMap jmsEntryQueues = (HashMap) singleComp.get("JMS_Entry_Queues") ;

						if(isStart.equals(lbl_stringTrue)) {
							connMapOrderToNick.put(0,lbl_userNode);
							connMapNickToOrder.put(lbl_userNode,0);
							connMapOrderToNick.put(1,compName);
							connMapNickToOrder.put(compName,1);
						}

						// No of nodes including exit call calculation starts here
						if(singleCompLineValue != null && singleCompLineValue.size()>0)
						{
							Iterator itr = singleCompLineValue.keySet().iterator();
							while(itr.hasNext())
							{
								String thisTypeAndNick = (String) itr.next();
								String thisNick =  thisTypeAndNick.substring(thisTypeAndNick.indexOf(":")+1);

								// Mapping of component name and component order for drawing topology.
								if(isStart.equals(lbl_stringTrue) && jmsEntryQueues!=null && jmsEntryQueues.containsKey(thisTypeAndNick) && (thisTypeAndNick.startsWith("queue=*=") || thisTypeAndNick.startsWith("topic=*=")))
								{
									connMapOrderToNick.put(0,thisTypeAndNick);
									connMapNickToOrder.put(thisTypeAndNick,0);
									//When JMS_Entry is the First Node, Need to remove the User
									connMapNickToOrder.remove(lbl_userNode);
								}
								else if(connMapOrderToNick != null && connMapOrderToNick.size()>0)
								{
									if(!connMapOrderToNick.containsKey(thisNick))
									{
										if(rearrangeHt != null && rearrangeHt.containsKey(thisNick))
										{
											if(!connMapNickToOrder.containsKey(thisNick))
											{
												connMapOrderToNick.put(connMapOrderToNick.size(),thisNick);
												connMapNickToOrder.put(thisNick,connMapNickToOrder.size());
											}
										}
										else
										{
											String thisServerType = thisTypeAndNick.substring(0,thisTypeAndNick.indexOf(":"));
											if(thisServerType.endsWith("_M"))
											{
												if(!connMapNickToOrder.containsKey(thisNick))
												{
													connMapOrderToNick.put(connMapOrderToNick.size(),thisNick);
													connMapNickToOrder.put(thisNick,connMapNickToOrder.size());
												}
											}
											else
											{
												if(!connMapNickToOrder.containsKey(thisTypeAndNick))
												{
													connMapOrderToNick.put(connMapOrderToNick.size(),thisTypeAndNick);
													connMapNickToOrder.put(thisTypeAndNick,connMapNickToOrder.size());
												}
											}
										}
									}
								}
								ArrayList lineValuesList = (ArrayList) singleCompLineValue.get(thisTypeAndNick);
								int lineValuesListSize = lineValuesList.size();
								long totalTimetmp  =  0 ; 
								long connectedNodeTimetmp = 0L;
								boolean httpCallPresent = false ; 
								for(int l=0;l<lineValuesListSize;l++)
								{
									//ArrayList thisLineValue = (ArrayList) singleCompLineValue.get(thisTypeAndNick);
									ArrayList thisLineValue = (ArrayList) lineValuesList.get(l);
									String callType = (String) thisLineValue.get(0);
									String connectedNodeOrder = null;
									if(thisLineValue.size() == 4)
										connectedNodeOrder = (String) thisLineValue.remove(3);
									long totalTime = Long.parseLong((String) thisLineValue.remove(1));
									long connectedNodeTime = 0L;

									boolean isSelfCall = false;
									if(compName.equals(thisNick))
										isSelfCall = true;

									// Code for subtracting the line value from the next node value - only if the call goes to the next managed node.
									// This code will not effect if it is exit call
									if(rearrangeHt != null && rearrangeHt.containsKey(thisNick))  
									{
										ArrayList detailsHolderArray = (ArrayList) rearrangeHt.get(thisNick);
										int detailsHolderArraySize = detailsHolderArray.size();
										if(detailsHolderArray != null && detailsHolderArraySize > 0)
										{
											for(int s=0;s<detailsHolderArraySize;s++)
											{
												HashMap temphm = (HashMap) detailsHolderArray.get(s);
												String nodeOrder = (String) temphm.get("nodeOrder");

												// For multiple incoming request to same node, then we need to check the right node to substract
												if(connectedNodeOrder != null && !connectedNodeOrder.equals(nodeOrder))
													continue;

												ArrayList connNodeValueList = (ArrayList) temphm.get(lbl_nodeValue);
												long nodeValue = Long.parseLong((String)connNodeValueList.get(0));
												HashMap connLineValueMap = (HashMap) temphm.get(lbl_lineValue);
												long connLineValue = 0;
												Iterator connItr = connLineValueMap.keySet().iterator();
												while(connItr.hasNext())
												{
													String key = (String) connItr.next();
													ArrayList allConnectedValues = (ArrayList) connLineValueMap.get(key);
													int allConnectedValuesSize = allConnectedValues.size();
													for(int a=0;a<allConnectedValuesSize;a++)
													{
														ArrayList singleConnection = (ArrayList) allConnectedValues.get(a);
														if(singleConnection != null /*&& singleConnection.size() == 4*/)
														{
															long singleConnectionValue = Long.parseLong((String)singleConnection.get(1));
															connLineValue += singleConnectionValue;
														}
													}
												}
												connectedNodeTime = nodeValue+connLineValue;
												connectedNodeTimetmp+=connectedNodeTime;
												//connectedNodeTime = Long.parseLong((String) temphm.get("totalResponseTime"));
											}
										}
									}
									long excludedTime = totalTime - connectedNodeTime;
									/*This block iof code checks if there are any child for this Node order if present then that time is added up and it is excluded*/
									if(callType.equals("HTTP"))
									{
										long overallChildTime = 0 ; 
										if(nodeMappingData!=null && nodeMappingData.containsKey(connectedNodeOrder))
										{
											ArrayList al = (ArrayList)nodeMappingData.get(connectedNodeOrder); 
											for(int i=0 ;i < al.size() ; i++)
											{
												String conNodeOrder = (String)al.get(i);
												
												if(jvmTimeList!=null && jvmTimeList.containsKey(conNodeOrder))
												{
													Object obj = (Object)jvmTimeList.get(conNodeOrder) ; 
													String str = obj.toString();
													double dbl = Double.valueOf(str);
													long value = (long) dbl;
													overallChildTime = overallChildTime+value ; 
												}
											}
										}
										excludedTime = excludedTime - overallChildTime ; 
									}
									// When target is unknown or timing is in negative, no need to show line value.
		
									// Adding the new values
									thisLineValue.add(1,String.valueOf(excludedTime));
									thisLineValue.remove(2);
									double percent = 0.0;
									try
									{
										 if(excludedTime > 0)
											percent = (excludedTime/rootJvmTotalResponseTime)*100;
									}
									catch(Exception ex){}
									if(Double.isNaN(percent) || Double.isInfinite(percent))
									{
										percent = 0.0;
									}
									thisLineValue.add(2, percentFormat.format(percent));
								}
							}
						}
						// No of nodes including exit call calcualtion ends here

						// For Async, No of total nodes calculation starts here
						if(isAsync)
						{
							HashMap singleCompAsyncLineValue = (HashMap) singleComp.get(lbl_asyncValue);
							if(singleCompAsyncLineValue != null && singleCompAsyncLineValue.size()>0)
							{
								Iterator itr = singleCompAsyncLineValue.keySet().iterator();
								while(itr.hasNext())
								{
									String thisTypeAndNick = (String) itr.next();
									String thisNick =  thisTypeAndNick.substring(thisTypeAndNick.indexOf(":")+1);

									if(connMapOrderToNick != null && connMapOrderToNick.size()>0)
									{
										if(!connMapOrderToNick.containsKey(thisNick))
										{
											
											if(rearrangeHt != null && rearrangeHt.containsKey(thisNick))
											{
												if(!connMapNickToOrder.containsKey(thisNick))
												{
													connMapOrderToNick.put(connMapOrderToNick.size(),thisNick);
													connMapNickToOrder.put(thisNick,connMapNickToOrder.size());
												}
											}
											else
											{
										
												String thisServerType = thisTypeAndNick.substring(0,thisTypeAndNick.indexOf(":"));
												if(thisServerType.endsWith("_M"))
												{
													if(!connMapNickToOrder.containsKey(thisNick))
													{
														connMapOrderToNick.put(connMapOrderToNick.size(),thisNick);
														connMapNickToOrder.put(thisNick,connMapNickToOrder.size());
													}
												}
												else
												{
													if(!connMapNickToOrder.containsKey(thisTypeAndNick))
													{
														connMapOrderToNick.put(connMapOrderToNick.size(),thisTypeAndNick);
														connMapNickToOrder.put(thisTypeAndNick,connMapNickToOrder.size());
													}
												}
											}
										}
									}
								}
							}
						}
						else{
							if(connMapNickToOrder.containsKey(compName)){
								// Already avilable
							}
							else{
								int size = connMapNickToOrder.size();
								connMapNickToOrder.put(compName , size);
								connMapOrderToNick.put(size, compName);
							}
						}
						// For Async, No of total nodes calculation ends here
					}
				}
			//}
			try
			{
				// Json Data Formation goes here
				jsonResult = topologyDagreJsonBuild(monitor_Skin,rearrangeHt,connMapOrderToNick,connMapNickToOrder,responseTime,overAllExperience,timeString.toString(),mappingInfo,rumDataTable,requestUrl,apmType,testName,webTempCallCount,httpUrlStatusCodeTable,jmsConList,userName , webOrderList , guidNodeHostTable);
				//System.out.println("jsonResult ___________- "+jsonResult);
				// SAVE To PDF
				JSONObject jsonPDFResult = new JSONObject();
				JSONObject totalHeaderDataObj = new JSONObject();
				jsonPDFResult.put("requestUrl",requestUrl);
				session.setAttribute("userName",userName);
				jsonPDFResult.put("URLAccessedTime",fromNodeTimeFormat);
				jsonPDFResult.put("TestName",testName);
				session.setAttribute("TopologyData",jsonPDFResult);
				session.setAttribute("jsonResult",jsonResult);
				// PDF Code End
			}
			catch (Exception e)
			{
				e.printStackTrace();
				System.out.println("Exception occured while creating json");
			}

			/*nodeOrderString = nodeOrderBuffer.toString();
			if(nodeOrderString.endsWith("!*!")){
				nodeOrderString = nodeOrderString.substring(0,nodeOrderString.lastIndexOf("!*!"));
			}*/
		}

		boolean isData = false;
		boolean proceed = false;
		Hashtable positionTable = new Hashtable();
		ArrayList dimensionList = new ArrayList();
		if(positionHelperList!=null && positionHelperList.size()  > 0){
			proceed = true;
			session.setAttribute("SummaryData",requestDataList);
			session.setAttribute("ExternalData",externalDataTable);
			session.setAttribute("jmsHelper",jmsTable);
		}
		else{
			proceed = false;
		}

		if(proceed)
		{
			String topologyPageTitle = "Cross-Application Transaction Flow";
			if(!fromNodeRequestUrl.equals("-") && !fromNodeCompNamePort.equals("-") && !fromNodeTimeFormat.equals("-")){
				// topologyPageTitle = "Cross-Application Transaction Flow for "+fromNodeRequestUrl+" received on node <span class='node_active'>"+fromNodeCompNamePort+"</span> at "+fromNodeTimeFormat;
				topologyPageTitle = "Cross-Application Transaction Flow for "+transName+" received on node <span class='node_active'>"+fromNodeCompNamePort+"</span> at "+fromNodeTimeFormat;
			}
			String userExpIconOverall = "BTM_transaction_state_"+overAllExperience;

			String topologyPageTitle2 = "URL Clicked by "+userName+" : "+requestUrl+" received at "+managerTimeFormat;
			if(requestUrl.equals("-"))
				// topologyPageTitle2 = "URL accessed on this node: "+fromNodeRequestUrl+" received at "+fromNodeTimeFormat;
				topologyPageTitle2 = "URL accessed on this node: "+transName+" received at "+fromNodeTimeFormat;
			
%>
		
	<div class="btmnewWindow">	
	<div class="x-window-header x-window-header-default x-horizontal x-window-header-horizontal	x-window-header-default-horizontal x-top x-window-header-top x-window-header-default-top x-docked-top x-window-header-docked-top x-window-header-default-docked-top" style="left: 0px; top: 0px;">
   <div class="x-window-header-body">
      <div  class="" role="presentation">
         
            <div class="x-window-header-text-container" style="width:80%;text-align: left; left: 0px; top: 0px; margin: 0px;height:32px;float:left" ><span class="x-window-header-text x-window-header-text-default" data-qtip="<%=topologyPageTitle%>" data-qclass="yellowTip qtipwidth" id="btmwindowtitle"> <%=topologyPageTitle%></span></div>
            <div class="btm-tool" style="float:right">
			<img  src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-btn-icon iconSave" role="presentation" data-qtip="Save as PDF" id="pdfDownload" data-qclass="" style="margin:0px 3px 0px 3px">
			<img src="../images/Light/sepratorlight.png" width="2px" border="0px" height="16px;"/>
			<img  src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="iconBtmAutoLayout" role="presentation" id="autofit" data-qtip="AutoFit Layout" data-qclass="">
			<img src="../images/Light/sepratorlight.png" width="2px" border="0px" height="16px;"/>
			<img  src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="iconBtmMoreOptions" role="presentation" id="moreoptions" data-qtip="More Options"  data-qclass="">
			<img  src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" class="x-tool-close" role="presentation" id="closewindow" data-qtip="Close"  data-qclass=""></div>
      </div>
   </div>
</div>

<% 

	//if(!requestUrl.equals("-") || !fromNodeRequestUrl.equals("-"))
	{
%>

<div class="btm_url" id="btm_url"><span class="" data-qtip="<%=topologyPageTitle2%>" data-qclass="yellowTip qtipwidth"> <%=topologyPageTitle2%></span></div>

<%
	}
%>
<div id="info" class="btminfo"></div>
</div>
<!-- dont change the ID "paper" -->
<div  id="paper" name="paper" style="">

</div>

<script>

	Ext.tip.QuickTipManager.init();
	
	// Graph DATA 
	var data = <%=jsonResult%>;
	
</script>
<script src="../monitor/eg_scripts/moreOptionsBTMtopology.js"></script>
<script src="../monitor/eg_scripts/BTMtopologygraph.js"></script>
<%
		}
	}
	catch(Exception e)
	{
		e.printStackTrace();
		System.out.println("Exception occured at eGBTMd3Topology.jsp");
	}
%>

</body>
</html>
