<%
/*******************************************************************************
*   Name                        :   Tvmodejson.jsp
*   Purpose						:   For Tv mode input
*   Version                     :   6.0.1
*   Created						:   12.12.2014
*   Author                      :   Antony & Team

*******************************************************************************/
%>

<%@ taglib prefix = "egui" uri = "WEB-INF/eg-taglib.tld"%>
<%@ include file="admin/EgAdminTracker.jsp" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*" %>
<%@ page import="com.egurkha.*"%>
<%@ page import="com.eg.EgCrypt"%>
<%@ page import="com.eg.IniFile"%>
<%@ page import="com.eg.EgURLEncoder"%>
<%@ page import="com.egurkha.User"%>
<%@ page import="com.egurkha.ini.*"%>
<%@ page import="com.egurkha.util.*"%>
<%@ page import="com.eg.EgInstallInfo"%>
<%@ page import="com.eg.EgServicesInfo"%>
<%@ page import="com.eg.EgDbInfo"%>
<%@ page import="com.eg.EgManagersIniForManager"%>
<%@ page import="egurkha.EgDbAdapterUI"%>
<%@ page import="com.eg.EgDbAdapterTypeUI"%>
<%@ page import="com.egurkha.UserRegistry"%>
<%@ page import = "com.egurkha.monitor.ServicesDashboardBean"%>
<%@ page import="com.egurkha.monitor.alarms.*"%>
<%@ page import="com.egurkha.monitor.Dashboard"%>
<%@ page import="com.egurkha.monitor.MonitorDAOFactory"%>
<%@ page import="com.egurkha.monitor.EgServerDashBoardDAO"%>
<%@ page import = "com.eg.EgTopoInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import="com.egurkha.util.DateUtil"%>
<%@ page import="com.egurkha.util.EgSorter"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@ page import="net.sf.json.JSONArray"%>
<%@ page import ="egurkha.reporter.ErUserData"%>
<%@ page import ="com.egurkha.monitor.EgCustomModel"%>
<%@ page language="java" contentType="application/json;charset=UTF-8" pageEncoding="UTF-8" %>
<%
try
{
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);
	String  param=request.getParameter("Tvmodule");
	JSONObject rootJson=new JSONObject();
	JSONArray TvModulecombo = new JSONArray();

	
	User this_user = UserRegistry.getInstance().getUser(sessionID,true);	
	ErUserData uBean =this_user.getReporterData();
	session.putValue("UBean",uBean);
	User user = registry.getUser(session.getId());
	List usr_server=user.getServers(false);
	List userServerTypes = new LinkedList();
	String thisLanguage = "";
	if(user != null){
		userServerTypes.addAll(user.getServerTypes());
		thisLanguage = user.getLanguage();
	}
	ServicesDashboardBean serviceBean = new ServicesDashboardBean();
	EgMappingInfo mappingInfo = new EgMappingInfo(thisLanguage);
	EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
	EgUserRole userRole = EgUserRole.getRoleObject(user.getLoginType());
	IniFile egUi = new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_ui.ini");
	IniFile egDashConfig = new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_dashboardConfig.ini");
	IniFile citrixConfig = new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_citrixdashboard.ini");
	IniFile eg_dbaseIni =  new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_dbase.ini");
	IniFile eg_externalIni =  new IniFile(EgInstallInfo.getInstallDir() + "/manager/config/eg_external.ini");
	boolean hasConfigEnabled = EgInstallInfo.isConfigSupported;
	boolean hasReporteEnabled = EgInstallInfo.isReporterSupported;
	boolean login_as_egsm_in_sm=false;
	String needTvModeIntroSlide = egUi.getValue("Kiosk_Misc","needTvModeIntroSlide");
	String ManagerVersion = eg_dbaseIni.getValue("MANAGER_DETAILS","ManagerVersion");
	if(EgInstallInfo.isSuperManager)
	{
		login_as_egsm_in_sm=user.getLoginID().equals("egsm");
	}
	if(!StringUtils.isNull(param) && param.equalsIgnoreCase("All")) 
	{
		try
		{
			if (login_as_egsm_in_sm || userRole.getMonitorPerm() > 0 || hasReporteEnabled && userRole.getReporterPerm() > 0 || hasConfigEnabled && userRole.getConfigPerm() > 0)
			{
				Hashtable playbackFreq = new Hashtable();
				String kio_Frequency=egUi.getValue("Kiosk_Playback_Frequency",user.getLoginID().toLowerCase());
				if(kio_Frequency == null || kio_Frequency.equals(""))
				{
					kio_Frequency=egUi.getValue("Kiosk_Playback_Frequency","Kiosk_Default_Frequency");
				}
				EgTopoInfo topoinfo = null;
				Dashboard dash = null;
				MonitorDAOFactory monitorDaoFactory = null;
				EgServerDashBoardDAO dashboardDAO=null;
				StringTokenizer stFreq=new StringTokenizer(kio_Frequency,","); 
				while (stFreq.hasMoreTokens()) { 
					String val = stFreq.nextToken();
					StringTokenizer freq=new StringTokenizer(val,"^"); 
					while (freq.hasMoreTokens()) { 
						String screen_Key = freq.nextToken();
						String screen_Val = freq.nextToken();
						int timeFreq = Integer.parseInt(screen_Val);
						playbackFreq.put(screen_Key,timeFreq);
					}
				 }
				String eGTVModesupportedscreens = egUi.getValue("eG_TVMode_selected_screens",user.getLoginID().toLowerCase());
				eGTVModesupportedscreens = eGTVModesupportedscreens.replace('^',',');
				Map tvMp=new HashMap();
				tvMp.put("Monitor Dashboard","Monitor Dashboard");
				tvMp.put("Current Alarms","Current Alarms");
				tvMp.put("Virtual Dashboard","Virtual Dashboard");
				tvMp.put("Config Dashboard","Config Dashboard");
				tvMp.put("Reporter Dashboard","Reporter Dashboard");
				tvMp.put("Servers","Servers");
				StringTokenizer TvModetokens1 = new StringTokenizer(eGTVModesupportedscreens,",");
				while (TvModetokens1.hasMoreTokens())
				{
					JSONObject TvModuleMonObj = new JSONObject();
					StringTokenizer stokens1 = new StringTokenizer(TvModetokens1.nextToken(),"#");
					if(stokens1.countTokens()==2)
					{
						String TvKey = ((String)stokens1.nextToken()).toString();
						String TvValue = ((String)stokens1.nextToken()).toString();

						if( TvKey.indexOf("Service Topology")>-1)
						{
							List services =null;
							String serviceName = "";
							String serviceState = "";
							String segmentList = "";
							EgService serviceObj = null;
							String segment=null; 
							EgList serviceListObj = new EgList();
							if(dash==null)
							{
								dash = new Dashboard(user);
							}
							if(topoinfo==null)
							{
								topoinfo = new EgTopoInfo("manager");
							}
							services = dash.getSiteStatus();
						ArrayList serviceTopologySelectedScreensList = new ArrayList();
						String serviceTopologySelectedScreens=egUi.getValue("Service_Topology_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(!StringUtils.isNull(serviceTopologySelectedScreens))
						{
							StringTokenizer serviceTopologySelectedScreensTokens=new StringTokenizer(serviceTopologySelectedScreens,"~!~");
							while(serviceTopologySelectedScreensTokens.hasMoreTokens())
							{
								serviceTopologySelectedScreensList.add(serviceTopologySelectedScreensTokens.nextToken().toString());
							}
						}
						if(services!=null && !services.isEmpty())
						{
							String topologyUrl=TvValue+"?physical_topology=0&type=monitor&treeFlag=null&zoneName=&currentTab=null&aggregateTab=null&openNode=null&treeFlag=null&fromHomepage=&serviceGroup=null&iszoneName=&isFromZone=null&parentZone=undefined&action=service&serviceState=service20New_";
							 
							if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
							{
								TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
								TvModuleMonObj.put("timeFrequency",2000);
								TvModuleMonObj.put("module","Monitor");
								TvModuleMonObj.put("dashboardName","Service Topology");
								TvModuleMonObj.put("ManagerVersion",ManagerVersion);
								TvModuleMonObj.put("about","true");
								TvModulecombo.add(TvModuleMonObj);
							}
							for(int s = 0; s < services.size(); s++)
							{
								List row = (List)services.get(s);
								serviceName = row.get(0).toString().trim();
								serviceState = row.get(1).toString().trim();
								if(serviceTopologySelectedScreensList.contains(serviceName))
								{
									segmentList = topoinfo.getValue("WEB_SITE_SEGMENTS","Web_site:" + serviceName);
									StringTokenizer st = new StringTokenizer(segmentList,",");
									JSONObject TvModuleTopolgy = new JSONObject();
									while(st.hasMoreTokens()){
										segment = (String)st.nextToken();
										String serviceTopologyUrl = topologyUrl+serviceState+"&service="+serviceName+"&segment="+segment+"&site="+serviceName;
										String sp=new String(" ");
										String title="Service Name : "+serviceName;
										TvModuleMonObj.put("title",title);
										TvModuleMonObj.put("url",serviceTopologyUrl);
										TvModuleMonObj.put("timeFrequency",playbackFreq.get("Service Topology"));
										TvModuleMonObj.put("module","Monitor");
										TvModuleMonObj.put("dashboardName","Service Name : "+serviceName);
										TvModuleMonObj.put("about","false");
										TvModulecombo.add(TvModuleMonObj);
									}
								}
								else
								{
									if(!(serviceTopologySelectedScreensList.size() > 0))
									{
										segmentList = topoinfo.getValue("WEB_SITE_SEGMENTS","Web_site:" + serviceName);
										StringTokenizer st = new StringTokenizer(segmentList,",");
										JSONObject TvModuleTopolgy = new JSONObject();
										while(st.hasMoreTokens()){
											segment = (String)st.nextToken();
											String serviceTopologyUrl = topologyUrl+serviceState+"&service="+serviceName+"&segment="+segment+"&site="+serviceName;
											String sp=new String(" ");
											String title="Service Name : "+serviceName;
											TvModuleMonObj.put("title",title);
											TvModuleMonObj.put("url",serviceTopologyUrl);
											TvModuleMonObj.put("timeFrequency",playbackFreq.get("Service Topology"));
											TvModuleMonObj.put("module","Monitor");
											TvModuleMonObj.put("dashboardName","Service Name : "+serviceName);
											TvModuleMonObj.put("about","false");
											TvModulecombo.add(TvModuleMonObj);
										}
									}
								}
								
							}
						}
						else
						{
							TvModuleMonObj.put("title","Service Topology");
							TvModuleMonObj.put("url","/final/servlet/com.eg.EgMonitorController?monCmd=serviceList&from=MainDashboard&action=service&isFromMenu=true");
							TvModuleMonObj.put("timeFrequency",playbackFreq.get("Service Topology"));
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Service Topology");
							TvModuleMonObj.put("about","false");
							TvModulecombo.add(TvModuleMonObj);
						}
					
					}
					else if(TvKey.indexOf("My Dashboard")>-1)
					{
						JSONArray TvModeArrayMyDJson = new JSONArray();
						JSONObject TvModeMyDJson = new JSONObject();
						Hashtable templateDetails = new Hashtable();
						Vector personalTempdetails = new Vector();
						Vector shareTempdetails = new Vector();
						ArrayList mydashboardSelectedScreensList = new ArrayList();
						String mydashboardSelectedScreens=egUi.getValue("My_Dashboard_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(mydashboardSelectedScreens != null)
						{
							StringTokenizer mydashboardSelectedScreensTokens=new StringTokenizer(mydashboardSelectedScreens,"~!~");
							while(mydashboardSelectedScreensTokens.hasMoreTokens())
							{
								mydashboardSelectedScreensList.add(mydashboardSelectedScreensTokens.nextToken().toString());
							}
						}
						String myDashUrl=TvValue+"?comesFrom=myDashboard&action=showMyDashboard&isTvMode=true&profileName=";
						
						if(userRole.getMonitorPerm() > 0)
						{
							EgCustomModel egCustom = new EgCustomModel();
							templateDetails = egCustom.getTempDetails(user.getLoginID());
							JSONObject TvModuleConfigObj = new JSONObject();
							if ( templateDetails != null && !templateDetails.isEmpty() )
							{
								   
									personalTempdetails = (Vector)templateDetails.get("personal");
									shareTempdetails = (Vector)templateDetails.get("shared");
									if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
									{
										TvModuleConfigObj.put("url", "/final/tvmodeslidedetails.jsp");
										TvModuleConfigObj.put("timeFrequency",2000);
										TvModuleConfigObj.put("module","Monitor");
										TvModuleConfigObj.put("dashboardName","My Dashboard");
										TvModuleConfigObj.put("ManagerVersion",ManagerVersion);
										TvModuleConfigObj.put("about","true");
										TvModulecombo.add(TvModuleConfigObj);
									}	
									if ( personalTempdetails != null && personalTempdetails.size() > 0 )
									{
										for ( int i = 0 ; i < personalTempdetails.size() ; i++ )
										{
											String teomplateWithUser = (String)personalTempdetails.get(i);
											String template = teomplateWithUser.substring(0,teomplateWithUser.lastIndexOf("~#~"));
											
											if(mydashboardSelectedScreensList.contains(template))
											{
												TvModuleConfigObj.put("title",template);
												TvModuleConfigObj.put("url",myDashUrl+template);
												TvModuleConfigObj.put("timeFrequency",playbackFreq.get("My Dashboard"));
												TvModuleConfigObj.put("module","Monitor");
												TvModuleConfigObj.put("dashboardName",template);
												TvModuleConfigObj.put("about","false");
												TvModulecombo.add(TvModuleConfigObj);
											}
											else
											{
												if(!(mydashboardSelectedScreensList.size() > 0)){
													TvModuleConfigObj.put("title",template);
													TvModuleConfigObj.put("url",myDashUrl+template);
													TvModuleConfigObj.put("timeFrequency",playbackFreq.get("My Dashboard"));
													TvModuleConfigObj.put("module","Monitor");
													TvModuleConfigObj.put("dashboardName",template);
													TvModuleConfigObj.put("about","false");
													TvModulecombo.add(TvModuleConfigObj);
												}
											}
										}	
									}
									if ( shareTempdetails != null && shareTempdetails.size() > 0 )
									{
										for ( int j = 0 ; j < shareTempdetails.size() ; j++ )
										{
											String shareWithUser = (String)shareTempdetails.get(j);
											String shareTemplate = shareWithUser.substring(0,shareWithUser.lastIndexOf("~#~"));
											String sharedUser = shareWithUser.substring(shareWithUser.lastIndexOf("~#~")+3);
											String title = shareTemplate+" - "+sharedUser;
											if(mydashboardSelectedScreensList.contains(title))
											{
												TvModuleConfigObj.put("title",title);
												TvModuleConfigObj.put("url",myDashUrl+EgURLEncoder.encode(shareTemplate+"|USRSEP|"+sharedUser,"UTF-8"));
												TvModuleConfigObj.put("timeFrequency",playbackFreq.get("My Dashboard"));
												TvModuleConfigObj.put("module","Monitor");
												TvModuleConfigObj.put("dashboardName",shareTemplate+" - "+sharedUser);
												TvModuleConfigObj.put("about","false");
												TvModulecombo.add(TvModuleConfigObj);
											}
											else
											{
												if(!(mydashboardSelectedScreensList.size() > 0)){
													TvModuleConfigObj.put("title",title);
													TvModuleConfigObj.put("url",myDashUrl+EgURLEncoder.encode(shareTemplate+"|USRSEP|"+sharedUser,"UTF-8"));
													TvModuleConfigObj.put("timeFrequency",playbackFreq.get("My Dashboard"));
													TvModuleConfigObj.put("module","Monitor");
													TvModuleConfigObj.put("dashboardName",shareTemplate+" - "+sharedUser);
													TvModuleConfigObj.put("about","false");
													TvModulecombo.add(TvModuleConfigObj);
												}
											}
										}
									}
								}
								else
								{
									TvModuleConfigObj.put("url",TvValue);
									TvModuleConfigObj.put("timeFrequency",playbackFreq.get("My Dashboard"));
									TvModuleConfigObj.put("module","Monitor");
									TvModuleConfigObj.put("dashboardName","My Dashboard");
									TvModuleConfigObj.put("about","false");
									TvModulecombo.add(TvModuleConfigObj);
								}
						}
						
					}
					else if(TvKey.indexOf("Real User Monitoring")>-1)
					{
						String[] viewList = {"overview_view","geo_view","response_time_breakup_view","omni_channel","page_views","usage","errors"};
						Map viewListMap = new HashMap();
						viewListMap.put("overview_view","Overview");
						viewListMap.put("geo_view","Geo");
						viewListMap.put("response_time_breakup_view","Response Time Breakup");
						viewListMap.put("omni_channel","Omni Channel");
						viewListMap.put("page_views","Page Views");
						viewListMap.put("usage","Usage");
						viewListMap.put("errors","Errors");
						JSONObject TvModuleConfigObj = new JSONObject();
						String tvModeKey=TvKey+"#Real_user_monitor";
						String displayName=tvModeKey.substring(0,tvModeKey.indexOf("#"));
						String TVserverType=tvModeKey.substring(tvModeKey.indexOf("#")+1);
						ArrayList serverComp=user.getServersForType(TVserverType);
						ArrayList rumSelectedScreensList = new ArrayList();
						String rumSelectedScreens=egUi.getValue("Real_User_Monitoring_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(rumSelectedScreens != null){
							StringTokenizer rumSelectedScreensTokens=new StringTokenizer(rumSelectedScreens,"~!~");
							while(rumSelectedScreensTokens.hasMoreTokens())
							{
								rumSelectedScreensList.add(rumSelectedScreensTokens.nextToken().toString());
							}
						}
						if(serverComp!=null && !serverComp.isEmpty())
						{
							if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
							{
								TvModuleConfigObj.put("url", "/final/tvmodeslidedetails.jsp");
								TvModuleConfigObj.put("timeFrequency",2000);
								TvModuleConfigObj.put("module","Monitor");
								TvModuleConfigObj.put("dashboardName","Real User Monitoring Dashboard");
								TvModuleConfigObj.put("ManagerVersion",ManagerVersion);
								TvModuleConfigObj.put("about","true");
								TvModulecombo.add(TvModuleConfigObj);
							}
							TvModuleConfigObj.put("url",TvValue);
							TvModuleConfigObj.put("timeFrequency",playbackFreq.get("Real User Monitoring"));
							TvModuleConfigObj.put("module","Monitor");
							TvModuleConfigObj.put("dashboardName","Real User Monitoring Dashboard");
							TvModuleConfigObj.put("about","false");
							TvModulecombo.add(TvModuleConfigObj);
							String valueField="";
							for (int m=0;m<serverComp.size();m++)
							{
								String usercomp=(String)serverComp.get(m);
								String tmpserver=usercomp.substring(usercomp.indexOf(":")+1);
								String urltmpserver = tmpserver;
								if(tmpserver.indexOf(":NULL")>-1)
									tmpserver = tmpserver.substring(0,tmpserver.indexOf(":NULL"));
								String tmpserverType=usercomp.substring(0,usercomp.indexOf(":"));
								if(rumSelectedScreensList.contains(tmpserver))
								{
									if(tmpserverType!=null)
									{	
										for(int i=0;i<viewList.length;i++)
										{
											TvModuleConfigObj.put("url","/final/monitor/rumAppFlow.jsp?iniName=eg_rumdashboard&userBased=true&fromMenu=false&showConfig=true&dashboard_name=RUM_Dashboard&appliesTo="+urltmpserver+"&isBackFromRUM=true&view_name="+viewList[i]);
											TvModuleConfigObj.put("timeFrequency",playbackFreq.get("Real User Monitoring"));
											TvModuleConfigObj.put("module","Monitor");
											TvModuleConfigObj.put("dashboardName","Real User Monitoring Dashboard - "+tmpserver+" (View: "+viewListMap.get(viewList[i])+")");
											TvModuleConfigObj.put("about","false");
											TvModulecombo.add(TvModuleConfigObj);

										}
									}
								}
								else
								{
									if(!(rumSelectedScreensList.size() > 0))
									{
										if(tmpserverType!=null)
										{
											for(int i=0;i<viewList.length;i++)
											{
												TvModuleConfigObj.put("url","/final/monitor/rumAppFlow.jsp?iniName=eg_rumdashboard&userBased=true&fromMenu=false&showConfig=true&dashboard_name=RUM_Dashboard&appliesTo="+urltmpserver+"&isBackFromRUM=true&view_name="+viewList[i]);
												TvModuleConfigObj.put("timeFrequency",playbackFreq.get("Real User Monitoring"));
												TvModuleConfigObj.put("module","Monitor");
												TvModuleConfigObj.put("dashboardName","Real User Monitoring Dashboard - "+tmpserver+" (View: "+viewListMap.get(viewList[i])+")");
												TvModuleConfigObj.put("about","false");
												TvModulecombo.add(TvModuleConfigObj);
											}
										}
									}
								}
							}
						}
						else
						{	
							TvModuleConfigObj.put("url","/final/monitor/realUserMonitorsDashboard.jsp?drilldown=true&isFromMenu=true");
							TvModuleConfigObj.put("timeFrequency",playbackFreq.get("Real User Monitoring"));
							TvModuleConfigObj.put("module","Monitor");
							TvModuleConfigObj.put("dashboardName","Real User Monitoring");
							TvModuleConfigObj.put("about","false");
							TvModulecombo.add(TvModuleConfigObj);
						}
							
					}
					else if(TvKey.indexOf("Service List")>-1)
					{
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Services");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						TvModuleMonObj.put("url",TvValue+"?monCmd=serviceList&from=MainDashboard&action=service&isFromMenu=true");
						TvModuleMonObj.put("timeFrequency",playbackFreq.get("Services"));
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("dashboardName","Services");
						TvModuleMonObj.put("about","false");
						TvModulecombo.add(TvModuleMonObj);
					}
					else if(TvKey.indexOf("Zones")>-1)
					{
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Zones");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						TvModuleMonObj.put("url",TvValue+"?monCmd=zoneList&from=MainDashboard&action=zone&isFromMenu=true&fromKioskMode=yes");
						TvModuleMonObj.put("timeFrequency",playbackFreq.get("Zones"));
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("dashboardName","Zones");
						TvModuleMonObj.put("about","false");
						TvModulecombo.add(TvModuleMonObj);
					}
					else if(TvKey.indexOf("Business Dashboard")>-1)
					{
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Business Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						TvModuleMonObj.put("url",TvValue+"?monCmd=serviceList&from=MainDashboard&action=service&isServiceBusiDash=true&isFromMenu=true");
						TvModuleMonObj.put("timeFrequency",playbackFreq.get("Business Dashboard"));
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("dashboardName","Business Dashboard");
						TvModuleMonObj.put("about","false");
						TvModulecombo.add(TvModuleMonObj);
					}
					else if(TvKey.indexOf("Monitor Dashboard")>-1)
					{
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Monitor Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						TvModuleMonObj.put("url",TvValue+"?monCmd=dashboard");
						TvModuleMonObj.put("timeFrequency",playbackFreq.get("Monitor Dashboard"));
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("dashboardName","Monitor Dashboard");
						TvModuleMonObj.put("about","false");
						TvModulecombo.add(TvModuleMonObj);
					}
					else if(TvKey.indexOf("Synthetic Monitoring")>-1)
					{
						ArrayList allMonitorsList = new ArrayList();
						Hashtable monitorsAllTest = new Hashtable();
						List serverTypeList = user.getServerTypes();
						Vector params = egDashConfig.getAllValues("ExtTestDashboard");
						params.add("CtxXcXALogonSimTest");
						params.add("HrznLogonSimTest");
						params.add("AWSLogonSimTest");
						params.add("XchgLogonSimTest");
						Map allTestList = user.getTests();
						EgList componentList =null;
						componentList = serviceBean.getComponentsForUser(usr_server);
						boolean isallTestList = false;
						ArrayList syntheticMonitoringSelectedScreensList = new ArrayList();
						String syntheticMonitoringSelectedScreens=egUi.getValue("Synthetic_Monitoring_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(syntheticMonitoringSelectedScreens != null)
						{
							StringTokenizer syntheticMonitoringSelectedScreensTokens=new StringTokenizer(syntheticMonitoringSelectedScreens,"~!~");
							while(syntheticMonitoringSelectedScreensTokens.hasMoreTokens())
							{
								syntheticMonitoringSelectedScreensList.add(syntheticMonitoringSelectedScreensTokens.nextToken().toString());
							}
						}
						
						if(allTestList!=null && allTestList.size()>0 )
							isallTestList = true;
						if(params != null && params.size() > 0){
							for(int p=0;p<params.size();p++){
								String test =  (String) params.get(p);
								String disp_test = mappingInfo.getTestDescription(test);
								if(test.equalsIgnoreCase("OraSqlNetTest") && serverTypeList.contains("Oracle_server"))		
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.Oracle");				
								else if(test.equalsIgnoreCase("MsSqlNetTest") && serverTypeList.contains("MS_sql_server"))		
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.Microsoft SQL");
								else if(test.equalsIgnoreCase("CitraTest"))
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.Client Session Simulation");
								else if(test.equalsIgnoreCase("GenericLogonSimTest"))
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.Web App Simulation");
								else if(test.equalsIgnoreCase("HttpTest"))
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.HTTP Access");
								else if(test.equalsIgnoreCase("NetworkTest"))
									disp_test = mappingInfo.getTextDescription("monitor.endUserDashboard.Network Access");
								else if(test.equalsIgnoreCase("CtxXcXALogonSimTest"))
									disp_test = mappingInfo.getTestDescription(test);
								else if(test.equalsIgnoreCase("HrznLogonSimTest"))
									disp_test = mappingInfo.getTestDescription(test);
								else if(test.equalsIgnoreCase("AWSLogonSimTest"))
									disp_test = mappingInfo.getTestDescription(test);
								else if(test.equalsIgnoreCase("XchgLogonSimTest"))
									disp_test = mappingInfo.getTestDescription(test);
								else
									continue;
								
								allMonitorsList.add(disp_test);
								monitorsAllTest.put(disp_test,test);
							}
						}
						
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						for(int i=0;i<allMonitorsList.size();i++)
						{
							String name = (String)allMonitorsList.get(i);
							if(monitorsAllTest.containsKey(name))
							{
								String testName = (String)monitorsAllTest.get(name);
								if(isallTestList && allTestList.containsKey(testName))
								{
									boolean isLogonType = false;
									String locationBy = "";
									String componentNameSearch = "";
									String simulationName = "";
									String monitorBy = getMonitorBy(testName,egDashConfig);
									if(testName.equalsIgnoreCase("CtxXcXALogonSimTest"))
									{
										monitorBy="logonSimualtion";
									}
									String sortType = "ASC";
									String ltype = "";
									String sortBy = "";
									if(monitorBy.equalsIgnoreCase("logonSimualtion"))
									{
										ltype = "Citrix_XcLogon_Emulation";
										sortBy = "MSMT_TIME";
									}
									else if(monitorBy.equalsIgnoreCase("CITRA"))
									{
										ltype = "Emulated_client";
										sortBy = "TRGT_HOST,MSMT_TIME";
									}
									else if(monitorBy.equalsIgnoreCase("GENERIC"))
									{
										ltype = "Generic_Emulation";
										sortBy = "TRGT_HOST,MSMT_TIME";
									}
									ArrayList compTypeList = specsInfo.getAllComponentTypesForTest(testName);
									ArrayList externalAgentList =  new ArrayList();
									externalAgentList.add("All");
									if(compTypeList!=null && compTypeList.size()>0 )
									{
										for(int compTypeListIdx=0; compTypeListIdx < compTypeList.size(); compTypeListIdx++)
										{
											String compType = compTypeList.get(compTypeListIdx).toString();
											List compNameList = user.getServersForType(compType);
											if(compNameList!=null && compNameList.size()>0 )
											{
												
												for(int compNameListIdx=0; compNameListIdx < compNameList.size(); compNameListIdx++)
												{
													String compName = compNameList.get(compNameListIdx).toString();
													compName = compName.substring(compName.indexOf(":")+1,compName.lastIndexOf(":"));
													if(compName.indexOf(":")>-1)
														compName = compName.substring(0,compName.indexOf(":"));
													String tempExternalAgent = eg_externalIni.getValue("Test_Mapping_Section",compName);
													if(!StringUtils.isNull(tempExternalAgent) && !externalAgentList.contains(tempExternalAgent))
														externalAgentList.add(tempExternalAgent);
												}
											}
										}
									}
									if(externalAgentList.size() == 2 || externalAgentList.size() == 1)
										externalAgentList.remove("All");
									String treeTitle="";
									if(testName.equalsIgnoreCase("CtxXcXALogonSimTest"))
										treeTitle = "logonSimualtion";
									else if(testName.equalsIgnoreCase("HrznLogonSimTest"))
										treeTitle = "Hrzn_Logon_Emulation";
									else if(testName.equalsIgnoreCase("AWSLogonSimTest"))
										treeTitle = "Amazon_Logon_Emulation";
									else if(testName.equalsIgnoreCase("GenericLogonSimTest"))
										treeTitle = "ExtTestDashboard";
									else if(testName.equalsIgnoreCase("CitraTest"))
										treeTitle = "ExtTestDashboard";
									else if(testName.equalsIgnoreCase("XchgLogonSimTest"))
										treeTitle = "Xchg_Logon_Emulation";
									else
										treeTitle = "ExtTestDashboard";
									if(externalAgentList!=null && externalAgentList.size()>0 )
									{
										for(int externalAgentListIdx=0; externalAgentListIdx < externalAgentList.size(); externalAgentListIdx++)
										{
											String externalAgent = externalAgentList.get(externalAgentListIdx).toString();
											String syntheticMonitoringSelectedScreensCheck = name+"#"+externalAgent;
											if(syntheticMonitoringSelectedScreensList.contains(syntheticMonitoringSelectedScreensCheck))
											{
												
												TvModuleMonObj.put("url",TvValue+"?treeTitle="+treeTitle+"&isFromMenu=true&isLogonType=false&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent);
												TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
												TvModuleMonObj.put("module","Monitor");
												TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
												TvModuleMonObj.put("about","false");
												TvModulecombo.add(TvModuleMonObj);
												if(componentList!=null)
												{
													Hashtable measureDataTotal = null;
													Hashtable measureDataCitra = new Hashtable();
													boolean isCitraType = false;
													String testNameMonitorBy = egDashConfig.getValue("New_View_External_Monitor",monitorBy);
													if(testNameMonitorBy != null && testNameMonitorBy.trim().length()>0)
														isCitraType = true;
													if(!isLogonType && sortBy != null && sortBy.trim().length() > 0 && sortType != null && sortType.trim().length() > 0){
														String tmonitorBy = monitorBy;
														if(monitorBy.equalsIgnoreCase("logonSimualtion"))
															tmonitorBy = "LogonSimulator";
														measureDataTotal = serviceBean.getTestMeasureDataforExternal(componentList,true,tmonitorBy,locationBy,externalAgent,ltype,componentNameSearch+"||"+simulationName,sortBy,sortType);
														if(monitorBy !=null && isCitraType)
														{
															measureDataCitra = (Hashtable)measureDataTotal.get("dataCitra");	
														}
														ArrayList sortedMeasures = (ArrayList)measureDataTotal.get("sortedData");
														if(sortedMeasures != null && sortedMeasures.size() > 0){
															int sortedMeas_count=sortedMeasures.size();
															for(int u=0;u<sortedMeas_count;u++){
																ArrayList elements = (ArrayList)sortedMeasures.get(u);
																for(int l=0;l<elements.size();l++){
																	ArrayList innerEl = (ArrayList)elements.get(l);
																	if(innerEl != null && innerEl.size() > 0){
																		String info_elment = (String)innerEl.get(0);
																		String sorted_key_elemet = (String)innerEl.get(1);
																		String el_state = null;
																		if(innerEl.size() == 3)
																			el_state = (String)innerEl.get(2);
																		ArrayList sorted_key_elemet_list = com.egurkha.util.StringUtils.egTokenizer(sorted_key_elemet, ":",true,false,true);//3-->includeEmpty,4-->unique,5-->trim
																		if(sorted_key_elemet_list != null && sorted_key_elemet_list.size() == 7){
																			String el_comp_name = (String)sorted_key_elemet_list.get(0);
																			String el_port_name = (String)sorted_key_elemet_list.get(1);
																			String el_comp_type_name = (String)sorted_key_elemet_list.get(2);
																			String el_layer_name = (String)sorted_key_elemet_list.get(3);
																			String el_info_name = (String)sorted_key_elemet_list.get(4);
																			String sid = "";
																			if(el_info_name != null && el_info_name.trim().length() > 1 && !el_info_name.startsWith("+"))
																				sid = el_info_name.substring(0,el_info_name.indexOf("+"));
																			String el_test_name = (String)sorted_key_elemet_list.get(5);
																			String el_msmt_host_name = (String)sorted_key_elemet_list.get(6);
																			String temp_ext_agnet = el_msmt_host_name ;
																			String infoName = el_info_name;
																			if(infoName.startsWith("+"))
																					infoName=infoName.substring(1);
																			String temp_site="NULL";
																			String compWithPort = el_comp_name+":"+el_port_name;
																			if(sid != null && sid.trim().length() > 1)
																				compWithPort = compWithPort+":"+sid;
																			String tempDispComp = compWithPort;
																			if(tempDispComp!=null && tempDispComp.indexOf(":") > -1)
																			{
																				tempDispComp = tempDispComp.substring(0,tempDispComp.indexOf(":"));
																			}
																			String enInfoName="";
																			if(infoName!=null && infoName.trim().length()>0)
																			{
																				enInfoName=infoName;
																				enInfoName = com.egurkha.util.StringUtils.replace(enInfoName,"#","|hash|");
																				enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"+","|plus|");
																				enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"&","|amp|");
																				enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"%","|pct|");
																			}
																			
																			if(testName.equalsIgnoreCase("CtxXcXALogonSimTest")){
																				TvModuleMonObj.put("url","/final/monitor/componentMeasureTabSet.jsp?type="+ltype+"&site=NULL&host="+el_comp_name+"&port="+el_port_name+"&info="+el_msmt_host_name+"&orgInfo="+EgURLEncoder.encode(enInfoName,"UTF-8")+"&state=GOOD&messy=Logon_availability&clicked=dd&newWindow=true&from=cls&test="+testName+"&fromLogonSimualtion=true");
																				TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																				TvModuleMonObj.put("module","Monitor");
																				TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																				TvModuleMonObj.put("about","false");
																				TvModulecombo.add(TvModuleMonObj);
																			}else if(testName.equalsIgnoreCase("CitraTest")){
																				Hashtable dataCitra=(Hashtable)measureDataCitra.get(el_comp_name);
																				ArrayList scriptNameList= new ArrayList();
																				String keyScriptList = tempDispComp+":"+temp_ext_agnet+":"+testName+":SCRIPT:NAMELIST";
																				if(dataCitra.containsKey(keyScriptList))
																				{									
																					scriptNameList = (ArrayList)dataCitra.get(keyScriptList);
																				}
																				for(int ss=0;ss<scriptNameList.size();ss++)
																				{
																					String tempScriptName = (String)scriptNameList.get(ss);
																					TvModuleMonObj.put("url","/final/monitor/sessionSimulation.jsp?compName="+compWithPort+"&site="+EgURLEncoder.encode(temp_site,"UTF-8")+"&compType="+el_comp_type_name+"&msmt_host="+el_msmt_host_name+"&treeTitle="+treeTitle+"&ltype="+ltype+"&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent+"&isFromMenu=false&zoneName=null&fromHomepage=null&parentZone=null&isLogonType=false&fromp=ctxLogonDashboard&scriptName="+tempScriptName);
																					TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																					TvModuleMonObj.put("module","Monitor");
																					TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																					TvModuleMonObj.put("about","false");
																					TvModulecombo.add(TvModuleMonObj);
																				}
																			}else if(testName.equalsIgnoreCase("GenericLogonSimTest")){
																				TvModuleMonObj.put("url","/final/monitor/sessionSimulation.jsp?compName="+compWithPort+"&site="+EgURLEncoder.encode(temp_site,"UTF-8")+"&compType="+el_comp_type_name+"&msmt_host="+el_msmt_host_name+"&treeTitle="+treeTitle+"&ltype="+ltype+"&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent+"&isFromMenu=false&zoneName=null&fromHomepage=null&parentZone=null&isLogonType=false&fromp=ctxLogonDashboard&fromKioskMode=yes");
																				TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																				TvModuleMonObj.put("module","Monitor");
																				TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																				TvModuleMonObj.put("about","false");
																				TvModulecombo.add(TvModuleMonObj);
																			}
																		}
																	}
																}
															}
														}
														
													}
													
												}
												
											}
											else
											{
												if(!(syntheticMonitoringSelectedScreensList.size() > 0))
												{
													TvModuleMonObj.put("url",TvValue+"?treeTitle="+treeTitle+"&isFromMenu=true&isLogonType=false&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent);
													TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
													TvModuleMonObj.put("module","Monitor");
													TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
													TvModuleMonObj.put("about","false");
													TvModulecombo.add(TvModuleMonObj);
													if(componentList!=null)
													{
														Hashtable measureDataTotal = null;
														Hashtable measureDataCitra = new Hashtable();
														boolean isCitraType = false;
														String testNameMonitorBy = egDashConfig.getValue("New_View_External_Monitor",monitorBy);
														if(testNameMonitorBy != null && testNameMonitorBy.trim().length()>0)
															isCitraType = true;
														if(!isLogonType && sortBy != null && sortBy.trim().length() > 0 && sortType != null && sortType.trim().length() > 0){
															String tmonitorBy = monitorBy;
															if(monitorBy.equalsIgnoreCase("logonSimualtion"))
																tmonitorBy = "LogonSimulator";
															measureDataTotal = serviceBean.getTestMeasureDataforExternal(componentList,true,tmonitorBy,locationBy,externalAgent,ltype,componentNameSearch+"||"+simulationName,sortBy,sortType);
															if(monitorBy !=null && isCitraType)
															{
																measureDataCitra = (Hashtable)measureDataTotal.get("dataCitra");	
															}
															ArrayList sortedMeasures = (ArrayList)measureDataTotal.get("sortedData");
															if(sortedMeasures != null && sortedMeasures.size() > 0){
																int sortedMeas_count=sortedMeasures.size();
																for(int u=0;u<sortedMeas_count;u++){
																	ArrayList elements = (ArrayList)sortedMeasures.get(u);
																	for(int l=0;l<elements.size();l++){
																		ArrayList innerEl = (ArrayList)elements.get(l);
																		if(innerEl != null && innerEl.size() > 0){
																			String info_elment = (String)innerEl.get(0);
																			String sorted_key_elemet = (String)innerEl.get(1);
																			String el_state = null;
																			if(innerEl.size() == 3)
																				el_state = (String)innerEl.get(2);
																			ArrayList sorted_key_elemet_list = com.egurkha.util.StringUtils.egTokenizer(sorted_key_elemet, ":",true,false,true);//3-->includeEmpty,4-->unique,5-->trim
																			if(sorted_key_elemet_list != null && sorted_key_elemet_list.size() == 7){
																				String el_comp_name = (String)sorted_key_elemet_list.get(0);
																				String el_port_name = (String)sorted_key_elemet_list.get(1);
																				String el_comp_type_name = (String)sorted_key_elemet_list.get(2);
																				String el_layer_name = (String)sorted_key_elemet_list.get(3);
																				String el_info_name = (String)sorted_key_elemet_list.get(4);
																				String sid = "";
																				if(el_info_name != null && el_info_name.trim().length() > 1 && !el_info_name.startsWith("+"))
																					sid = el_info_name.substring(0,el_info_name.indexOf("+"));
																				String el_test_name = (String)sorted_key_elemet_list.get(5);
																				String el_msmt_host_name = (String)sorted_key_elemet_list.get(6);
																				String temp_ext_agnet = el_msmt_host_name ;
																				String infoName = el_info_name;
																				if(infoName.startsWith("+"))
																						infoName=infoName.substring(1);
																				String temp_site="NULL";
																				String compWithPort = el_comp_name+":"+el_port_name;
																				if(sid != null && sid.trim().length() > 1)
																					compWithPort = compWithPort+":"+sid;
																				String tempDispComp = compWithPort;
																				if(tempDispComp!=null && tempDispComp.indexOf(":") > -1)
																				{
																					tempDispComp = tempDispComp.substring(0,tempDispComp.indexOf(":"));
																				}
																				String enInfoName="";
																				if(infoName!=null && infoName.trim().length()>0)
																				{
																					enInfoName=infoName;
																					enInfoName = com.egurkha.util.StringUtils.replace(enInfoName,"#","|hash|");
																					enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"+","|plus|");
																					enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"&","|amp|");
																					enInfoName=com.egurkha.util.StringUtils.replace(enInfoName,"%","|pct|");
																				}
																				
																				if(testName.equalsIgnoreCase("CtxXcXALogonSimTest")){
																					TvModuleMonObj.put("url","/final/monitor/componentMeasureTabSet.jsp?type="+ltype+"&site=NULL&host="+el_comp_name+"&port="+el_port_name+"&info="+el_msmt_host_name+"&orgInfo="+EgURLEncoder.encode(enInfoName,"UTF-8")+"&state=GOOD&messy=Logon_availability&clicked=dd&newWindow=true&from=cls&test="+testName+"&fromLogonSimualtion=true");
																					TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																					TvModuleMonObj.put("module","Monitor");
																					TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																					TvModuleMonObj.put("about","false");
																					TvModulecombo.add(TvModuleMonObj);
																				}else if(testName.equalsIgnoreCase("CitraTest")){
																					Hashtable dataCitra=(Hashtable)measureDataCitra.get(el_comp_name);
																					ArrayList scriptNameList= new ArrayList();
																					String keyScriptList = tempDispComp+":"+temp_ext_agnet+":"+testName+":SCRIPT:NAMELIST";
																					if(dataCitra.containsKey(keyScriptList))
																					{									
																						scriptNameList = (ArrayList)dataCitra.get(keyScriptList);
																					}
																					for(int ss=0;ss<scriptNameList.size();ss++)
																					{
																						String tempScriptName = (String)scriptNameList.get(ss);
																						TvModuleMonObj.put("url","/final/monitor/sessionSimulation.jsp?compName="+compWithPort+"&site="+EgURLEncoder.encode(temp_site,"UTF-8")+"&compType="+el_comp_type_name+"&msmt_host="+el_msmt_host_name+"&treeTitle="+treeTitle+"&ltype="+ltype+"&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent+"&isFromMenu=false&zoneName=null&fromHomepage=null&parentZone=null&isLogonType=false&fromp=ctxLogonDashboard&scriptName="+tempScriptName);
																						TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																						TvModuleMonObj.put("module","Monitor");
																						TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																						TvModuleMonObj.put("about","false");
																						TvModulecombo.add(TvModuleMonObj);
																					}
																				}else if(testName.equalsIgnoreCase("GenericLogonSimTest")){
																					TvModuleMonObj.put("url","/final/monitor/sessionSimulation.jsp?compName="+compWithPort+"&site="+EgURLEncoder.encode(temp_site,"UTF-8")+"&compType="+el_comp_type_name+"&msmt_host="+el_msmt_host_name+"&treeTitle="+treeTitle+"&ltype="+ltype+"&ltest="+testName+"&monitorsBy="+monitorBy+"&externalAgent="+externalAgent+"&isFromMenu=false&zoneName=null&fromHomepage=null&parentZone=null&isLogonType=false&fromp=ctxLogonDashboard&fromKioskMode=yes");
																					TvModuleMonObj.put("timeFrequency",playbackFreq.get("Synthetic Monitoring"));
																					TvModuleMonObj.put("module","Monitor");
																					TvModuleMonObj.put("dashboardName","Synthetic Monitoring Dashboard"+" ("+name+")");
																					TvModuleMonObj.put("about","false");
																					TvModulecombo.add(TvModuleMonObj);
																				}
																			}
																		}
																	}
																}
															}
															
														}
														
													}
												}
											}
										}
									}
								}

							}
							
						}
					}
					else if(TvKey.indexOf("Office 365")>-1)
					{
						ArrayList off365DashboardSelectedScreensList = new ArrayList();
						String off365DashboardSelectedScreens=egUi.getValue("Office_365_Dashboard_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(off365DashboardSelectedScreens != null)
						{
							StringTokenizer off365DashboardSelectedScreensTokens=new StringTokenizer(off365DashboardSelectedScreens,"~!~");
							while(off365DashboardSelectedScreensTokens.hasMoreTokens())
							{
								off365DashboardSelectedScreensList.add(off365DashboardSelectedScreensTokens.nextToken().toString());
							}
						}
						String[] viewList = {"overview_view","service_health_view","license_usage_view","users_group_view","service_usage_view","All_Events"};
						Map viewListMap = new HashMap();
						viewListMap.put("overview_view","Overview");
						viewListMap.put("service_health_view","Service Health");
						viewListMap.put("license_usage_view","License Usage");
						viewListMap.put("users_group_view","Users/Groups");
						viewListMap.put("service_usage_view","Service Usage");
						viewListMap.put("All_Events","All Events");
						ArrayList accountValues  = (ArrayList) user.getServersForType("MS_Office_365");
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Office 365 Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						if(accountValues!=null && !accountValues.isEmpty())
						{
							for(int j=0; j<accountValues.size(); j++)
							{
								String accountValue = accountValues.get(j).toString();
								String accountName = accountValue.substring(accountValue.indexOf(":")+1,accountValue.lastIndexOf("_"));
								if(off365DashboardSelectedScreensList.contains(accountName))
								{
									for(int i=0; i<viewList.length;i++)
									{
										String dashboardName = "";
										if(viewList[i].equalsIgnoreCase("All_Events"))
											dashboardName = "365AlarmDetailsDashboard";
										else
											dashboardName = "MS365_Dashboard";
										TvModuleMonObj.put("url",TvValue+"?iniName=eg_msdashboard&userBased=true&fromMenu=true&showConfig=true&firstTimeHit=true&dashboard_name="+dashboardName+"&active_view="+viewList[i]+"&accountValue="+accountValue+"&accountName="+accountName);
										TvModuleMonObj.put("timeFrequency",playbackFreq.get("Office 365"));
										TvModuleMonObj.put("module","Monitor");
										TvModuleMonObj.put("dashboardName","Office 365 Dashboard"+" Tenant: "+accountName+" View: "+viewListMap.get(viewList[i]));
										TvModuleMonObj.put("about","false");
										TvModulecombo.add(TvModuleMonObj);
									}
								}
								else
								{
									if(!(off365DashboardSelectedScreensList.size() > 0))
									{
										for(int i=0; i<viewList.length;i++)
										{
											String dashboardName = "";
											if(viewList[i].equalsIgnoreCase("All_Events"))
												dashboardName = "365AlarmDetailsDashboard";
											else
												dashboardName = "MS365_Dashboard";
											TvModuleMonObj.put("url",TvValue+"?iniName=eg_msdashboard&userBased=true&fromMenu=true&showConfig=true&firstTimeHit=true&dashboard_name="+dashboardName+"&active_view="+viewList[i]+"&accountValue="+accountValue+"&accountName="+accountName);
											TvModuleMonObj.put("timeFrequency",playbackFreq.get("Office 365"));
											TvModuleMonObj.put("module","Monitor");
											TvModuleMonObj.put("dashboardName","Office 365 Dashboard"+" Tenant: "+accountName+" View: "+viewListMap.get(viewList[i]));
											TvModuleMonObj.put("about","false");
											TvModulecombo.add(TvModuleMonObj);
										}
									}
								}
							}
						}
					}
					else if(TvKey.indexOf("SAP Platform")>-1)
					{
						
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","SAP Platform Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
							
						TvModuleMonObj.put("url",TvValue);
						TvModuleMonObj.put("timeFrequency",playbackFreq.get("SAP Platform"));
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("dashboardName","SAP Platform Dashboard");
						TvModuleMonObj.put("about","false");
						TvModulecombo.add(TvModuleMonObj);
					}
					else if(TvKey.indexOf("SAP ABAP Dashboard")>-1)
					{
						ArrayList sapDashboardSelectedScreensList = new ArrayList();
						String sapDashboardSelectedScreens=egUi.getValue("SAP_ABAP_Dashboard_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(sapDashboardSelectedScreens != null){
							StringTokenizer sapDashboardSelectedScreensTokens=new StringTokenizer(sapDashboardSelectedScreens,"~!~");
							while(sapDashboardSelectedScreensTokens.hasMoreTokens())
							{
								sapDashboardSelectedScreensList.add(sapDashboardSelectedScreensTokens.nextToken().toString());
							}
						}
						
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","SAP ABAP Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						
						ArrayList serverComp=user.getServersForType("SAP_R3_server");
						if(serverComp!=null && !serverComp.isEmpty())
						{
							for (int m=0;m<serverComp.size();m++)
							{
								String usercomp=(String)serverComp.get(m);
								String tmpserver=usercomp.substring(usercomp.indexOf(":")+1);
								if(sapDashboardSelectedScreensList.contains(tmpserver))
								{
									TvModuleMonObj.put("url",TvValue+"?loadSAPCombo=true&action=loadSAPDashboard&selectedComp="+tmpserver);
									TvModuleMonObj.put("timeFrequency",playbackFreq.get("SAP ABAP Dashboard"));
									TvModuleMonObj.put("module","Monitor");
									TvModuleMonObj.put("dashboardName","SAP ABAP Dashboard"+" ("+tmpserver+")");
									TvModuleMonObj.put("about","false");
									TvModulecombo.add(TvModuleMonObj);
								}
								else
								{
									if(!(sapDashboardSelectedScreensList.size() > 0))
									{
										TvModuleMonObj.put("url",TvValue+"?loadSAPCombo=true&action=loadSAPDashboard&selectedComp="+tmpserver);
										TvModuleMonObj.put("timeFrequency",playbackFreq.get("SAP ABAP Dashboard"));
										TvModuleMonObj.put("module","Monitor");
										TvModuleMonObj.put("dashboardName","SAP ABAP Dashboard"+" ("+tmpserver+")");
										TvModuleMonObj.put("about","false");
										TvModulecombo.add(TvModuleMonObj);
									}
								}
								
							}
						}
					}
					else if(TvKey.indexOf("Citrix/VDI Dashboard")>-1)
					{
						ArrayList xenappDashboardSelectedScreensList = new ArrayList();
						String xenappDashboardSelectedScreens=egUi.getValue("Citrix/VDI_Dashboard_TVMode_selected_screens",user.getLoginID().toLowerCase());
						if(xenappDashboardSelectedScreens != null)
						{
							StringTokenizer xenappDashboardSelectedScreensTokens=new StringTokenizer(xenappDashboardSelectedScreens,"~!~");
							while(xenappDashboardSelectedScreensTokens.hasMoreTokens())
							{
								xenappDashboardSelectedScreensList.add(xenappDashboardSelectedScreensTokens.nextToken().toString());
							}
						}
						String dashboardTypesList[] = citrixConfig.getVariables("Dashboard_Types");
						String[] viewList = {"Geo_View","Logon_View","UserExperience_View","Broker_View","Sessions_View","Applications_View","Resources_View","Alerts_View"};
						Map viewListMap = new HashMap();
						viewListMap.put("Geo_View","Overview");
						viewListMap.put("Logon_View","Logon");
						viewListMap.put("UserExperience_View","User Experience");
						viewListMap.put("Broker_View","Delivery Groups");
						viewListMap.put("Sessions_View","Sessions");
						viewListMap.put("Applications_View","Applications");
						viewListMap.put("Resources_View","Resources");
						viewListMap.put("Alerts_View","Alerts");
						if(!StringUtils.isNull(needTvModeIntroSlide) && needTvModeIntroSlide.equalsIgnoreCase("yes"))
						{
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("dashboardName","Citrix/VDI Dashboard");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
						}
						if(dashboardTypesList.length > 0)
						{
							for(int j=0; j<dashboardTypesList.length; j++)
							{
								String dashboardType = dashboardTypesList[j];
								String type_dash_str=citrixConfig.getValue("Dashboard_Types",dashboardType);
								
								ArrayList type_dash_list_main = null;
								if(type_dash_str!=null && type_dash_str.trim().length()>0)
								{
									type_dash_list_main = (ArrayList)com.egurkha.util.StringUtils.egTokenizer(type_dash_str, ",",false,true,true);		//param 3-->includeEmpty,4-->unique,5-->trim
								}

								if(type_dash_list_main!=null && type_dash_list_main.size()>0)
								{
									for(int hh=0;hh<type_dash_list_main.size();hh++)
									{
										String type_dash_str_final=(String)type_dash_list_main.get(hh);
										if(type_dash_str_final!=null && type_dash_str_final.length()>0)
										{
											ArrayList f_typedashboard_list = (ArrayList)com.egurkha.util.StringUtils.egTokenizer(type_dash_str_final, ":",false,false,true);		//param 3-->includeEmpty,4-->unique,5-->trim
											String dash_name=(String)f_typedashboard_list.get(0);
											String Dashboard_Title = citrixConfig.getValue(dash_name,"Dashboard_Title");
											String d_comp_type=(String)f_typedashboard_list.get(1);
											String d_agg_comp_type = "";
											String disp_comp_type="";
											String userName = user.getLoginID();
											if(d_comp_type != null && !d_comp_type.startsWith("Agg"))
												d_agg_comp_type = "Agg_"+d_comp_type;

											if(userServerTypes!=null && (userServerTypes.contains(d_comp_type) || userServerTypes.contains(d_agg_comp_type)))
											{
												disp_comp_type=mappingInfo.getComponentTypeDescription(d_comp_type);
											}
											String[] dashboards_arr = citrixConfig.getVariables(userName+":"+dash_name+":Mapping");
											if(dashboards_arr.length>0)
											{
												for(int a = 0; a < dashboards_arr.length; a++)
												{
													String selected_dash = dashboards_arr[a];
													if(selected_dash.equalsIgnoreCase("DefaultView"))
														continue;
													String xenappDashboardSelectedScreensCheck = Dashboard_Title+"#"+disp_comp_type+"#"+selected_dash;
													if(xenappDashboardSelectedScreensList.contains(xenappDashboardSelectedScreensCheck))
													{
														for(int i=0; i<viewList.length;i++)
														{
															TvModuleMonObj.put("url",TvValue + "?iniName=eg_citrixdashboard&userBased=true&fromMenu=true&showConfig=true&dashboard_name="+dash_name.trim()+"&dashboard_type="+dashboardType.trim()+"&view_name="+viewList[i]+"&dashboard_mapping="+selected_dash.trim());
															TvModuleMonObj.put("timeFrequency",playbackFreq.get("Citrix/VDI Dashboard"));
															TvModuleMonObj.put("module","Monitor");
															TvModuleMonObj.put("dashboardName","XenApp Dashboard View: "+selected_dash.trim()+" Tab: "+viewListMap.get(viewList[i]));
															TvModuleMonObj.put("about","false");
															TvModulecombo.add(TvModuleMonObj);
														}
													}
													else
													{
														if(!(xenappDashboardSelectedScreensList.size() > 0))
														{
															for(int i=0; i<viewList.length;i++)
															{
																TvModuleMonObj.put("url",TvValue + "?iniName=eg_citrixdashboard&userBased=true&fromMenu=true&showConfig=true&dashboard_name="+dash_name.trim()+"&dashboard_type="+dashboardType.trim()+"&view_name="+viewList[i]+"&dashboard_mapping="+selected_dash.trim());
																TvModuleMonObj.put("timeFrequency",playbackFreq.get("Citrix/VDI Dashboard"));
																TvModuleMonObj.put("module","Monitor");
																TvModuleMonObj.put("dashboardName","XenApp Dashboard View: "+selected_dash.trim()+" Tab: "+viewListMap.get(viewList[i]));
																TvModuleMonObj.put("about","false");
																TvModulecombo.add(TvModuleMonObj);
															}
														
														}
													}
												}
											}
										}
									}
								}
								
							}
						}
						
					}
					else
					{
						if(tvMp.containsKey(TvKey) || TvKey.indexOf("FAV-")>-1){
							if(TvKey.indexOf("FAV-")>-1){
								TvKey = TvKey.substring("FAV-".length());
							}
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("dashboardName",TvKey);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
							TvModuleMonObj.put("title",TvKey);
							TvModuleMonObj.put("timeFrequency",playbackFreq.get(TvKey));
							TvModuleMonObj.put("dashboardName",TvKey);
						}else{
							TvKey=null;
							TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
							TvModuleMonObj.put("timeFrequency",2000);
							TvModuleMonObj.put("dashboardName",TvKey);
							TvModuleMonObj.put("module","Monitor");
							TvModuleMonObj.put("ManagerVersion",ManagerVersion);
							TvModuleMonObj.put("about","true");
							TvModulecombo.add(TvModuleMonObj);
							TvModuleMonObj.put("title",TvKey);
							TvModuleMonObj.put("timeFrequency",playbackFreq.get(TvKey));
							TvModuleMonObj.put("dashboardName",TvKey);
						}
						TvModuleMonObj.put("module","Monitor");
						TvModuleMonObj.put("about","false");
						TvModuleMonObj.put("url",TvValue);
						TvModulecombo.add(TvModuleMonObj);
					}
				
				}
				
			}
		}
		
		rootJson.put("AllTvModulecombo", TvModulecombo);
		}
		catch(Throwable t)
		{
			t.printStackTrace();
		}
	}
	else if(param!=null && param.equalsIgnoreCase("Monitor")) 
	{
		if (login_as_egsm_in_sm || userRole.getMonitorPerm() > 0)
		{
			String MonitorTVModesupportedscreens = egUi.getValue("Monitor_TVMode_selected_screens",user.getLoginID().toLowerCase());
			StringTokenizer TvModetokens1 = new StringTokenizer(MonitorTVModesupportedscreens,",");
			JSONObject TvModuleMonObj = new JSONObject();
			while (TvModetokens1.hasMoreTokens())
			{
				
				StringTokenizer stokens1 = new StringTokenizer(TvModetokens1.nextToken(),"#");
				if(stokens1.countTokens()==2)
				{
					String TvKey = ((String)stokens1.nextToken()).toString();
					String TvValue = ((String)stokens1.nextToken()).toString();
					TvModuleMonObj.put("url", "/final/tvmodeslidedetails.jsp");
					TvModuleMonObj.put("timeFrequency",2000);
					TvModuleMonObj.put("module","Monitor");
					TvModuleMonObj.put("dashboardName",TvKey);
					TvModuleMonObj.put("ManagerVersion",ManagerVersion);
					TvModuleMonObj.put("about","true");
					TvModulecombo.add(TvModuleMonObj);
					TvModuleMonObj.put("title",TvKey);
					TvModuleMonObj.put("url",TvValue);
					TvModuleMonObj.put("timeFrequency",10000);
					TvModuleMonObj.put("module","Monitor");
					TvModuleMonObj.put("dashboardName",TvKey);
					TvModuleMonObj.put("about","false");
				}
				TvModulecombo.add(TvModuleMonObj);
			}
		}
		rootJson.put("MonitorTvModulecombo", TvModulecombo);
	}
	else if(param!=null && param.equalsIgnoreCase("Reporter")) 
	{
		if (login_as_egsm_in_sm || hasReporteEnabled && userRole.getReporterPerm() > 0)
		{
			String ReporterTVModesupportedscreens = egUi.getValue("Reporter_TVMode_selected_screens",user.getLoginID().toLowerCase());
			StringTokenizer TvModetokens1 = new StringTokenizer(ReporterTVModesupportedscreens,",");
			JSONObject TvModuleRepObj = new JSONObject();
			while (TvModetokens1.hasMoreTokens())
			{
				StringTokenizer stokens1 = new StringTokenizer(TvModetokens1.nextToken(),"#");
				if(stokens1.countTokens()==2)
				{
					String TvKey = ((String)stokens1.nextToken()).toString();
					String TvValue = ((String)stokens1.nextToken()).toString();
					TvModuleRepObj.put("url", "/final/tvmodeslidedetails.jsp");
					TvModuleRepObj.put("timeFrequency",2000);
					TvModuleRepObj.put("module","Reporter");
					TvModuleRepObj.put("dashboardName",TvKey);
					TvModuleRepObj.put("ManagerVersion",ManagerVersion);
					TvModuleRepObj.put("about","true");
					TvModulecombo.add(TvModuleRepObj);
					TvModuleRepObj.put("title",TvKey);
					TvModuleRepObj.put("url",TvValue);
					TvModuleRepObj.put("timeFrequency",10000);
					TvModuleRepObj.put("module","Reporter");
					TvModuleRepObj.put("dashboardName",TvKey);
					TvModuleRepObj.put("about","false");
				}
				TvModulecombo.add(TvModuleRepObj);
			}
		}
		rootJson.put("ReporterTvModulecombo", TvModulecombo);
	} 
	else if(param!=null && param.equalsIgnoreCase("Config")) 
	{
		if (login_as_egsm_in_sm || hasConfigEnabled && userRole.getConfigPerm() > 0)
		{
			String ConfigTVModesupportedscreens = egUi.getValue("Config_TVMode_selected_screens",user.getLoginID().toLowerCase());
			StringTokenizer TvModetokens1 = new StringTokenizer(ConfigTVModesupportedscreens,",");
			JSONObject TvModuleConfigObj = new JSONObject();
			while (TvModetokens1.hasMoreTokens())
			{
				StringTokenizer stokens1 = new StringTokenizer(TvModetokens1.nextToken(),"#");
				if(stokens1.countTokens()==2)
				{
					String TvKey = ((String)stokens1.nextToken()).toString();
					String TvValue = ((String)stokens1.nextToken()).toString();
					TvModuleConfigObj.put("url", "/final/tvmodeslidedetails.jsp");
					TvModuleConfigObj.put("timeFrequency",2000);
					TvModuleConfigObj.put("module","Config");
					TvModuleConfigObj.put("dashboardName",TvKey);
					TvModuleConfigObj.put("ManagerVersion",ManagerVersion);
					TvModuleConfigObj.put("about","true");
					TvModulecombo.add(TvModuleConfigObj);
					TvModuleConfigObj.put("title",TvKey);
					TvModuleConfigObj.put("url",TvValue);
					TvModuleConfigObj.put("timeFrequency",10000);
					TvModuleConfigObj.put("module","Config");
					TvModuleConfigObj.put("dashboardName",TvKey);
					TvModuleConfigObj.put("about","false");
				}
				TvModulecombo.add(TvModuleConfigObj);
			}
		}
		rootJson.put("ConfigTvModulecombo", TvModulecombo);
	}
	else if(param!=null && param.equalsIgnoreCase("MyDashboard"))
	{
		JSONArray TvModeArrayMyDJson = new JSONArray();
		JSONObject TvModeMyDJson = new JSONObject();
		Hashtable templateDetails = new Hashtable();
		Vector personalTempdetails = new Vector();
		Vector shareTempdetails = new Vector();
		ArrayList mydashboardSelectedScreensList = new ArrayList();
		String mydashboardSelectedScreens=egUi.getValue("My_Dashboard_TVMode_selected_screens",user.getLoginID().toLowerCase());
		if(mydashboardSelectedScreens != null)
		{
			StringTokenizer mydashboardSelectedScreensTokens=new StringTokenizer(mydashboardSelectedScreens,"~!~");
			while(mydashboardSelectedScreensTokens.hasMoreTokens())
			{
				mydashboardSelectedScreensList.add(mydashboardSelectedScreensTokens.nextToken().toString());
			}
		}
		String myDashUrl="/final/monitor/MyDashboard.jsp?comesFrom=myDashboard&action=showMyDashboard&isTvMode=true&profileName=";
		if(userRole.getMonitorPerm() > 0)
		{
			EgCustomModel egCustom = new EgCustomModel();
			templateDetails = egCustom.getTempDetails(user.getLoginID());
			if ( templateDetails != null && !templateDetails.isEmpty() )
			{
				   	JSONObject TvModuleConfigObj = new JSONObject();
					personalTempdetails = (Vector)templateDetails.get("personal");
					shareTempdetails = (Vector)templateDetails.get("shared");
					TvModuleConfigObj.put("url", "/final/tvmodeslidedetails.jsp");
					TvModuleConfigObj.put("timeFrequency",2000);
					TvModuleConfigObj.put("module","Monitor");
					TvModuleConfigObj.put("dashboardName","My Dashboard");
					TvModuleConfigObj.put("ManagerVersion",ManagerVersion);
					TvModuleConfigObj.put("about","true");
					TvModulecombo.add(TvModuleConfigObj);
					if ( personalTempdetails != null && personalTempdetails.size() > 0 )
					{
						for ( int i = 0 ; i < personalTempdetails.size() ; i++ )
						{
							String teomplateWithUser = (String)personalTempdetails.get(i);
							String template = teomplateWithUser.substring(0,teomplateWithUser.lastIndexOf("~#~"));
							if(mydashboardSelectedScreensList.contains(template))
							{
								TvModuleConfigObj.put("title",template);
								TvModuleConfigObj.put("url",myDashUrl+template);
								TvModuleConfigObj.put("timeFrequency",10000);
								TvModuleConfigObj.put("module","Monitor");
								TvModuleConfigObj.put("dashboardName",template);
								TvModuleConfigObj.put("about","false");
								TvModulecombo.add(TvModuleConfigObj);
							}
							else
							{
								if(!(mydashboardSelectedScreensList.size() > 0)){
									TvModuleConfigObj.put("title",template);
									TvModuleConfigObj.put("url",myDashUrl+template);
									TvModuleConfigObj.put("timeFrequency",10000);
									TvModuleConfigObj.put("module","Monitor");
									TvModuleConfigObj.put("dashboardName",template);
									TvModuleConfigObj.put("about","false");
									TvModulecombo.add(TvModuleConfigObj);
								}
							}
						}	
					}
					if ( shareTempdetails != null && shareTempdetails.size() > 0 )
					{
						for ( int j = 0 ; j < shareTempdetails.size() ; j++ )
						{
							String shareWithUser = (String)shareTempdetails.get(j);
							String shareTemplate = shareWithUser.substring(0,shareWithUser.lastIndexOf("~#~"));
							String sharedUser = shareWithUser.substring(shareWithUser.lastIndexOf("~#~")+3);
							String title = shareTemplate+" - "+sharedUser;
							if(mydashboardSelectedScreensList.contains(title))
							{
								TvModuleConfigObj.put("title",title);
								TvModuleConfigObj.put("url",myDashUrl+EgURLEncoder.encode(shareTemplate+"|USRSEP|"+sharedUser,"UTF-8"));
								TvModuleConfigObj.put("timeFrequency",10000);
								TvModuleConfigObj.put("module","Monitor");
								TvModuleConfigObj.put("dashboardName",shareTemplate+" ("+sharedUser+")");
								TvModuleConfigObj.put("about","false");
								TvModulecombo.add(TvModuleConfigObj);
							}
							else
							{
								if(!(mydashboardSelectedScreensList.size() > 0)){
									TvModuleConfigObj.put("title",title);
									TvModuleConfigObj.put("url",myDashUrl+EgURLEncoder.encode(shareTemplate+"|USRSEP|"+sharedUser,"UTF-8"));
									TvModuleConfigObj.put("timeFrequency",10000);
									TvModuleConfigObj.put("module","Monitor");
									TvModuleConfigObj.put("dashboardName",shareTemplate+" ("+sharedUser+")");
									TvModuleConfigObj.put("about","false");
									TvModulecombo.add(TvModuleConfigObj);
								}
							}
						}
					}
				}
		}
		rootJson.put("AllTvModulecombo", TvModulecombo);
	}else if(!StringUtils.isNull(param) && param.equalsIgnoreCase("tvModeGeneric")) 
	{
		String imageName = getLogo(_user);
		rootJson.put("logo",imageName);
	}
	response.getWriter().write(rootJson.toString());
} 
catch(Throwable e) 
{
	e.printStackTrace();
}
%>
<%!
public String getMonitorBy(String test_name,com.eg.IniFile egDashConfig)
{
	String monitor_by = "";
	String dash_ar[]= egDashConfig.getVariables("ExtTestDashboard");
	if(dash_ar!=null && dash_ar.length>0)
	{
		for(int monT=0;monT<dash_ar.length;monT++)
		{
			String s_support_type = dash_ar[monT];
			String s_support_type_test =egDashConfig.getValue("ExtTestDashboard",s_support_type);
			if(s_support_type_test.equalsIgnoreCase(test_name))
			{
				monitor_by = s_support_type;
				break;
			}
		}
	}
	return monitor_by;
}
%>
<%! 
	public String getLogo(User _user){
		String temp_id = _user.getLoginID();
		String imageName = null;
		String tempLogo=_user.getUserLogo();
		IniUI ui = IniUI.getInstance();
		String userLogo[] = StringUtils.getTokens(tempLogo,"\\");
		String temp="";
		ArrayList extensionList = new ArrayList();
		extensionList.add("gif");
		extensionList.add("jpeg");
		extensionList.add("jpg");
		extensionList.add("png");
		if(userLogo!=null && userLogo.length==5)
		{
			temp=userLogo[1];
		}
		if(!temp.equals("c"))
		{
			imageName = ui.getMonitorHomeLogo();
		}
		else if(EgInstallInfo.isSuperManager)
		{
			imageName="/final/monitor/eg_images/egsm_monitor.gif";
		}
		else
		{
			if(temp_id!=null && temp_id.indexOf("/")>-1)
			{
				String domainName=temp_id.substring(0,temp_id.indexOf("/"));
				String userName=temp_id.substring(temp_id.indexOf("/")+1,temp_id.length());
				if(userName.indexOf("Grp")>-1)
				{
					userName=userName.substring(userName.indexOf("/")+1,userName.length());
				}
				userName = StringUtils.replace(userName," ","");
				temp_id=domainName.toLowerCase()+"_"+userName;
				
			}
			for (int ext = 0; ext < extensionList.size(); ext++)
			{
				String strExtension = (String)extensionList.get(ext);
				File sourceFile = new File(EgInstallInfo.getInstallDir()+"/manager/tomcat/webapps/final/monitor/eg_images/"+temp_id+"_monitor."+strExtension);
				if (sourceFile.exists())
				{
					try{
						imageName="/final/monitor/eg_images/"+EgURLEncoder.encode(temp_id,"UTF-8")+"_monitor."+strExtension;
					}catch(Exception e){
						System.out.println("Exception in getLogo method of tvmode.jsp : "+e);
					}
					break;
				}
			}
		}
		return imageName;
	}
%>