<%
/************************************************************************************************
*	File				: ErApplicationLaunchCountReport.jsp
*	Purpose			:	Displays the configured measures and its details for the Citrix Applications
*	Version			:	Reporter v5.65
*	Author			:	Arul Edward J
*	Creation Date	:	03/06/14 
*
*************************************************************************************************/
%>

<%@ page import = "egurkha.reporter.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.text.SimpleDateFormat" %>
<%@ page import = "java.text.ParseException" %>
<%@ page import ="com.eg.ErDbServer"%>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.eg.EgDbInfo" %>
<%@ page import ="com.eg.EgInstallInfo"%>
<%@ page import ="com.eg.IniFile"%>
<%@ page import="com.egurkha.ini.*" %>
<%@ page import="com.eg.EgDateInfo" %>
<%@ page import="com.eg.EgGroupInfo" %>
<%@ page import="com.eg.EgReportInfo" %>
<%@ page import = "com.egurkha.*" %>
<%@ include file = "ErReporterTracker.jsp" %>
<%@ page import = "java.net.*" %>
<%@ page import="com.eg.EgThresholdInfo" %>
<%@ page import="com.eg.EgTablesInfo" %>
<%@ page import="com.eg.EgMappingInfo" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "java.net.URLDecoder" %>
<%@ page import = "com.eg.EgURLEncoder" %>
<%@ page import = "com.egurkha.util.DateTimeTokenizer" %>
<%@ page import = "com.egurkha.util.DateUtil" %>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import = "egurkha.reporter.ErNumreicComparator" %>
<%@ page import = "java.text.*" %>
<%@ page import="net.sf.json.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgAgentInfo" %>
<%@ page import = "egurkha.reporter.ErVMGuestServerReportBean" %>


<%@ taglib prefix="egui" uri="../WEB-INF/eg-taglib.tld" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%//6/18/2014 1:34 PM
try
{	
	JSONObject combo=new JSONObject();
	JSONObject urlFields=new JSONObject();
	JSONObject labelFields=new JSONObject();
    JSONObject hiddenFields = new JSONObject();
	JSONObject selectedFields = new JSONObject();
	JSONObject selectionDetails = new JSONObject();
	JSONObject data = new JSONObject();
	JSONObject graph = new JSONObject();
	JSONObject durationGraph = new JSONObject();
	JSONObject iterateJObject;
	JSONArray iterateJArray;
	JSONArray selectedComboJArray=null;
 	JSONObject applicationLaunch=new JSONObject();
	JSONObject loopJsonObj = new JSONObject();

	String bggroundStr = (String)request.getAttribute("bggroundStr");
	String status = (String)request.getAttribute("status");
	String isSearchByVmCompSt = request.getParameter("isSearchByVmComp");
	String isLaunchByVmSt = request.getParameter("islaunchByVm");

	boolean isLaunchByVm=false;
	boolean isSearchByVmComp=false;
	boolean isAppLaunchDuarationColumnEnabled = false;

	if(isSearchByVmCompSt!=null && isSearchByVmCompSt.equalsIgnoreCase("true"))
	{
		isSearchByVmComp=true;
	}
	if(isLaunchByVmSt!=null && isLaunchByVmSt.equalsIgnoreCase("true"))
	{
		isLaunchByVm=true;
	}
	String strTestt="";
	//Back Button - Start

	HashMap backreqMap = (HashMap)session.getAttribute("backQuery");
	String backQnumber = request.getParameter("backQnumber");
	String servlet2 = request.getParameter("backServletName");
	String reqFromFavorite = request.getParameter("fromFavorite");
	String favorite_id = request.getParameter("FavoriteId");
	 List tListt=null;
	ErHelperUtils erhelputils = null;
	ErEsxVMutils erEsxUtils = new ErEsxVMutils();
	erEsxUtils.setNeedGroupTire(true);
	if( servlet2!=null && !servlet2.equals(""))
		erhelputils = new ErHelperUtils(backreqMap,backQnumber,servlet2);
	else
		erhelputils = new ErHelperUtils(backreqMap,backQnumber);

	boolean enableBack=erhelputils.isBackButtonEnable();
	String backButtonEnable = request.getParameter("back");
	applicationLaunch.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
	if(backButtonEnable != null && backButtonEnable.equalsIgnoreCase("True"))
	{
		status = (String)request.getParameter("status");
		request.setAttribute("htdata",null);
		request.setAttribute("app_topusers",null);
		request.setAttribute("appChartData",null);
		bggroundStr = (String)request.getParameter("bggroundStr");
	}
	//Back Button - End
	Map resultMap = (HashMap) session.getAttribute("APPLICATION_LAUNCH_COUNT");
	String mngrIProc = new IniFile(new EgConfigInfo("manager").getDbFile()).getValue("DB_PROPERTIES","ManagerUrl");

	IniFile inifile_service = new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_services.ini");
	boolean showADShortName = false;
	String strShowEntities = inifile_service.getValue("AD_XENUSER_REPORT","ShowEntities");
	if(strShowEntities!=null && !strShowEntities.equalsIgnoreCase("descriptive"))
	showADShortName = true;
	List lst = new LinkedList();
	Vector v_measure_csv = new Vector();
	List list_data = new LinkedList();

	IniUI ui = IniUI.getInstance();
	EgDateInfo egDt = new EgDateInfo();
	String Hourfrom="";
	String Minfrom="";
	String Hourto="";
	String Minto="";
	String fromTime,toTime;
	String variable;
	String s_QSGraph="";
	StringTokenizer st;

	ErComponentsUtils compUtils = new ErComponentsUtils(thisuser.getLoginID());
	EgMappingInfo intlmap=new EgMappingInfo(thisuser.getLanguage());
	ErUtils erUtils = new ErUtils();
	ErInfo erInfo = new ErInfo();
	EgReportInfo reportInfo=new EgReportInfo("manager");
	String confrimation = reportInfo.getValue("BACKGROUND_PROCESS","NeedConfirmation");
	String strbgrepportName = reportInfo.getValue("BACKGROUND_PROCESS","EnableBackgroundReport");
	String limitforbg = reportInfo.getValue("BACKGROUND_PROCESS","MinDurationForReport");
	String moreUsersStr = reportInfo.getValue("APPLICATION_LAUNCH_COUNT","moreUsers");
	boolean getSessionDetails = true;
	String ShowSessionDetails= reportInfo.getValue("APPLICATION_LAUNCH_COUNT","ShowSessionDetails");
	if(ShowSessionDetails!=null && (ShowSessionDetails.equalsIgnoreCase("NO") || ShowSessionDetails.equalsIgnoreCase("FALSE")))
		getSessionDetails = false;

	int moreUserCount = 100;
	try {
		moreUserCount = Integer.parseInt(moreUsersStr);
	} catch(Exception e) {
		moreUserCount = 100;
	}
	EgThresholdInfo hreshholdInfo = new EgThresholdInfo("manager");
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	String s_user[] = request.getParameterValues("er_user");
	//String er_workerGroup = request.getParameter("er_workgrpname");
	String er_detailsBasedOn = request.getParameter("er_detailsBasedOn");
	String s_compType = request.getParameter("er_compType");
	String geoDetails = request.getParameter("geoDetails");
	String selected_CompType = request.getParameter("er_compType");
	
	if(selected_CompType==null)
		selected_CompType="";
	Hashtable htt=new Hashtable();
	htt=(Hashtable)request.getAttribute("htdata");
	Vector v_components = compUtils.getAllUserComponents1();
	Vector v_component = new Vector();
	ArrayList v_Workgroupcomponents = new ArrayList();

	Vector v_temp = new Vector();
	Vector defComps = new Vector();
	Vector colZoneComps = new Vector();
	Vector v_comptype=new Vector();
	ArrayList aListCompType = new ArrayList();
	Vector v_tmp = new Vector();
	Vector v_infos=null;
	List v_application=new ArrayList();
	ArrayList aListworkGrp = new ArrayList();
	Vector v_comp_popup = new Vector();
	Vector v_comp_popup_disp = new Vector();

	List topList = new ArrayList();
	String maxStr = reportInfo.getValue("APPLICATION_LAUNCH_COUNT","Showtop");
	int maxInfo = 10;
	try {
		maxInfo = Integer.parseInt(maxStr);
	} catch(Exception e) {
		maxInfo = 10;
	}
	topList.add("TOP  - " +maxInfo/4);
	topList.add("TOP  - " +maxInfo/2);
	topList.add("TOP  - " +maxInfo);
	topList.add("ALL");
	topList.add("LAST  - " +maxInfo);
	topList.add("LAST  - " +maxInfo/2);
	topList.add("LAST  - " +maxInfo/4);
	
	List groupByList = new ArrayList();
	List groupByListforAppln = new ArrayList();
	groupByList.add("Component");
	groupByListforAppln.add("Component");
	if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("User"))
		groupByList.add("Application");
	else 
		groupByList.add("User");
	groupByListforAppln.add("Application");
	String installDir = EgInstallInfo.getInstallDir();
	IniFile inifile = new IniFile(installDir +"/manager/config/eg_report.ini");
	String sub = "MISC";
	String var = "CtxServer";
	String values = inifile.getValue(sub,var);
	String val="";
	String s_component = "";
	String s_qryString	="";
	String timeline =request.getParameter("er_timeline");
	String testmes = request.getParameter("select_testmes");
	String rtype =request.getParameter("er_type");
	String reqFromSchedule = request.getParameter("fromSchedule");
	String schedule_id = request.getParameter("schedule_id");
	String divStatus = request.getParameter("divStatus");
	String er_groupby = request.getParameter("er_groupBy");
	String isSubmit = request.getParameter("isSubmit");

	String s_application = request.getParameter("er_application");
	
	String er_top = request.getParameter("er_top");
	String er_topString = request.getParameter("er_top");
	if(er_topString!=null && er_topString.indexOf("-")>-1)
		er_topString=er_topString.substring(0,er_topString.indexOf("-"));
	String er_mode = request.getParameter("er_mode");
	String er_zone = request.getParameter("er_zone");
	String[] er_component = request.getParameterValues("er_component");
	String eruserid = request.getParameter("eruserid");
	String er_workerGroup = request.getParameter("er_workerGroup");
	String er_adGroup = request.getParameter("er_adGroup");
	String[] er_adGroupArr = request.getParameterValues("er_adGroup");
	ArrayList er_adGroupList=new ArrayList();
	if(er_adGroupArr != null && er_adGroupArr.length > 0)
		er_adGroupList.addAll(Arrays.asList(er_adGroupArr));
	String er_usertxt = request.getParameter("er_usertxt");
	if (er_usertxt == null)
		er_usertxt = "";
	String srcForImg="";
	if (er_groupby == null) {
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("User"))
			er_groupby = "Application";
		else 
			er_groupby = "User";
	}
	if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("User")){
		if (er_groupby != null && er_groupby.equalsIgnoreCase("User")) 
			er_groupby = "Application";
	} else 
	if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application")){
		if (er_groupby != null && er_groupby.equalsIgnoreCase("Application")) 
			er_groupby = "User";
	}
	if(divStatus==null)
	{
		divStatus="none";
	}
	if(divStatus.equals("none"))
	{
		srcForImg="/final/images/moreoption.png";
	}
	else if(divStatus.equals("block"))
	{
		srcForImg="/final/images/lessoption.png";
	}
	if (er_top == null)
		er_top = (String)topList.get(2);
	ArrayList aListSupportedComponentType = reportInfo.getComponentsList("APPLICATION_LAUNCH_COUNT",false);
	ArrayList aListAlltype = new ArrayList();
	for(int kk=0;kk<aListSupportedComponentType.size();kk++)
	{
		aListAlltype.add("All "+aListSupportedComponentType.get(kk));
	}
	if (rtype==null)
	{
		rtype="Yes";
	}
	boolean termpresent=false;
	Vector v_testmes = new Vector();
	HashMap htHeading = new HashMap();
	ArrayList headingList = new ArrayList();
	ArrayList aList1 = new ArrayList();
	ArrayList aList2 = new ArrayList();
	ArrayList aList3 = new ArrayList();

/*	for(int i=0;i<v_components.size();i++)
	{
		String s_tmp = (String)v_components.get(i);
		StringTokenizer tk = new StringTokenizer(values,",");
		while(tk.hasMoreTokens())
		{
			val = tk.nextToken();
			if(val==null || val.equals(""))
			{
				if (s_tmp.endsWith(val))
				{
					v_tmp.add(s_tmp);
				}
			}
			else
			{
				if(s_tmp.endsWith(val))
				{
					v_tmp.add(s_tmp);
				}
			}
		}
	}				 */
	Hashtable ht_data = (Hashtable)request.getAttribute("Report_data");
	Vector app_data = (Vector)request.getAttribute("App_data");
	ArrayList app_topusers = (ArrayList)request.getAttribute("app_topusers");
	Vector v_qry_string = (Vector)request.getAttribute("appChartData");
	Vector pdfQuery = (Vector)request.getAttribute("appPdfData");
	String backQS = (String)session.getAttribute("topBackQuery");
	String backQSserver = (String)session.getAttribute("topBackQuery_server");
	
	session.setAttribute("ApplicationReport",app_data);
	session.setAttribute("appForPrint",app_topusers);
	session.removeAttribute("topBackQuery");
	session.removeAttribute("backQSserver");

	HashMap Report_data=null;
	Hashtable h_data = new Hashtable();
	Hashtable h_rep = new Hashtable();
	Vector v_data1 = new Vector();
	Vector  v_add = new Vector();

	ArrayList subjects = (ArrayList)reportInfo.getVariables("APPLICATION_LAUNCH_COUNT");
	String numTopUsers = reportInfo.getTop("APPLICATION_LAUNCH_COUNT");
	Vector v_sort=new Vector();
	v_sort.add("% Time in use");
	v_sort.add("Number of unique users");

	String s_variable="";
	StringTokenizer tok1=null;
	String type="";
	String mes="";
	
	String s_sort=request.getParameter("er_sortby");
	String tbound = request.getParameter("er_tbound");
	String cTime = request.getParameter("currTime");
	String s_application1 = request.getParameter("er_application1");

	String key="";
	ErReqData erd = new ErReqData(request);
	EgDateInfo egDate = new EgDateInfo();
	String stdate="";
	String enddate="";
	String sthr="";
	String endhr="";
	String sthr1 = "";
	String endhr1 = "";
	long msecsPerHour = (long) 1000 * 60 * 60;

	fromTime = reportInfo.getTimeFrame("APPLICATION_LAUNCH_COUNT","FROM");
	toTime = reportInfo.getTimeFrame("APPLICATION_LAUNCH_COUNT","TO");

	st = new StringTokenizer(fromTime,":");
	if(st.hasMoreTokens())
	{
		Hourfrom = st.nextToken();
		Minfrom = st.nextToken();
	}
	st=new StringTokenizer(toTime,":");
	if(st.hasMoreTokens())
	{
		Hourto = st.nextToken();
		Minto = st.nextToken();
	}
	String Days = reportInfo.getExcludeWeekend("APPLICATION_LAUNCH_COUNT");
	String NoofServers = reportInfo.getNoOfBars("APPLICATION_LAUNCH_COUNT","top");
	Vector v_time=new Vector();
	v_time.add("00");
	v_time.add("01");
	v_time.add("02");
	v_time.add("03");
	v_time.add("04");
	v_time.add("05");
	v_time.add("06");
	v_time.add("07");
	v_time.add("08");
	v_time.add("09");
	v_time.add("10");
	v_time.add("11");
	v_time.add("12");
	v_time.add("13");
	v_time.add("14");
	v_time.add("15");
	v_time.add("16");
	v_time.add("17");
	v_time.add("18");
	v_time.add("19");
	v_time.add("20");
	v_time.add("21");
	v_time.add("22");
	v_time.add("23");

	Vector v_min=new Vector();
	v_min.add("00");
	v_min.add("05");
	v_min.add("10");
	v_min.add("15");
	v_min.add("20");
	v_min.add("30");
	v_min.add("35");
	v_min.add("40");
	v_min.add("45");
	v_min.add("50");
	v_min.add("55");
	v_min.add("59");

	String timefrom2=request.getParameter("timefrom");
	String minfrom2=request.getParameter("minfrom");
	String timeto2=request.getParameter("timeto");
	String minto2=request.getParameter("minto");

	if (timefrom2!=null)
		Hourfrom=timefrom2;
	if (minfrom2!=null)
		Minfrom=minfrom2;
	if (timeto2!=null)
		Hourto=timeto2;
	if (minto2!=null)
		Minto=minto2;

		//-Report By Combo
		String er_option =request.getParameter("er_option");
		String er_site = request.getParameter("er_site");
		if(er_option == null || (er_option!=null && er_option.isEmpty()) || er_option.equalsIgnoreCase("null"))
		{
			 er_option = "Zone";
			 
		}	
			//  for - reports by segment,Service default loading setup
		String er_dataFrom =request.getParameter("er_dataFrom");
		String er_service = request.getParameter("er_service");
		if(er_dataFrom!=null && (er_dataFrom.equalsIgnoreCase("Group")||er_dataFrom.equalsIgnoreCase("Segment")||er_dataFrom.equalsIgnoreCase("Service")||er_dataFrom.equalsIgnoreCase("Zone")))
		{
			if(er_service!=null)
			{
				er_option=er_dataFrom;
				er_site=er_service;
			
			}
		}
		//for - reports by Component default loading setup
		else if(er_dataFrom!=null && er_dataFrom.equalsIgnoreCase("Component"))
		{
			er_option=er_dataFrom;
			er_site=null;
		}
		User this_user = UserRegistry.getInstance().getUser(session.getId());
		String loginid = this_user.getLoginID();
		List v_option = new ArrayList();
		List v_site=new ArrayList();
		Hashtable htAllGroups=erEsxUtils.getGroups(null,aListSupportedComponentType, thisuser, loginid, "Yes",true);
		ArrayList aListOption = erEsxUtils.getOptions(htAllGroups);
		if(aListOption!=null && aListOption.size()>0)
			v_option.addAll(aListOption);
		JSONArray arr = new JSONArray();
		JSONObject obj1=null;
		if(v_option!=null && v_option.size()>0 )
		{
			selectedFields.put("selectedAnalysisByCombo",er_option);
			for(int i=0; i<v_option.size(); i++)
			{
				obj1 = new JSONObject();
				obj1.put("displayField", intlmap.getTextDescription("reporter.common."+v_option.get(i)));
				obj1.put("valueField",v_option.get(i));
				arr.add(obj1);
				}
		}
		else
		{
			obj1 = new JSONObject();
			obj1.put("displayField", intlmap.getTextDescription("reporter.common.Not Applicable"));
			obj1.put("valueField","-1");
			arr.add(obj1);
		}
	combo.put("analysisByCombo",arr);
		//end
	String value1 = inifile.getValue(sub,var);
	sub ="LIST_OF_ZONES";
	inifile = new IniFile(installDir +"/manager/config/eg_group.ini");
	String vari[] = inifile.getVariables(sub);
	for(int i=0;i<vari.length;i++)
	{
		variable = vari[i];
		v_component.add(variable);
	}
	List aListComponentTemp =new ArrayList();
	List v_serverName=new ArrayList();
	String show_timeinuse = request.getParameter("sh_timeinuse");
	String s_farmserver = request.getParameter("select_farm");
	String[] selectedAppArrays = null;
	selectedAppArrays = request.getParameterValues("er_application");
	String s_server = request.getParameter("er_server");
	String strFromBack = request.getParameter("fromBack");
	String[] selectedCompArrays = null;
	selectedCompArrays = request.getParameterValues("er_component");
	String[] selectedVmArrays = request.getParameterValues("er_vm");
	//---testin
	EgGroupInfo gpinfo = new EgGroupInfo();
	String tmpComponent="";
	Vector v_comp = compUtils.getAllUserComponents1();
	boolean present=false;
	Vector dispzone = new Vector();
	List zonelist = compUtils.getUserZones();
	if(zonelist != null && zonelist.contains("--Default--"))
		zonelist.remove("--Default--");
	ArrayList getComponent=new ArrayList();
	Vector v_zonelist = new Vector();
	v_zonelist.addAll(zonelist);
	List selectedCompList = new ArrayList();
	for(int k1=0;k1<zonelist.size();k1++)
	{
		String vali=(String)zonelist.get(k1);
		getComponent = compUtils.getTypeModifyComponents(compUtils.getZoneComponents(vali,true),2);
		for(int i=0;i<getComponent.size();i++)
		{
			String getcomp=(String)getComponent.get(i);
			String strComponentType = "";
			if(getcomp!=null && getcomp.indexOf(":")>-1)
				strComponentType = getcomp.substring(0,getcomp.indexOf(":"));
			//if (getcomp.startsWith("Citrix_MF_XP:") || getcomp.startsWith("Citrix_server:")|| getcomp.startsWith("Agg_Citrix_MF_XP:") || getcomp.startsWith("Agg_Citrix_server:")|| getcomp.startsWith("Terminal_server:") || getcomp.startsWith("2X_APP_Server"))
			if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(strComponentType))
			{
				if(!dispzone.contains(vali))
					dispzone.add(vali);
				if(getcomp.indexOf(":")>-1)
				{
					String strCompType = getcomp.substring(0,getcomp.indexOf(":"));
					if(aListCompType!=null && !aListCompType.contains(strCompType))
						aListCompType.add(strCompType);
				}
			}
		}
		vali="";
	}
	int countTerminal=0,countCitrix=0;
	for(int i=0;i<v_component.size();i++)
	{
		String s_tmp = (String)v_component.get(i);
		if(!v_zonelist.contains(s_tmp))
		{
			continue;
		}
		ArrayList al = compUtils.getTypeModifyComponents(compUtils.getZoneComponents(s_tmp,true),2);
		if(value1==null || value1.equals(""))
		{
			String strComponentType = "";
			if(s_tmp!=null && s_tmp.indexOf(":")>-1)
				strComponentType = s_tmp.substring(s_tmp.lastIndexOf(":")+1);
			if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(strComponentType))
			//if (s_tmp.endsWith(":Citrix_MF_XP") || s_tmp.endsWith(":Citrix_server") || s_tmp.endsWith(":Agg_Citrix_MF_XP") || s_tmp.endsWith(":Agg_Citrix_server") || s_tmp.endsWith(":Terminal_server") || s_tmp.endsWith(":2X_APP_Server"))
			{
				v_tmp.add(s_tmp);
				if(s_tmp.indexOf(":")>-1)
				{
					String strCompType = s_tmp.substring(s_tmp.lastIndexOf(":")+1);
					if(aListCompType!=null && !aListCompType.contains(strCompType))
						aListCompType.add(strCompType);
				}
			}
		}
		else
		{
			st=new StringTokenizer(value1,",");
			while (st.hasMoreTokens())
			{
				 String comp=st.nextToken();
				if(s_tmp.endsWith(comp))
				{
					v_tmp.add(s_tmp);
					if(s_tmp.indexOf(":")>-1)
					{
						String strCompType = s_tmp.substring(s_tmp.indexOf(":")+1);
						if(aListCompType!=null && !aListCompType.contains(strCompType))
							aListCompType.add(strCompType);
					}
				}
			}
		}
		for(int m=0;m<al.size();m++)
		{
			String comp = (String)al.get(m);
			StringTokenizer token1 = new StringTokenizer(comp,":");
			String sid="";
			while(token1.hasMoreTokens())
			{
				String comptype=token1.nextToken();
				String component = token1.nextToken();
				String port=token1.nextToken();

				if (comptype.equalsIgnoreCase("Oracle_server"))
				{
					sid=token1.nextToken();
				}
				if(sid.equals(""))
				{
					tmpComponent=component+":"+port+":"+comptype;
				}
				else
				{
					tmpComponent=component+":"+port+":" + sid + ":"+comptype;
				}
				if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(comptype))
				//if (comptype.equalsIgnoreCase("Citrix_MF_XP") || comptype.equalsIgnoreCase("Citrix_server") || comptype.equalsIgnoreCase("Agg_Citrix_MF_XP") || comptype.equalsIgnoreCase("Agg_Citrix_server") || comptype.equalsIgnoreCase("2X_APP_Server"))
				{
					if(aListCompType!=null && !aListCompType.contains(comptype))
						aListCompType.add(comptype);
				}
			}
			if(s_tmp!=null)
			{
				if (v_comp.contains(tmpComponent) && (present || termpresent))
				{
					if (!v_temp.contains(s_tmp))
						v_temp.add(s_tmp);
				}
			}
			if(!colZoneComps.contains(tmpComponent))
			{
				colZoneComps.add(tmpComponent);
			}
		}
	}
	if(v_comp!=null && v_comp.size() > 0)
	{
		for(int vc =0; vc < v_comp.size(); vc++)
		{
			String s_comp = (String)v_comp.get(vc);
			if(!colZoneComps.contains(s_comp))
			{
				//If there are only citrix
				String strComponentType = "";
				if(s_comp!=null && s_comp.indexOf(":")>-1)
					strComponentType = s_comp.substring(s_comp.lastIndexOf(":")+1);
				if(!defComps.contains(s_comp) && (aListSupportedComponentType!=null && aListSupportedComponentType.contains(strComponentType)))
				//if(!defComps.contains(s_comp) && (s_comp.endsWith("Citrix_MF_XP")|| s_comp.endsWith("Citrix_server") || s_comp.endsWith("Agg_Citrix_MF_XP")|| s_comp.endsWith("Agg_Citrix_server") || s_comp.endsWith("Terminal_server") || s_comp.endsWith("2X_APP_Server")))
				{
					defComps.add(s_comp);
					if(s_comp.indexOf(":")>-1)
					{
						String strCompType = s_comp.substring(s_comp.lastIndexOf(":")+1);
						if(aListCompType!=null && !aListCompType.contains(strCompType))
							aListCompType.add(strCompType);
					}
				}
			}
		}
		if(!defComps.isEmpty())
		{
			if(!dispzone.contains("--Default--"))
				dispzone.insertElementAt("--Default--",0);
		}
	}
	if(s_farmserver == null && dispzone != null && dispzone.size() > 0)
	{
		s_farmserver = (String)dispzone.get(0);
	}
	List aTemp = compUtils.getUserZones();
	if(aTemp != null && aTemp.contains("--Default--"))
		aTemp.remove("--Default--");
	String zones[] = new String[aTemp.size()];
	for(int l=0;l<aTemp.size();l++)
	{
		zones[l] = (String)aTemp.get(l);
	}
	Vector aListCompType_value = new Vector();
	aListCompType_value=erUtils.getAllComponentTypeForZone(s_farmserver,zones,v_zonelist,v_comp,aListSupportedComponentType);

	if(v_comp!=null&&v_comp.size()>0)
	{
		String strcomptype="";
		if(v_temp.isEmpty()||v_temp.size()==0)
		{
			int  compsize = v_comp.size();
			for(int v=0;v<compsize;v++)
			{
				boolean b_val = false;
				String st_comp =(String) v_comp.get(v);
				StringTokenizer strtok = new StringTokenizer(st_comp,":");
				int cttok = strtok.countTokens();
				if(cttok==4)
					b_val = true;
				if(cttok>=3)
				{
					strtok.nextToken();
					strtok.nextToken();
					if(b_val)
					{
						strtok.nextToken();
					}
					strcomptype = strtok.nextToken();
				}
				if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(strcomptype))
				//if(strcomptype.equalsIgnoreCase("Citrix_MF_XP")|| strcomptype.equalsIgnoreCase("Citrix_server") || strcomptype.equalsIgnoreCase("Agg_Citrix_MF_XP")|| strcomptype.equalsIgnoreCase("Agg_Citrix_server") || strcomptype.equalsIgnoreCase("Terminal_server") || strcomptype.equalsIgnoreCase("2X_APP_Server"))
				{
					if(!dispzone.contains("--Default--"))
						dispzone.insertElementAt("--Default--",0);
					v_comptype.add(strcomptype);
					//if(aListCompType_value!=null && !aListCompType_value.contains(strcomptype))
						//aListCompType_value.add(strcomptype);
				}
			}
		}
	}
	if(selectedVmArrays!=null && selectedVmArrays.length>0)
	{
		ErApplicationLaunchCountReportBean erApBEan = new ErApplicationLaunchCountReportBean();
		selectedVmArrays=erApBEan.replaceVmNameByHash(selectedVmArrays);
	}
			//-report by combo for zone, segment, service & component
		if (er_option!=null)
		{
			v_site = erEsxUtils.getGroupsName(htAllGroups,er_option);
			if(v_site!=null)
			Collections.sort(v_site,String.CASE_INSENSITIVE_ORDER);
			aListComponentTemp=null;
			if(er_option.equals("Group") || er_option.equals("Segment") || er_option.equals("Service"))
			{
				if(er_site==null && v_site!=null && v_site.size()>0)
				{
					er_site=(String)v_site.get(0);
				}
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
				selectionDetails.put(intlmap.getTextDescription("reporter.thin."+er_option),er_site);
				combo.put("siteCombo",getJSONComboFromList(v_site,"",intlmap));
				labelFields.put("siteComboLabel",er_option);
				selectedFields.put("selectedSiteCombo",er_site);
			}
			else if(er_option.equals("Zone"))
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
				if(rtype!=null)
				{
					iterateJArray=new JSONArray();
					if(dispzone!=null && dispzone.size()>0)
					{
						for(int n=0;n<dispzone.size();n++)
						{
							String s=(String)dispzone.get(n);
							iterateJObject=new JSONObject();
							iterateJObject.put("displayField",s);
							iterateJObject.put("valueField",s);
							iterateJArray.add(iterateJObject);
							if(s_farmserver!=null && s_farmserver.equalsIgnoreCase(s))
							{
								selectedFields.put("zoneSelected",s);
								selectionDetails.put(intlmap.getTextDescription("reporter.thin.Zone"),s);
							}
						}
					}
					else
					{
						iterateJObject=new JSONObject();
						iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
						iterateJObject.put("valueField","-1");
						iterateJArray.add(iterateJObject);
					}
					combo.put("zoneCombo",iterateJArray);
				}
			}
			else if(er_option.equals("Component"))
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			}
		}
		if(aListComponentTemp!=null && aListComponentTemp.size()>0)
		{
			v_serverName = new ArrayList();
			for(int i=0; i<aListComponentTemp.size(); i++) 
			{
				String loopComponent = (String) aListComponentTemp.get(i);
				if(loopComponent.lastIndexOf(":")>-1)
				{
					String loopComp = loopComponent.substring(0,loopComponent.lastIndexOf(":"));
					String  loopType = loopComponent.substring(loopComponent.lastIndexOf(":")+1);
					{
						if(v_serverName!=null && !v_serverName.contains(loopType))
							v_serverName.add(loopType);
					}
				}
			}
		}
			Collections.sort(v_serverName,String.CASE_INSENSITIVE_ORDER);
		// for component types [Component Type Combo]
		if(er_option.equals("Zone"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
		}
		else if (er_option.equals("Group")||er_option.equals("Segment")||er_option.equals("Service"))
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
		}
		else
		{
			aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
		}
		JSONArray comptypeArray = new JSONArray();
        if(aListComponentTemp!=null && !aListComponentTemp.isEmpty())
		{
			
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Please choose a Component Type"));
			loopJsonObj.put("valueField", "-1");
			comptypeArray.add(loopJsonObj);
			for(int n=0;n<aListComponentTemp.size();n++)
			{
				String comp = (String)aListComponentTemp.get(n);
				int index=comp.lastIndexOf(":");
				if(index>-1)
				{ 
					String  ctype = comp.substring(index+1); 
					if(!v_serverName.contains(ctype))
					{
						v_serverName.add(ctype);
						
					}
					if(v_serverName !=null && rtype.equalsIgnoreCase("no") && ctype.equalsIgnoreCase("all"))
					{
						v_serverName.addAll(aListComponentTemp);
					}
				}
			}
			for(int n=0;n<v_serverName.size();n++)
			{
				String ctype = (String) v_serverName.get(n);
				loopJsonObj = new JSONObject();
				loopJsonObj.put("displayField",intlmap.getComponentTypeDescription(ctype));
				loopJsonObj.put("valueField",ctype);
				comptypeArray.add(loopJsonObj);
			}
			if(rtype!=null && rtype.equalsIgnoreCase("no") && v_serverName.size()>1)
			{
				loopJsonObj = new JSONObject();
				//loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.All"));
				//loopJsonObj.put("valueField", "all");
				comptypeArray.add(loopJsonObj);
			}
			if(s_compType==null && v_serverName!=null && v_serverName.size()>0)
			{
				s_compType=(String)v_serverName.get(0);
				selectedFields.put("componentTypeSelected",s_compType);
			}
			else
			{
				selectedFields.put("componentTypeSelected",s_compType);
			}
			selectionDetails.put(intlmap.getTextDescription("reporter.thin.Component Type"),intlmap.getComponentTypeDescription(s_compType));
			combo.put("componentTypeCombo",comptypeArray);
		}
        else
		{
			loopJsonObj = new JSONObject();
			loopJsonObj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			loopJsonObj.put("valueField", "-1");
			comptypeArray.add(loopJsonObj);
		}
		//End
		List componentsForSpecificCompType=new ArrayList();
		if(aListComponentTemp!=null)
		for(int n=0;n<aListComponentTemp.size();n++)
		{
			String comp = (String)aListComponentTemp.get(n);
			if(comp.endsWith(s_compType))
			{
				componentsForSpecificCompType.add(comp);
			}
		}
		aListComponentTemp=componentsForSpecificCompType;
		if(selectedCompArrays == null || selectedCompArrays.length==0)
		{
			selectedCompArrays = new String[aListComponentTemp.size()];
			selectedCompArrays = (String[])aListComponentTemp.toArray(new String[aListComponentTemp.size()]);
		}
		//component [Multiselect] starts..
		if(rtype!=null && rtype.equals("No"))
		{
			if(er_option.equals("Zone"))
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,s_farmserver);
			}
			else if (er_option.equals("Group") || er_option.equals("Segment")||er_option.equals("Service"))
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,er_site);
			}
			else
			{
				aListComponentTemp = erEsxUtils.getComponentForGroup(htAllGroups,er_option,null);
			}
			if(aListComponentTemp!=null )
			{
				if(s_compType!=null && !s_compType.equalsIgnoreCase("All"))
				{
						List vecAll = new Vector();
						for(int m=0;m< aListComponentTemp.size();m++)
						{
							String tempcomp=(String)aListComponentTemp.get(m);
							StringTokenizer t_token= new StringTokenizer(tempcomp,":");
							while(t_token.hasMoreTokens())
							{
								String tempcomptype=t_token.nextToken();
								if(s_compType.equalsIgnoreCase(tempcomptype))
								{
									vecAll.add(tempcomp);
								}
							}
						}
						aListComponentTemp=vecAll;
				}
			}
			 if(aListComponentTemp !=null && !aListComponentTemp.isEmpty())
			{
				Collections.sort(aListComponentTemp,String.CASE_INSENSITIVE_ORDER);
				iterateJArray=new JSONArray(); 
				selectedComboJArray=new JSONArray(); 
				ArrayList aListSelectedList = new ArrayList();
				if(selectedCompArrays!=null && selectedCompArrays.length>0)
					aListSelectedList.addAll(Arrays.asList(selectedCompArrays));
				StringBuffer str=new StringBuffer();
				StringBuffer strVal=new StringBuffer();
				for(int n=0;n<aListComponentTemp.size();n++)
				{
					String s=(String)aListComponentTemp.get(n);
					String s1 = s;
					if(s1.indexOf(":NULL")>-1)
						s1 = s1.substring(0,s1.indexOf(":NULL"))+s1.substring(s1.indexOf(":NULL")+5);
					String strDipServer = s1;
					if(s.indexOf(":")>-1)
					{
						String strTemp="";
						String strTemp1="";
						if(s.indexOf(":")>-1)
						{
							strTemp = s1.substring(0,s1.indexOf(":"));
							strTemp1 = s.substring(s.lastIndexOf(":")+1);
						}
						if(s_compType!=null)
						{
							//strDipServer = strTemp+":"+intlmap.getComponentTypeDescription();
							strDipServer = strTemp;
						}
					}
					iterateJObject=new JSONObject();
					iterateJObject.put("displayField",strDipServer);
					iterateJObject.put("valueField",s);
					iterateJArray.add(iterateJObject);
					if(aListSelectedList!=null && !aListSelectedList.isEmpty()&& aListSelectedList.contains(s))
					{
						v_comp_popup.add(s);
						v_comp_popup_disp.add(strDipServer);
						strVal.append(s).append(",");
						//str.append(intlmap.getComponentTypeDescription(strDipServer)).append(",");
						str.append(strDipServer).append(",");
						selectedComboJArray.add(s);
					}else
					{
						v_comp_popup.add(s);
						v_comp_popup_disp.add(strDipServer);
						//selectedComboJArray.add(s);
					}
				}
				if(str.length()>0 && strVal.length()>0)
				{
					str.deleteCharAt(str.length() - 1);
					strVal.deleteCharAt(strVal.length() - 1);
					if(str.length()>66)
					{
						strVal.append("...");
						str.append("...");
					}
					if(!isLaunchByVm)
					{
						selectionDetails.put(intlmap.getTextDescription("reporter.thin.Component"),str.toString());
					}
				}
			}
			else
			{
				iterateJArray=new JSONArray();
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
				iterateJObject.put("valueField","-1");
				iterateJArray.add(iterateJObject);			
				v_comp_popup.add("-1");
				v_comp_popup_disp.add("Not Applicable");
			}
			selectedFields.put("componentSelected",selectedComboJArray);
			combo.put("componentCombo",iterateJArray);
		}
		
		 //component [Multiselect] end.
	String serverForSorting=null;
	String s_perserver=request.getParameter("er_perserver");
	if (s_perserver==null || s_perserver.equals(""))
		s_perserver="Yes";
	if(s_application==null)
		s_application = request.getParameter("er_user");
	ArrayList aListSelectedList_temp = null;
	ArrayList aListSelectedCompList_temp = null;
	String fromToplink = request.getParameter("fromToplink");
	if(fromToplink!=null && fromToplink.equalsIgnoreCase("Yes")){
	//aListSelectedCompList_temp = (ArrayList)session.getAttribute("SelectedComponent");
	//aListSelectedList_temp = (ArrayList)session.getAttribute("SelectedApplication");
	if(aListSelectedCompList_temp!=null && aListSelectedCompList_temp.size()>0)
		selectedCompArrays = (String[])aListSelectedCompList_temp.toArray(new String[aListSelectedCompList_temp.size()]);
	if(aListSelectedList_temp!=null && aListSelectedList_temp.size()>0)
		selectedAppArrays = (String[])aListSelectedList_temp.toArray(new String[aListSelectedList_temp.size()]);
	}
	String geoColDetails = (String)reportInfo.getValue("APPLICATION_LAUNCH_COUNT","GeoColumnDetails_"+s_compType);
	ArrayList geoColumnList = com.egurkha.util.StringUtils.egTokenizer(geoColDetails, ",",false,false,true);
	if(strFromBack!=null && strFromBack.equalsIgnoreCase("Yes"))
	{
		session.removeAttribute("SelectedApplication");
		session.removeAttribute("SelectedComponent");
	}
	String strEncodeFarmserver = s_farmserver;
	String strEncodeServer = s_server;
	if(strEncodeFarmserver!=null)
		strEncodeFarmserver = EgURLEncoder.encode(strEncodeFarmserver,"UTF-8");
	if(strEncodeServer!=null)
		strEncodeServer = EgURLEncoder.encode(strEncodeServer,"UTF-8");

	String sub1 = "MISC";
	String var1 = "CtxServer";
	Vector v_server=new Vector();

	if(s_compType == null )
	{
		if(aListCompType_value!=null && aListCompType_value.size()>0)
		{
			s_compType = (String)aListCompType_value.get(0);
		}
	}
	if (s_farmserver!=null && !s_farmserver.equals(""))
	{
		if(s_farmserver.equalsIgnoreCase("--Default--"))
		{
			if(!defComps.isEmpty())
			{
				countTerminal=0;
				countCitrix=0;
				for(int dc=0; dc < defComps.size(); dc++)
				{
					String s_comp = (String)defComps.get(dc);
					StringTokenizer st_colon = new StringTokenizer(s_comp,":");
					String comp  = st_colon.nextToken();
					String port =  st_colon.nextToken();
					String sid = "";
					if(st_colon.countTokens() >1)
					{
						sid = st_colon.nextToken();
					}
					String s_type = st_colon.nextToken();
				/*	if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(s_type))
					//if(s_type.equals("Citrix_MF_XP") || s_type.equals("Citrix_server") || s_type.equals("Agg_Citrix_MF_XP") || s_type.equals("Agg_Citrix_server") || s_type.equals("2X_APP_Server"))
					{
						if(aListCompType_value!=null && !aListCompType_value.contains(s_type))
							aListCompType_value.add(s_type);
					}	*/
					/*if(s_type.equalsIgnoreCase("Terminal_server"))
					{
						countTerminal++;
						if(countTerminal>1)
							termpresent=true;
						if(aListCompType_value!=null && !aListCompType_value.contains(s_type))
							aListCompType_value.add(s_type);
					}*/
					if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(s_type))
					//if (s_type.equalsIgnoreCase("Citrix_MF_XP") || s_type.equals("Citrix_server")|| s_type.equalsIgnoreCase("Agg_Citrix_MF_XP") || s_type.equals("Agg_Citrix_server")|| s_type.equalsIgnoreCase("Terminal_server") || s_type.equalsIgnoreCase("2X_APP_Server"))
					{
						if(s_compType!=null && (s_compType.equalsIgnoreCase("ALL") || s_compType.equals(s_type)))
							v_server.add(comp+":"+port+":"+s_type);
						if(aListCompType_value!=null && !aListCompType_value.contains(s_type))
							aListCompType_value.add(s_type);
					}
				}
			}
		}
		ArrayList al = compUtils.getTypeModifyComponents(compUtils.getZoneComponents(s_farmserver,true),2);
		for (int k=0;k<al.size();k++)
		{
			String server = (String)al.get(k);
			StringTokenizer st_server = new StringTokenizer(server,":");
			String sid="";
			while(st_server.hasMoreTokens())
			{
				String server_comptype=st_server.nextToken();
				String server_component = st_server.nextToken();
				String server_port=st_server.nextToken();
				if (server_comptype.equalsIgnoreCase("Oracle_server"))
					sid=st_server.nextToken();
				if(aListSupportedComponentType!=null && aListSupportedComponentType.contains(server_comptype))
				//if (server_comptype.equalsIgnoreCase("Citrix_MF_XP") ||server_comptype.equalsIgnoreCase("Citrix_server") || server_comptype.equalsIgnoreCase("Agg_Citrix_MF_XP") ||server_comptype.equalsIgnoreCase("Agg_Citrix_server") || server_comptype.equalsIgnoreCase("Terminal_server") || server_comptype.equalsIgnoreCase("2X_APP_Server"))
				{
					if(s_compType!=null && (s_compType.equalsIgnoreCase("ALL") || s_compType.equals(server_comptype)))
						v_server.add(server_component+":"+server_port+":"+server_comptype);
					if(aListCompType_value!=null && !aListCompType_value.contains(server_comptype))
						aListCompType_value.add(server_comptype);
				}
				break;
			}
		}
	}
	/*	for(int i=0;i<v_components.size();i++)
	{
		String s_tmp = (String)v_components.get(i);
		String tmp_serverValue="";
		for(int k=0;k<aListCompType_value.size();k++)
		{
		 tmp_serverValue=(String)aListCompType_value.get(k);
			if(tmp_serverValue==null || tmp_serverValue.equals(""))
			{
				if (s_tmp.endsWith(tmp_serverValue))
				{
					if(!v_tmp.contains(s_tmp))	
					{
					v_tmp.add(s_tmp);
					}
				}
			}
			else
			{
				if(s_tmp.endsWith(tmp_serverValue))
				{
					if(!v_tmp.contains(s_tmp))	
					{
		 			   v_tmp.add(s_tmp);
					}
				}
			}
		}
	}
	if (v_server.size()>0)
	{
		v_components=v_server;
	}
	else
	{
		v_components = v_tmp;
	}*/
	//if (s_server!=null && !s_server.equals("") && !s_server.equals("-1")&& s_server.equals("All Citrix_MF_XP Servers") && s_server.equals("All Terminal_Servers")&&!s_server.equals("All Citrix_servers") && !s_server.equals("All 2X_APP_Server"))

	Collections.sort(v_components,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_tmp,String.CASE_INSENSITIVE_ORDER);
	Collections.sort(v_temp,String.CASE_INSENSITIVE_ORDER);

	boolean allServerPresent=false;
	Hashtable htComponentcount = new Hashtable();
	if(s_compType == null )
	{
		if(aListCompType_value!=null && aListCompType_value.size()>0)
		{
			s_compType = (String)aListCompType_value.get(0);
		}
	}
	if(aListCompType_value!=null && aListCompType_value.size()>0)
	{
		if(aListCompType_value.size()>1)
		{
			if(rtype !=null && rtype.equalsIgnoreCase("No"))
				aListCompType_value.add(0,"ALL");
			allServerPresent = true;
		}
	}
	Vector v_appgrp =new Vector();
	// karthikeyan 
			boolean wrkGrouper = false;
			if(s_compType!=null)
				 strTestt = reportInfo.getTestName("CITRIX_USER_REPORT",s_compType,false);
	if(s_compType!=null && s_compType.length()>0)
	{
		String strTestName = strTestt;
		strTestt= strTestt+"_DDD";
		EgAgentInfo agentInfo = new EgAgentInfo("manager");
		if(v_components!=null && v_components.size()>0 && strTestName!=null && strTestName.length()>0)
		{
			boolean found = false;
			String showUserWorkGroup = reportInfo.getValue("MISC","ShowUserWorkGroup");
			if(showUserWorkGroup!=""&&"yes".equalsIgnoreCase(showUserWorkGroup))
			{
				for(int aa=0;aa<v_components.size();aa++){
					String strVar =  agentInfo.getValueForVar(strTestName+"::"+v_components.get(aa));
					if(strVar!=null && strVar.length()>0)
					{
						int srt=strVar.indexOf("Show_worker_groups");
						int end=strVar.indexOf("-",srt)+1;
						strVar=strVar.substring(srt,end);
						if(strVar!=null && strVar.length()>0)
						{
							strVar=strVar.substring(strVar.indexOf(" "),strVar.indexOf("-"));
							if(strVar!=null && strVar.length()>0)
							{
								strVar=strVar.trim();
								if(strVar.equalsIgnoreCase("true"))
								{
									found=true;
									wrkGrouper = true;
									break;
								}
							}
						}
					}
					
				}
			}
			if(!found)
				wrkGrouper = false;
		}
		else
			wrkGrouper = false;
	}
	if(s_compType!=null && s_compType.length()>0)
	{
		if(!s_compType.equalsIgnoreCase("ALL"))
		{
			String strTest = "ctxAppTest";

			if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXpUserTest_DDD"))
			{
				strTest="CtxAppTest";
			}
			else if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXcXAUserTest_DDD"))
			{
				strTest="CtxXcXAAppTest";
			}

			ArrayList aListGrupNames=null;
			if(wrkGrouper)
			{
				aListGrupNames = erUtils.getAllCtirixWorkGroup(strTest);
			}
			if(aListGrupNames!=null)
				v_appgrp.addAll(aListGrupNames);
		}
		else
		{
			for (int kk=1;kk<aListCompType_value.size();kk++)
			{
				String strTempCompType = (String) aListCompType_value.get(kk);
				String strTest = "ctxAppTest";
				if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXpUserTest_DDD"))
				{
					strTest="CtxAppTest";
				}
				else if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXcXAUserTest_DDD"))
				{
					strTest="CtxXcXAAppTest";
				}
				ArrayList aListGrupNames=null;
				if(wrkGrouper)
				{
					 aListGrupNames = erUtils.getAllCtirixWorkGroup(strTest);
				}
				if(aListGrupNames!=null)
					v_appgrp.addAll(aListGrupNames);
			}
		}
	}
	for (int m=0;m<v_appgrp.size();m++)
	{
		String app=(String)v_appgrp.get(m);
		if (!aListworkGrp.contains(app))
			aListworkGrp.add(app);
	}
	Collections.sort(aListworkGrp,String.CASE_INSENSITIVE_ORDER);
	if(aListworkGrp!=null && aListworkGrp.size()>0)
		aListworkGrp.add(0,"Any");
	if(er_workerGroup == null || er_workerGroup.equals(""))
	{
		if(aListworkGrp!=null && aListworkGrp.size()>0)
			er_workerGroup = "Any";
	}if (aListworkGrp.size() > 0){
		//aListworkGrp.add("All");
		if (er_workerGroup == null)
			er_workerGroup = "Any";
	}
	if(er_workerGroup != null && !er_workerGroup.equalsIgnoreCase("Any")&& !er_workerGroup.equalsIgnoreCase("null"))
	{
		ArrayList aListCompGrp = new ArrayList();
		if(!s_compType.equalsIgnoreCase("ALL"))
		{
			String strTest = "CtxAppTest";
			if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXpUserTest_DDD"))
			{
				strTest="CtxAppTest";
			}
			else if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXcXAUserTest_DDD"))
			{
				strTest="CtxXcXAAppTest";
			}
			aListCompGrp = erInfo.getServersForWorkGroup(strTest,er_workerGroup,true);
		}else
		{
			for (int kk=1;kk<aListCompType_value.size();kk++)
			{
				String strTempCompType = (String) aListCompType_value.get(kk);
				//String testName = reportInfo.getValue("APPLICATION_LAUNCH_COUNT",strTempCompType+"_Data");
				String strTest = "CtxAppTest";
				if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXpUserTest_DDD"))
				{
					strTest="CtxAppTest";
				}
				else if(strTestt!=null && strTestt.equalsIgnoreCase("CtxXcXAUserTest_DDD"))
				{
					strTest="CtxXcXAAppTest";
				}
				ArrayList aListGrupserver = erInfo.getServersForWorkGroup(strTest,er_workerGroup,true);
				if(aListGrupserver!=null)
					aListCompGrp.addAll(aListGrupserver);
			}
		}
		if(aListCompGrp!=null && aListCompGrp.size()>0)
		{
			for(int i=0; i<v_components.size(); i++) 
			{
				String loopComponent = (String) v_components.get(i);
				String strComp = loopComponent;
				if(aListCompGrp.contains(strComp))
					v_Workgroupcomponents.add(strComp);
			}
		}
		if(v_Workgroupcomponents!=null && v_Workgroupcomponents.size()==0)
		{
			v_components = new Vector();
		}
	}
	if(v_Workgroupcomponents!=null && v_Workgroupcomponents.size()>0)
	{
		v_components = new Vector();
		v_components.addAll(v_Workgroupcomponents);
	}
	int v_componentSize = 0;
	if(v_components!=null && v_components.size()>0)
	{
		v_componentSize=v_components.size();
		if(selectedCompArrays == null || selectedCompArrays.length==0)
		{
			selectedCompArrays = new String[v_components.size()];
			selectedCompArrays = (String[])v_components.toArray(new String[v_components.size()]);
		}
	}
	if(v_componentSize>0)
	{
		/*
		if(countCitrix>0 && countTerminal>0)
			allServerPresent=true;
		*/
		if(s_server==null)
		{
			s_server=(String)v_components.get(0);
		}
	}
	String testStr = reportInfo.getValue("APPLICATION_LAUNCH_COUNT",s_compType);
	String launchLimit = reportInfo.getValue("CitrixXenApp_OverView","LaunchLimit");
	String er_launchDuration=request.getParameter("er_launchDuration");
	if(er_launchDuration != null)
	{
		launchLimit=er_launchDuration;
		selectedFields.put("er_launchDuration",launchLimit);	
	}
	
	List v_user = new Vector();
	for (int i=0; i<v_components.size(); i++) {
		//v_user.addAll(erInfo.getInfosForTest("NULL","termAppTest",(String)v_components.get(i)));
	}
	if (rtype!= null && er_option!=null)
	{
		if(er_option.equalsIgnoreCase("Zone"))
		{
			v_user = erUtils.getAllUsersForComponents(s_compType,s_farmserver,aListSupportedComponentType,zones,v_zonelist,v_components,new ArrayList(v_components));
		}
		else
		{
			v_user = erUtils.getAllUsersForComponentName(er_option,er_site,s_compType,aListSupportedComponentType,loginid);
		}
	}
	//v_user.addAll(erInfo.getInfosForTest("ctxAppTest"));
	ErApplicationLaunchCountReportBean erAppBEan = new ErApplicationLaunchCountReportBean();
	List directoryList = erAppBEan.getADList();
	//directoryList.add("EnterpriseAdmins");
	//directoryList.add("DomainAdmins");
	//directoryList.add("Controllers");
	//directoryList.add("Domain Guests");
	if ((er_adGroupList == null  || er_adGroupList.size() < 0 ) && directoryList.size() > 0){
	er_adGroup = "All";
		er_adGroupList.add("All");
}
	v_application=new ArrayList();
	String strTest ="";
	boolean isVm = false;
	if(selectedCompArrays!=null && selectedCompArrays.length>0)
	{
		Vector v_app=new Vector();
		for(int ii=0;ii<selectedCompArrays.length;ii++)
		{
			String strComp = selectedCompArrays[ii];
			String strTempCompType = strComp;
			String strCompNameTemp = strComp; 
			if(strComp.lastIndexOf(":")>-1)
			{
				strTempCompType = strComp.substring(strComp.lastIndexOf(":")+1);
				strCompNameTemp = strComp.substring(0,strComp.lastIndexOf(":"));
			}
			//if(s_compType.equalsIgnoreCase(strTempCompType))
			{
				strTest = reportInfo.getValue("APPLICATION_LAUNCH_COUNT",strTempCompType);
				if (strTest.indexOf("_DDD")> -1) 
					strTest = strTest.substring(0,strTest.indexOf("_DDD"));
				if(strTest!=null && (strTest.equalsIgnoreCase("AppLaunchTest") || strTest.equalsIgnoreCase("VmgApplaunchTest") || strTest.equalsIgnoreCase("VTAppLaunchTest")))
					isAppLaunchDuarationColumnEnabled = true;
				if(strTest!=null && strTest.equalsIgnoreCase("VmgApplaunchTest"))
					isVm =true;
				//strTest = "CtxAppTest";
				ArrayList aListCompGrp =  null;
				
				if(er_workerGroup != null && !er_workerGroup.equalsIgnoreCase("Any") && !er_workerGroup.equalsIgnoreCase("null"))
				{
					// here  add applications from  AppLaunchTest & CtxAppTest
					if(strTest!=null && strTest.equalsIgnoreCase("AppLaunchTest"))
					{
						aListCompGrp = erInfo.getApplicationForWorkgroup("AppLaunchTest",er_workerGroup,strComp);
						ArrayList tempList = erInfo.getApplicationForWorkgroup("CtxAppTest",er_workerGroup,strComp);
						if(aListCompGrp!=null)
							v_app.addAll(aListCompGrp);
						if(aListCompGrp==null || aListCompGrp.size()==0 && tempList!=null)
							v_app.addAll(tempList);

					}
					else if(strTest!=null && strTest.equalsIgnoreCase("CtxAppTest"))
					{
						aListCompGrp = erInfo.getApplicationForWorkgroup("AppLaunchTest",er_workerGroup,strComp);
						ArrayList tempList = erInfo.getApplicationForWorkgroup("CtxAppTest",er_workerGroup,strComp);
						if(aListCompGrp!=null)
							v_app.addAll(aListCompGrp);
						if(aListCompGrp==null || aListCompGrp.size()==0 && tempList!=null)
							v_app.addAll(tempList);
					}
					// here  add applications from  AppLaunchTest & CtxXcXAAppTest
					else if(strTest!=null && strTest.equalsIgnoreCase("AppLaunchTest"))
					{
						aListCompGrp = erInfo.getApplicationForWorkgroup("AppLaunchTest",er_workerGroup,strComp);
						ArrayList tempList = erInfo.getApplicationForWorkgroup("CtxXcXAAppTest",er_workerGroup,strComp);
						if(aListCompGrp!=null)
							v_app.addAll(aListCompGrp);
						if(aListCompGrp==null || aListCompGrp.size()==0 && tempList!=null)
							v_app.addAll(tempList);
					}
					else if(strTest!=null && strTest.equalsIgnoreCase("CtxXcXAAppTest"))
					{
						aListCompGrp = erInfo.getApplicationForWorkgroup("AppLaunchTest",er_workerGroup,strComp);
						ArrayList tempList = erInfo.getApplicationForWorkgroup("CtxXcXAAppTest",er_workerGroup,strComp);
						if(aListCompGrp!=null)
							v_app.addAll(aListCompGrp);
						if(aListCompGrp==null || aListCompGrp.size()==0 && tempList!=null)
							v_app.addAll(tempList);
					}
					else
					{
						aListCompGrp = erInfo.getApplicationForWorkgroup(strTest,er_workerGroup,strComp);
						if(aListCompGrp!=null)
							v_app.addAll(aListCompGrp);
					}
				}
				else
				{
					// here  add applications from  AppLaunchTest & CtxAppTest
					if(strTest!=null && strTest.equalsIgnoreCase("AppLaunchTest"))
					{
						Vector v_apps=erInfo.getInfosForTest("NULL","AppLaunchTest",strComp);
						if(v_apps==null || v_apps.size()==0)
							v_apps = erInfo.getInfosForTest("NULL","CtxAppTest",strComp);
						v_app.addAll(v_apps);
					}
					else if(strTest!=null && strTest.equalsIgnoreCase("CtxAppTest"))
					{
						 Vector v_apps=erInfo.getInfosForTest("NULL","AppLaunchTest",strComp);
						if(v_apps==null || v_apps.size()==0)
							v_apps = erInfo.getInfosForTest("NULL","CtxAppTest",strComp);
						v_app.addAll(v_apps);
					}
					// here  add applications from  AppLaunchTest & CtxXcXAAppTest
					else if(strTest!=null && strTest.equalsIgnoreCase("AppLaunchTest"))
					{
						Vector v_apps=erInfo.getInfosForTest("NULL","AppLaunchTest",strComp);
						if(v_apps==null || v_apps.size()==0)
							v_apps = erInfo.getInfosForTest("NULL","CtxXcXAAppTest",strComp);
						v_app.addAll(v_apps);
					}
					else if(strTest!=null && strTest.equalsIgnoreCase("CtxXcXAAppTest"))
					{
						 Vector v_apps=erInfo.getInfosForTest("NULL","AppLaunchTest",strComp);
						if(v_apps==null || v_apps.size()==0)
							v_apps = erInfo.getInfosForTest("NULL","CtxXcXAAppTest",strComp);
						v_app.addAll(v_apps);
					}
					else
					{
						v_app.addAll(erInfo.getInfosForTest("NULL",strTest,strComp));
					}
				}
				
			}
		}
		if(er_workerGroup == null || er_workerGroup.equalsIgnoreCase("Any"))
			v_app = ErUtils.formatString(v_app,"$0+$1","$1");
		for (int m=0;m<v_app.size();m++)
		{
			String app=(String)v_app.get(m);
			if(strTest != null && strTest.equalsIgnoreCase("VmgApplaunchTest")){
				if(app != null && app.indexOf(":")> -1)
					app=app.substring(app.lastIndexOf(":")+1);
			}
			if (!v_application.contains(app))
				v_application.add(app);
		}
	}
	/*if(s_server!=null && !s_server.equals(""))
	{
		v_application=new Vector();
		Vector v_app=new Vector();
		if (s_server.equals("-1")) // Get list of applications for All  Servers
		{
			for (int l=0;l<v_components.size();l++)
			{
				String server=(String)v_components.get(l);
				String strTempComponentType1 = "";
				if(server!=null && server.lastIndexOf(":")>-1)
				strTempComponentType1 = server.substring(server.lastIndexOf(":")+1);
				String strTest = reportInfo.getTestName("APPLICATION_LAUNCH_COUNT",strTempComponentType1,false);
				v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
			}
		}
		else if(s_server.indexOf("All")>-1 && s_server.indexOf(" ")>-1) //Get list of applications for Spefic Components type Ex :Citrix Server
		{
			String strComponentType = "";
			StringTokenizer stToken = new StringTokenizer(s_server);
			if(stToken.countTokens()>=2)
			{
				stToken.nextToken();
				strComponentType = stToken.nextToken();
			}
			for (int l=0;l<v_components.size();l++)
			{
				String server=(String)v_components.get(l);
				String strTempComponentType1 = "";
				if(server!=null && server.lastIndexOf(":")>-1)
				strTempComponentType1 = server.substring(server.lastIndexOf(":")+1);
				if(strTempComponentType1!=null && strTempComponentType1.equalsIgnoreCase(strComponentType))
				{
					String strTest = reportInfo.getTestName("APPLICATION_LAUNCH_COUNT",strComponentType,false);
					v_app.addAll(erInfo.getInfosForTest("NULL",strTest,server));
				}
			}
		}
		else // Get list fo application for specfic components
		{
			String strTempComponentType1 = s_server.substring(s_server.lastIndexOf(":")+1);
			String strTest = reportInfo.getTestName("APPLICATION_LAUNCH_COUNT",strTempComponentType1,false);
			v_app.addAll(erInfo.getInfosForTest("NULL",strTest,s_server));
		}
		
		v_app = ErUtils.formatString(v_app,"$0+$1","$1");
		for (int m=0;m<v_app.size();m++)
		{
			String app=(String)v_app.get(m);
			if (!v_application.contains(app))
				v_application.add(app);
		}
	}*/
	Collections.sort(v_application,String.CASE_INSENSITIVE_ORDER);
	serverForSorting=s_server;
	for(int m=0;m<subjects.size();m++)
	{
		//s_variable = (String)subjects.get(m);
		tok1 = new StringTokenizer(s_variable,":");
		String displayname="";
		String s_test="";
		String s_measure="";
		while(tok1.hasMoreTokens())
		{
			String com=tok1.nextToken();
			if(aListCompType_value !=null && !aListCompType_value.contains(com))
				continue;
			if(s_compType!=null && !s_compType.equalsIgnoreCase("ALL") && !s_compType.equalsIgnoreCase(com))
				continue;
			s_test = tok1.nextToken();
			String val2=tok1.nextToken();
			StringTokenizer meas=new StringTokenizer(val2,"#");
			if(meas.hasMoreTokens() )
				 mes=meas.nextToken();
			else
				 mes=val2;
			if(meas.hasMoreTokens() )
				displayname=meas.nextToken();
			else
				displayname=val2;
			if (!v_testmes.contains(s_test+"/"+mes))
				v_testmes.add(s_test+"/"+mes);
		}
		if(serverForSorting!=null && !serverForSorting.equals("All") && !serverForSorting.equals("-1"))
		{
			if(serverForSorting.indexOf(":")>-1)
			{
				serverForSorting=serverForSorting.substring(serverForSorting.lastIndexOf(":")+1,serverForSorting.length());
			}
			else if(serverForSorting.indexOf("All")>-1 && serverForSorting.indexOf(" ")>-1)
			{
				serverForSorting=serverForSorting.substring(serverForSorting.indexOf("All")+4,serverForSorting.length());
			}
			if(s_variable.indexOf(":")>-1)
			{
				String str_temp=s_variable.substring(0,s_variable.indexOf(":"));
				if(str_temp.equalsIgnoreCase(serverForSorting))
				{
					String st_value=reportInfo.getValue("APPLICATION_LAUNCH_COUNT",s_variable);
					StringTokenizer cols=new StringTokenizer(st_value,",");
					while (cols.hasMoreTokens())
					{
						v_sort.add(displayname+"_"+cols.nextToken());
					}
				}
			}
		}
	}
	v_testmes.add("Number of unique users");
	if(testmes == null && v_testmes != null && v_testmes.size() >0)
	{
		testmes = (String)v_testmes.get(0);
	}

	String uiFile = "eg_ui.ini";
	String s_iniFile_dir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile egUI = new IniFile(s_iniFile_dir + uiFile);
	String currentDateFormat = strUserDateFormat;//egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	String starttimeformat="";
	String endtimeformat="";
	String dispDate = null;
	String comFormat = null;
	String  s_st_time   = request.getParameter("startdate");
	String s_en_time    = request.getParameter("enddate");
	String s_st_hr      = request.getParameter("starthr");
	String s_en_hr      = request.getParameter("endhr");
	String strmin       = request.getParameter("startmin");
	String enmin        = request.getParameter("endmin");
	String  er_timeline = request.getParameter("er_timeline");
	String start_date   = request.getParameter("startdate");
	String end_date     = request.getParameter("enddate");

	String  pdfStartDate = s_st_time+" "+s_st_hr+":"+strmin;
	String  pdfEndDate   = s_en_time+" "+s_en_hr+":"+enmin;
	String pdfTime = "From "+pdfStartDate+" hrs "+" "+" To "+pdfEndDate+" hrs";

	Vector applnPdfData = new Vector();
	applnPdfData = (Vector)request.getAttribute("applnPdfData");
	pdfTime = "Application Report "+pdfTime;

	if(applnPdfData!=null && !applnPdfData.isEmpty())
	{
		Vector forTime = (Vector)applnPdfData.get(1);
		forTime.removeElementAt(0);
		forTime.insertElementAt(pdfTime,0);
		applnPdfData.removeElementAt(1);
		applnPdfData.insertElementAt(forTime,1);
	}
	if(er_timeline==null  || er_timeline.equals(" "))
	{
		er_timeline="1 day";
	}
	//Date calculation according to time select
	String[] options = {"Any","1 hour", "3 hours", "6 hours", "9 hours", "12 hours", "15 hours", "18 hours", "21 hours","1 day", "2 days", "3 days", "4 days", "5 days", "6 days","1 week","2 weeks","3 weeks","4 weeks","1 month","2 months","3 months"};
	String startDateTime="";
	String endDateTime="";
	if(er_timeline!=null&&!er_timeline.equals("Any"))
	{
		int blankSpaceIndex = er_timeline.indexOf(DateTimeTokenizer.BLANK_SPACE);
		if (blankSpaceIndex > 0)
		{
			SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm");
			java.util.Date today =egDt.egetRealDate();
			endDateTime = sdf.format(today);
			long value = Integer.parseInt(er_timeline.substring(0, blankSpaceIndex));
			String unit = er_timeline.substring(blankSpaceIndex+1).toLowerCase();
			if (unit.startsWith("h"))
			{//hours
				value *= 3600;
			}
			else if (unit.startsWith("d"))
			{//days
				value *= (24 * 3600);
			}
			else if (unit.startsWith("w"))
			{//weeks
				value *= (7 * 24 * 3600);
			}
			else if (unit.startsWith("mo"))
			{//months
				java.util.Date dt_temp = new java.util.Date(egDt.egetUTCDate());
				Calendar cal_temp = new GregorianCalendar();
				cal_temp.setTime(dt_temp);
				//cal_temp.add(Calendar.DATE,-1);
				cal_temp.add(Calendar.HOUR_OF_DAY,0);
				java.util.Date dt_temp1 = cal_temp.getTime();
				long l_temp = dt_temp1.getTime();
				int  totalDays=24*(ErUtils.getMaxDaysInMonth());
				startDateTime = egDt.egetDate(l_temp -(long)( (value*totalDays * msecsPerHour)));
				startDateTime = DateUtil.changeDateFormat(startDateTime,
				"dd/MM/yyyy HH:mm","MM/dd/yyyy HH:mm");
			}
			if (unit!=null&&!unit.startsWith("mo"))
			{
				java.util.Date start = egDt.egetRealDate();
				start.setTime(today.getTime() - (value * 1000));
				startDateTime = sdf.format(start);
			}
		}
		if ((startDateTime != null) && (endDateTime != null))
		{
			int shr = Integer.parseInt(startDateTime.substring(startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, startDateTime.indexOf(":")));
			strmin=startDateTime.substring(startDateTime.indexOf(":")+1);
			int en_hr = Integer.parseInt(endDateTime.substring(endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE)+1, endDateTime.indexOf(":")));
			enmin=endDateTime.substring(endDateTime.indexOf(":")+1);
			s_en_time=endDateTime.substring(0, endDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
			s_st_time=startDateTime.substring(0, startDateTime.indexOf(DateTimeTokenizer.BLANK_SPACE));
			s_st_hr = String.valueOf(shr);
			s_en_hr = String.valueOf(en_hr);
		}
	}
	String disable="";
	if(er_timeline!=null&&!er_timeline.equals("Any"))
	{
		disable ="disabled";
	}
	if(er_timeline!=null&&er_timeline.equals("Any"))
	{
		String StrDate="";
		try
		{
			java.text.SimpleDateFormat df=new java.text.SimpleDateFormat("MM/dd/yyyy k 'at' hh:mm");
			StrDate =df.format(egDt.egetRealDate());
		}
		catch(Exception ee)
		{
			////System.out.println("Exception is"+ee);
		}
		String SDate =StrDate.substring(0,StrDate.indexOf(" "));
		String shour =StrDate.substring(StrDate.indexOf(" "),StrDate.lastIndexOf(""));
		shour = shour.substring(0,3);
		if(s_st_time==null)
		{
			s_st_time=SDate;
		}
		if(s_en_time==null)
		{
			s_en_time=SDate;
		}
		if(s_st_hr==null)
		{
			shour =shour.trim();
			int starthr = Integer.parseInt(shour);
			starthr = starthr-1;
			s_st_hr=String.valueOf(starthr);
		}
		if(s_en_hr==null)
		{
			shour =shour.trim();
			s_en_hr =shour;
		}
		strmin="00";
		enmin="00";
	}
	String strServergroupQs = "";
	String strUserLinkServerQs="";
	if(selectedCompArrays!=null && selectedCompArrays.length>0)
	{
		for (int i=0;i<selectedCompArrays.length;i++)
		{
			try{
				strServergroupQs += "&er_component="+EgURLEncoder.encode(selectedCompArrays[i],"UTF-8");
				String strComp = selectedCompArrays[i];
				if(strComp!=null && strComp.lastIndexOf(":")>-1)
					strComp = strComp.substring(0,strComp.lastIndexOf(":"));
				strUserLinkServerQs += "&er_componentserver="+EgURLEncoder.encode(strComp,"UTF-8");
			}catch(Exception e){}
		}
	}
	session.setAttribute("PDF_URL", mngrIProc+"/final/reporter/ErApplicationLaunchCountReportPrint.jsp");
	urlFields.put("PDF_URL",mngrIProc+"/final/reporter/ErApplicationLaunchCountReportPrint.jsp");

	String excludeweekend=request.getParameter("er_excwe");
	if (excludeweekend==null ||	excludeweekend.equals(""))
		excludeweekend="No";

	hiddenFields.put("option","Citrix");
	hiddenFields.put("inidate",currentDateFormat);
	hiddenFields.put("currTime","");
	hiddenFields.put("er_rtype","CtxApplication");
	hiddenFields.put("er_trgttype","Application Launch Count Report");
	hiddenFields.put("er_gtype","Citrix");
	hiddenFields.put("pdfTime",pdfTime);
	hiddenFields.put("uid",EgURLEncoder.encode(loginid,"UTF-8"));
	hiddenFields.put("userID",EgURLEncoder.encode(loginid,"UTF-8"));
	hiddenFields.put("eruserid",EgURLEncoder.encode(loginid,"UTF-8"));
	hiddenFields.put("er_trenddata","No");
	hiddenFields.put("servers",request.getParameter("servers"));
	hiddenFields.put("er_check",request.getParameter("er_check"));
	hiddenFields.put("er_application1",request.getParameter("er_application1"));
	hiddenFields.put("schedule_id",schedule_id);
	hiddenFields.put("er_ViewName","ErApplicationLaunchCountReport.jsp");
	hiddenFields.put("getMaxDaysInMonth",ErUtils.getMaxDaysInMonth());
	hiddenFields.put("forwardto","ErApplicationLaunchCountReportJson");
	hiddenFields.put("er_bgreportfrom","Application_Launch");
	hiddenFields.put("bgenabled",strbgrepportName);
	hiddenFields.put("limitforbg",limitforbg);
	hiddenFields.put("savereport","save");
	hiddenFields.put("servletName","com.eg.ErApplicationLaunchCountReportC");
	if(reqFromFavorite!=null)
	{
		hiddenFields.put("fromFavorite",reqFromFavorite);
	}
	else
	{
		hiddenFields.put("fromFavorite","null");
	}
	if(reqFromSchedule!=null)
	{
		hiddenFields.put("fromSchedule",reqFromSchedule);
	}
	else
	{
		hiddenFields.put("fromSchedule","null");
	}
	hiddenFields.put("FavoriteId",favorite_id);
	if(rtype!=null&&rtype.equals("Yes"))
	{
		hiddenFields.put("opt","chart");
	}
	else
	{
		hiddenFields.put("opt","data");
	}

	String strwidth = "90%";
	if(backreqMap == null || backreqMap != null && backreqMap.size() == 0)
		strwidth="100%";

		String fromFavSch = request.getParameter("fromFavSch");
		if(backreqMap != null && backreqMap.size() > 0 &&  enableBack && request.getParameter("enableBack")!=null && request.getParameter("enableBack").equalsIgnoreCase("true") && (fromFavSch!=null && fromFavSch.equalsIgnoreCase("true")))
			{
				hiddenFields.put("ID","backQnumber="+erhelputils.getBackID()+"&"+erhelputils.getQueryString());
			}
		lst.add(intlmap.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmap.getTextDescription("reporter.common.APPLICATION LAUNCH"));
		headingList.add(intlmap.getTextDescription("reporter.thin.THIN CLIENT REPORTS")+" - "+intlmap.getTextDescription("reporter.common.APPLICATION LAUNCH"));
 	if (dispzone != null)
	Collections.sort(dispzone,String.CASE_INSENSITIVE_ORDER);
	labelFields.put("zoneLabel",intlmap.getTextDescription("reporter.thin.Zone"));
	labelFields.put("componentTypeLabel",intlmap.getTextDescription("reporter.thin.Component Type"));
	if(rtype == null || (rtype!=null && rtype.equals("No")))
	{
		labelFields.put("componentLabel",intlmap.getTextDescription("reporter.thin.Components"));
		String strColSpan="";
		// by karthikenyan - for vm ware virtual machines lookup
	  if(isLaunchByVm)
	  {
		if(s_compType!=null)
		{
			ErVMGuestServerReportBean ervmGuest = new ErVMGuestServerReportBean();
			ArrayList vmList = ervmGuest.getAllGuest("",s_compType,loginid);
			ArrayList listSelectedVms=new ArrayList();
			if(selectedVmArrays!=null)
			{
				listSelectedVms.addAll(Arrays.asList(selectedVmArrays));
			}

			JSONArray vmOptsJson = new JSONArray();
			StringBuffer strVal=new StringBuffer();
			if(vmList == null && vmList.size() == 0 )
			{
				JSONObject noDataOpt = new JSONObject();
				noDataOpt.put("displayField","Not Applicable");
				noDataOpt.put("valueField","Not Applicable");
				vmOptsJson.add(noDataOpt);
			}
			else
			{
				Collections.sort(vmList,String.CASE_INSENSITIVE_ORDER);
				/*JSONObject defaultDataOpt = new JSONObject();
				defaultDataOpt.put("displayField",mappingInfo.getTextDescription("reporter.esx.Please choose a Virtual Machine"));
				defaultDataOpt.put("valueField","-1");
				vmOptsJson.add(defaultDataOpt);*/
				ArrayList uniqueVmList=new ArrayList();
				Iterator itrGuestVms = vmList.iterator();
				while(itrGuestVms.hasNext())
				{
					String vmName = (String) itrGuestVms.next();
					if(vmName!=null&&vmName.indexOf("&")>=0)
						vmName="";
					String disName=vmName;
					if(vmName!=null)
					{
						if(disName!=null && disName.indexOf("_on_")>=0)
						{
						disName=StringUtils.replace(vmName,"_on_","$");
						disName = disName.substring(disName.indexOf("$")+1);
						}

					}
					if(!uniqueVmList.contains(disName))
						uniqueVmList.add(disName);
					else
						continue;
				
					JSONObject vmOpt = new JSONObject();
					vmOpt.put("displayField",disName);
					vmOpt.put("valueField",disName);
					vmOptsJson.add(vmOpt);
					strVal.append(disName).append(",");
				}
			}
			combo.put("vmOptsJson",vmOptsJson);
			if(listSelectedVms!=null && listSelectedVms.size()>0)
			{
				String selectedvm=StringUtils.replace(listSelectedVms.toString(),"[","");
				selectedvm=StringUtils.replace(selectedvm,"]","");
				selectedFields.put("vmSelected",selectedvm);
				if(selectedvm.length()>66)
				{
					selectedvm=selectedvm.substring(0,65)+"...";
				}
				selectionDetails.put("selectedvm",selectedvm);
			}
			else
				selectedFields.put("vmSelected",strVal.toString());
		}
	  }
		for(int n=0;n<v_comp_popup.size();n++)
		{
			String s=(String)v_comp_popup.get(n);
			String ss=(String)v_comp_popup_disp.get(n);
		}
	}
	labelFields.put("reportTypeLabel",intlmap.getTextDescription("reporter.thin.Report Type"));
	iterateJArray=new JSONArray();
	
	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.Graph"));
	iterateJObject.put("valueField","Yes");
	iterateJArray.add(iterateJObject);

	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.Data"));
	iterateJObject.put("valueField","No");
	iterateJArray.add(iterateJObject);
	combo.put("reportTypeCombo",iterateJArray);
	if(rtype!=null&&rtype.equals("Yes"))
	{
		selectedFields.put("reportTypeSelected","Yes");
		//selectionDetails.put(intlmap.getTextDescription("reporter.thin.Report Type"),"Graph");
	}
	else
	{
		if (s_farmserver!=null && !s_farmserver.equals("-1") && s_server!=null && !s_server.equalsIgnoreCase("All") &&  !s_server.equalsIgnoreCase("-1") || v_comptype.size()==1)
		{
			selectedFields.put("reportTypeSelected","No");
			//selectionDetails.put(intlmap.getTextDescription("reporter.thin.Report Type"),"Data");
		}
		else
		{
			selectedFields.put("reportTypeSelected","No");
			//selectionDetails.put(intlmap.getTextDescription("reporter.thin.Report Type"),"Data");
		}
	}
	labelFields.put("detailsBasedOnLabel",intlmap.getTextDescription("reporter.thin.Details based on"));
	iterateJArray=new JSONArray();

	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.User"));
	iterateJObject.put("valueField","user");
	iterateJArray.add(iterateJObject);

	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.Application"));
	iterateJObject.put("valueField","application");
	iterateJArray.add(iterateJObject);
	combo.put("detailsBasedOnCombo",iterateJArray);

	if(er_detailsBasedOn!=null && er_detailsBasedOn.equals("user"))
	{
		selectedFields.put("detailsBasedOnSelected","user");
		selectionDetails.put(intlmap.getTextDescription("reporter.thin.Details based on"),"user");
	}else
	{
		selectedFields.put("detailsBasedOnSelected","application");	
		selectionDetails.put(intlmap.getTextDescription("reporter.thin.Details based on"),"application");
	}
	if(geoDetails != null){
		selectedFields.put("GeodetailsBasedOnSelected",geoDetails);	
	//	selectionDetails.put(intlmap.getTextDescription("reporter.thin.Details based on"),geoDetails);
	}
	if (aListworkGrp.size() > 0){
		labelFields.put("workerGroupLabel",intlmap.getTextDescription("reporter.common.Worker Group"));
			iterateJArray=new JSONArray();
			for(int i=0; i<aListworkGrp.size(); i++) {
				String userStr = (String) aListworkGrp.get(i);
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",userStr);
				iterateJObject.put("valueField",userStr);
				iterateJArray.add(iterateJObject);
				if (userStr.equalsIgnoreCase(er_workerGroup)){	
					selectedFields.put("workerGroupSelected",userStr);
					selectionDetails.put(intlmap.getTextDescription("reporter.common.Worker Group"),userStr);
			
				} 
			}
			combo.put("workerGroupCombo",iterateJArray);
		}
	if (er_detailsBasedOn != null && !er_detailsBasedOn.equalsIgnoreCase("application"))
	{
		String str_select="";
		ArrayList aListSelectedList = new ArrayList();
		if(s_user!=null && s_user.length>0)
			aListSelectedList.addAll(Arrays.asList(s_user));
		if (aListSelectedList.contains("Not Applicable")){
			aListSelectedList = new ArrayList();
			aListSelectedList.add("all");
		}
		labelFields.put("userLabel",intlmap.getTextDescription("reporter.thin.User"));
		//if (moreUserCount < v_user.size()){
		//} 
		//else 
 			if(v_user!=null && v_user.size()>0)
			{
				iterateJArray=new JSONArray();

				if (aListSelectedList.contains("all") || aListSelectedList.size() == 0){
					aListSelectedList.add("all");
					iterateJObject=new JSONObject();
					iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.All Users"));
					iterateJObject.put("valueField","all");
					iterateJArray.add(iterateJObject);
				} 
				StringBuffer str=new StringBuffer();
				for(int n=0;n<v_user.size();n++)
				{
					String s=(String)v_user.get(n);
					if(s.startsWith("+"))
						s = s.substring(1);
					iterateJObject=new JSONObject();
					iterateJObject.put("displayField",s);
					iterateJObject.put("valueField",s);
					iterateJArray.add(iterateJObject);

					if(aListSelectedList!=null && aListSelectedList.contains(s) && !v_user.contains("all"))
					{
						str.append(s).append(",");
					}
				}
				if(str.length()>0)
				{
					str.deleteCharAt(str.length() - 1);
					selectedFields.put("userSelected",str.toString());
					selectionDetails.put(intlmap.getTextDescription("reporter.thin.User"),str.toString());
				} 
				combo.put("userCombo",iterateJArray);
			}
			else
			{
				iterateJArray=new JSONArray();
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
				iterateJObject.put("valueField","-1");
				iterateJArray.add(iterateJObject);
				combo.put("userCombo",iterateJArray);
			}
			if (aListSelectedList.contains("Not Applicable")){
				aListSelectedList = new ArrayList();
				aListSelectedList.add("all");
			}
			if (aListSelectedList.size() == 0 ||  aListSelectedList.contains("all"))
			{
				aListSelectedList.add("all");
			}
			if (v_user!=null && v_user.size()>0)
			{
				for(int n=0;n<v_user.size();n++)
				{
					String s=(String)v_user.get(n);
					String ss=(String)v_user.get(n);
				}
			}
		labelFields.put("applicationLabel",intlmap.getTextDescription("reporter.thin.Applications"));
		str_select="";
		if(selectedAppArrays == null || selectedAppArrays.length==0 || (s_application!=null && s_application.equals("-1")))
		{
			//selectedAppArrays = new String[v_application.size()];
			//selectedAppArrays = (String[])v_application.toArray(new String[v_application.size()]);
		}
		aListSelectedList = new ArrayList();
		if(selectedAppArrays!=null && selectedAppArrays.length>0)
			aListSelectedList.addAll(Arrays.asList(selectedAppArrays));
		if(v_application!=null && v_application.size()>0 && selected_CompType!=null && !selected_CompType.equalsIgnoreCase("-1"))
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.All Applications"));
			iterateJObject.put("valueField","all");
			iterateJArray.add(iterateJObject);
			if (aListSelectedList.contains("all") || v_application.contains("all") || aListSelectedList.contains("Not Applicable") || aListSelectedList.size() == 0)
			{
				selectedFields.put("applicationSelected","all");
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.Applications"),"all");
			} else {
				selectedFields.put("applicationSelected","all");
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.Applications"),"all");
			}
			Collections.sort(v_application,String.CASE_INSENSITIVE_ORDER);
			StringBuffer str=new StringBuffer();
			for(int n=0;n<v_application.size();n++)
			{
				String s=(String)v_application.get(n);
				if(s.startsWith("+"))
					s = s.substring(1);
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",s);
				iterateJObject.put("valueField",s);
				iterateJArray.add(iterateJObject);
				if(aListSelectedList!=null && aListSelectedList.contains(s))
				{
					str.append(s).append(",");
  				}
			}
			if(str.length()>0)
			{
				str.deleteCharAt(str.length() - 1);
				selectedFields.put("applicationSelected",str.toString());
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.Applications"),str.toString());
			}
			combo.put("applicationCombo",iterateJArray);
		}
		else
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			iterateJObject.put("valueField","-1");
			iterateJArray.add(iterateJObject);
			combo.put("applicationCombo",iterateJArray);
		}
		if (v_application!=null && v_application.size()>0)
		{
			
			for(int n=0;n<v_application.size();n++)
			{
				String s=(String)v_application.get(n);
				String ss=(String)v_application.get(n);
			}
		}
		if (aListworkGrp.size() == 0){
		}
		aListSelectedList = new ArrayList();
		if(s_user!=null && s_user.length>0)
			aListSelectedList.addAll(Arrays.asList(s_user));
		if (aListSelectedList.contains("Not Applicable")){
			aListSelectedList = new ArrayList();
			aListSelectedList.add("all");
		}
		if (directoryList.size() > 0 && aListSelectedList.contains("all"))
		{
			labelFields.put("adGroupLabel",intlmap.getTextDescription("reporter.thin.AD Group"));
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.thin.All"));
			iterateJObject.put("valueField","All");
			iterateJArray.add(iterateJObject);
			if (er_adGroupList != null && er_adGroupList.contains("All"))
			{
				selectedFields.put("adGroupSelected","All");
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.AD Group"),"All");
			} 
			Collections.sort(directoryList,String.CASE_INSENSITIVE_ORDER);
			StringBuffer str=new StringBuffer();
			for (int i=0; i<directoryList.size(); i++)
			{
				String dirStr = (String) directoryList.get(i);
				iterateJObject=new JSONObject();
				String strdispDirStr=dirStr;
				if(showADShortName)
				{
					if(strdispDirStr!=null && strdispDirStr.indexOf(",")>-1)
					{
						StringTokenizer stToken = new StringTokenizer(strdispDirStr,",");
						if(stToken.countTokens()>1)
						{
							String strAdName = stToken.nextToken();
							if(strAdName!=null && strAdName.indexOf("=")>-1)
							{
								strdispDirStr = strAdName.substring(strAdName.indexOf("=")+1);
							}
						}
					}
				}
				iterateJObject.put("displayField",strdispDirStr);
				iterateJObject.put("valueField",dirStr);
				iterateJArray.add(iterateJObject);

				if (dirStr.equals(er_adGroup)) {
					str.append(dirStr).append(",");
				} 
			}
			if(er_adGroupList != null && er_adGroupList.size() > 0)
			{
				//str.deleteCharAt(str.length() - 1);
				//selectedFields.put("adGroupSelected",str.toString());
				selectedFields.put("adGroupSelected",er_adGroupList);
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.AD Group"),er_adGroupList.toString());
			}
				combo.put("adGroupCombo",iterateJArray);
										if (er_adGroup != null && er_adGroup.equals("All")) {			
										} 
										for (int i=0; i<directoryList.size(); i++) {
											String dirStr = (String) directoryList.get(i);
											if (dirStr.equals(er_adGroup)) {			
											} 
										}
	} 
									
		} 
		else 
		{
			labelFields.put("applicationLabel",intlmap.getTextDescription("reporter.thin.Applications"));
		String str_select="";
		if(selectedAppArrays == null || selectedAppArrays.length==0 || (s_application!=null && s_application.equals("-1")))
		{
			//selectedAppArrays = new String[v_application.size()];
			//selectedAppArrays = (String[])v_application.toArray(new String[v_application.size()]);
		}
		ArrayList aListSelectedList = new ArrayList();
		if(selectedAppArrays!=null && selectedAppArrays.length>0)
			aListSelectedList.addAll(Arrays.asList(selectedAppArrays));
		if(v_application!=null && v_application.size()>0 && selected_CompType!=null && !selected_CompType.equalsIgnoreCase("-1"))
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.All Applications"));
			iterateJObject.put("valueField","all");
			iterateJArray.add(iterateJObject);
			if (aListSelectedList.contains("all") || v_application.contains("all") || aListSelectedList.contains("Not Applicable") || aListSelectedList.size() == 0)
			{
				selectedFields.put("applicationSelected","all");	
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.Applications"),"all");
			} 
			Collections.sort(v_application,String.CASE_INSENSITIVE_ORDER);
			StringBuffer str=new StringBuffer();
			if(v_application.contains("Total"))
			{
				v_application.remove("Total");
			}
			for(int n=0;n<v_application.size();n++)
			{
				String s=(String)v_application.get(n);
				if(s.startsWith("+"))
					s = s.substring(1);
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",s);
				iterateJObject.put("valueField",s);
				iterateJArray.add(iterateJObject);
				if(aListSelectedList!=null && aListSelectedList.contains(s))
				{
					str.append(s).append(",");
 				}
			}
			if(str.length()>0)
			{
				str.deleteCharAt(str.length() - 1);
				selectedFields.put("applicationSelected",str.toString());
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.Applications"),str.toString());
			}
			combo.put("applicationCombo",iterateJArray);
		}
		else
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			iterateJObject.put("valueField","-1");
			iterateJArray.add(iterateJObject);
			selectedFields.put("applicationSelected","-1");	
			combo.put("applicationCombo",iterateJArray);
		}
	if (v_application!=null && v_application.size()>0)
	{
		for(int n=0;n<v_application.size();n++)
		{
			String s=(String)v_application.get(n);
			String ss=(String)v_application.get(n);
		}
	}
		labelFields.put("userLabel",intlmap.getTextDescription("reporter.thin.User"));
		str_select="";
		aListSelectedList = new ArrayList();
		if(s_user!=null && s_user.length>0)
			aListSelectedList.addAll(Arrays.asList(s_user));
		if(v_user!=null && v_user.size()>0)
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.All Users"));
			iterateJObject.put("valueField","all");
			iterateJArray.add(iterateJObject);
 			if (aListSelectedList.contains("Not Applicable")){
				aListSelectedList = new ArrayList();
				aListSelectedList.add("all");
			}
			if (aListSelectedList.size() == 0 ||  aListSelectedList.contains("all")){
				aListSelectedList.add("all");
				selectedFields.put("userSelected","all");
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.User"),"all");
			}
			Collections.sort(v_user,String.CASE_INSENSITIVE_ORDER);
			StringBuffer str=new StringBuffer();
			for(int n=0;n<v_user.size();n++)
			{
				String s=(String)v_user.get(n);
				if(s.startsWith("+"))
					s = s.substring(1);
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",s);
				iterateJObject.put("valueField",s);
				iterateJArray.add(iterateJObject);
				if(aListSelectedList!=null && aListSelectedList.contains(s) && !v_user.contains("all"))
				{
					str.append(s).append(",");
  				}
			}
			if(str.length()>0)
			{
				str.deleteCharAt(str.length() - 1);
				selectedFields.put("userSelected",str.toString());
				selectionDetails.put(intlmap.getTextDescription("reporter.thin.User"),str.toString());
			}
			combo.put("userCombo",iterateJArray);
		}
		else
		{
			iterateJArray=new JSONArray();
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
			iterateJObject.put("valueField","-1");
			iterateJArray.add(iterateJObject);
			combo.put("userCombo",iterateJArray);
		}
			if (aListSelectedList.contains("Not Applicable")){
				aListSelectedList = new ArrayList();
				aListSelectedList.add("all");
			}
			if (aListSelectedList.size() == 0 ||  aListSelectedList.contains("all")){
				aListSelectedList.add("all");
			} 
			if (v_user!=null && v_user.size()>0)
			{
				for(int n=0;n<v_user.size();n++)
				{
					String s=(String)v_user.get(n);
					String ss=(String)v_user.get(n);
				}
			}
				if (directoryList.size() > 0 && (aListSelectedList.contains("all")))
				{
					labelFields.put("adGroupLabel",intlmap.getTextDescription("reporter.thin.AD Group"));
					iterateJArray=new JSONArray();
					iterateJObject=new JSONObject();
					iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.All"));
					iterateJObject.put("valueField","All");
					iterateJArray.add(iterateJObject);
					if (er_adGroupList != null && er_adGroupList.contains("All")) {
						selectedFields.put("adGroupSelected","All");
						selectionDetails.put(intlmap.getTextDescription("reporter.thin.AD Group"),"All");
					}
					Collections.sort(directoryList,String.CASE_INSENSITIVE_ORDER);
					StringBuffer str=new StringBuffer();
					for (int i=0; i<directoryList.size(); i++) {
						String dirStr = (String) directoryList.get(i);
					String strdispDirStr=dirStr;
					if(showADShortName)
					{
						if(strdispDirStr!=null && strdispDirStr.indexOf(",")>-1)
						{
							StringTokenizer stToken = new StringTokenizer(strdispDirStr,",");
							if(stToken.countTokens()>1)
							{
								String strAdName = stToken.nextToken();
								if(strAdName!=null && strAdName.indexOf("=")>-1)
								{
									strdispDirStr = strAdName.substring(strAdName.indexOf("=")+1);
								}
							}
						}
					}
						iterateJObject=new JSONObject();
						iterateJObject.put("displayField",strdispDirStr);
						iterateJObject.put("valueField",dirStr);
						iterateJArray.add(iterateJObject);
						if (dirStr.equals(er_adGroup)) {
							str.append(dirStr).append(",");
 						} 
					}
					if(er_adGroupList != null && er_adGroupList.size() > 0)
					{
						if(str.length()>0)
							str.deleteCharAt(str.length() - 1);
						//selectedFields.put("adGroupSelected",str.toString());
						selectedFields.put("adGroupSelected",er_adGroupList);
						selectionDetails.put(intlmap.getTextDescription("reporter.thin.AD Group"),er_adGroupList.toString());
					}
					combo.put("adGroupCombo",iterateJArray);
					for (int i=0; i<directoryList.size(); i++) {
						String dirStr = (String) directoryList.get(i);
					}
			} 
		}
	iterateJArray=new JSONArray();
	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.Yes")+" ("+Days+") ");
	iterateJObject.put("valueField","Yes");
	iterateJArray.add(iterateJObject);
	iterateJObject=new JSONObject();
	iterateJObject.put("displayField",intlmap.getTextDescription("reporter.common.No"));
	iterateJObject.put("valueField","No");
	iterateJArray.add(iterateJObject);
	combo.put("excludeWeekendsCombo",iterateJArray);
	labelFields.put("excludeWeekendsLabel",intlmap.getTextDescription("reporter.thin.Exclude weekends"));
	labelFields.put("excludeDaysLabel",intlmap.getTextDescription("reporter.thin.Excludes")+" "+Days);
	if(excludeweekend.equalsIgnoreCase("Yes") )
	{
		selectedFields.put("excludeWeekendsSelected","Yes");
		//selectionDetails.put(intlmap.getTextDescription("reporter.thin.Exclude weekends"),"Yes");
		lst.add('"'+intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs")+'"'+","+'"'+
		intlmap.getTextDescription("reporter.common.Exclude weekends")+":"+Days+'"');
		headingList.add('"'+intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs")+'"'+","+'"'+intlmap.getTextDescription("reporter.common.Exclude weekends")+":"+Days+'"');
	}
	else
	{
		selectedFields.put("excludeWeekendsSelected","No");
		//selectionDetails.put(intlmap.getTextDescription("reporter.thin.Exclude weekends"),"No");
		lst.add(intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs"));
		headingList.add(intlmap.getTextDescription("reporter.common.Time period")+":"+intlmap.getTextDescription("reporter.common.From")+" "+request.getParameter("timefrom")+":"+request.getParameter("minfrom")+intlmap.getTextDescription("reporter.common.Hrs")+" "+intlmap.getTextDescription("reporter.common.To")+" "+request.getParameter("timeto")+":"+request.getParameter("minto")+intlmap.getTextDescription("reporter.common.Hrs"));
	}
	if (rtype != null && rtype.equalsIgnoreCase("yes"))
	{
		labelFields.put("showLabel",intlmap.getTextDescription("reporter.common.Show"));
		iterateJArray=new JSONArray();

			String selected = "";
			for (int i=0; i<topList.size(); i++)
			{
				String topStr = (String) topList.get(i);
				selected = "";
				iterateJObject=new JSONObject();
				iterateJObject.put("displayField",topStr);
				iterateJObject.put("valueField",topStr);
				iterateJArray.add(iterateJObject);

				if (er_top.equals(topStr)){
					selectedFields.put("showSelected",topStr);
					selected = "selected";
				}
			}
			combo.put("showCombo",iterateJArray);
	}
	else
	{
		labelFields.put("groupByLabel",intlmap.getTextDescription("reporter.common.Group by"));
		iterateJArray=new JSONArray();	
		for (int g=0; g<groupByList.size(); g++) 
		{
			String groupStr = (String) groupByList.get(g);
			String display=groupStr;
			iterateJObject=new JSONObject();
			if(isLaunchByVm)
			{
				if(groupStr!=null && groupStr.equalsIgnoreCase("Component"))
					display="Desktop";
			}
			iterateJObject.put("displayField",display);
			iterateJObject.put("valueField",groupStr);
			iterateJArray.add(iterateJObject);
			if (er_groupby.equals(groupStr)) 
			{
				selectedFields.put("groupBySelected",groupStr);		
				//selectionDetails.put(intlmap.getTextDescription("reporter.common.Group by"),groupStr);
			}
		}
		combo.put("groupByCombo",iterateJArray);
		iterateJArray=new JSONArray();	
		for (int g=0; g<groupByListforAppln.size(); g++) 
		{
			String groupStr = (String) groupByListforAppln.get(g);
			String display=groupStr;
			iterateJObject=new JSONObject();
			if(isLaunchByVm)
			{
				if(groupStr!=null && groupStr.equalsIgnoreCase("Component"))
					display="Desktop";
			}
			iterateJObject.put("displayField",display);
			iterateJObject.put("valueField",groupStr);
			iterateJArray.add(iterateJObject);
			selectedFields.put("groupBySelectedAppln",groupStr);		
		
		}
		combo.put("groupByComboForUser",iterateJArray);		

	}
	String select_yes = "";
	String select_no = "";
	if(show_timeinuse != null && show_timeinuse.equalsIgnoreCase("Yes"))
	{
		select_yes = "checked";
		select_no="";
	}
	else
	{
		select_yes="";
		select_no = "checked";
	}
	if(rtype == null || (rtype!=null && rtype.equals("No")))
	{
		if (v_sort.isEmpty())
		{
		}
		else
		{
			for (int i =0;i<v_sort.size();i++)
			{
				String strsort=String.valueOf(i+1);
				
			}
		}
	}
	selectedFields.put("selectedTimeFrom",Hourfrom);
	selectedFields.put("selectedMinsFrom",Minfrom);
	selectedFields.put("selectedTimeTo",Hourto);
	selectedFields.put("selectedMinsTo",Minto);
%>
	<%@  include file ="ErTimeFormatJSON.jsp"%>
	<%
	String sdate = request.getParameter("startdate");	
	String edate = request.getParameter("enddate");	
	String shr = request.getParameter("starthr");	
	String ehr = request.getParameter("endhr");	
	String smin = request.getParameter("startmin");	
	String emin = request.getParameter("endmin");
	
	starttimeformat = sdate+ " " +shr+":"+smin+" "+"Hrs ";
	
	endtimeformat   = edate+ " " +ehr+":"+emin+" Hrs ";
	//Time zone conversion 
	
	pdfStartDate=startDateForDisplay+" "+startHourForDisplay+":"+startMinForDisplay;
	pdfEndDate = endDateForDisplay+" "+endHourForDisplay+":"+endMinForDisplay;
		

	Vector dvec = new Vector();
	String stimefmt = "Start Date : "+pdfStartDate;
	String etimefmt = "End Date : "+pdfEndDate;
	dvec.add('"'+stimefmt+'"');
	dvec.add('"'+etimefmt+'"');
	lst.add(dvec);
	dvec = new Vector();
	dvec.add(stimefmt);
	dvec.add(etimefmt);
	headingList.add(dvec);
	if(s_compType != null && s_compType.equalsIgnoreCase("Citrix_XcXenApp_server"))
		hiddenFields.put("showGeoDetails","Yes");
	else
		hiddenFields.put("showGeoDetails","No");
	hiddenFields.put("userTimeline",strUsrTimeline);
	combo.put("timelineCombo",timelineComboArray);
	selectedFields.put("selectedTimeline",er_timeline);
	selectedFields.put("startDate",startDateJSON);
	selectedFields.put("endDate",endDateJSON);
	selectedFields.put("startHour",startHourJSON);
	selectedFields.put("endHour",endHourJSON);
	selectedFields.put("startmin",startMin);
	selectedFields.put("endmin",endMin);
	selectedFields.put("selectedGraphMode",selectedGraphMode);

	//User TimeZone changes
	selectedFields.put("startDateForDisplay",startDateForDisplay);
	selectedFields.put("startHourForDisplay",startHourForDisplay);
	selectedFields.put("startMinForDisplay",startMinForDisplay);
	selectedFields.put("endDateForDisplay",endDateForDisplay);
	selectedFields.put("endHourForDisplay",endHourForDisplay);
	selectedFields.put("endMinForDisplay",endMinForDisplay);
	
	selectionDetails.put(intlmap.getTextDescription("reporter.common.Time Period"),Hourfrom+":"+Minfrom+"<span class='font_bold'>  "+intlmap.getTextDescription("reporter.common.to")+" </span> "+Hourto+":"+Minto);
		
	selectionDetails.put((String)intlmap.getTextDescription("reporter.common.Timeline"),pdfStartDate+" "+intlmap.getTextDescription("reporter.common.hrs")+" <span class='font_bold'>"+intlmap.getTextDescription("reporter.common.to")+"</span> "+pdfEndDate+" "+intlmap.getTextDescription("reporter.common.hrs"));
 	
	String er_reportgenration = request.getParameter("er_reportgenration");
	String er_background ="";
	String er_foreground ="";
	if (er_reportgenration != null && er_reportgenration.equals("background"))
	{
		selectedFields.put("reportGenerationSelected","background");
		er_background = "selected";
		er_foreground = "";
	}
	else if (er_reportgenration != null && er_reportgenration.equals("background-xls"))
	{
		selectedFields.put("reportGenerationSelected","background-xls");
		er_background = "selected";
		er_foreground = "";
	}
	else if(er_reportgenration != null && er_reportgenration.equals("background-csv"))
	{
		selectedFields.put("reportGenerationSelected","background-csv");
		er_background = "selected";
		er_foreground = "";
	}
	else
	{
		selectedFields.put("reportGenerationSelected","foreground");
		er_background = "";
		er_foreground = "selected";
	}
	String bg_reportname = request.getParameter("bg_reportname");
	if(bg_reportname == null)
	{
		bg_reportname = "";
	}
	String reportgenColspan = "5";
	if(rtype != null && rtype.equalsIgnoreCase("No"))
	{
		if(er_reportgenration != null && er_reportgenration.equals("background"))
			reportgenColspan = "2";
		else if(er_reportgenration != null && er_reportgenration.equals("background-xls"))
			reportgenColspan = "2";
		else
			reportgenColspan = "3";
	}
	if(strbgrepportName != null && strbgrepportName.equalsIgnoreCase("Yes"))
	{
		labelFields.put("reportGenerationLabel",intlmap.getTextDescription("reporter.consolidated.Report Generation"));
		labelFields.put("reportNameLabel",intlmap.getTextDescription("reporter.consolidated.Report Name"));
		iterateJArray=new JSONArray();
		iterateJObject=new JSONObject();
		iterateJObject.put("displayField",strbackground);
		iterateJObject.put("valueField","background");
		iterateJArray.add(iterateJObject);
		if(rtype != null && rtype.equalsIgnoreCase("No"))
		{
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField","Background Save - CSV");
			iterateJObject.put("valueField","background-csv");
			iterateJArray.add(iterateJObject);
			iterateJObject=new JSONObject();
			iterateJObject.put("displayField","Background Save - Excel");
			iterateJObject.put("valueField","background-xls");
			iterateJArray.add(iterateJObject);
		}
		iterateJObject=new JSONObject();
		iterateJObject.put("displayField",strforeground);
		iterateJObject.put("valueField","foreground");
		iterateJArray.add(iterateJObject);
		combo.put("reportGenerationCombo",iterateJArray);

		if (er_reportgenration != null && (er_reportgenration.equalsIgnoreCase("background")||er_reportgenration.equalsIgnoreCase("background-csv")||er_reportgenration.equals("background-xls")))
		{
			selectedFields.put("reportNameSelected",bg_reportname);
		}
	}
		if((reqFromSchedule!=null && reqFromSchedule.equalsIgnoreCase("Yes")) || (reqFromFavorite!=null && reqFromFavorite.equalsIgnoreCase("Yes")))
		{
			labelFields.put("saveButton",intlmap.getTextDescription("reporter.common.SAVE"));
			String fromReq = "schedule";
			if(reqFromFavorite!=null && reqFromFavorite.equalsIgnoreCase("Yes"))
				fromReq = "favorite";
		}
		else
		{
			labelFields.put("submitButton",intlmap.getTextDescription("reporter.common.SUBMIT"));
		}
	if(bggroundStr != null && !bggroundStr.equals(""))
	{
		String strreportName ="Application_Launch";
 		if(status != null && (status.equalsIgnoreCase("duplicate") || status.equalsIgnoreCase("exceedLimit")))
		{
			strreportName ="All Report Types";
		}
		if(status!=null && status.equalsIgnoreCase("success"))
			labelFields.put("bgStatus","success");
		else if(status!=null && status.equalsIgnoreCase("duplicate"))
			labelFields.put("bgStatus","duplicate");
		if(strreportName!=null && strreportName.indexOf(" ") > -1)
		{
			strreportName = com.eg.EgURLEncoder.encode(strreportName, "UTF-8");
		}
		if(status != null && !status.equalsIgnoreCase("exceedLimit"))
		{
			labelFields.put("bgResponseText",erbgreport.getlangsupportedString(bggroundStr,bgString,urs));
		}
		else
		{
			labelFields.put("bgResponseText",bggroundStr);
		}
		urlFields.put("bgUrl","/final/servlet/com.eg.ErStartBackGroundReportC?back=true&er_bgreportfrom="+strreportName+"&userID="+com.eg.EgURLEncoder.encode(urs, "UTF-8")+"&savereport=search&er_filterby=Report_Name&forwardto=ErBackGoundProcess");
		labelFields.put("bgAnchor",intlmap.getTextDescription("reporter.common.Click here to see a list of generated and processing reports"));
		
	}
	int appValue=0;
	if(htt!=null && !htt.isEmpty())
	{
		for(Enumeration en = htt.keys(); en.hasMoreElements();)
		{
			Vector v_value = (Vector)htt.get((String)en.nextElement());
			if(v_value!=null && !v_value.isEmpty())
				appValue++;
		}
	}
	if((htt!=null && appValue >0) || (app_topusers!=null && app_topusers.size()>0) || (v_qry_string!=null && v_qry_string.size()>0))
	{
		if(er_workerGroup != null && !er_workerGroup.equalsIgnoreCase("Any"))
			s_server = "-1";
		String s_reportType="";
		if(rtype!=null && rtype.equals("Yes")) {
			s_reportType="Graph";
		} else {
			s_reportType="Data";
		}

		String server = (s_server!=null && s_server.equals("-1")) ? "All Server" : s_server;
		if(server!=null && server.indexOf(":NULL")>-1)
			server = server.substring(0,server.indexOf(":NULL"))+server.substring(server.indexOf(":NULL")+5);
		if(testmes!=null && rtype!= null && rtype.equals("Yes"))
		{
			if(testmes.indexOf("/") >-1)
			{
				String str_test = testmes.substring(0,testmes.indexOf("/"));
				String s_meas = testmes.substring(testmes.indexOf("/")+1);
			} 
		}
		String strApp = (s_application!=null && s_application.equals("-1")) ? "All Application" : s_application;
	}
	ArrayList sublist=(ArrayList)reportInfo.getVariables("APPLICATION_LAUNCH_COUNT");
	for(int i=0; i<sublist.size(); i++)
	{
		String tempsub1=(String)sublist.get(i);
		String s=request.getParameter("er_server");
		if(s!=null && !s.equals("All") && !s.equals("-1") && s.lastIndexOf(":")>0)
		{
			s=s.substring(s.lastIndexOf(":")+1,s.length());
			s=s.trim();
			if(tempsub1.indexOf(s)==-1)
			{
				sublist.remove(i);
				i=i-1;
			}
		}
	}
	if(rtype==null)
	{
		rtype="No";
	}
if (StringUtils.isNull(bg_reportname) && isSubmit != null && isSubmit.equalsIgnoreCase("true")) 
{
	//Data View starts here
	if(rtype=="Yes")
		rtype="No";
	if(rtype!=null&&rtype.equals("No") || rtype== null)
	{
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application")){
		data.put("title",intlmap.getTextDescription("reporter.common.Application Launch"));
	} 
	else 
	{
		data.put("title",intlmap.getTextDescription("reporter.common.Application Launch by User"));
	} 
	Map dataMap = (HashMap)resultMap.get("REPORT_DATA");
	int divCount = 1;
	if (dataMap.keySet().size() > 0) {
		data.put("s1","SUMMARY");
		data.put("s2","Unique Users");//..
		data.put("s4","Application Launches");//..
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			data.put("c1",intlmap.getTextDescription("reporter.common.Application"));
			data.put("s3","Unique Users");
			data.put("s6","Average Launch Duration");//..
		}
		else
		{ 
			data.put("c1",intlmap.getTextDescription("reporter.common.Users"));
		} 
		data.put("s5","Unique Applications");
		data.put("c2",intlmap.getTextDescription("reporter.common.Launches"));
		if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			data.put("v2",intlmap.getTextDescription("reporter.common.Avg Launch Duration (Secs)"));
		}
		Iterator itr = dataMap.keySet().iterator();
		Set qq = dataMap.keySet();
		List ww = new ArrayList(qq);
		int userCount = 0;
		Map tempDataMap = new HashMap();
		// by karthikeyan
		HashSet overAllUniqueUserForLaunchByUser = new HashSet();
		HashSet overAllUniqueUserForLaunchByApplication = new HashSet();
		HashSet overAllUniqueUserGroupByComponent = new HashSet();
		HashMap uniqueUsrCntByGrpComp = new HashMap();
		HashMap overAllAppLaunchDuration = new HashMap();
		HashMap AppLanchDuration = new HashMap();

		boolean isGroupByComponent=false;
		if (er_groupby != null && er_groupby.equalsIgnoreCase("Component"))
		{
			isGroupByComponent=true;
		}
		int launchCount = 0;
		while(itr.hasNext()) 
		{
			String keyStr = (String) itr.next();
			overAllUniqueUserForLaunchByUser.add(keyStr);
			Map userMap = (HashMap) dataMap.get(keyStr);
			Iterator userItr = userMap.keySet().iterator();
			Iterator userItr2 = userMap.keySet().iterator();
			int count = 0;
			double totalAppLaunchDuration = 0.0;
			String strOverAllAppLaunchDuration = "-";

			HashSet hsTemp=new HashSet();
			while(userItr2.hasNext()){
				String usr = (String) userItr2.next();
				overAllUniqueUserForLaunchByApplication.add(usr);
				List vList = (ArrayList) userMap.get(usr);
				count += vList.size();
				launchCount += vList.size();
				// by karthikeyan
				if(isGroupByComponent)
				{
					for(int k=0;k<vList.size();k++)
					{
						ArrayList ss=(ArrayList)vList.get(k);
						for(int i=0;i<ss.size();i++)
						{
							hsTemp.add(ss.get(0));
							overAllUniqueUserGroupByComponent.add(ss.get(0));
						}
					}
					uniqueUsrCntByGrpComp.put(keyStr,hsTemp.size());
				}
			if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
			{
				double totalLaunchDurationByComp=0.0;
				double avgLaunchDurationByComp=0.0;
				String strAvgLaunchTime = "-";
				int laucnhcolumn=2;
				if(isVm)
					laucnhcolumn=3;
				if(vList!=null && vList.size()>0)
				{
					for(int y=0;y<vList.size();y++)
					{
						ArrayList aListUserData = (ArrayList)vList.get(y);
						if(aListUserData!=null && aListUserData.size()>2)
						{
							String getAvg = (String)aListUserData.get(laucnhcolumn);
							if(getAvg!=null && getAvg.length()>0 && !getAvg.equals("-"))
							{
								totalLaunchDurationByComp+=Double.valueOf(getAvg);
								totalAppLaunchDuration+=Double.valueOf(getAvg);
							}
						}
					}
					if(totalLaunchDurationByComp>0)
					{
						avgLaunchDurationByComp = totalLaunchDurationByComp/vList.size();
						strAvgLaunchTime = erUtils.round(avgLaunchDurationByComp,4);
					}
				}
				AppLanchDuration.put(usr+keyStr,strAvgLaunchTime);
			
			//
			}
			
				if(totalAppLaunchDuration>0)
				{
					if(launchCount>0)
					{
						double tempavg = totalAppLaunchDuration/count;
						strOverAllAppLaunchDuration = erUtils.round(tempavg,4);
					}
				}
			}
			List list = new ArrayList();
			if (tempDataMap.containsKey(count+""))
				list = (ArrayList) tempDataMap.get(count+"");
			list.add(keyStr);
			tempDataMap.put(count+"",list);
			overAllAppLaunchDuration.put(keyStr,strOverAllAppLaunchDuration);
			
		}
		Set set = tempDataMap.keySet();
		List timeList = new ArrayList(set);
		// by karthikeyan
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{

			if(isGroupByComponent)
			{
				lst.add("SUMMARY");
				lst.add("Total Number of Unique Users "+" - "+ overAllUniqueUserForLaunchByApplication.size());
				lst.add("Total Number of Application Launches"+" - "+launchCount);
				data.put("TotalUniqueUsers",overAllUniqueUserGroupByComponent.size());
				data.put("TotalAppLaunches",launchCount);
			}
			else
			{
				lst.add("SUMMARY");
				lst.add("Total Number of Unique Users "+" - "+ overAllUniqueUserForLaunchByApplication.size());
				lst.add("Total Number of Application Launches"+" - "+launchCount);
				data.put("TotalUniqueUsers",overAllUniqueUserForLaunchByApplication.size());
				data.put("TotalAppLaunches",launchCount);
				
			}
			data.put("TotalUniqueApplications",overAllUniqueUserForLaunchByUser.size());
			lst.add("Total Number of Unique Applications "+" - "+ overAllUniqueUserForLaunchByUser.size());
			lst.add(" "+"Published Application");
		}
		else
		{
			lst.add("SUMMARY");
			lst.add("Total Number of Unique Users "+" - "+ overAllUniqueUserForLaunchByUser.size());
			lst.add("Total Number of Application Launches"+" - "+launchCount);

			data.put("TotalUniqueUsers",overAllUniqueUserForLaunchByUser.size());
			data.put("TotalAppLaunches",launchCount);
			if(isGroupByComponent)
			{
				data.put("TotalUniqueApplications",overAllUniqueUserGroupByComponent.size());
				lst.add("Total Number of Unique Applications "+" - "+ overAllUniqueUserGroupByComponent.size());
			}
			else
			{
				data.put("TotalUniqueApplications",overAllUniqueUserForLaunchByApplication.size());
				lst.add("Total Number of Unique Applications "+" - "+ overAllUniqueUserForLaunchByApplication.size());
			}
			lst.add(" "+"Published Application");
		}
			if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
			{
				v_measure_csv.add("Applications");
			}
			else if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("user"))
			{
				v_measure_csv.add("User");
			}
			v_measure_csv.add("");
			v_measure_csv.add("");
			v_measure_csv.add("");
			v_measure_csv.add("");
			v_measure_csv.add("Launches");
			if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
			{
				if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
				{
					v_measure_csv.add("Avg Launch Duration (Secs)");
				}
				v_measure_csv.add("Unique Users");
				v_measure_csv.add("");
			}
			else
			{
				v_measure_csv.add("");
				v_measure_csv.add("");
			}
			v_measure_csv.add("");
			v_measure_csv.add("");
				if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
					v_measure_csv.add("");
					v_measure_csv.add("");
				}
//
			Comparator comparator = new ErNumreicComparator();
			Collections.sort(timeList, comparator);
			String ves ="";
			
			JSONArray rootParentArray=new JSONArray();
			double totalAvgLaunchduration=0;
			for (int k=timeList.size()-1; k>=0; k--) 
			{
				String tempKey = (String) timeList.get(k);
				List list = (ArrayList) tempDataMap.get(tempKey);
				HashSet hsTemp=new HashSet();
				int uniqUserByGrpComp=0;
				for (int l=0; l<list.size(); l++)
				{
					String keyStr = (String)list.get(l);
					Map userMap = (HashMap) dataMap.get(keyStr);
					Set userKeySet = userMap.keySet();
					Iterator userItr = userMap.keySet().iterator();
					String strAppLauncDuration = (String)overAllAppLaunchDuration.get(keyStr);
					// by karthikeyan
					if(isGroupByComponent)
					{
						uniqUserByGrpComp=(Integer)uniqueUsrCntByGrpComp.get(keyStr);
					}
					//
					
					list_data.add(keyStr);
					list_data.add("");
					list_data.add("");
					list_data.add("");
					list_data.add("");
					list_data.add(tempKey);
					if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
					{
						list_data.add(strAppLauncDuration);
						totalAvgLaunchduration += Double.parseDouble(strAppLauncDuration);//..
					}
					
					if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
					{
						if(isGroupByComponent)
						{
							list_data.add(uniqUserByGrpComp+"");
						}
						else
						{
							list_data.add(userKeySet.size()+"");
						}
						
						list_data.add("");
					}
					else
					{
						list_data.add("");
						list_data.add("");
					}
					list_data.add("");
					list_data.add("");
						if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
							list_data.add("");
							list_data.add("");
						}
					JSONArray subMenuArray=new JSONArray();
					JSONObject parentObject=new JSONObject();
					if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
					{
						JSONObject appUniqueUserCnt=new JSONObject();
						if(isGroupByComponent)
						{
							appUniqueUserCnt.put(tempKey,uniqUserByGrpComp+""+","+strAppLauncDuration);
						}
						else
						{
							appUniqueUserCnt.put(tempKey,userKeySet.size()+""+","+strAppLauncDuration);
						}
						if(keyStr.startsWith("+"))
							keyStr=keyStr.substring(1);
						parentObject.put(keyStr,appUniqueUserCnt);
					}
					else if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
					{
						JSONObject appUniqueUserCnt=new JSONObject();
						if(isGroupByComponent)
						{
							appUniqueUserCnt.put(tempKey,uniqUserByGrpComp+"");
						}
						else
						{
							appUniqueUserCnt.put(tempKey,userKeySet.size()+"");
						}
						if(keyStr.startsWith("+"))
							keyStr=keyStr.substring(1);
						parentObject.put(keyStr,appUniqueUserCnt);
					}
					else
					{
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
							parentObject.put(keyStr+","+strAppLauncDuration,tempKey);
						else
							parentObject.put(keyStr,tempKey);
					}
					Map tempMap = new HashMap();
					while(userItr.hasNext())
					{
						String usrName = (String) userItr.next();
						List valueList = (ArrayList) userMap.get(usrName);
						List vlist = new ArrayList();
						if (tempMap.containsKey(valueList.size()+""))
							vlist = (ArrayList) tempMap.get(valueList.size()+"");
						vlist.add(usrName);
						tempMap.put(valueList.size()+"",vlist);
					}
			set = tempMap.keySet();
			List tList = new ArrayList(set);
			Collections.sort(tList, comparator);
			JSONArray dat=new JSONArray();
			
			for (int m=tList.size()-1;m>=0;m--)
			{
				String countStr = (String) tList.get(m);
				List outList = (ArrayList) tempMap.get(countStr);
				for (int n=0; n<outList.size(); n++)
				{
					String usrNameStr = (String) outList.get(n);
					divCount++;
					List valueList = (ArrayList) userMap.get(usrNameStr);
					JSONObject childObject=new JSONObject();
					JSONArray childCols=new JSONArray();
		
						list_data.add("");
						if (er_groupby != null && er_groupby.equalsIgnoreCase("user"))
						{
							list_data.add("User");
							childCols.add("User");
						} 
						else if (er_groupby != null && er_groupby.equalsIgnoreCase("application"))
						{
							list_data.add("Application");
							childCols.add("Application");
						} 
						else 
						{
							if(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm)
							{
								list_data.add("Desktop");
								childCols.add("Desktop");
							}
							else
							{
								list_data.add("Server");
								childCols.add("Server");
							}
						}
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
						{
							childCols.add("Avg Launch Duration (Secs)");
						}
						childCols.add("Launches");
						String strves = (String)AppLanchDuration.get(usrNameStr+keyStr);
						
						childObject.put("cols",childCols);
						List secondCol = new ArrayList();
						secondCol.add(usrNameStr);
						secondCol.add(countStr);
						secondCol.add(strves);
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
							childObject.put("secondCol",secondCol);
						else
							childObject.put(usrNameStr,countStr);
						
					
						list_data.add("");
						list_data.add("");
						list_data.add("");
						list_data.add("Launches");
						list_data.add("");
						list_data.add("");
						list_data.add("");
						list_data.add("");
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
						{
							list_data.add("Avg Launch Duration (Secs)");
						}
						list_data.add("");
							if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
								list_data.add("");
								list_data.add("");
							}
						list_data.add(usrNameStr);
						list_data.add("");
						list_data.add("");
						list_data.add("");
						list_data.add(countStr);
						list_data.add("");
						list_data.add("");
						list_data.add("");
						list_data.add("");
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
						{
							list_data.add(strves);
						}
						JSONObject subChildCols=new JSONObject();
						list_data.add("");
						list_data.add("");
							if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
									list_data.add("");
									list_data.add("");
							}
					if (er_groupby != null && er_groupby.equalsIgnoreCase("user"))
					{
						if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
						{
							list_data.add("Server");
							subChildCols.put("c1","Server");
						} 
						else 
						{
							list_data.add("Application");
							subChildCols.put("c1","Application");
						}
					} 
					else if (er_groupby != null && er_groupby.equalsIgnoreCase("application"))
					{
						if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("user"))
						{
							list_data.add("Server");
							subChildCols.put("c1","Server");
						} 
						else 
						{
							list_data.add("User");
							subChildCols.put("c1","User");
						}
					} 
					else 
					{
						if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("user"))
						{
							list_data.add("Application");
							subChildCols.put("c1","Application");
						} 
						else 
						{
							list_data.add("User");
							subChildCols.put("c1","User");
						}
					}
					Comparator comparator1 = new ErNumreicComparator(strUserDateFormat); // DATE FORMAT ALONE
					if(isLaunchByVm || isSearchByVmComp)
						comparator1 = new ErNumreicComparator(2,strUserDateFormat);// SORT INDEX AND DATE FORMAT
					Collections.sort(valueList,comparator1);
					Collections.reverse(valueList);

					JSONObject subChildObject=new JSONObject();
					if(valueList!=null && valueList.size()>0)
						tListt = (ArrayList) valueList.get(0);

						if(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm)
						{
							list_data.add("Server");
							list_data.add("Application Launch Time");
							if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
							{
								list_data.add("Launch duration (Secs)");
							}
							if(getSessionDetails)
							{
								list_data.add("Session Start");
								list_data.add("Session End");
							}
							int sizeOftList =5;
							if(!getSessionDetails)
								sizeOftList =3;
							if(tListt!=null && tListt.size()>sizeOftList)
							{
								list_data.add("Client Address");
								list_data.add("Client Name");
								list_data.add("Client Version");
							}
							else
							{
								list_data.add("");
								list_data.add("");
								list_data.add("");
							}
						}
						else if(isSearchByVmComp)
						{
							int sizeOftList =5;
							if(!getSessionDetails)
								sizeOftList =3;
							list_data.add("Desktop");
							list_data.add("Application Launch Time");
							if (s_compType!=null &&  isAppLaunchDuarationColumnEnabled)
							{
								list_data.add("Launch duration (Secs)");
								sizeOftList++;
							}
							if(getSessionDetails)
							{
								list_data.add("Session Start");
								list_data.add("Session End");
							}

							if(tListt!=null && tListt.size()>sizeOftList)
							{
								list_data.add("Client Address");
								list_data.add("Client Name");
								list_data.add("Client Version");
							}
							else
							{
								list_data.add("");
								list_data.add("");
								list_data.add("");
							}
						}
						else
						{
							int sizeOftList =4;
							if(!getSessionDetails)
								sizeOftList =2;
							list_data.add("Application Launch Time");
							if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
							{
								list_data.add("Launch duration (Secs)");
								sizeOftList++;
							}
							if(getSessionDetails)
							{
								list_data.add("Session Start");
								list_data.add("Session End");
							}
							if(tListt!=null && tListt.size()>sizeOftList)
							{
								list_data.add("Client Address");
								list_data.add("Client Name");
								list_data.add("Client Version");
							}
							else
							{
								list_data.add("");
								list_data.add("");
							}
						}
						if(!getSessionDetails)
						{
							list_data.add("");
							list_data.add("");
						}

							if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
								if(geoColumnList != null){
										for(int i=0;i<geoColumnList.size();i++)
											list_data.add((String)geoColumnList.get(i));
									}
							}
							if (s_compType!=null && (s_compType.equalsIgnoreCase("Citrix_XcXenApp_server") || s_compType.equalsIgnoreCase("Citrix_server"))){
								list_data.add("");
							}
							else if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("application")){
								list_data.add("");
							}
							if(geoDetails == null || geoDetails.equalsIgnoreCase("no"))
								list_data.add("");
							int columnSize=0;
							dat=new JSONArray();
						int sizeOftList =5;
						if(!getSessionDetails)
							sizeOftList =3;
						//
						for (int i=0; i<valueList.size(); i++)
						{
							if(i>0)
							{
								if(isSearchByVmComp||(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm))
								{
									if(tListt!=null && tListt.size()>sizeOftList)
									{
										list_data.add("");
									}
									else
									{
										list_data.add("");
									}
								}
								else
								{
									if(geoDetails == null || geoDetails.equalsIgnoreCase("no"))
										list_data.add("");
									if (s_compType!=null && !(s_compType.equalsIgnoreCase("Citrix_XcXenApp_server") || s_compType.equalsIgnoreCase("Citrix_server")|| s_compType.equalsIgnoreCase("VMWareView_RDS")))
									{
										list_data.add("");
									}
								}
							}
							if (!isLaunchByVm && !isSearchByVmComp && !isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("user"))
								list_data.add("");
							List tempList = (ArrayList) valueList.get(i);
							columnSize=tempList.size();
							JSONObject datObject=new JSONObject();
							if(isSearchByVmComp)
							{
								if(tListt!=null && tListt.size()>sizeOftList && !isAppLaunchDuarationColumnEnabled)
								{
									list_data.add("");
								}
							}
							else if(tListt!=null && tListt.size()>sizeOftList-1)
							{
								if (s_compType!=null && (s_compType.equalsIgnoreCase("VMWareView_RDS") ||s_compType.equalsIgnoreCase("Citrix_XcXenApp_server") || s_compType.equalsIgnoreCase("Citrix_server")) && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
								{
									list_data.add("");
								}
							}
							else
							{
								if(i==0)
								{
									list_data.add("");
								if (s_compType!=null && !(s_compType.equalsIgnoreCase("Citrix_XcXenApp_server") || s_compType.equalsIgnoreCase("Citrix_server")|| s_compType.equalsIgnoreCase("VMWareView_RDS")))
									{
										list_data.add("");
									}
								}
							}
							List avgLaunchDuration=new ArrayList();
							for (int j=0; j<tempList.size(); j++) 
							{
								String tempStr = (String) tempList.get(j);
								dat.add(tempStr);
								list_data.add("\""+tempStr+"\"");
							}
							if(tempList!=null && tempList.size()<=sizeOftList-1)
							{
								list_data.add("");
								list_data.add("");
								list_data.add("");
							}
							if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
								if(i<valueList.size()-1)
									list_data.add("");
							}
							else if (s_compType!=null && (s_compType.equalsIgnoreCase("Citrix_XcXenApp_server") || s_compType.equalsIgnoreCase("Citrix_server"))){
								list_data.add("");
							}
							else if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("application")){
								list_data.add("");
							}
							if(isSearchByVmComp||(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm))
							{
								if(i==valueList.size()-1)
								{
									list_data.add("");
									list_data.add("");
								}
								else
								{
									list_data.add("");
									list_data.add("");
									list_data.add("");
								}
							}
							if(!getSessionDetails)
							{
								list_data.add("");
								list_data.add("");
							}
						}
						if(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm)
						{
							subChildCols.put("c2","Server");
							subChildCols.put("c3","Launch Time");
							if(getSessionDetails)
							{
								subChildCols.put("c4","Session Start");
								subChildCols.put("c5","Session End");
							}
							sizeOftList =5;
							if(!getSessionDetails)
								sizeOftList =3;
							if(columnSize>sizeOftList)
							{
								subChildCols.put("c6","Client Address");
								subChildCols.put("c7","Client Name");
								subChildCols.put("c8","Client Version");
							}
						}
						else if(isSearchByVmComp)
						{
							subChildCols.put("c2","Desktop");
							subChildCols.put("c3","Launch Time");
							if (s_compType!=null &&  isAppLaunchDuarationColumnEnabled)
							{
								subChildCols.put("c4","Launch duration (Secs)");
								sizeOftList =6;
								if(!getSessionDetails)
									sizeOftList =3;
								if(getSessionDetails)
								{
									subChildCols.put("c5","Session Start");
									subChildCols.put("c6","Session End");
								}
								if(columnSize>sizeOftList)
								{
									subChildCols.put("c7","Client Address");
									subChildCols.put("c8","Client Name");
									subChildCols.put("c9","Client Version");
								}
							}
							else
							{
								sizeOftList =5;
								if(!getSessionDetails)
									sizeOftList =3;
								if(getSessionDetails)
								{
									subChildCols.put("c4","Session Start");
									subChildCols.put("c5","Session End");
								}
								if(columnSize>sizeOftList)
								{
									subChildCols.put("c6","Client Address");
									subChildCols.put("c7","Client Name");
									subChildCols.put("c8","Client Version");
								}
							}
						}
						else
						{
							subChildCols.put("c2","Launch Time");
							if (s_compType!=null &&  isAppLaunchDuarationColumnEnabled)
							{
								subChildCols.put("c9","Launch duration (Secs)");
								sizeOftList = 5;
								if(!getSessionDetails)
									sizeOftList =3;
							}
							else
							{
								sizeOftList =4;
								if(!getSessionDetails)
									sizeOftList = 2;
							}
							if(getSessionDetails)
							{
								subChildCols.put("c3","Session Start");
								subChildCols.put("c4","Session End");
							}
							if(columnSize>sizeOftList)
							{
								subChildCols.put("c5","Client Address");
								subChildCols.put("c6","Client Name");
								subChildCols.put("c7","Client Version");
							}
							}
							if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
								if(geoColumnList != null){
									int c=10;
									for(int i=0;i<geoColumnList.size();i++)
										subChildCols.put("c"+(c+i),(String)geoColumnList.get(i));
								}
						}
						subChildObject.put("cols",subChildCols);
						subChildObject.put("dat",dat);
						if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
							childObject.put("secondCol",secondCol);
						childObject.put("children",subChildObject);
						subMenuArray.add(childObject);
					}
				}
				userCount++;
				if(subMenuArray.size()>0)
					parentObject.put("subMenu",subMenuArray);
				rootParentArray.add(parentObject);
				
			}
		}
		if(isAppLaunchDuarationColumnEnabled)//..
		{
			int TotalUniqueApplications=(Integer)data.get("TotalUniqueApplications");
			totalAvgLaunchduration = totalAvgLaunchduration/TotalUniqueApplications;
			data.put("totalAvgLaunchduration",(new ErUtils()).roundOffDigit(totalAvgLaunchduration,2));
		}	
		data.put("table",rootParentArray);
		data.put("isAppLaunchDuarationColumnEnabled",isAppLaunchDuarationColumnEnabled);
		applicationLaunch.put("selectionDetails",selectionDetails);
	} 
	else 
	{
		data.put("noMeasures",intlmap.getTextDescription("reporter.common.No measures available for the current selection"));
		lst.add(intlmap.getTextDescription("reporter.common.No measures available for the current selection"));
	}
		applicationLaunch.put("data",data);
	} //Graph View start here
	else 
	{
		int topCount  = 0;
		ErFusionChartBean chartbean = new ErFusionChartBean();
		String labelStr = "<categories>";
		String valueStr = "<dataset  color='007D00' alpha='100' anchorAlpha='0' lineThickness='2' showAnchors='1' >";
		Map graphMap = (HashMap) resultMap.get("GRAPH_DATA");
		List launchDurationList =(ArrayList) resultMap.get("launchDurationList");
		
		Set set = graphMap.keySet();
		List keyList = new ArrayList(set);
		Comparator comparator = new ErNumreicComparator();
		Collections.sort(keyList, comparator);
		if (er_top != null && (er_top.indexOf("TOP") > -1 || er_top.equalsIgnoreCase("ALL")))
		{
			Collections.reverse(keyList);
		}
		String strXml = "<chart plotGradientColor='' palette='1' alpha='0' caption='' shownames='1' showvalues='1'  showSum='0' placeValuesInside='1' decimals='2' overlapBars='0' showShadow='1' formatNumberScale = '0' baseFontColor='000000'  yAxisMinValue='0'  >";
		Iterator itr = graphMap.keySet().iterator();
		int countNo = 0;
		int num = 0;
		int colorCount = 0;
		String colorStr = reportInfo.getValue("APPLICATION_LAUNCH_COUNT","ChartColor");
		st = new StringTokenizer(colorStr,",");
		List colorList = new ArrayList();
		while(st.hasMoreTokens())
		{
			String tempStr = (String) st.nextToken();
			tempStr = tempStr.substring(tempStr.indexOf("#")+1);
			colorList.add(tempStr);
		}
		try 
		{
			if (er_top.indexOf("-")> -1)
				er_top = er_top.substring(er_top.indexOf("-")+2);
			topCount = Integer.parseInt(er_top);
		} 
		catch(Exception e)
		{
			topCount = -1;
		}
		boolean infoExceeded = false;
		boolean durationInfoExceeded = false;
		boolean dataAvailable = false;
		boolean durationAvailable = false;
		JSONArray barDataSet=new JSONArray();
		JSONArray xAxisLabel=new JSONArray();
		JSONArray barDuration=new JSONArray();

		for (int i=0; i<keyList.size(); i++)
		{
			String keyStr = (String) keyList.get(i);
			List infoList = (ArrayList) graphMap.get(keyStr);
			for (int j=0; j<infoList.size(); j++)
			{
				if (!StringUtils.isNull((String)infoList.get(j)))
				{
					dataAvailable = true;
					String info=(String)infoList.get(j);
					int index=info.indexOf("+");
 					if(info.startsWith("+"))
						info=info.substring(1);
					JSONObject obj = new JSONObject();
 					xAxisLabel.add(info);
					obj.put("name",info);
					obj.put("color","#"+colorList.get(colorCount));
					obj.put("y",Double.valueOf(keyStr));
					obj.put("url","");
					barDataSet.add(obj);
					labelStr += " <category label='"+info+"' toolText='"+info+"'/>";
					valueStr += " <set value='"+keyStr+"' alpha='100' color='"+colorList.get(colorCount)+"'/>";
					countNo++;
					if (colorCount == colorList.size()-1)
						colorCount = 0;
					else 
						colorCount++;
					if (topCount != -1 && topCount == countNo)
					{
						infoExceeded = true;
						break;
					}
				}
			}
			if (infoExceeded)
				break;
		}
		JSONArray dataSet = new JSONArray();
		JSONObject s1=new JSONObject();
		s1.put("name","");
		s1.put("data",barDataSet);
		s1.put("showInLegend", new Boolean(false));
		dataSet.add(s1);
 		int heightForapplet = chartbean.getbarHeightforCount(countNo);
		labelStr += "</categories>";
		valueStr += "</dataset>";
		strXml += labelStr;
		strXml += valueStr+"</chart>";

		String swf = "/final/FusionCharts/swf/StackedBar" +  (er_mode != null && er_mode.equalsIgnoreCase("2D") ? "2" : "3" ) + "D.swf";
		String chartTitle="";
		if(barDataSet!=null && barDataSet.size()>1 && s_application!=null && !s_application.equalsIgnoreCase("all"))
		{
			 chartTitle=er_topString+" "+barDataSet.size()+" ";
		}
		if(s_application!=null && s_application.equalsIgnoreCase("all"))
		{
			if(s_application.equalsIgnoreCase("all") && er_topString!=null && !er_topString.equalsIgnoreCase("All"))
				chartTitle=er_topString+"  "+er_top+" ";
			else
				chartTitle=er_top+" ";
		}
		else if(er_topString!=null)
		{
			chartTitle=er_topString+" ";
		}
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			graph.put("panelTitle",intlmap.getTextDescription("reporter.common.Application Launch"));
			chartTitle+=intlmap.getTextDescription("reporter.common.Application Launches");
		} 
		else 
		{ 
			graph.put("panelTitle",intlmap.getTextDescription("reporter.common.Application Launch by User"));
			chartTitle+=intlmap.getTextDescription("reporter.common.Application Launch by User");
		} 
		if (dataAvailable)
		{
			String chartType=request.getParameter("chartType");
			Map ChartMap = (HashMap) resultMap.get("ChartMap");
			graph.put("chartTitle",chartTitle);
			graph.put("chartWidth","600");
			graph.put("chartHeight",chartbean.getBarChartHeight(barDataSet));	
			if(chartType!=null && chartType.equalsIgnoreCase("fusionchart"))
			{
				graph.put("fusionChartTypeUrl",swf);
				graph.put("fusionChartXml",strXml);
			}
			else 
			{
				graph.put("DataSet",dataSet);
				graph.put("chartType","bar");
				graph.put("allowDecimal",new Boolean(false));
				graph.put("xAxisLabel",xAxisLabel);
				if (s_compType!=null &&  isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
					graph.put("yAxisLabel","Number");
				else
					graph.put("yAxisLabel",(String)ChartMap.get("rangeAxisLabel"));
			}
		}
		else
		{
			graph.put("noMeasures",intlmap.getTextDescription("reporter.common.No measures available for the current selection"));
		}
		applicationLaunch.put("graph",graph);
		applicationLaunch.put("selectionDetails",selectionDetails);
		//////
		chartTitle="";
		if(barDataSet!=null && barDataSet.size()>1 && s_application!=null && !s_application.equalsIgnoreCase("all"))
		{
			 chartTitle=er_topString+" "+barDataSet.size()+" ";
		}
		if(s_application!=null && s_application.equalsIgnoreCase("all"))
		{
			if(s_application.equalsIgnoreCase("all") && er_topString!=null && !er_topString.equalsIgnoreCase("All"))
				chartTitle=er_topString+"  "+er_top+" ";
			else
				chartTitle=er_top+" ";
		}
		else if(er_topString!=null)
		{
			chartTitle=er_topString+" ";
		}
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			durationGraph.put("panelTitle",intlmap.getTextDescription("reporter.common.Application Launch"));
			chartTitle+=intlmap.getTextDescription("reporter.common.Applications by Launch Duration");
		} 
		else 
		{ 
			durationGraph.put("panelTitle",intlmap.getTextDescription("reporter.common.Application Launch by User"));
			chartTitle+=intlmap.getTextDescription("reporter.common.Application Launch by User");
		} 
		if(launchDurationList!=null && launchDurationList.size()>0)
		{
			colorCount = 0;
			xAxisLabel=new JSONArray();
			if (er_topString != null && (er_topString.indexOf("LAST") > -1 ))
			{
				Collections.reverse(launchDurationList);
			}
			for(int g=0;g<launchDurationList.size();g++)
			{
				durationAvailable=true;
				String info = (String)launchDurationList.get(g);
				String apps =info.substring(0,info.indexOf("$"));
				String durationSeconds =info.substring(info.indexOf("$")+1,info.length());
				JSONObject bobj = new JSONObject();
				xAxisLabel.add(apps);
				bobj.put("name",apps);
				bobj.put("color","#"+colorList.get(colorCount));
				bobj.put("y",Double.valueOf(durationSeconds));
				bobj.put("url","");
				barDuration.add(bobj);
				num++;
				colorCount++;
				//
				if (topCount != -1 && topCount == num)
				{
					durationInfoExceeded = true;
					break;
				}
				//
			}
			JSONArray dataArr = new JSONArray();
			JSONObject v1=new JSONObject();
			v1.put("name","");
			v1.put("data",barDuration);
			v1.put("showInLegend", new Boolean(false));
			dataArr.add(v1);
			if(durationAvailable)
			{
				Map ChartMap = (HashMap) resultMap.get("ChartMap");
				durationGraph.put("chartWidth","600");
				durationGraph.put("chartHeight",chartbean.getBarChartHeight(barDataSet));
				durationGraph.put("DataSet",dataArr);
				durationGraph.put("chartType","bar");
				durationGraph.put("xAxisLabel",xAxisLabel);
				durationGraph.put("yAxisLabel","Seconds");
			}
			else
			{
				durationGraph.put("noMeasures",intlmap.getTextDescription("reporter.common.No measures available for the current selection"));
			}
		}
		durationGraph.put("chartTitle",chartTitle);
		applicationLaunch.put("durationGraph",durationGraph);
		applicationLaunch.put("selectionDetails",selectionDetails);
		applicationLaunch.put("isAppLaunchDuarationColumnEnabled",isAppLaunchDuarationColumnEnabled);
		/////////
	}
}
	session.setAttribute("htdat",htt);

	Hashtable h_tabrc = new Hashtable();	//SubTable Data
	Hashtable h_tab = new Hashtable();	//SubTitle with SubTable Data
	String s_title = "";

		h_tabrc.put(v_measure_csv,list_data);
		h_tab.put(s_title,h_tabrc);
		lst.add(h_tab);
		if(lst!= null && !lst.isEmpty())
		{
			session.setAttribute("list",lst);
		}
		Map parameters = new HashMap();
		parameters= request.getParameterMap();
		String queryString =(String)ErUtils.prepareQueryString(request.getParameterMap());
		String Qstring="";
		String lastAccQstring="";
		if(queryString!=null)
		{
			StringTokenizer strtok = new StringTokenizer(queryString,"&");
			while(strtok.hasMoreTokens())
			{
				String param = strtok.nextToken();
				int ind = param.indexOf("=");
				if (ind < 0)
					continue;
				String reqparam =param.substring(0,ind);
				String value = param.substring(ind+1);
				if(reqparam!=null&&reqparam.equals("select_farm") )
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equals("userID"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null&&reqparam.equals("uid"))
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				if(reqparam!=null && ( reqparam.equals("startdate") || reqparam.equals("enddate") || reqparam.equals("inidate") || reqparam.equals("pdfTime") || reqparam.equals("select_testmes") || reqparam.equals("er_workgrpname") || reqparam.equals("er_trgttype") || reqparam.equals("limitforbg") || reqparam.equals("er_timeline") || reqparam.equals("er_usertimeline") || reqparam.equals("er_top") || reqparam.equals("limitforbg") || reqparam.equals("limitforbg")||reqparam.equals("er_vm") || reqparam.equals("er_application")) )
				{
					value=com.eg.EgURLEncoder.encode(value, "UTF-8");
				}
				lastAccQstring=lastAccQstring+reqparam+"="+value+"&";
				if(reqparam!=null&&reqparam.equals("er_application"))
				{
					continue;
				}
					if(reqparam!=null&&reqparam.equals("er_component"))
				{
					continue;
				}
					if(reqparam!=null&&reqparam.equals("er_vm"))
				{
					continue;
				}
					if(reqparam!=null&&reqparam.equals("er_user"))
				{
					continue;
				}
				Qstring=Qstring+reqparam+"="+value+"&";
			}
			Qstring=Qstring;
			lastAccQstring=lastAccQstring;
		}
		String dataProcess = mngrIProc+"/final/reporter/ErApplicationLaunchCountReportPrint.jsp;jsessionid="+ session.getId()+"?"+Qstring;
		session.setAttribute("MAIL_URL",dataProcess);
		HashMap hmQry = ErUtils.parseQueryString(Qstring);
		String targetType = "";
		if(hmQry != null && hmQry.get("er_trgttype") instanceof String)
		{
			targetType = (String)hmQry.get("er_trgttype");
		}
		else if(hmQry != null && hmQry.get("er_trgttype") instanceof String[])
		{
			targetType = ((String[])hmQry.get("er_trgttype"))[0];
		}
		if (targetType != null && targetType.equalsIgnoreCase("Application+Launch+Count+Report"))
		{
			hmQry.remove("er_application");
			hmQry.remove("er_component");
			if(hmQry.containsKey("er_vm"))
			 hmQry.remove("er_vm");
			if(hmQry.containsKey("er_user"))
			 hmQry.remove("er_user");
		}
		String qString = ErUtils.prepareQueryString(hmQry);
		urlFields.put("saveQueryString",qString);
		ArrayList listbackvar = new  ArrayList();
		if(request.getParameter("isSubmit")!=null)
		{
			session.setAttribute("reportLastAccessedURL","/final/reporter/ErApplicationLaunchCountReport.jsp?"+lastAccQstring);
			listbackvar.add("/servlet/com.eg.ErApplicationLaunchCountReportC?");
			listbackvar.add("status="+status+"&bggroundStr="+bggroundStr+"&"+queryString);
			session.setAttribute("favSchBackDisplay","Yes");
		}
		else
		{
			session.setAttribute("reportLastAccessedURL","/final/reporter/ErApplicationLaunchCountReport.jsp?"+lastAccQstring);
			listbackvar.add("ErApplicationLaunchCountReport.jsp");
			listbackvar.add(queryString);
			session.setAttribute("favSchBackDisplay","No");
		}
		session.setAttribute("reportLastAccessedURL","/final/reporter/ErApplicationLaunchCountReport.jsp?"+lastAccQstring);
		String backadded = erhelputils.getBackID();
		backreqMap = erhelputils.setBackQueryMap(backreqMap,backadded,listbackvar);
		session.setAttribute("backQuery",backreqMap);

		//Back button - End
		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			aList1.add("Application");
			aList1.add("Launches");
			if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
			{
				aList1.add("Avg Launch Duration (Secs)");
			}
			aList1.add("Unique Users");
		}
		else 
		{
			aList1.add("User");
			aList1.add("Launches");
		}
		if (er_groupby != null && er_groupby.equalsIgnoreCase("Application"))
			aList2.add("Application");
		else if (er_groupby != null && er_groupby.equalsIgnoreCase("User"))
			aList2.add("User");
		else 
		{
			if(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm)
				aList2.add("Desktop");
			else
			aList2.add("Component");
		}
		aList2.add("Launches");
		if (s_compType!=null && isAppLaunchDuarationColumnEnabled && er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application"))
		{
			aList2.add("Avg Launch Duration (Secs)");
		}

		if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("Application")){
			if (er_groupby != null && er_groupby.equalsIgnoreCase("User"))
				aList3.add("Component");
			else 
				aList3.add("User");
		} else if (er_detailsBasedOn != null && er_detailsBasedOn.equalsIgnoreCase("User")){
			if (er_groupby != null && er_groupby.equalsIgnoreCase("Application"))
				aList3.add("Component");
			else 
				aList3.add("Application");
		}
		if(er_groupby != null && er_groupby.equalsIgnoreCase("Component") && isLaunchByVm)
		{
			aList3.add("Component");
			aList3.add("Application Launch Time");
			int sizeOftList =5;
			if(!getSessionDetails)
				sizeOftList =3;
			if(getSessionDetails)
			{
				aList3.add("Session Start");
				aList3.add("Session End");
			}
		if(tListt!=null && tListt.size()>sizeOftList){
				aList3.add("Client Address");
				aList3.add("Client Name");
				aList3.add("Client Version");
			}
		}
		else if(isSearchByVmComp)
		{
			aList3.add("Desktop");
			aList3.add("Application Launch Time");
			int sizeOftList =5;
			if(!getSessionDetails)
				sizeOftList =3;
			if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
			{
				aList3.add("Launch duration (Secs)");
				sizeOftList++;
			}
			if(getSessionDetails)
			{
				aList3.add("Session Start");
				aList3.add("Session End");
			}
			if(tListt!=null && tListt.size()>sizeOftList){
				aList3.add("Client Address");
				aList3.add("Client Name");
				aList3.add("Client Version");
			}
		}
		else
		{
			aList3.add("Application Launch Time");
			if (s_compType!=null && isAppLaunchDuarationColumnEnabled)
			{
				aList3.add("Launch duration (Secs)");
			}
			int sizeOftList =4;
			if(!getSessionDetails)
				sizeOftList =2;
			if(getSessionDetails)
			{
			aList3.add("Session Start");
			aList3.add("Session End");
			}
			if(tListt!=null && tListt.size()>sizeOftList){
				aList3.add("Client Address");
				aList3.add("Client Name");
				aList3.add("Client Version");
			}
		}
		if(geoDetails != null && geoDetails.equalsIgnoreCase("yes")){
			if(geoColumnList != null){
				for(int i=0;i<geoColumnList.size();i++)
					aList3.add((String)geoColumnList.get(i));
			}
		}
		htHeading.put("MainHeading",aList1);
		htHeading.put("Heading",headingList);
		htHeading.put("SubHeading1",aList2);
		htHeading.put("SubHeading2",aList3);

		session.setAttribute("REPORT_DATA_TITLE",htHeading);
		applicationLaunch.put("selectedFields",selectedFields);
		applicationLaunch.put("hiddenFields",hiddenFields);
		applicationLaunch.put("combo",combo);
		applicationLaunch.put("labelFields",labelFields);
		applicationLaunch.put("urlFields",urlFields);
		
		out.println(applicationLaunch.toString());
	}
	catch(Throwable t)
	{
		t.printStackTrace();
	}

	//For Setting the PDf File Name
	HashMap paramVal =new HashMap();
	paramVal.put("fileName","Application_Launch_Count_Report");
	session.setAttribute("parameters", paramVal);
%>
<%!
public synchronized JSONArray getJSONComboFromList(List list,String infoVal,EgMappingInfo intlmap)
 {
	JSONArray arr=new JSONArray();
	JSONObject obj=null;
	if(list !=null && list.size()>0)
	{
		for (int i=0;i<list.size();i++)
		{
			String text=(String)list.get(i);
			obj=new JSONObject();
			obj.put("displayField",text);
			obj.put("valueField",text);
			arr.add(obj);
		}
	}
	else
	{
		obj=new JSONObject();
		obj.put("displayField",intlmap.getTextDescription("reporter.common.Not Applicable"));
		obj.put("valueField","-1");
		arr.add(obj);
	}
	return arr;
 }
 %>