<%
/*******************************************************************************
*	File name		: egDashBoardHistory.jsp
*	Purpose			: To display various graphs in dashbard for all subsystem
*	Version			: eG 5.0
*	Creation Date	: 20/03/2009
*	Authtor			: Simeon.D
********************************************************************************/
%>
<%@ include file = "EgServerDashboardTracker.jsp"%>
<%@ page import = "com.egurkha.ini.IniUI"%>
<%@ page import = "com.eg.EgDateInfo"%>
<%@ page import = "com.eg.EgURLEncoder"%>
<%@ page import = "com.eg.EgSpecsInfo"%>
<%@ page import = "com.eg.EgTablesInfo"%>
<%@ page import = "com.eg.EgDbInfo"%>
<%@ page import= "com.eg.EgMappingInfo"%>
<%@ page import= "com.egurkha.HighChartTimeline"%>
<%@ page import= "com.egurkha.monitor.*"%>
<%@ page import = "java.util.*"%>
<%@ page import = "com.egurkha.EgMeasureGraphExt"%>
<%@ page import = "com.egurkha.util.DateUtil"%>
<%@ page import = "com.egurkha.util.StringUtils"%>
<%@ page import = "com.egurkha.util.TimeZoneUtil"%>
<%@ page import = "java.text.SimpleDateFormat"%>
<%@ page import = "com.egurkha.util.DateTimeTokenizer"%>
<%@ page import="com.eg.EgMappingInfo"%>
<%@ page import="com.eg.EgDiscInfo" %>
<%@ page import="com.eg.EgMemInfo"%>
<%@ page import="com.eg.EgTesterInfo"%>
<%@ page import="com.eg.EgFormatInfo"%>
<%@ page import="com.eg.EgInstallInfo"%>
<%@ page import="com.eg.supermanager.*"%>
<%@ page import="com.egurkha.util.MathUtils"%>
<%@ page import="egurkha.reporter.ErUtils"%>
<%@ page import="net.sf.json.*"%>

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

<%
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);
try
{
//	System.out.println("1111The request is "+ErUtils.prepareQueryString(request.getParameterMap()));
	JSONObject rootJson = new JSONObject();
	JSONObject screenLabels = new JSONObject();
	JSONObject hiddens = new JSONObject();
	String currentBrowser = request.getHeader("User-Agent");

	boolean isFirefox = ( currentBrowser != null && currentBrowser.indexOf( "Firefox/" ) != -1 );
	boolean isMSIE6 = ( currentBrowser != null && currentBrowser.indexOf( "MSIE 6.0" ) != -1 );
	boolean isMSIE7 = ( currentBrowser != null && currentBrowser.indexOf( "MSIE 7.0" ) != -1 );

	EgSpecsInfo specsInfo = new EgSpecsInfo("manager");
	EgTablesInfo tablesInfo=new EgTablesInfo("manager");
	EgDbInfo dbInfo=new EgDbInfo("manager");
	EgTesterInfo testerInfo=new EgTesterInfo("manager");

	UserRegistry registry = UserRegistry.getInstance();
	User user = registry.getUser(session.getId());

	EgMappingInfo mappingInfo=new EgMappingInfo(trackerLanguage);

	EgMeasureGraphExt measureGraphInfo = new EgMeasureGraphExt();
	IniUI iniUI = IniUI.getInstance();
	String currentDateFormat = iniUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");

	EgMappingInfo egMappingInfo=new EgMappingInfo(trackerLanguage);

	EgMonFusionChart egMon = new EgMonFusionChart();
	AvgTrendFusionChart avgTrend = new AvgTrendFusionChart();

	String s_iniFile_dir=EgInstallInfo.getInstallDir()+"/manager/config/";

	String compType=request.getParameter("compType");

	String dashboardIni = "eg_serverdashboard.ini";
	EgServerDashboardModel  egDashboard=null;
	if(compType!=null && compType.startsWith("Agg_"))
	{
		egDashboard=new  EgServerDashboardModel(true);
		dashboardIni = "eg_aggregateserverdashboard.ini";
	}
	else
	{
		egDashboard=new  EgServerDashboardModel();
	}
	IniFile iniObj=new IniFile(s_iniFile_dir+dashboardIni);
	IniFile iniTests=new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_tests.ini",true);
	EgServerDashboardMGraphModel measureGraph=new EgServerDashboardMGraphModel();
	MonitorDAOFactory monitorDaoFactory = MonitorDAOFactory.getInstance();
	EgServerDashBoardDAO dashboardDAO=monitorDaoFactory.getServerDashBoardDAO();
	EgFusionChartUtil fusionChart=new EgFusionChartUtil(trackerLanguage);
	EgGraphsUtil graphUtil=new EgGraphsUtil(trackerLanguage);
	EgFormatInfo formatInfo = new EgFormatInfo("manager");
	IniFile formatIni=new IniFile(EgInstallInfo.getInstallDir()+"/manager/config/eg_format.ini",true);
	ErUtils  erutils=new  ErUtils();
	ServiceTopology topology=new ServiceTopology(request);

	String compName=request.getParameter("hostName");
	String subsystem=request.getParameter("subsystem");
	String graphType=request.getParameter("graphType");
	String tab=request.getParameter("tab");
	String screenWidth=request.getParameter("screenWidth");
	String screenHeight=request.getParameter("screenHeight");
	double screenWidthInDouble=1024.0;
	double screenHeightInDouble=768.0;
	if (EgInstallInfo.isSuperManager)
	{
		String s_comp = compType+":"+compName;// gen_26:NULL:Generic_server
		String currentSession = session.getId();
		if(s_comp != null && s_comp.indexOf(":")>0)
		{
			ArrayList managerIDs = EgElementInfo.getInstance().getManagerIDs("component",s_comp);
			if(managerIDs != null && !managerIDs.isEmpty())
			{
				Hashtable paramHt = new Hashtable();
				paramHt.put("managerIds",managerIDs);
				EgSMDBHelper.paramsOfJSP.put(currentSession,paramHt);
				EgThreadLocal.clear();
				SmSessionData smsData = new SmSessionData(currentSession,managerIDs);
				EgThreadLocal egtl = new EgThreadLocal();
				egtl.set(smsData);
			}
		}
	}

	if(screenWidth!=null && !screenWidth.equals(""))
	{
		screenWidthInDouble=Double.parseDouble(screenWidth);
	}
	if(screenHeight!=null && !screenHeight.equals(""))
	{
		screenHeightInDouble=Double.parseDouble(screenHeight);
	}

	String hostName="";
	String portNo="";

	String startTime=request.getParameter("starttime");
	String endTime=request.getParameter("endtime");
	String startHour=request.getParameter("starthr");
	String endHour=request.getParameter("endhr");
	String startMin=request.getParameter("startmin");
	String endMin=request.getParameter("endmin");
	String startSec=request.getParameter("startSec");
	String endSec=request.getParameter("endSec");

	String graphTimeline=request.getParameter("time_line");

	SimpleDateFormat dateFormatDDMM=new SimpleDateFormat("dd/MM/yyyy");
	SimpleDateFormat dateFormatMMDD=new SimpleDateFormat("MM/dd/yyyy");
	SimpleDateFormat testTableDateFmt=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	SimpleDateFormat dateFormatWithTime=new SimpleDateFormat("dd/MM/yyyy HH:mm");
	SimpleDateFormat dfForParse=new SimpleDateFormat(currentDateFormat);

	String startDateTime="";
	String endDateTime="";
	boolean isSystemTab=(tab!=null && tab.equalsIgnoreCase("System"));
	boolean isNetworkTab=(tab!=null && tab.equalsIgnoreCase("Network"));
	boolean isApplicationTab=(tab!=null && tab.equalsIgnoreCase("Application"));
	boolean isMeasureGraph=(graphType !=null && graphType.equalsIgnoreCase("measureGraph"));
	boolean isUptime=(subsystem!=null && subsystem.equalsIgnoreCase("Uptime"));
	String UseCutOffFactor=iniObj.getValue("Dashboard_Settings","UseCutOffFactor");
	String defaultTopNPriority=iniObj.getValue("Dashboard_Settings","show_top");
	if(StringUtils.isNull(defaultTopNPriority))
		defaultTopNPriority="5";

	defaultTopNPriority="TOP+-+"+defaultTopNPriority;

	String vTitlemsmtHost = "";
	String fontForLanguage="verdana";
	String fontSize="7.5";
	boolean isNonEnglishLanguage=((EgDbInfo.doubleByteEnabled && !trackerLanguage.equals("en_US")) || !trackerLanguage.equals("en_US"));

	if(isNonEnglishLanguage)
	{
			fontForLanguage=iniUI.getFontName();
			fontSize="12";
	}
	if(graphTimeline!=null && graphTimeline.equalsIgnoreCase("any"))
	{
		try
		{
			Date startDateFrmReq=dfForParse.parse(startTime);
			Date endDateFrmReq=dfForParse.parse(endTime);

			startDateTime=dateFormatDDMM.format(startDateFrmReq)+" "+startHour+":00";
			endDateTime=dateFormatDDMM.format(endDateFrmReq)+" "+endHour+":00";
			startTime=dateFormatMMDD.format(startDateFrmReq);
			endTime=dateFormatMMDD.format(endDateFrmReq);
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
	if(graphType==null || graphType.trim().equals(""))
		graphType="measureGraph";

	String chartOptionForTimeline = "graph";
	if ( !StringUtils.isNull(startTime) && !StringUtils.isNull(endTime) )
	{
		//Date startDateFrmReq1=dfForParse.parse(startTime);
		//Date endDateFrmReq1=dfForParse.parse(endTime);
		String tempStDate = startTime; //dateFormatMMDD.format(startDateFrmReq1);
		String tempEndDate = endTime; //dateFormatDDMM.format(endDateFrmReq1);
		if(!StringUtils.isNull(tempStDate) && tempStDate.lastIndexOf(" ")>0)
		{
			tempStDate=tempStDate.substring(0,tempStDate.lastIndexOf(" "));
		}
		if(!StringUtils.isNull(tempEndDate) && tempEndDate.lastIndexOf(" ")>0)
		{
			tempEndDate=tempEndDate.substring(0,tempEndDate.lastIndexOf(" "));
		}
		String timeDuration = iniObj.getValue("Default_MeasureGraph_Duration","duration");
		//chartOptionForTimeline = HighChartTimeline.getChartOption(graphTimeline,currentDateFormat,tempStDate,tempEndDate);
		chartOptionForTimeline = HighChartTimeline.getChartOption(timeDuration,currentDateFormat,tempStDate,tempEndDate);
	}
	else
	{
		if(graphType!=null && graphType.equals("measureGraph"))
		{
			String timeDuration = iniObj.getValue("Default_MeasureGraph_Duration","duration");
			String measuretimeline=egDashboard.convertDurtionIntoTimeline(timeDuration,true);

			if(timeDuration!=null && !timeDuration.equals(""))
			{
				Vector times=egDashboard.getStartEndDateTimeForMeasure(timeDuration);
				if(times!=null && times.size()>=4)
				{
					String tempStDate=(String)times.get(0);
					String tempEndDate=(String)times.get(1);
	//				startHour=(String)times.get(2);
	//				endHour=(String)times.get(3);
					chartOptionForTimeline = HighChartTimeline.getChartOption(timeDuration,currentDateFormat,tempStDate,tempEndDate);
				}			
			}
		}
	}
	String state="";
	String status="";
	String siteName="NULL";
	String sid="";
	String priority="TOP+-+3";
	String FullViewPriority="TOP+-+10";
	String compPort="";

	String timelineFormat=request.getParameter("format");
	String subject="";
	if(isSystemTab)
		subject="System_Dashboard_Metrics";

	if(compName!=null && !compName.equals(""))
	{
		StringTokenizer st=new StringTokenizer(compName,":");
		if(st.hasMoreTokens())
			hostName=st.nextToken();

		if(st.hasMoreTokens())
		{
			portNo=st.nextToken();
			compPort=portNo;
		}

		if(st.hasMoreTokens())
			sid=st.nextToken();
	}
	subject=request.getParameter("subject");
	ArrayList enabledTests=specsInfo.getEnabledTests(compType,false);

	if(isSystemTab)
	{
		subject="System_Dashboard_Metrics";
	}
	else if(isNetworkTab)
	{
		subject="Network_Dashboard_Metrics";
	}
	else
	{			
		String jvmAppTabForCompType = iniObj.getValue("JVM_Enabled_AppServers", compType);
		if(jvmAppTabForCompType != null && jvmAppTabForCompType.equalsIgnoreCase("Yes")) {
			subject = "Java_virtual_machine";
		} else {
			subject = compType;
		}		
	}

	String s_specificsubject=iniObj.getValue("CommonDashboardConfiguration",compType);
	boolean isSpecificSubject=(s_specificsubject!=null && s_specificsubject.equalsIgnoreCase("yes"));
	if(isSpecificSubject)
	{
		subject=compType;
	}

	egDashboard.setSubject(subject);

	String s_timelinegraph=iniObj.getValue(subject,tab+"_"+subsystem);
	Vector vec_timelineGraphTestMeasure=new Vector();
	ArrayList defaultTests = egDashboard.getDefaultTestsForServer(compType);
	if(isNetworkTab)
	{
		StringTokenizer stkGraphTestMeasures=new StringTokenizer(s_timelinegraph,",");
		while(stkGraphTestMeasures.hasMoreTokens())
		{
			String testMeasures=stkGraphTestMeasures.nextToken();
			String graphTestName=testMeasures.substring(0,testMeasures.indexOf(":"));
			
			if(defaultTests != null && defaultTests.contains(graphTestName)) {
				vec_timelineGraphTestMeasure.add(testMeasures);
			}	
			
			/**if(specsInfo.isTestRelevantForServer(compType,graphTestName))
			{
				vec_timelineGraphTestMeasure.add(testMeasures);
			}
			**/
		}
	}
	else
	{
		vec_timelineGraphTestMeasure=egDashboard.getTokensAsVector(s_timelinegraph,",");
	}
	Vector times=new Vector();

	Vector runingTestList=egDashboard.getRunningTest(compName,compType,tab);

	java.util.Date endDate=new java.util.Date();
	java.util.Date startDate=new java.util.Date(endDate.getTime()-(60*60*1000));
	boolean isOverview=subsystem!=null  && subsystem.equalsIgnoreCase("overview");
	String ddtest="";
	String ddmeasure="";
	String ddformat="";
	String dataTitle="";
	String unit="";
	String graphTitle="";
	boolean isRuningTest=false;

	String defaultSparklineDuration=iniObj.getValue("Default_SparkLineGraph_Duration","duration");

	Hashtable allMsmtHosts=dashboardDAO.getMsmtHostForAllTest(compName,compType,tab);
	Hashtable allTestInfos=dashboardDAO.getDescriptorsForAllTest(compName,compType,tab);

	boolean isFullView=false;
	String lastFullViewURL=(String)session.getAttribute("lastFullViewURLForDashboard");
	String fullViewGraphType="";

	if(lastFullViewURL!=null && (!lastFullViewURL.equals("") && !lastFullViewURL.equalsIgnoreCase("null")))
	{
		String tempLastFullViewURL=lastFullViewURL.substring((lastFullViewURL.indexOf("?")+1));
		StringTokenizer stkParams=new StringTokenizer(tempLastFullViewURL,"&");
		while(stkParams.hasMoreTokens())
		{
			String paramWithValue=stkParams.nextToken();
			if(paramWithValue!=null && paramWithValue.indexOf("=")>0)
			{
				String param=paramWithValue.substring(0,paramWithValue.indexOf("="));
				if(param!=null && param.equals("isFullView"))
				{
					String value=paramWithValue.substring(paramWithValue.indexOf("=")+1,paramWithValue.length());
					if(value!=null && value.equalsIgnoreCase("true"))
					{
						isFullView=true;
					}
				}
				else if(param!=null && param.equals("graphType"))
				{
					fullViewGraphType=paramWithValue.substring(paramWithValue.indexOf("=")+1,paramWithValue.length());
					if(fullViewGraphType!=null && (!fullViewGraphType.equals("") && !fullViewGraphType.equalsIgnoreCase("null")))
					{
						if(isFullView)
							break;
					}
				}
			}
		}
	}
	if((compType!=null && (compType.equalsIgnoreCase("VmEsx_i_server") || compType.equalsIgnoreCase("VmVdi_i_server"))) && (isSystemTab && subsystem.equalsIgnoreCase("Disk") && graphType.equalsIgnoreCase("DDgraph")))
	{
	String s_disabledBlocks=iniObj.getValue("Disabled_blocks",tab+"_Overview");
	Vector disabledBlocks=egDashboard.getTokensAsVector(s_disabledBlocks,",");
	String s_comparisiontable=iniObj.getValue(subject,tab+"_Disk_comparisiontable");
	if(s_comparisiontable!=null && !s_comparisiontable.trim().equals(""))
	{
		int tablescount=0;
		int imgcnt=0;
		int stColPos=1;
		int endColPos=0;
		String msmtHost="";
		int divCount=0;
		String measure="";
		Vector comparisionVector=egDashboard.getTokensAsVector(s_comparisiontable,"#");
		String info="";
		Iterator comparionTableItr=comparisionVector.iterator();
		while(comparionTableItr.hasNext())
		{
			String s_alltestmeasure=(String)comparionTableItr.next();
			String colspan="1";
			String tableWidth="";
			if(isFirefox)
			{
				tableWidth="96%";
			}
			else
				tableWidth="50%";

			info="+";

			Vector allMeasures=egDashboard.getTokensAsVector(s_alltestmeasure,",");
			Iterator allMeasuresItr=allMeasures.iterator();

			String tempTestName="";
			if(allMeasures.size()>0)
			{
				tempTestName=(String)allMeasures.get(0);
				if(tempTestName!=null && tempTestName.indexOf(":")!=-1)
					tempTestName=tempTestName.substring(0,tempTestName.indexOf(":"));
			}
			String tableTitle=iniObj.getValue("Dashboard_Comparison_TableTitle",tempTestName);
			if(tableTitle!=null && tableTitle.equals(""))
			{
				tableTitle=mappingInfo.getTestDescription(tempTestName);
			}

			Vector allInfos=(Vector)allTestInfos.get(tempTestName);

			boolean hasInfos=(allInfos!=null && allInfos.size()>0 && !(allInfos.size()==1 && allInfos.contains("+")));
			int colCountForFullTable=5;
			if(allMeasures!=null && allMeasures.size()>=colCountForFullTable && hasInfos)
			{
				tableWidth="100%";
				colspan="2";
			}
			if(hasInfos)
			{
				Vector measures=new Vector();
				String measuresForDB="";
				String testName="";

				for(int i=0;i<allMeasures.size();i++)
				{
					String tempStr=(String)allMeasures.get(i);
					if(tempStr!=null && tempStr.indexOf(":")!=-1)
					{
						testName=tempStr.substring(0,tempStr.indexOf(":"));
						String tempMeasure=tempStr.substring(tempStr.indexOf(":")+1);
						measures.add(tempMeasure);
						measuresForDB+=dbInfo.getColumnForMeasure(testName,tempMeasure);
						if(allMeasures.size()>i+1)
							measuresForDB+=",";
					}
				}

				msmtHost=(String)allMsmtHosts.get(testName);
				if(msmtHost==null)
					msmtHost="";

				String s_infomapping=iniObj.getValue("Dashboard_Info_Mapping",testName);
				if(s_infomapping==null || s_infomapping.trim().length()==0)
				{
					s_infomapping="Info";
				}
				String rsTableName="rsTable"+(tablescount+1);
				int totalMeasureCols=measures.size();
				Vector allValuesForInfo=new Vector();
				allValuesForInfo=dashboardDAO.getCurrentForAllInfos(hostName,portNo,testName,measuresForDB,msmtHost);
					endColPos+=(totalMeasureCols+1);
				boolean isValuesAvailableForInfo=(allValuesForInfo!=null && !allValuesForInfo.isEmpty());
				if(!disabledBlocks.contains(testName) &&  isValuesAvailableForInfo)
				{
					JSONObject VmEsxObj = new JSONObject();
					JSONArray VmEsxArr = new JSONArray();
					
					
					String defaultMGraphDuration=iniObj.getValue("Default_MeasureGraph_Duration","duration");
					if(defaultSparklineDuration==null || (defaultSparklineDuration!=null && defaultSparklineDuration.equals("")))
						defaultSparklineDuration="1 hour";
					String comparisonTableFullViewURL=response.encodeURL("/final/monitor/egCustomDashboardp.jsp")+"?"+"compName="+EgURLEncoder.encode(compName,"UTF-8")+"&compType="+compType+"&subject="+EgURLEncoder.encode(subject,"UTF-8")+"&site="+siteName+"&tab="+tab+"&defaultMGraphDuration="+defaultMGraphDuration+"&defaultSparklineDuration="+defaultSparklineDuration+"&divCount=0&state="+state+"&blockType=comparisontable&comparisontable_type=esxdatastore";
					
					JSONObject vmObj = new JSONObject();
					vmObj.put("TITLE",mappingInfo.getTextDescription("monitor.dashboard."+tableTitle));
					vmObj.put("FULLVIEW_URL",comparisonTableFullViewURL);

					boolean isTestHas_CutOffFactor=true;
					if(UseCutOffFactor!=null && !UseCutOffFactor.equals("") && UseCutOffFactor.equalsIgnoreCase("Yes"))
					{
						if(egDashboard.isTestHasCutOffFactor(testName))
						{
							if(allValuesForInfo!=null && !allValuesForInfo.isEmpty())
							{
								for(int d=0;d<allValuesForInfo.size();d+=measures.size()+1)
								{
									String info_for_cutofffactor=(String)allValuesForInfo.get(d);
									boolean isTestExceededCutOffFactor=dashboardDAO.isTestExceededCutOffFactor(compType,hostName,portNo,sid,testName,msmtHost,info_for_cutofffactor);
									if(!isTestExceededCutOffFactor)
										isTestHas_CutOffFactor=false;
								}
							}			
						}
					}
					if(!isTestHas_CutOffFactor)
					{
						JSONObject colObj = new JSONObject();
						String colNam0=mappingInfo.getTextDescription("monitor.dashboard."+s_infomapping);
						colObj.put("COLUMNNAM_0",colNam0);
						imgcnt=imgcnt+1;

						for(int i=0;i<totalMeasureCols;i++)
						{
							//JSONObject colObj1 = new JSONObject();
							measure=(String)measures.get(i);

							String tableHeader=iniObj.getValue("Dashboard_TableColumn_mapping",testName+":"+measure);
							if(tableHeader!=null && tableHeader.equals(""))
							{
								tableHeader=mappingInfo.getMeasureDescription(testName,measure);
							}
							else
							{
								tableHeader=mappingInfo.getTextDescription("monitor.dashboard."+tableHeader);
							}

							String units = tablesInfo.getUnitForMeasure(testName,measure);

							if(units!=null && units.equalsIgnoreCase("MB"))
								units="GB";
							

					if(tableHeader.equalsIgnoreCase("Availability"))
					{
						colObj.put("COLUMNNAM_"+(i+1),tableHeader);
					}
					else
					{
						String unitMapping = graphUtil.getUnitMapping(units);
						colObj.put("COLUMNNAM_"+(i+1),tableHeader+" ("+unitMapping+")");

					}
									
					imgcnt++;
					}
					VmEsxArr.add(colObj);
					JSONArray VmEsxArray = new JSONArray();
					
					for(int i=0;i<allValuesForInfo.size();i+=measures.size()+1)
					{
						JSONObject colVal = new JSONObject();
						info=(String)allValuesForInfo.get(i);
						String tmpInfo = info;
						info=com.egurkha.util.StringUtils.replace(info,"+","");
						if(info!=null && info.equalsIgnoreCase("Total"))
						{
							continue;
						}
						
						String descSate =(String)topology.getDescriptorState(compType, compName, testName, tmpInfo);

						int colIdx=0;
						if(colIdx==0)
						{
							colVal.put("COLUMN_"+colIdx+"_STATE",descSate); 
						}
						colVal.put("COLUMN_"+(colIdx++),info);
						//VmEsxArray.add(colVal);

						for(int j=1;j<=measures.size();j++)
						{	
							measure=(String)measures.get(j-1);
							String value=(String)allValuesForInfo.get(j+i);
							String units = tablesInfo.getUnitForMeasure(testName,measure);

							if(!testerInfo.getAllowNegativeValues(testName,measure) && (value!=null) && (value.startsWith("-") || value.trim().equals("")))
							{
								value = "-";
							}

							if((value!=null && !value.equals("-")) && (units!=null && units.equalsIgnoreCase("MB")))
							{
								double floatVal=(Double.parseDouble(value))/1024;
								floatVal=MathUtils.round(floatVal,2);
								value=floatVal+"";
							}
							else if((value!=null && !value.equals("-")) && (units!=null && units.equalsIgnoreCase("boolean")))
							{
								if(value.equals("0"))
									value="No";
								else if(value.equals("1"))
									value="Yes";
							}
							String img="";
							if(measure!=null && measure.equalsIgnoreCase("Availability"))
							{
								if(value.equals("100"))
								{
									
									img="iconArrowUp";
								}
								else
								{
									img="iconArrowDown";
								}
								colVal.put("COLUMN_"+(colIdx++),img);

							}
							else
							{
								colVal.put("COLUMN_"+(colIdx++),value);

							}
						}
						VmEsxArray.add(colVal);
					
					}
					int defaultColumnSortIndex=0;
					int defaultColumnSortImageIndex=stColPos;
					vmObj.put("Disk_ESX_COLUMNNAME",VmEsxArr);
					vmObj.put("Disk_ESX_COLUMNVAL",VmEsxArray);
					rootJson.put("DISK_ESX", vmObj);
					}
					else
					{
						JSONObject chartObj = new JSONObject();
						chartObj.put("NO_CHARTS", "true");
						chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.dashboard.No measures available ")+"!");
						rootJson.put("DISK_ESX", chartObj);
					}

				}
				else
				{
					JSONObject chartObj = new JSONObject();
					chartObj.put("NO_CHARTS", "true");
					chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.dashboard.No measures available ")+"!");
					rootJson.put("DISK_ESX", chartObj);
				}
			}
		}
	}

	}
	
	String ddGraphWidth="320";
	String ddGraphHeight="200";
	String historyGraphWidth="320";
	String historyGraphHeight="200";
	String summaryGraphWidth="320";
	String summaryGraphHeight="180";
	String summaryTrendGraphHeightForInfoChange="320";
	double defaultDDGraphWidth=400;
	double defaultDDGraphHeight=225;
	double defaultHistoryGraphWidth=280; 
	double defaultHistoryGraphHeight=198;
	double defaultSummaryGraphWidth=400;
	double defaultSummaryGraphHeight=215;
	double defaultGraphTitleLength=27;
	int graphTitlelength=27;
	if(screenWidthInDouble>0)
	{
		double ddgraphWidthTo1024Px=defaultDDGraphWidth/1024;
		double ddGraphWidthInDouble=screenWidthInDouble*ddgraphWidthTo1024Px;
		ddGraphWidth=erutils.round(ddGraphWidthInDouble,0);
		double ddgraphHeightToDefaultDDHeightInPercent=defaultDDGraphHeight/defaultDDGraphWidth;
		double ddGraphHeightInDouble=ddGraphWidthInDouble*ddgraphHeightToDefaultDDHeightInPercent;
		ddGraphHeight=erutils.round(ddGraphHeightInDouble,0);
		double historyGraphWidthTo1024Px=defaultHistoryGraphWidth/1024;
		double historyGraphWidthInDouble=screenWidthInDouble*historyGraphWidthTo1024Px;
		historyGraphWidth=erutils.round(historyGraphWidthInDouble,0);
		double historyGraphHeightToDefaultDDHeightInPercent=defaultHistoryGraphHeight/defaultHistoryGraphWidth;
		double historyGraphHeightInDouble=historyGraphWidthInDouble*historyGraphHeightToDefaultDDHeightInPercent;
		historyGraphHeight=erutils.round(historyGraphHeightInDouble,0);
		summaryGraphWidth=ddGraphWidth;
		double sumGraphHeightToSumHeightInPercent=defaultSummaryGraphHeight/defaultSummaryGraphWidth;
		double summaryGraphHeightInDouble=ddGraphWidthInDouble*sumGraphHeightToSumHeightInPercent;
		summaryGraphHeight=erutils.round(summaryGraphHeightInDouble,0);
		summaryTrendGraphHeightForInfoChange=erutils.round((summaryGraphHeightInDouble-2),0);
		double graphTitleLengthInPercentTo1024px=defaultGraphTitleLength/defaultSummaryGraphWidth;
		graphTitlelength=((int)(historyGraphWidthInDouble*graphTitleLengthInPercentTo1024px));
	}
	int graphCount=0;
	/* 
	*If  block will execute when you click comparision or Details tab in dashbord
	*Else block will be executed for the History tab
	*/
	if(graphType!=null && graphType.equalsIgnoreCase("DDgraph"))
	{
		boolean ddEnabled=EgMemInfo.ddEnabled;
		boolean isDDFromFirstMsmt=true;
		boolean testsEnabled=false;

		SimpleDateFormat sf=new SimpleDateFormat("MM/dd/yyyy");

		String ddtimeline=iniObj.getValue("Default_DD_Duration","duration");;

		if(graphTimeline!=null && !graphTimeline.trim().equals(""))
		{
			ddtimeline=graphTimeline;
		}

		String startenddates="";

		if(ddtimeline==null || !ddtimeline.equalsIgnoreCase("any"))
		{
			startenddates=egDashboard.getStartEndDatesForTimelines(ddtimeline,"");
		}

		if(ddtimeline!=null && ddtimeline.equalsIgnoreCase("any"))
		{
			try
			{
				Date startDateFrmReq=dfForParse.parse(startTime);
				Date endDateFrmReq=dfForParse.parse(endTime);

				startTime=dateFormatMMDD.format(startDateFrmReq);
				endTime=dateFormatMMDD.format(endDateFrmReq);
			}
			catch(Exception ex)
			{
				ex.printStackTrace();
			}
		}

		String  ddTitle="";
		String  s_ddinivalue = egDashboard.getDDMeasures(subject, tab, subsystem);
		boolean isTestConfigured=true;
		if((s_ddinivalue== null || s_ddinivalue.trim().equals("")) && (subsystem!=null && !subsystem.equalsIgnoreCase("memory")))
		{
			isTestConfigured=false;
		}
		Vector vec_ddtestmeasure=new Vector();
		ArrayList defaultTestsForserver = egDashboard.getDefaultTestsForServer(compType);
		if(isNetworkTab)
		{
			StringTokenizer stkDDTestMeasures=new StringTokenizer(s_ddinivalue,",");
			while(stkDDTestMeasures.hasMoreTokens())
			{
				String DDTestMeasures=stkDDTestMeasures.nextToken();
				String ddTestName=DDTestMeasures.substring(0,DDTestMeasures.indexOf(":"));
				
				//disable
				if(defaultTestsForserver != null && defaultTestsForserver.contains(ddTestName)){
					vec_ddtestmeasure.add(DDTestMeasures);
				}
				/**if(specsInfo.isTestRelevantForServer(compType,ddTestName))
				{
					vec_ddtestmeasure.add(DDTestMeasures);
				}**/
				
			}
		}
		else
		{
			vec_ddtestmeasure=egDashboard.getTokensAsVector(s_ddinivalue,",");
		}
		if(startenddates!=null && !startenddates.equals("") && startenddates.indexOf("|")>0)
		{
			String start_Date=startenddates.substring(0,startenddates.indexOf("|"));
			String end_Date=startenddates.substring(startenddates.indexOf("|")+1);
			startDate=new java.util.Date(start_Date);
			endDate=new java.util.Date(end_Date);
			startTime=sf.format(startDate);
			endTime=sf.format(endDate);
		}
		int i=0;
		int ddNoMeasuresGraphCount=0;
		JSONArray chartArr = new JSONArray();
		TreeMap linksMap = new TreeMap();
		int cnt=0;
		int ddMeasuresCnt = 0;
		
		for(i=0;i<vec_ddtestmeasure.size();i++)
		{
			JSONObject chartObj = new JSONObject();
			String info="";
			String s_singleDDtestmeasure=(String)vec_ddtestmeasure.get(i);
			String test = s_singleDDtestmeasure.substring(0, s_singleDDtestmeasure.indexOf(":"));
				

			boolean isExcludedTest = egDashboard.isExcludedComponentForTest(compType, compName, test);
			if(isExcludedTest || (enabledTests != null && !enabledTests.contains(test))) {
				continue;
			} else {
				ddMeasuresCnt++; 
			}
			if(s_singleDDtestmeasure!=null && s_singleDDtestmeasure.indexOf("Format:")!=-1)
			{
				endDate=new java.util.Date();

				String s_test=s_singleDDtestmeasure.substring(0,s_singleDDtestmeasure.indexOf(":"));
				String s_measure=s_singleDDtestmeasure.substring(s_singleDDtestmeasure.indexOf(":")+1,s_singleDDtestmeasure.indexOf("#"));
				String unit_for_measure=tablesInfo.getUnitForMeasure(s_test,s_measure);
				String format=s_singleDDtestmeasure.substring(s_singleDDtestmeasure.indexOf("#")+1,s_singleDDtestmeasure.length());

				if(s_singleDDtestmeasure.equals("OSMemoryTest:Physical_mem_utilze#Format:ARGS %MEM"))
				{
					s_singleDDtestmeasure="SystemTest:Free_memory#Format:ARGS %UTIL";
					s_test="SystemTest";
					s_measure="Free_memory";
					format="Format:ARGS %UTIL";
					unit_for_measure=tablesInfo.getUnitForMeasure(s_test,s_measure);
				}
				/*else
				{
					ddNoMeasuresGraphCount++;
					continue;
				}*/		

				testsEnabled=true;

				String msmtHost=(String)allMsmtHosts.get(s_test);
				if(msmtHost==null)
					msmtHost="";
				Vector allInfos=(Vector)allTestInfos.get(s_test);
				String desc="*";
				if(allInfos!=null && allInfos.size()>0)
				{
					if(allInfos.contains("+Summary"))
					{
							desc="+Summary";
					}
					else
					{
						desc=(String)allInfos.get(0);
					}
				}
				String infoForLastDDMsmtTime=desc;
				if(formatInfo.isDDDTest(s_test))
				{
					String ddWithoutInfo = formatIni.getValue("Tests_For_DDWithoutInfos", s_test + ":" + s_measure);
					if(ddWithoutInfo!=null && ddWithoutInfo.equalsIgnoreCase("yes"))
					{
						infoForLastDDMsmtTime = "+";
					}
				}

				String s_lastMsmtTime=measureGraph.getLastRuntimeForDDTest(s_test,s_measure,hostName,portNo,"NULL",infoForLastDDMsmtTime,msmtHost);
				/*if (EgInstallInfo.isSuperManager && s_lastMsmtTime != null && s_lastMsmtTime.trim().length()>0)
				{
					TimeZoneUtil timeZoneUtil = new TimeZoneUtil();
					ArrayList mgrList = EgThreadLocal.getManagerList();
					String mgrId = "";
					if (mgrList != null && !mgrList.isEmpty())
					{
						mgrId = (String)mgrList.get(0);
					}
					EgManagersInfo mgrInfo = EgManagersInfo.getInstance();
					com.egurkha.EgManager mgr = (EgManager)mgrInfo.getReportingManagers().get(mgrId);
					String managerTimeZone = mgr.getTimeZoneId();
					if(managerTimeZone != null && !managerTimeZone.equals(EgInstallInfo.timeZoneId))
					{
						s_lastMsmtTime = timeZoneUtil.convertTimeZone(s_lastMsmtTime,"yyyy-MM-dd HH:mm:ss",managerTimeZone ,EgInstallInfo.timeZoneId);
					}
				}*/

				java.util.Date lastMsmtTime=new java.util.Date();
				if(s_lastMsmtTime!=null && !s_lastMsmtTime.trim().equals(""))
					lastMsmtTime=testTableDateFmt.parse(s_lastMsmtTime);
				else
					s_lastMsmtTime=testTableDateFmt.format(lastMsmtTime);
				String startTimeforDD=sf.format(lastMsmtTime);
				String endTimeforDD=sf.format(lastMsmtTime);
				String s_timeonly=s_lastMsmtTime.substring(s_lastMsmtTime.indexOf(" ")+1);
				Vector vec_times=egDashboard.getTokensAsVector(s_timeonly,":");

				startHour=(String)vec_times.get(0);
				endHour=(String)vec_times.get(0);
				startMin=(String)vec_times.get(1);
				endMin=(String)vec_times.get(1);

				int i_endMin=Integer.parseInt(endMin);
				if(i_endMin==59)
				{
					i_endMin=0;
					endHour=(Integer.parseInt(endHour)+1)+"";
				}
				else
				{
					i_endMin++;
				}
				endMin=i_endMin+"";

				startSec=(String)vec_times.get(2);
				endSec=(String)vec_times.get(2);


				ddTitle=iniObj.getValue("Dashboard_ComparisonGraph_Mapping",s_singleDDtestmeasure);
				Vector Infos=(Vector)allTestInfos.get(s_test);

				String ddinfo="";
				if(Infos!=null && Infos.size()>0)
				{
					if(s_test.equals("SystemTest") && Infos.contains("+Summary"))
					{
						ddinfo="+Summary";
					}
					else
					{
						ddinfo=(String)Infos.get(0);
					}
				}
				String dd_info = ddinfo;
				dd_info=com.egurkha.util.StringUtils.replace(dd_info,"+","*");
				ddinfo=com.egurkha.util.StringUtils.replace(ddinfo,"+","");

				String ddGraphUrlLarge="";
				String ddGraphUrl="";
				String dddataurl="";

				String s_layer=dashboardDAO.getLayerForTest(compType,s_test,s_measure);

				dddataurl=response.encodeURL("/final/monitor/componentMeasureTabSet.jsp?")+"fromPage=current&site=NULL&comptype=Host_system"+"&host="+hostName+"&port="+portNo+"&layer=HOST&test="+s_test+"&stest="+s_test+"-*"+ddinfo+"&info=*"+ddinfo+"&msmt_host="+msmtHost+"&time=Any&timeline=Any&measure="+s_measure+"&from=0&firsttime=true&flag=1&fromDDGraphs=true&newWindow=true&comeFrom=dashboard&ddTitle="+com.egurkha.util.StringUtils.replace(ddTitle,"%","|pct|")+"&starttime="+startTime+"&starthr="+startHour+"&endtime="+endTime+"&endhr="+endHour+"&startmin="+startMin+"&endmin="+endMin+"&module="+tab+"&clicked=dd&messy="+s_measure;
				
				String compddLink = "/final/monitor/EgDiagnosis.jsp?site=NULL&host="+hostName+"&port="+portNo+"&test="+s_test+ "&info="+EgURLEncoder.encode(dd_info,"UTF-8")+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&from=0&measure="+s_measure+"&flag=1&firsttime=true";					
				String measureForDB=dbInfo.getColumnForMeasure(s_test,s_measure);
				String aggregateLink="../monitor/dispAggComponentGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNo + "&layer=" +EgURLEncoder.encode(s_layer,"UTF-8")+ "&test=" + s_test + "&comptype="+EgURLEncoder.encode(compType,"UTF-8") + "&info="+EgURLEncoder.encode(dd_info,"UTF-8")+ "&gtype=1&measure="+measureForDB+ "&msmt_host="+	EgURLEncoder.encode(msmtHost,"UTF-8")+"&state="+state;				
				
				
				String  graphLink = "/final/monitor/dispComponentGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNo+"&layer="+EgURLEncoder.encode(s_layer,"UTF-8")+"&test="+s_test+"&comptype="+EgURLEncoder.encode(compType,"UTF-8") + "&info="+EgURLEncoder.encode(dd_info,"UTF-8")+ "&gtype=1&measure="+measureForDB+ "&msmt_host="+	EgURLEncoder.encode(msmtHost,"UTF-8")+"&state="+state;				

				String summarygraphLink = "/final/monitor/dispComponentSummaryGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNo + "&layer=" +EgURLEncoder.encode(s_layer,"UTF-8")+ "&test=" + s_test + "&comptype="+EgURLEncoder.encode(compType,"UTF-8") + "&info="+EgURLEncoder.encode(dd_info,"UTF-8")+ "&gtype=1&measure="+measureForDB+ "&msmt_host="+	EgURLEncoder.encode(msmtHost,"UTF-8")+"&state="+state;

				String trendgraphLink = "../monitor/dispComponentTrendGraphs.jsp?site=NULL&host=" +EgURLEncoder.encode(hostName,"UTF-8")+ "&port=" + portNo + "&layer=" +EgURLEncoder.encode(s_layer,"UTF-8")+ "&test=" + s_test + "&comptype="+EgURLEncoder.encode(compType,"UTF-8") + "&info="+EgURLEncoder.encode(dd_info,"UTF-8")+ "&gtype=1&measure="+measureForDB+ "&msmt_host="+	EgURLEncoder.encode(msmtHost,"UTF-8")+"&state="+state;
				
				String server = msmtHost+":"+portNo;
				String historyLink ="../monitor/dispComponentHistory.jsp?site=NULL&info=" + EgURLEncoder.encode(dd_info,"UTF-8") + "&test=" + s_test + "&component=" +EgURLEncoder.encode(server+":"+compType,"UTF-8")+"&measure="+s_measure;

				String portForMsmtTime="NULL";
				String port_number = portNo;
				if(!specsInfo.isPortRelevantForTest(s_test))
				{
					port_number = "NULL";
				}
				String key=hostName+":"+port_number+":"+s_test+":"+msmtHost;
				String msmtTimeStr=dashboardDAO.getMeasureLastMsmtTime(key,dd_info);
				String msmtTimeStr2="";
				try
				{
					if(msmtTimeStr!="" && msmtTimeStr!=null)
					{
						SimpleDateFormat df=new SimpleDateFormat("MM/dd/yyyy*HH:mm:ss");
						SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
						java.util.Date msd=sdf2.parse(msmtTimeStr);
						msmtTimeStr2 =df.format(msd);
					}
				}
				catch(Exception eexx)
				{
					eexx.printStackTrace();
				}
				String feedLink="/final/monitor/dispComponentFeedback.jsp?site=NULL&trgthost="+EgURLEncoder.encode(hostName,"UTF-8")+"&port="+portNo+"&test="+s_test+"&comptype="+EgURLEncoder.encode(compType,"UTF-8");

				String feedbackLink =  feedLink+"&info="+EgURLEncoder.encode(dd_info,"UTF-8")+ "&measure="+s_measure+ "&msmttime="+msmtTimeStr2 +"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8");
				
				//linksMap.put(s_test+"#"+s_measure+"#"+dd_info+"#"+msmtHost+"compddlink", compddLink);
				linksMap.put(s_measure+"compddlink", compddLink);

				linksMap.put(s_measure+"aggregateLink", aggregateLink);

				linksMap.put(s_measure+"compgraphlink", graphLink);

				linksMap.put(s_measure+"compsummarygraphlink", summarygraphLink);

				linksMap.put(s_measure+"comptrendgraphlink", trendgraphLink);

				linksMap.put(s_measure+"comphistorylink", historyLink);

				linksMap.put(s_measure+"compfeedbacklink", feedbackLink);

				session.setAttribute("linksMap", linksMap);
				ddGraphUrl="/final/servlet/com.egurkha.monitor.EgDDTopview?host="+compName+"&compType="+compType+"&test="+s_test+"&measure="+s_measure+"&format="+EgURLEncoder.encode(format,"UTF-8")+"&module="+tab+"&width=301&height=183&endtime="+EgURLEncoder.encode(endTime,"UTF-8")+"&starthr="+startHour+"&endhr="+endHour+"&starttime="+startTime+"&monitorSkin="+monitor_Skin+"&mode=3D&startmin="+startMin+"&endmin="+endMin+"&startsec="+startSec+"&endsec="+endSec+"&timeline_compare="+ddtimeline+"&priority="+priority;

				String encodedFormat=com.egurkha.util.StringUtils.replace(format,"%","|pct|");
				ddGraphUrlLarge="/final/servlet/com.egurkha.monitor.EgDashboardBarchart?host="+EgURLEncoder.encode(compName,"UTF-8")+"&compType="+compType+"&test="+s_test+"&measure="+s_measure+"&format="+encodedFormat+"&module="+tab+"&width=880&height=320&from=fullview&endtime="+endTimeforDD+"&starthr="+startHour+"&endhr="+endHour+"&starttime="+startTimeforDD+"&startMin="+startDate.getMinutes()+"&endMin="+endDate.getMinutes()+"&mode=3D&&timeline_compare="+ddtimeline+"&monitorSkin="+monitor_Skin+"&showDDData=true&fullview=true&priority="+FullViewPriority+"&isInfoRelevantMeasureGraph=true&display=false&fromHist=true&fromChart=DDGraph";

				vTitlemsmtHost=(String)allMsmtHosts.get(s_test);

				Vector ddChartAttribute=new Vector();
				//ddChartAttribute.add("caption='"+EgURLEncoder.encode(ddTitle,"UTF-8")+"'");
				ddChartAttribute.add("caption='"+ddTitle+"'");
				ddChartAttribute.add("palette='2'");
				ddChartAttribute.add("showValues='1'");
				ddChartAttribute.add("showLabels='1'");
				ddChartAttribute.add("showYAxisValues='0'");
				ddChartAttribute.add("decimals='4'");
				ddChartAttribute.add("formatNumberScale='0'");
				ddChartAttribute.add("useRoundEdges='1'");
				ddChartAttribute.add("exportTargetWindow='1'");
				ddChartAttribute.add("clickURL='javascript:ddOnclick(&apos;ddBar"+i+"&apos;);setDDDataURL(&apos;"+EgURLEncoder.encode(dddataurl,"UTF-8")+"&apos;)'");				
				//ddChartAttribute.add("clickURL='javascript:ddOnclick(&apos;ddBar"+i+"&apos;)'");	
				ddChartAttribute.add("exportEnabled='0'");
				ddChartAttribute.add("exportAction='download'");
				ddChartAttribute.add("exportAtClient='0'");
				ddChartAttribute.add("exportHandler='/final/FusionCharts/jsp/FCExporter.jsp'");
				ddChartAttribute.add("bgColor='ffffff'");
				ddChartAttribute.add("borderAlpha='100'");
				ddChartAttribute.add("showToolTipShadow='1'");
				ddChartAttribute.add("chartLeftMargin='8'");
				ddChartAttribute.add("chartRightMargin='8'");
				ddChartAttribute.add("chartTopMargin='8'");
				ddChartAttribute.add("chartBottomMargin='8'");
				ddChartAttribute.add("canvasBorderColor  ='000000'");
				ddChartAttribute.add("canvasBorderThickness  ='0'");
				ddChartAttribute.add("plotSpacePercent  ='40'");
				ddChartAttribute.add("baseFont='"+fontForLanguage+"'");
			//	
				if(!isNonEnglishLanguage)
				{
					ddChartAttribute.add("outCnvBaseFontSize='"+fontSize+"'");
					ddChartAttribute.add("outCnvBaseFontColor ='000000'");
				}

				ddChartAttribute.add("showBorder ='0'");
				ddChartAttribute.add("adjustDiv='1'");
				ddChartAttribute.add("yAxisValueDecimals='2'");
				ddChartAttribute.add("placeValuesInside='0'");

			/*	if(endHour.equals(startHour))
				{
					if(!startHour.equals("00"))
						startHour  = String.valueOf((Integer.parseInt(startHour) - 1));

				}*/
				//endMin = startMin;
				if(ddTitle==null || ddTitle.equals(""))
				{
					ddTitle=mappingInfo.getMeasureDescription(s_test,s_measure);
				}
				else
				{
					ddTitle = mappingInfo.getTextDescription("monitor.dashboard."+ddTitle);
				}
				String ddXMLData=graphUtil.getXMLforDD(tab,compName,compType,s_test,s_measure,startTime,startHour,startMin,endTime,endHour,endMin,format,null,false,defaultTopNPriority,ddChartAttribute,ddTitle);

				//ddXMLData=com.egurkha.util.StringUtils.replace(ddXMLData,"\"","");				
				if(ddEnabled && ddXMLData!=null && ddXMLData.trim().length()>0)
				{
					chartObj.put("SWF_PATH", "/final/FusionCharts/swf/Bar2D.swf");
					chartObj.put("XML_DATA", ddXMLData);
					chartObj.put("WIDTH", ddGraphWidth);
					chartObj.put("HEIGHT", ddGraphHeight);
					chartObj.put("ddBar"+i, ddGraphUrlLarge);
					chartObj.put("ddGraphUrlLarge", ddGraphUrlLarge+"~"+dddataurl);
					hiddens.put("ddBar"+i, ddGraphUrlLarge);					
				}
				else
				{
					ddNoMeasuresGraphCount++;
				}				
			}
			else
			{
				String s_test=s_singleDDtestmeasure.substring(0,s_singleDDtestmeasure.indexOf(":"));
				String s_measure=s_singleDDtestmeasure.substring(s_singleDDtestmeasure.indexOf(":")+1);

				/*if(enabledTests!=null && !enabledTests.contains(s_test))
				{
					ddNoMeasuresGraphCount++;
					continue;
				}*/

				testsEnabled=true;

				String measureMapping=iniObj.getValue("Dashboard_ComparisonGraph_Mapping",s_singleDDtestmeasure);
				if(measureMapping==null || measureMapping.equals(""))
				{
					measureMapping=mappingInfo.getMeasureDescription(s_test,s_measure);
				}
				else
				{
					measureMapping = mappingInfo.getTextDescription("monitor.dashboard."+measureMapping);
				}

				unit=tablesInfo.getUnitForMeasure(s_test,s_measure);
				//String ddGraphUrlLarge=response.encodeURL("/final/servlet/com.egurkha.monitor.EgDashboardBarchart?")+"host="+EgURLEncoder.encode(compName,"UTF-8")+"&compType="+compType+"&width=301&height=183&monitorSkin="+monitor_Skin+"&mode=3D&graphdisplay=defaultView&test="+s_test+"&testmeasure="+s_singleDDtestmeasure+"&minmaxavgRequired=false&timeline_compare="+ddtimeline+"&priority="+FullViewPriority+"&isInfoRelevantMeasureGraph=true&starttime="+startTime+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&subsystem="+subsystem+"&graphType="+graphType+"&display=false&fromHist=true&module="+tab;

				String ddGraphUrlLarge=response.encodeURL("/final/servlet/com.egurkha.monitor.EgDashboardBarchart?")+"host="+EgURLEncoder.encode(compName,"UTF-8")+"&compType="+compType+"&width=301&height=183&monitorSkin="+monitor_Skin+"&mode=3D&graphdisplay=defaultView&test="+s_test+"&testmeasure="+s_singleDDtestmeasure+"&minmaxavgRequired=false&timeline_compare="+ddtimeline+"&priority="+FullViewPriority+"&isInfoRelevantMeasureGraph=true&starttime="+startTime+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&startMin="+startDate.getMinutes()+"&endMin="+endDate.getMinutes()+"&subsystem="+subsystem+"&display=false&fromHist=true&fromChart=ComparisonGraph&module="+tab;

				Vector comparionChartAttribute=new Vector();
				//comparionChartAttribute.add("caption='"+EgURLEncoder.encode(measureMapping+"("+unit+")","UTF-8")+"'");
				String unitMapping = graphUtil.getUnitMapping(unit);
				comparionChartAttribute.add("caption='"+measureMapping+" ("+unitMapping+")"+"'");
				comparionChartAttribute.add("palette='2'");
				comparionChartAttribute.add("showValues='1'");
				comparionChartAttribute.add("showLabels='1'");
				comparionChartAttribute.add("showYAxisValues='0'");
				comparionChartAttribute.add("formatNumberScale='0'");
				comparionChartAttribute.add("useRoundEdges='1'");
				//comparionChartAttribute.add("clickURL='javascript:comparisionBarOnclick(&apos;bar"+i+"&apos;)'");	
				comparionChartAttribute.add("clickURL='javascript:comparisionBarOnclick(&apos;bar"+i+"&apos;)'");	
				comparionChartAttribute.add("bgColor='ffffff'");
				comparionChartAttribute.add("showToolTipShadow='1'");
				comparionChartAttribute.add("chartLeftMargin='8'");
				comparionChartAttribute.add("chartRightMargin='8'");
				comparionChartAttribute.add("chartTopMargin='8'");
				comparionChartAttribute.add("chartBottomMargin='8'");
				comparionChartAttribute.add("exportEnabled='0'");
				comparionChartAttribute.add("exportAction='download'");
				comparionChartAttribute.add("exportAtClient='0'");
				comparionChartAttribute.add("exportHandler='/final/FusionCharts/jsp/FCExporter.jsp'");
			//	comparionChartAttribute.add("outCnvBaseFontSize='"+fontSize+"'");
				if(!isNonEnglishLanguage)
				{
					comparionChartAttribute.add("outCnvBaseFontSize='"+fontSize+"'");
					comparionChartAttribute.add("outCnvBaseFontColor ='000000'");
				}
				comparionChartAttribute.add("showBorder ='0'");
				comparionChartAttribute.add("canvasBorderColor  ='000000'");
				comparionChartAttribute.add("plotSpacePercent  ='40'");
				comparionChartAttribute.add("baseFont  ='"+fontForLanguage+"'");
				comparionChartAttribute.add("adjustDiv='1'");
				comparionChartAttribute.add("yAxisValueDecimals='2'");
				if(graphType.equals("DDgraph")&& (compType.equals("Java_virtual_machine")&& subsystem.equals("JVM Memory")))
				{
					comparionChartAttribute.add("decimals='2'");
				}
				else
				{
					comparionChartAttribute.add("decimals='4'");
				}
				comparionChartAttribute.add("placeValuesInside='0'");
				String port_no=portNo;	
				if(compType!=null && compType.equals("Oracle_server"))
				{
					if(specsInfo.isPortRelevantForTest(s_test))
					{
						if(sid!=null && !sid.equals(""))
						{
								port_no=portNo+":"+sid;
								
						}
					}
				}
				String xmlData=graphUtil.getXMLForComparision(compType,hostName,port_no,s_singleDDtestmeasure,defaultTopNPriority,isDDFromFirstMsmt,comparionChartAttribute,measureMapping+" ("+unitMapping+")");
				boolean isTestHas_CutOffFactor=true;
				String msmtForCutOffFactor="";
				Vector infos=dashboardDAO.getDescriptorsForTest(compName,compType,s_test,tab);
				String tempCompName=compName.substring(0,compName.indexOf(":"));
				String portForMsmt=compName.substring(compName.indexOf(":")+1);
				Vector msmt_host=dashboardDAO.getMsmtHost(tempCompName,compType,s_test,port_no);
				if(msmt_host!=null && !msmt_host.isEmpty())
					msmtForCutOffFactor=(String)msmt_host.get(0);
				if(UseCutOffFactor!=null && !UseCutOffFactor.equals("") && UseCutOffFactor.equalsIgnoreCase("Yes"))
				{
					if(egDashboard.isTestHasCutOffFactor(s_test))
					{
						if(infos!=null && !infos.isEmpty())
						{
							for(int d=0;d<infos.size();d++)
							{
								boolean isTestExceededCutOffFactor=dashboardDAO.isTestExceededCutOffFactor(compType,tempCompName,portNo,sid,s_test,msmtForCutOffFactor,(String)infos.get(d));
								if(!isTestExceededCutOffFactor)
									isTestHas_CutOffFactor=false;
							}
						}
					}
				}				
				if(xmlData!=null && xmlData.trim().length()>0 && !isTestHas_CutOffFactor)
				{
					chartObj.put("SWF_PATH", "/final/FusionCharts/swf/Bar2D.swf");
					chartObj.put("XML_DATA", xmlData);
					chartObj.put("WIDTH", ddGraphWidth);
					chartObj.put("HEIGHT", ddGraphHeight);
					chartObj.put("ddGraphUrlLarge", ddGraphUrlLarge);
					hiddens.put("bar"+i, ddGraphUrlLarge);
				}
				else
				{
					ddNoMeasuresGraphCount++;
				}
				
			}
			if ( !chartObj.isEmpty() )
			{
				chartArr.add(chartObj);
			}
			cnt++;
		}
		if(!chartArr.isEmpty())
		{
			rootJson.put("CHARTS", chartArr);
		}
		boolean isDDOverviewDataAvailable=false;
		boolean isDDTestRelevantForServer=false;
		if(isNetworkTab)// && !isOverview)
		{
			String s_singleDDtestmeasure=iniObj.getValue(subject,"Network_HopDelays");
			if(s_singleDDtestmeasure!=null && s_singleDDtestmeasure.indexOf(":")>0)
			{
				ddtest=s_singleDDtestmeasure.substring(0,s_singleDDtestmeasure.indexOf(":"));	ddmeasure=s_singleDDtestmeasure.substring(s_singleDDtestmeasure.indexOf(":")+1,s_singleDDtestmeasure.indexOf("#"));ddformat=s_singleDDtestmeasure.substring(s_singleDDtestmeasure.indexOf("#")+1,s_singleDDtestmeasure.length());
				isDDTestRelevantForServer=specsInfo.isTestRelevantForServer(compType,ddtest);
				ddTitle=iniObj.getValue("Dashboard_ComparisonGraph_Mapping",s_singleDDtestmeasure);
				dataTitle=ddTitle;
				graphTitle=ddTitle;
				unit=tablesInfo.getUnitForMeasure(ddtest,ddmeasure);
			}
		}
		//if(subsystem!=null && !isOverview && subsystem.equalsIgnoreCase("Network") && runingTestList!=null && ddtest!=null && runingTestList.size()>0 && runingTestList.contains(ddtest))
		if(subsystem!=null  && runingTestList!=null && ddtest!=null && runingTestList.size()>0 && runingTestList.contains(ddtest))
		{
			isDDOverviewDataAvailable=true;
			Hashtable analysisData=new Hashtable();
			EgDDOverview  ddoverview=new  EgDDOverview();
			String msmtHst=(String)allMsmtHosts.get(ddtest);
			analysisData=ddoverview.getDDAnalysisData(compName,compType,ddtest,ddmeasure,ddformat,"Network","","","","","","","",msmtHst);
			testsEnabled=true;

			JSONObject detailsHopObj = new JSONObject();
			JSONArray detailHopArr = new JSONArray();

			detailsHopObj.put("TABLETITLE",mappingInfo.getTextDescription("monitor.dashboard."+dataTitle));
			detailsHopObj.put("TYPE","TABLE");					

			Hashtable graphParams=new Hashtable();
			if(analysisData!=null && analysisData.size()>0)
			{
				int topcnt=0;	
				detailsHopObj.put("Msg","false");
				detailsHopObj.put("COLUMN_0",mappingInfo.getTextDescription("monitor.dashboard.Router"));	
				detailsHopObj.put("COLUMN_1",mappingInfo.getTextDescription("monitor.common.Min"));	
				detailsHopObj.put("COLUMN_2",mappingInfo.getTextDescription("monitor.common.Max"));	
				detailsHopObj.put("COLUMN_3",mappingInfo.getTextDescription("monitor.common.Avg"));	
				detailsHopObj.put("COLUMN_4",mappingInfo.getTextDescription("monitor.common.Hop Delay"));			

					Vector top=ddoverview.getTopValues();				
					Iterator itr=top.iterator();
					while(itr.hasNext())
					{
						String key=(String)itr.next();
						Vector  analysis=(Vector)analysisData.get(key);
						if(analysis!=null)
						{

							Vector graphValues=(Vector)analysis.get(0);					
							Vector graphData=(Vector)analysis.get(1);
							graphParams.put(key,graphValues);
							if(topcnt==10)
								break;

					detailsHopObj.put("COLUMN_0_val",key);					

					if(graphValues!=null && graphValues.size()>2)
					{
						detailsHopObj.put("COLUMN_1_val",(String)graphValues.get(0));	
						detailsHopObj.put("COLUMN_2_val",(String)graphValues.get(1));	
						detailsHopObj.put("COLUMN_3_val",(String)graphValues.get(2));	

							}
							else
							{
								detailsHopObj.put("COLUMN_1_val","-");	
								detailsHopObj.put("COLUMN_2_val","-");	
								detailsHopObj.put("COLUMN_3_val","-");	
							}
							detailsHopObj.put("COLUMN_4_class","hop");
							detailsHopObj.put("COLUMN_4_val_0",(String)graphData.get(0));
							detailsHopObj.put("COLUMN_4_val_1",(String)graphData.get(1));
							detailsHopObj.put("COLUMN_4_val_2",(String)graphData.get(2));
							topcnt++;	
						}
					}				
				}
				else
				{
					detailsHopObj.put("Msg","true");
					detailsHopObj.put("noMsg",mappingInfo.getTextDescription("monitor.common.No detailed measures available")+"!");				
				}
				detailHopArr.add(detailsHopObj);
				rootJson.put("detailHopArr",detailHopArr);

		}
		EgDDOverview  ddoverview=new  EgDDOverview();

		String ddoverviewurl="";
		String fullimageURI="";
		String imageURI="";
		if(subsystem!=null && subsystem.equals("CPU"))
		{
			ddtest="SystemTest";
			ddmeasure="Cpu_util";
			ddformat="%CPU";
			dataTitle=mappingInfo.getTextDescription("monitor.dashboard.Top CPU Consuming Processes - Data view");
			graphTitle=mappingInfo.getTextDescription("monitor.dashboard.Top CPU Consuming Processes - Graph view");
			unit=" (%)";
		}
		if(subsystem!=null && subsystem.equals("Memory"))
		{
			ddtest="OSMemoryTest";
			ddmeasure="Physical_mem_utilze";
			ddformat="%MEM";
			/*if(enabledTests!=null && !enabledTests.contains(ddtest))
			{
				ddtest="SystemTest";
				ddmeasure="Free_memory";
				ddformat="%MEM";
			}*/
			dataTitle=mappingInfo.getTextDescription("monitor.dashboard.Top Memory usage processes - Data view");
			graphTitle=mappingInfo.getTextDescription("monitor.dashboard.Top Memory usage processes - Graph view");
			unit=" (%)";
		}
		if(subsystem!=null && subsystem.equals("Disk"))
		{
			ddtest="DiskActivityTest";
			ddmeasure="Percent_busy";
			ddformat="IO_Rate(KB/sec)";
			dataTitle=mappingInfo.getTextDescription("monitor.dashboard.Top Disk activity processes - Data view");
			graphTitle=mappingInfo.getTextDescription("monitor.dashboard.Top Disk Busy Processes - Graph view");
			unit=" (KB/sec)";
		}
		if(runingTestList.size()>0)
			isRuningTest= runingTestList.contains(ddtest);
		Hashtable analysisData=ddoverview.getDDAnalysisData(compName,compType,ddtest,ddmeasure,ddformat,tab,"","","","","","","",vTitlemsmtHost);

	
		if((subsystem!=null) && (subsystem.equalsIgnoreCase("cpu") || subsystem.equalsIgnoreCase("memory") || subsystem.equalsIgnoreCase("disk")))
		{
			JSONObject disksumObj = new JSONObject();
			JSONArray disksumArr = new JSONArray();
			JSONArray colArr = new JSONArray();
			testsEnabled=true;
			isDDOverviewDataAvailable=true;

			String defaultMGraphDuration=iniObj.getValue("Default_DD_Duration","duration");
			if(defaultMGraphDuration!=null && !defaultMGraphDuration.equals(""))
			{
				times=egDashboard.getStartEndDateTimeForMeasure(defaultMGraphDuration);
				if(times!=null && times.size()>=4)
				{
					startTime=(String)times.get(0);
					endTime=(String)times.get(1);
					startHour=(String)times.get(2);
					endHour=(String)times.get(3);
				}
			}
			disksumObj.put("TITLE",dataTitle+" - "+defaultMGraphDuration);
			Hashtable graphParams=new Hashtable();
			if(analysisData!=null && analysisData.size()>0)
			{
				JSONObject sumCol=new JSONObject();
				disksumObj.put("SUMMARY","true");
				int topcnt=0;
				String knownFileTypes=iniTests.getValue("AGENT_SETTINGS","KnownFileTypes");
				Vector knownFileExtensions=egDashboard.getTokensAsVector(knownFileTypes,",");
				if(knownFileExtensions!=null)
					knownFileExtensions.add(".EXE");
				String fileExtension="";
				sumCol.put("COLUMNNAM_0",mappingInfo.getTextDescription("monitor.dashboard.Process"));
				String unitMapping = graphUtil.getUnitMapping(unit);
				sumCol.put("COLUMNNAM_1",mappingInfo.getTextDescription("monitor.common.Min")+unitMapping);
				sumCol.put("COLUMNNAM_2",mappingInfo.getTextDescription("monitor.common.Max")+unitMapping);
				sumCol.put("COLUMNNAM_3",mappingInfo.getTextDescription("monitor.common.Avg")+unitMapping);
				disksumArr.add(sumCol);
				Vector top=ddoverview.getTopValues();
				Iterator itr=top.iterator();
				while(itr.hasNext())
				{	
					String key=(String)itr.next();
					Vector  analysis=(Vector)analysisData.get(key);
					if(analysis==null)
					{
						continue;
					}
					Vector graphValues=(Vector)analysis.get(0);
					Vector graphData=(Vector)analysis.get(1);
					graphParams.put(key,graphValues);

					if(topcnt==10)
						break;
					String keyTitle=key;

					String tmpStr=key;
					if(tmpStr!=null &&  (tmpStr.lastIndexOf(".")!=-1 && tmpStr.length()>=(tmpStr.lastIndexOf(".")+4)))
						fileExtension=tmpStr.substring(tmpStr.lastIndexOf("."),tmpStr.lastIndexOf(".")+4);
					if(tmpStr!=null && tmpStr.lastIndexOf(".")!=-1 && fusionChart.isStringContainsAlphabet(tmpStr) && (knownFileExtensions!=null && knownFileExtensions.contains(fileExtension)))
					{
						if(tmpStr.lastIndexOf("\\")>tmpStr.lastIndexOf(fileExtension))
						{
							tmpStr=tmpStr.substring(0,tmpStr.lastIndexOf(fileExtension));
							tmpStr=tmpStr.substring(tmpStr.lastIndexOf("\\")+1,tmpStr.length());
							// If the key like this "\\.\str" ,then the tmpstr will return empty string. the followinn code used to avoid this situation.
							if(tmpStr.trim().equals(""))
							{
								tmpStr=key.substring(key.lastIndexOf("\\")+1,key.length());
							}
						}
						else
						{
							tmpStr=tmpStr.substring(tmpStr.lastIndexOf("\\")+1,tmpStr.lastIndexOf("."));
						}
					}
					else if(tmpStr!=null && tmpStr.indexOf(" -")!=-1 &&  (tmpStr.lastIndexOf("\\")!=-1 || tmpStr.lastIndexOf("/")!=-1))
					{
							tmpStr=tmpStr.substring(0,tmpStr.indexOf(" -"));
							if(tmpStr.lastIndexOf("\\")!=-1)
								tmpStr=tmpStr.substring(tmpStr.lastIndexOf("\\")+1,tmpStr.length());
					else if(tmpStr.lastIndexOf("/")!=-1)
								tmpStr=tmpStr.substring(tmpStr.lastIndexOf("/")+1,tmpStr.length());
					}
					else if(tmpStr!=null && tmpStr.lastIndexOf("/")!=-1)
					{
						tmpStr=tmpStr.substring(tmpStr.lastIndexOf("/")+1,tmpStr.length());
					}
						if(tmpStr!=null && tmpStr.length()>15)
					{
						if(compType.equals("Java_virtual_machine") && ddtest.equals("JvmThreadTest"))
						{
								tmpStr=tmpStr;//.substring(0,12)+"...";
						}
						else
					{
						tmpStr=tmpStr;//"..."+tmpStr.substring(tmpStr.length()-12,tmpStr.length());
						}
					}

					key=tmpStr;
					JSONObject colObj=new JSONObject();
					colObj.put("COLUMN_0",key);
					colObj.put("COLUMN_1",(String)graphData.get(0));
					colObj.put("COLUMN_2",(String)graphData.get(1));
					colObj.put("COLUMN_3",(String)graphData.get(2));

					topcnt++;
					colArr.add(colObj);	
					
				}
				disksumObj.put("COULUMN_NAME",sumCol);
				disksumObj.put("COULUMN_VALUE",colArr);
				//disksumArr.add(colArr);
				//disksumArr.add(disksumObj);
			}
			else
			{
				disksumObj.put("SUMMARY","-");
				disksumObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No detailed measures available")+"!");
			}
			rootJson.put("DISK_SUMMARY", disksumObj);
			
			double defaultDDlineChartWidth=536;
			double defaultDDlineChartHeight=226;
			double defaultTopNTablewidth=370;
			String ddLineChartWitdh="536";
			String ddLineChartHeight="226";
			String ddLineChartDivWidth="536";
			if(screenWidthInDouble>0)
			{
				double ddLineWidthInPercentTo1024Px=defaultDDlineChartWidth/1024;
				double ddLineWidthInDouble=(screenWidthInDouble*(ddLineWidthInPercentTo1024Px+(defaultTopNTablewidth/1024))-defaultTopNTablewidth);
				ddLineChartWitdh=erutils.round(ddLineWidthInDouble,0);
				ddLineChartDivWidth=erutils.round((ddLineWidthInDouble+50),0);
				double ddLineHeightInPercent=defaultDDlineChartHeight/defaultDDlineChartWidth;
				double ddLineHeightInDouble=ddLineWidthInDouble*ddLineHeightInPercent;
				ddLineChartHeight=erutils.round(ddLineHeightInDouble,0);
			}
			JSONObject graphObj=new JSONObject();
			JSONArray graphArr=new JSONArray();
			graphObj.put("HISTORY","true");
			graphObj.put("WIDTH",ddLineChartDivWidth);
			graphObj.put("TITLE",graphTitle+" - "+defaultMGraphDuration);
			graphObj.put("WIDTH",ddLineChartDivWidth);
			if(analysisData!=null && analysisData.size()>0)
			{
			Vector Infos=(Vector)allTestInfos.get(ddtest);
			String msmthst=(String)allMsmtHosts.get(ddtest);

			String ddoverviewinfo="";
			if(Infos!=null && Infos.size()>0)
			{
				if(ddtest.equals("SystemTest") && Infos.contains("+Summary"))
				{
					ddoverviewinfo="+Summary";
				}
				else
				{
					ddoverviewinfo=(String)Infos.get(0);
				}
			}

			ddoverviewinfo=com.egurkha.util.StringUtils.replace(ddoverviewinfo,"+","");
			if(ddformat != null && ddformat.trim().length() > 0)
				ddformat = com.egurkha.util.StringUtils.encodeSecurityChar(ddformat);

			String s_layer=dashboardDAO.getLayerForTest(compType,ddtest,ddmeasure);
			ddoverviewurl=response.encodeURL("/final/monitor/egDashBoardDDData.jsp?")+"fromPage=current&site=-1&comptype=Host_system"+"&host="+hostName+"&port="+portNo+"&layer=HOST&test="+ddtest+"&stest="+ddtest+"-*"+ddoverviewinfo+"&info=*"+EgURLEncoder.encode(ddoverviewinfo,"UTF-8")+"&msmt_host="+msmthst+"&time=Any&timeline=Any&starttime="+startTime+"&starthr="+startHour+"&endtime="+EgURLEncoder.encode(endTime,"UTF-8")+"&endhr="+endHour+"&timeline_compare="+defaultMGraphDuration+"&measure="+ddmeasure+"&from=0&firsttime=true&flag=1&fromDDGraphs=true&newWindow=false&monitorSkin="+monitor_Skin+"&comeFrom=null&startmin="+startDate.getMinutes()+"&endmin="+endDate.getMinutes()+"&ddTitle="+graphTitle;

			fullimageURI=response.encodeURL("/final/servlet/com.egurkha.monitor.EgDDOverviewLineChart?")+"host="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+compType+"&test="+EgURLEncoder.encode(ddtest,"UTF-8")+"&measure="+EgURLEncoder.encode(ddmeasure,"UTF-8")+"&ddformat="+EgURLEncoder.encode(ddformat,"UTF-8")+"&module="+tab+"&starttime="+startTime+"&starthr="+startHour+"&timeline_compare="+EgURLEncoder.encode(defaultMGraphDuration,"UTF-8")+"&endtime="+endTime+"&endhr="+endHour+"&width=880&height=320&startMin="+startDate.getMinutes()+"&endMin="+endDate.getMinutes()+"&monitorSkin="+monitor_Skin+"&fullview=true&mode=3D&showDDData=true&graphTitle="+EgURLEncoder.encode(graphTitle,"UTF-8")+"&isInfoRelevantMeasureGraph=true&graphType=DDOverviewGraph&priority="+EgURLEncoder.encode(FullViewPriority,"UTF-8");

			imageURI="/final/servlet/com.egurkha.monitor.EgDDOverviewLineChart?host="+EgURLEncoder.encode(compName,"UTF-8")+"&comptype="+compType+"&test="+ddtest+"&measure="+ddmeasure+"&timeline_compare="+defaultMGraphDuration+"&ddformat="+EgURLEncoder.encode(ddformat,"UTF-8")+"&module="+tab+"&starttime="+startTime+"&starthr="+startHour+"&endtime="+endTime+"&endhr="+endHour+"&width="+ddLineChartWitdh+"&height="+ddLineChartHeight+"&startMin="+startDate.getMinutes()+"&endMin="+endDate.getMinutes()+"&monitorSkin="+monitor_Skin+"&mode=3D&priority="+FullViewPriority+"&from_page=sysDashboard";
			graphObj.put("OVERVIEW_URL",ddoverviewurl);
			graphObj.put("FULLIMAGE_URL",fullimageURI);
			graphObj.put("IMAGE_URL",imageURI);
			graphObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No detailed measures available")+"!");
			graphArr.add(graphObj);
			}			
			rootJson.put("DISK_HISTORY", graphArr);
		}
		if(!isTestConfigured)
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No Metrics Configured ")+"!");
			rootJson.put("CHARTS", chartObj);
		} else if (ddMeasuresCnt == 0 && !isDDOverviewDataAvailable){

			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.dashboard.The test has been excluded or disabled") + "!");
			rootJson.put("CHARTS", chartObj);
		}
		else if(!testsEnabled)
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		else if(ddNoMeasuresGraphCount==vec_ddtestmeasure.size() && !isDDOverviewDataAvailable)
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}else if(ddNoMeasuresGraphCount == ddMeasuresCnt && !isDDOverviewDataAvailable)
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		if(isFullView)
		{
			JSONObject fullViewObj = new JSONObject();
			fullViewObj.put("lastFullViewURL",lastFullViewURL);
			fullViewObj.put("fullViewGraphType",fullViewGraphType);
			rootJson.put("fullView", fullViewObj);
		}
	}
	else
	{
		boolean testsEnabled=false;
		String uptimeSummaryTest="UptimeTest";

		String durationSubject="Default_MeasureGraph_Duration";
		if(isUptime)
			durationSubject="Default_UpTimeSummary_Duration";
		String defaultMGraphDuration=iniObj.getValue(durationSubject,"duration");
		if(isUptime)
			defaultMGraphDuration=iniObj.getValue("Default_MeasureGraph_Duration","duration");
		if(graphTimeline!=null && !graphTimeline.trim().equals(""))
		{
			defaultMGraphDuration=graphTimeline;
		}


		EgDiscInfo discInfo = new EgDiscInfo("manager");
		List nwDevices = discInfo.getAllNetworkDevices();
		if((isUptime && isMeasureGraph) || (isNetworkTab && isUptime && nwDevices.contains(compType+":"+compName)))
		{
			String upTimeType="Systems";
			if(isNetworkTab && isUptime && nwDevices.contains(compType+":"+compName))
			{
				upTimeType="Network Devices";
			}
			else if(isSpecificSubject)
			{
				upTimeType=compType;
			}
			uptimeSummaryTest=iniObj.getValue("DASHBOARD_UPTIME_TESTS",upTimeType);
			if((uptimeSummaryTest!=null && uptimeSummaryTest.equals("")) && isSystemTab)
				uptimeSummaryTest="UptimeTest";

			boolean isExcludedTestUptime = egDashboard.isExcludedComponentForTest(compType,hostName,uptimeSummaryTest);
			boolean isProcessUptimeData = false;
			if(enabledTests!=null && enabledTests.contains(uptimeSummaryTest) && !isExcludedTestUptime)
			{
				isProcessUptimeData = true;
			}
			//{
				testsEnabled=true;
				rootJson.put("uptimeURL","/final/monitor/egUptimeSummaryJSON.jsp?hostName="+hostName+"&upTimeType="+upTimeType+"&duration="+defaultMGraphDuration+"&uptimeStartTime="+startDateTime+":00&uptimeEndTime="+endDateTime+":00"+"&isProcessUptimeData="+isProcessUptimeData);
			//}
		}

		int i=0;
		int noMeasureGraphCount=0;
		JSONArray measureArr = new JSONArray();
		JSONArray summaryArr = new JSONArray();
		JSONArray trendArr = new JSONArray();

		for(i=0;i<vec_timelineGraphTestMeasure.size();i++)
		{
			JSONObject measureObj = new JSONObject();
			JSONObject summaryObj = new JSONObject();
			JSONObject trendObj = new JSONObject();
			String info="";
			String s_testmeasure=(String)vec_timelineGraphTestMeasure.get(i);
			String s_test="";
			String s_measure="";
			String s_site="NULL";
			String s_layer="";

			if(s_testmeasure!=null && s_testmeasure.indexOf(":")!=-1)
			{
				s_test=s_testmeasure.substring(0,s_testmeasure.indexOf(":"));
				s_measure=s_testmeasure.substring(s_testmeasure.indexOf(":")+1);
			}

			/*if(enabledTests!=null && !enabledTests.contains(s_test))
				continue;*/
			if(graphType.equalsIgnoreCase("summaryGraph") || graphType.equalsIgnoreCase("trendGraph"))
			{
				ArrayList disabledTrend=testerInfo.getDisabledTrendTests();
				if(disabledTrend!=null && disabledTrend.contains(s_test))
					continue;
			}

			testsEnabled=true;

			s_layer=dashboardDAO.getLayerForTest(compType,s_test,s_measure);

			Vector allInfos=(Vector)allTestInfos.get(s_test);

			String measureForDB=dbInfo.getColumnForMeasure(s_test,s_measure);
			String msmtHost=(String)allMsmtHosts.get(s_test);
			if(msmtHost==null)
				msmtHost="";

			unit=tablesInfo.getUnitForMeasure(s_test,s_measure);

			boolean portReleventForTest = false;
			boolean siteReleventForTest = false;
			boolean infoReleventForTest = false;
			
			if(s_test!=null)
			{
				portReleventForTest = specsInfo.isPortRelevantForTest(s_test);
				siteReleventForTest = specsInfo.isSiteRelevantForTest(s_test);
				infoReleventForTest = specsInfo.isInfoRelevantForTest(s_test,compType);
			}

			if(!portReleventForTest)
			{
				portNo="NULL";
			}
			else
			{
				portNo=compPort;
			}

			Vector tempInfo=new Vector();

			if(allInfos!=null)
			{
				for(int infoCount=0;infoCount<allInfos.size();infoCount++)
				{
					String infoFormeasure=(String)allInfos.get(infoCount);
					if(compType!=null && compType.equals("Oracle_server"))
					{
						if(infoReleventForTest)
						{
							if(sid!=null && !sid.equals(""))
								infoFormeasure=sid+infoFormeasure;
						}
					}
					Vector measureNames=egDashboard.getMeasurenamesFromInfo(hostName,portNo,s_site,s_layer,s_test,infoFormeasure,msmtHost);

					if(measureNames!=null && measureNames.contains(measureForDB))
					{
						if(sid!=null && !sid.equals(""))
						{
							tempInfo.add(infoFormeasure.substring(infoFormeasure.indexOf("+"),infoFormeasure.length()));
						}
						else
						{
							tempInfo.add(infoFormeasure);
						}
					}
				}
			}
			allInfos=tempInfo;

			String gTitle="";
			String dispMeasureTitle=iniObj.getValue("Dashboard_measures_mapping",s_test+":"+s_measure);

			String dateDiff="";
			if(s_measure!=null && s_measure.equalsIgnoreCase("Uptime"))
			{
				info="+";
				String currentValue=dashboardDAO.getCurrentMeasure(hostName,portNo,com.egurkha.util.StringUtils.replace(info,"|plus|","+"),s_test,measureForDB,msmtHost);

				if(currentValue==null || currentValue.trim().equals(""))
					currentValue="0";

					long minites=0;
					int secounds=0;
					if(currentValue!=null && currentValue.indexOf(".")>0)
					{
						minites=Long.parseLong(currentValue.substring(0,currentValue.indexOf(".")));
						if(currentValue.substring(currentValue.indexOf(".")+1).length()>2)
							secounds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1,currentValue.indexOf(".")+3));
						else
							secounds=Integer.parseInt(currentValue.substring(currentValue.indexOf(".")+1));

					}
					else
					{
						minites=Long.parseLong(currentValue);
					}

					long valueInSecound=minites;
					if(unit!=null && unit.equalsIgnoreCase("Mins"))
						valueInSecound=(minites*60)+secounds;

					dateDiff=egDashboard.getDateDifferenceString(valueInSecound);
			}
			if(sid!=null && !sid.equals(""))
			{
				info=com.egurkha.util.StringUtils.replace(info,"+","");
				if(infoReleventForTest)
					info=sid+"*"+info;
			}
			else
				info=com.egurkha.util.StringUtils.replace(info,"+","|plus|");

			if(graphTimeline==null || (graphTimeline!=null && !graphTimeline.equalsIgnoreCase("any")))
			{
				String measuretimeline=egDashboard.convertDurtionIntoTimeline(defaultMGraphDuration,true);

				if(defaultMGraphDuration!=null && !defaultMGraphDuration.equals(""))
				{
					times=egDashboard.getStartEndDateTimeForMeasure(defaultMGraphDuration);
					if(times!=null && times.size()>=4)
					{
						startTime=(String)times.get(0);
						endTime=(String)times.get(1);
						startHour=(String)times.get(2);
						endHour=(String)times.get(3);
					}
				}
			}

			if(isMeasureGraph)
			{
				String s_tempinfo="";
				for(int infocount=0;infocount<allInfos.size();infocount++)
				{
					String infoFromVector=(String)allInfos.get(infocount);
					infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"+","*");
					infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"|plus|","*");
					if(infoReleventForTest && sid!=null && !sid.equals(""))
					{
							s_tempinfo+=sid+infoFromVector;
					}
					else
					{
						s_tempinfo+=infoFromVector;
					}

					if(infocount<allInfos.size()-1)
						s_tempinfo+=",";
				}
				String infoTkn[] = StringUtils.getTokens(s_tempinfo, ",");

				boolean hasDescsAllStar = true;
				if ( infoTkn != null && infoTkn.length > 0 )
				{
					for ( int ii = 0; ii < infoTkn.length; ii++ )
					{
						String tmpInfo = infoTkn[ii];
						if ( !tmpInfo.equals("*") )
						{
							hasDescsAllStar = false;
						}

					}
				}
				if ( hasDescsAllStar )
				{
					s_tempinfo = "*";
					info = "*";
				}
				if(!s_tempinfo.trim().equals(""))
					info=s_tempinfo;
				boolean isInfoRelevantMeasureGraph=(info!=null && !info.equals("") && !info.equals("+") && !info.equals("*") && !info.equalsIgnoreCase("null") && !info.equalsIgnoreCase("*Summary") &&  !info.equalsIgnoreCase("+Summary"));

				String measureGraphUrl=response.encodeURL("/final/servlet/com.egurkha.monitor.EgDashboardTimelineMeasures?")+"endtime="+endTime+"&port="+portNo+"&site=NULL&sid="+sid+"&starttime="+startTime+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&measure="+measureForDB+"&newWindow=true&test="+s_test+"&layer="+s_layer+"&comptype="+compType+"&from=MonitorDashboard&endhr="+endHour+"&gtype=1&mode=2D&starthr="+startHour+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&gformat=graph&monitorSkin="+monitor_Skin+"&width="+historyGraphWidth+"&height="+historyGraphHeight+"&legends=true&serverdashboard=true&title=false&priority=TOP+-+3&threshold=no&minmaxavgRequired=true&info="+EgURLEncoder.encode(info,"UTF-8")+"&mgstmin="+startDate.getMinutes()+"&mgendmin="+endDate.getMinutes();

			//	String urlForMaximize="/final/servlet/com.egurkha.monitor.EgDashboardTimelineMeasures?endtime="+request.getParameter("endtime")+"&port="+portNo+"&site=NULL&sid="+sid+"&starttime="+request.getParameter("starttime")+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&measure="+measureForDB+"&newWindow=true&test="+s_test+"&layer="+s_layer+"&comptype="+compType+"&from=MonitorDashboard&endhr="+endHour+"&gtype=1&mode=3D&starthr="+startHour+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&gformat=graph&monitorSkin="+monitor_Skin+"&width=880&height=320&legends=false&fromDashboard=true&timeline_compare="+defaultMGraphDuration+"&title=true&priority="+FullViewPriority+"&threshold=no&minmaxavgRequired=true&info="+EgURLEncoder.encode(info,"UTF-8")+"&isInfoReleventGraph="+isInfoRelevantMeasureGraph+"&fullView=true&module="+tab;
				String max_endTime = endTime;
				String max_startTime = startTime;				
				if( max_endTime!=null)
				{
					max_endTime=DateUtil.changeDateFormat(max_endTime,"MM/dd/yyyy",currentDateFormat);
				}
				if( max_startTime!=null)
				{
					max_startTime=DateUtil.changeDateFormat(max_startTime,"MM/dd/yyyy",currentDateFormat);
				}				
				String urlForMaximize="/final/servlet/com.egurkha.monitor.EgDashboardTimelineMeasures?endtime="+max_endTime+"&port="+portNo+"&site=NULL&sid="+sid+"&starttime="+max_startTime+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&measure="+measureForDB+"&newWindow=true&test="+s_test+"&layer="+s_layer+"&comptype="+compType+"&from=MonitorDashboard&endhr="+endHour+"&gtype=1&mode=3D&starthr="+startHour+"&startMin="+startDate.getMinutes()+"&endMin="+endDate.getMinutes()+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&gformat=graph&monitorSkin="+monitor_Skin+"&width=880&height=320&legends=false&fromDashboard=true&timeline_compare="+defaultMGraphDuration+"&title=true&priority="+FullViewPriority+"&threshold=no&minmaxavgRequired=true&info="+EgURLEncoder.encode(info,"UTF-8")+"&s_measure="+s_measure+"&isInfoReleventGraph="+isInfoRelevantMeasureGraph+"&fullView=true&module="+tab;
				measureObj.put("WIDTH", historyGraphWidth);
				measureObj.put("HEIGHT", historyGraphHeight);
				measureObj.put("METHOD_NAME", "showBigGraph");
				measureObj.put("PARAMS",urlForMaximize+EgURLEncoder.encode("|event|"+i+"|Measuregraph","UTF-8"));
				if ( chartOptionForTimeline.equalsIgnoreCase("highchart") || chartOptionForTimeline.indexOf("highchart") > -1 )
				{	
					measureObj.put("HIGH_CHART", "true");
				}
				else
				{
					measureObj.put("HIGH_CHART", "false");
				}
				measureObj.put("IMG_SRC", measureGraphUrl);
				String toolTipMeasureTitle=dispMeasureTitle;
				measureObj.put("TOOLTIP_TITLE", toolTipMeasureTitle);
				String tmpTitle = "";
				if(dispMeasureTitle==null || dispMeasureTitle.equals(""))
				{
					dispMeasureTitle=mappingInfo.getMeasureDescription(s_test,s_measure);
				}
				else
				{
					dispMeasureTitle = mappingInfo.getTextDescription("monitor.dashboard."+dispMeasureTitle);
				}
				tmpTitle = dispMeasureTitle;
				String unitMapping ="";
				if(s_measure!=null && s_measure.equalsIgnoreCase("Uptime") && isMeasureGraph && dateDiff!=null && !dateDiff.equals("") && !dateDiff.equals("-5"))
				{
					tmpTitle += ": "+dateDiff;
				}
				else
				{
					unitMapping = graphUtil.getUnitMapping(unit);
					//tmpTitle += " ("+unitMapping+")";
				}
						
				if(!StringUtils.isNull(unitMapping))
				{
					tmpTitle+="("+unitMapping+")";
				}
				measureObj.put("TITLE",tmpTitle);
				measureObj.put("HIDDEN", urlForMaximize);
			}
			else if(graphType.equalsIgnoreCase("summaryGraph"))
			{
				if(allInfos!=null && allInfos.size()>0)
					info=(String)allInfos.get(0);

				info=com.egurkha.util.StringUtils.replace(info,"+","");
				info=com.egurkha.util.StringUtils.replace(info,"|plus|","");

				String defaultSGraphDuration=iniObj.getValue("Default_SummaryGraph_Duration","duration");

				if(graphTimeline!=null && !graphTimeline.trim().equals(""))
					defaultSGraphDuration=graphTimeline;

				if(graphTimeline==null || (graphTimeline!=null && !graphTimeline.equalsIgnoreCase("any")))
				{
					String timeline=egDashboard.convertDurtionIntoTimeline(defaultSGraphDuration,true);
					times=egDashboard.getStartEndDateTime(defaultSGraphDuration,"summarygraph");
					if(times!=null && times.size()>=4)
					{
						startTime=(String)times.get(0);
						endTime=(String)times.get(1);
						startHour=(String)times.get(2);
						endHour=(String)times.get(3);
					}
				}
				boolean isInfoRelevantMeasureGraph=(info!=null && !info.equals("") && !info.equals("+") && !info.equals("*") && !info.equalsIgnoreCase("null") && !info.equalsIgnoreCase("*Summary") &&  !info.equalsIgnoreCase("+Summary"));
				if(sid!=null && !sid.equals(""))
				{
					info=sid+"*"+info;
				}
				else
				{
					info="*"+info;
				}
				
				String dbStTime=DateUtil.changeDateFormat(startTime,"MM/dd/yyyy","dd/MM/yyyy")+" "+startHour+":00:00";
				String dbEndTime = DateUtil.changeDateFormat(endTime,"MM/dd/yyyy","dd/MM/yyyy")+" "+endHour+":00:00";
				

				String summryFullviewGraphUrl="/final/servlet/com.egurkha.monitor.DashboardSummaryGraph?endtime="+endTime+"&port="+portNo+"&site=NULL&starttime="+startTime+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&measure="+measureForDB+"&test="+s_test+"&state=GOOD&layer=HOST&comptype="+compType+"&period=H&endhr="+endHour+"&gtype=1&mode=2D&info="+info+"&starthr="+startHour+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&monitorSkin="+monitor_Skin+"&period=H&width=890&height=390&timeline_compare="+defaultSGraphDuration+"&fullview=true&isInfoReleventGraph=false&userLanguage="+trackerLanguage+"&module="+tab+"&dbstarttime="+dbStTime+"&dbendtime="+dbEndTime;
			
		//added by arivu for fusion chart
		//---------------------------Summary chart attributes-----------------------------------------------//

				Vector chartAttribute=new Vector();
				chartAttribute.add("palette='2'");
				chartAttribute.add("showValues='0'");
				chartAttribute.add("useRoundEdges='4'");
				chartAttribute.add("exportEnabled='0'");
				chartAttribute.add("exportHandler='/final/FusionCharts/jsp/FCExporter.jsp'");
				chartAttribute.add("showExportDialog='1'");
				chartAttribute.add("exportAction='download'");
				chartAttribute.add("exportAtClient='0'");
				chartAttribute.add("exportTargetWindow='1'");
				chartAttribute.add("showShadow='1'");
				chartAttribute.add("showLegend='0'");
				chartAttribute.add("showFCMenuItem='0'");
				chartAttribute.add("showToolTipShadow='1'");
				chartAttribute.add("chartLeftMargin='2'");
				chartAttribute.add("chartRightMargin='7'");
				chartAttribute.add("chartTopMargin='10'");
				chartAttribute.add("chartBottomMargin='3'");
				chartAttribute.add("yAxisValuesPadding='1'");
				chartAttribute.add("xAxisNamePadding='1'");
				chartAttribute.add("labelPadding='1'");
				chartAttribute.add("canvasPadding='10'");
				//chartAttribute.add("showFCMenuItem='0'");
				chartAttribute.add("labelStep='2'");
				//chartAttribute.add("baseFontColor ='000000'");
				chartAttribute.add("canvasLeftMargin='5'");
				chartAttribute.add("canvasRightMargin='3'");
				chartAttribute.add("canvasTopMargin='5'");
				chartAttribute.add("canvasBottomMargin='3'");
				chartAttribute.add("showBorder='0'");
				chartAttribute.add("showAboutMenuItem='1' aboutMenuItemLabel='About eG Innovations' aboutMenuItemLink='n-http://www.eginnovations.com'");
				chartAttribute.add("clickURL='javascript:summaryGraphOnclick(&apos;summary"+i+"&apos;)'");
				chartAttribute.add("baseFontSize='"+fontSize+"'"); 
				//chartAttribute.add("baseFont='"+fontForLanguage+"'"); 

				EgSummaryChartUtil summaryChart=new EgSummaryChartUtil();

				String qStr="endtime="+endTime+"&port="+portNo+"&site=NULL&starttime="+startTime+"&host="+hostName+"&measure="+measureForDB+"&test="+s_test+"&state=GOOD&layer=HOST&comptype="+compType+"&period=H&endhr="+endHour+"&gtype=1&mode=2D&info="+info+"&starthr="+startHour+"&msmt_host="+msmtHost+"&monitorSkin="+monitor_Skin+"&period=H&width=301&height=180&timeLine="+defaultSGraphDuration+"&fullview=false&callfrom=sysdashboard&userLanguage="+trackerLanguage+"&module="+tab+"&dbstarttime="+dbStTime+"&dbendtime="+dbEndTime;

				String paramForInfochange="endtime="+endTime+"&port="+portNo+"&site=NULL&starttime="+startTime+"&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&measure="+measureForDB+"&test="+s_test+"&state=GOOD&layer=HOST&comptype="+compType+"&period=H&endhr="+endHour+"&gtype=1&mode=2D&info="+com.egurkha.util.StringUtils.replace(info,"+","|plus|")+"&starthr="+startHour+"&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&monitorSkin="+monitor_Skin+"&period=H&width="+summaryGraphWidth+"&height="+summaryTrendGraphHeightForInfoChange+"&timeLine="+defaultSGraphDuration+"&fullview=false&callfrom=sysdashboard&userLanguage="+trackerLanguage+"&module="+tab;
				String xmldata=summaryChart.getXMLForSummary(qStr,chartAttribute);
				if(xmldata!=null && xmldata.trim().length()>0)
				{
					summaryObj.put("WIDTH", ddGraphWidth);
					summaryObj.put("HEIGHT", summaryGraphHeight);
					String toolTipMeasureTitle=dispMeasureTitle;
					if(dispMeasureTitle==null || dispMeasureTitle.equals(""))
					{
						dispMeasureTitle=mappingInfo.getMeasureDescription(s_test,s_measure);
					}
					else
					{
						dispMeasureTitle=mappingInfo.getTextDescription("monitor.dashboard."+dispMeasureTitle);
					}
					if(dispMeasureTitle!=null && !dispMeasureTitle.equals(""))
					{
						toolTipMeasureTitle=dispMeasureTitle;
						int titleLength=dispMeasureTitle.length();
						if(unit!=null && !unit.equals(""))
						{
							int cgraphlen=graphTitlelength-unit.length();
							//if(titleLength>=cgraphlen)
								//dispMeasureTitle=dispMeasureTitle.substring(0,cgraphlen)+"...";
						}
						else
						{
							//if(titleLength>=graphTitlelength)
								//dispMeasureTitle=dispMeasureTitle.substring(0,graphTitlelength)+"...";
						}
					}
					summaryObj.put("TOOLTIP_TITLE", toolTipMeasureTitle);
					String tmpTitle = "";
					tmpTitle = dispMeasureTitle;
					String unitMapping ="";
					if(s_measure!=null && s_measure.equalsIgnoreCase("Uptime") && isMeasureGraph && dateDiff!=null && !dateDiff.equals("") && !dateDiff.equals("-5"))
					{
						tmpTitle += ": "+dateDiff;
					}
					else
					{
						unitMapping = graphUtil.getUnitMapping(unit);
						//tmpTitle += " ("+unitMapping+")";
					}

					//tmpTitle=mappingInfo.getTextDescription("monitor.dashboard."+tmpTitle);
					if(!StringUtils.isNull(unitMapping))
					{
						tmpTitle+="("+unitMapping+")";
					}
					summaryObj.put("TITLE", tmpTitle);
					if(allInfos!=null && allInfos.size()>1 && graphType!=null && !isMeasureGraph)
					{
						JSONObject infosObj = new JSONObject();
						infosObj.put("METHOD_NAME", "infoChange");
						infosObj.put("PARAMS", ""+i);
						JSONArray infoArr = new JSONArray();
						for(int infocount=0;infocount<allInfos.size();infocount++)
						{
							JSONObject infoObj = new JSONObject();
							String selected="";
							String infoFromVector=(String)allInfos.get(infocount);
							String displayinfo=infoFromVector;
							if(displayinfo.indexOf("Memory Pool")>-1)
							displayinfo= displayinfo.substring(displayinfo.indexOf("_")+1,displayinfo.length());
							String minfo=info;
							if(sid!=null && !sid.equals(""))
							{
								infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"+","*");
								minfo=com.egurkha.util.StringUtils.replace(minfo,"+","*");
								infoFromVector=sid+infoFromVector;
								minfo=sid+minfo;
							}

							if(infoFromVector!=null && infoFromVector.equals(minfo))
							{
								infosObj.put("selectedInfos", infoFromVector);
								selected="selected";
							}
							infoObj.put("valueField", infoFromVector);
							infoObj.put("displayField", com.egurkha.util.StringUtils.replace(displayinfo,"+",""));
							infoArr.add(infoObj);
						}
						summaryObj.put("INFOS", infoArr);
					}
					else if(allInfos!=null && allInfos.size()==1)
					{
						String infoFromVector=(String)allInfos.get(0);
						infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"+","");
						if((sid!=null && !sid.equals("")) && (infoFromVector!=null && !infoFromVector.equals("")))
						{
							infoFromVector=sid+"*"+infoFromVector;
						}
					}
					summaryObj.put("SWF_PATH", "/final/FusionCharts/swf/StackedColumn3D.swf");
					summaryObj.put("XML_DATA", xmldata);
					hiddens.put("summary"+i, summryFullviewGraphUrl);
					summaryObj.put("summryFullviewGraphUrl", summryFullviewGraphUrl);
					summaryObj.put("HIDDENS", paramForInfochange);
				}
				else
				{
					noMeasureGraphCount++;
				}
			}
			else if(graphType.equalsIgnoreCase("trendGraph"))
			{
				if(allInfos!=null && allInfos.size()>0)
					info=(String)allInfos.get(0);

				info=com.egurkha.util.StringUtils.replace(info,"+","");
				info=com.egurkha.util.StringUtils.replace(info,"|plus|","");

				String defaultTGraphDuration=iniObj.getValue("Default_TrendGraph_Duration","duration");

				if(graphTimeline!=null && !graphTimeline.trim().equals(""))
					defaultTGraphDuration=graphTimeline;

				String timeline=graphTimeline;
				if(graphTimeline==null || (graphTimeline!=null && !graphTimeline.equalsIgnoreCase("any")))
				{
					timeline=egDashboard.convertDurtionIntoTimeline(defaultTGraphDuration,true);

					times=egDashboard.getStartEndDateTime(defaultTGraphDuration,"trendgraph");
					if(times!=null && times.size()>=4)
					{
						startTime=(String)times.get(0);
						endTime=(String)times.get(1);
						startHour=(String)times.get(2);
						endHour=(String)times.get(3);
					}
				}

				if(sid!=null && !sid.equals(""))
				{
					info=sid+"*"+info;
				}
				else
				{
					info="*"+info;
				}
				String start_time=request.getParameter("starttime");
				String end_time=request.getParameter("endtime");
				if(start_time==null)
						start_time=startTime;
				if(end_time==null)
						end_time=endTime;
				String trendGraphUrl="/final/servlet/com.egurkha.monitor.DashboardTrendGraph?site=-1&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&layer="+s_layer+"&test="+s_test+"&port="+portNo+"&info="+com.egurkha.util.StringUtils.replace(info,"|plus|","")+"&gtype=0&draw=1&starttime="+startTime+"&mode=2D&time=1%20hour&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&comptype="+compType+"&measure="+measureForDB+"&period=H&qctr=5&stest=SystemTest-*Summary&search=&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&comp="+compType+":"+hostName+":"+portNo+"&graphmode=minmax&width=303&monitorSkin="+monitor_Skin+"&height=180&timeline"+timeline+"&module="+tab;

				String minMaxtrendFullView=response.encodeURL("/final/servlet/com.egurkha.monitor.DashboardTrendGraph?")+"site=-1&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&layer="+s_layer+"&test="+s_test+"&port="+portNo+"&info="+com.egurkha.util.StringUtils.replace(info,"|plus|","")+"&gtype=0&draw=1&starttime="+startTime+"&mode=2D&timeline_compare="+timeline+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&comptype="+compType+"&measure="+measureForDB+"&monitorSkin="+monitor_Skin+"&period=H&qctr=5&timeline_compare="+defaultTGraphDuration+"&stest=SystemTest-*Summary&search=&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&comp="+compType+":"+hostName+":"+portNo+"&graphmode=minmax&fromDashboard=true&width="+summaryGraphWidth+"&height="+summaryTrendGraphHeightForInfoChange+"&fullview=true&isInfoReleventGraph=false&module="+tab;
				String avgTrendFullView=response.encodeURL("/final/servlet/com.eg.AvgTrendGraph?")+"site=-1&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&layer="+s_layer+"&test="+s_test+"&port="+portNo+"&info="+com.egurkha.util.StringUtils.replace(info,"|plus|","")+"&gtype=0&draw=1&starttime="+startTime+"&mode=2D&timeline_compare="+timeline+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&comptype="+compType+"&measure="+measureForDB+"&monitorSkin="+monitor_Skin+"&period=H&qctr=5&stest=SystemTest-*Summary&search=&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&comp="+compType+":"+hostName+":"+portNo+"&graphmode=avg&&requestFrom=Avg&fromDashboard=true&isInfoReleventGraph=false&module="+tab;

				String sumTrendFullView=response.encodeURL("/final/servlet/com.eg.AvgTrendGraph?")+"site=-1&host="+EgURLEncoder.encode(hostName,"UTF-8")+"&layer="+s_layer+"&test="+s_test+"&port="+portNo+"&info="+com.egurkha.util.StringUtils.replace(info,"|plus|","")+"&gtype=0&draw=1&starttime="+startTime+"&mode=2D&timeline_compare="+timeline+"&endtime="+endTime+"&starthr="+startHour+"&endhr="+endHour+"&comptype="+compType+"&measure="+measureForDB+"&monitorSkin="+monitor_Skin+"&period=H&qctr=5&stest=SystemTest-*Summary&search=&msmt_host="+EgURLEncoder.encode(msmtHost,"UTF-8")+"&comp="+compType+":"+hostName+":"+portNo+"&graphmode=sum&&requestFrom=Sum&fromDashboard=true&isInfoReleventGraph=false&module="+tab;

				Hashtable hTable = new Hashtable();
				hTable.put("site","-1"); hTable.put("host",hostName); hTable.put("layer","HOST");
				hTable.put("test",s_test); hTable.put("port",portNo); hTable.put("info",com.egurkha.util.StringUtils.replace(info,"|plus|",""));
				hTable.put("gtype","0"); hTable.put("draw","1"); hTable.put("starttime",startTime);
				hTable.put("endtime",endTime); hTable.put("starthr",startHour);
				hTable.put("endhr",endHour); hTable.put("comptype",compType); hTable.put("measure",measureForDB);hTable.put("mode","2D");
				hTable.put("period","H"); hTable.put("msmt_host",msmtHost); hTable.put("graphmode","minmax");
				hTable.put("fromPage","dashboard");
				

				Vector TrendChartAttribute=new Vector();
				TrendChartAttribute.add("showValues='0'");
				TrendChartAttribute.add("showLabels='1'");
				TrendChartAttribute.add("labelDisplay='Rotate'");
				TrendChartAttribute.add("formatNumberScale='0'");
				TrendChartAttribute.add("lineThickness='2'");
				TrendChartAttribute.add("divLineColor='f7f7f7'");
				//TrendChartAttribute.add("divLineIsDashed='0'");
				//TrendChartAttribute.add("divLineThickness='0'");
				//TrendChartAttribute.add("divLineAlpha='50'");
				TrendChartAttribute.add("showAlternateHGridColor='1'");
				TrendChartAttribute.add("alternateHGridColor='e5e5e5'");
				TrendChartAttribute.add("shadowAlpha='99'");
				//TrendChartAttribute.add("anchorAlpha='0'");
				TrendChartAttribute.add("anchorRadius='2'");
				TrendChartAttribute.add("anchorBgAlpha='80'");
				//TrendChartAttribute.add("anchorBgColor='ff0000'");
				//TrendChartAttribute.add("labelStep='2'");
				TrendChartAttribute.add("chartLeftMargin='20'");
				TrendChartAttribute.add("chartRightMargin='20'");
				TrendChartAttribute.add("bgColor='FFFFFF,FFFFFF'");
				TrendChartAttribute.add("bgAngle='270'");
				TrendChartAttribute.add("bgAlpha='10,10'");
				TrendChartAttribute.add("canvasBgColor='f7f7f7'");
				TrendChartAttribute.add("showToolTipShadow ='1'");
				TrendChartAttribute.add("toolTipBgColor ='ffffff'");
				TrendChartAttribute.add("toolTipBorderColor ='555555'");
				//if(unit!=null && unit.equals("%"))
					//TrendChartAttribute.add("yAxisMaxValue='100'");
				TrendChartAttribute.add("exportEnabled='0'");
				TrendChartAttribute.add("exportHandler='/final/FusionCharts/jsp/FCExporter.jsp'");
				TrendChartAttribute.add("exportAtClient='0'");
				TrendChartAttribute.add("showBorder='0'");
				TrendChartAttribute.add("exportAction='download'");
				TrendChartAttribute.add("exportFileName='MinMaxTrendChart'");
				TrendChartAttribute.add("showAboutMenuItem='1' aboutMenuItemLabel='About eG Innovations' aboutMenuItemLink='n-http://www.eginnovations.com'");
				TrendChartAttribute.add("clickURL='javascript:trendGraphOnclick(&apos;trend"+i+"&apos;)'");

				if(portNo!=null && !portNo.equalsIgnoreCase("NULL"))
				{
					portNo="NULL";
				}
				String xmlData = (String)egMon.FusionGraph(user,hTable,TrendChartAttribute);
				if(portNo!=null && !portNo.equalsIgnoreCase("NULL"))
				{
					portNo="NULL";
				}
				if(xmlData!=null && xmlData.trim().length()>0)
				{
					trendObj.put("WIDTH", ddGraphWidth);
					trendObj.put("HEIGHT", summaryGraphHeight);
					String toolTipMeasureTitle=dispMeasureTitle;
					trendObj.put("TOOLTIP_TITLE", toolTipMeasureTitle);
					if(dispMeasureTitle==null || dispMeasureTitle.equals(""))
					{
						dispMeasureTitle=mappingInfo.getMeasureDescription(s_test,s_measure);
					}
					else
					{
						dispMeasureTitle=mappingInfo.getTextDescription("monitor.dashboard."+dispMeasureTitle);
					}
					if(dispMeasureTitle!=null && !dispMeasureTitle.equals(""))
					{
						toolTipMeasureTitle=dispMeasureTitle;
						int titleLength=dispMeasureTitle.length();
						if(unit!=null && !unit.equals(""))
						{
							int cgraphlen=graphTitlelength-unit.length();
							if(titleLength>=cgraphlen)
								dispMeasureTitle=dispMeasureTitle.substring(0,cgraphlen)+"...";
						}
						else
						{
							if(titleLength>=graphTitlelength)
								dispMeasureTitle=dispMeasureTitle.substring(0,graphTitlelength)+"...";
						}
					}
					String tmpTitle = toolTipMeasureTitle;
					String unitMapping = "";
					if(s_measure!=null && s_measure.equalsIgnoreCase("Uptime") && isMeasureGraph && dateDiff!=null && !dateDiff.equals("") && !dateDiff.equals("-5"))
					{
						tmpTitle += ": "+dateDiff;
					}
					else
					{
						unitMapping = graphUtil.getUnitMapping(unit);
						//tmpTitle += " ("+unitMapping+")";
					}
					//tmpTitle=mappingInfo.getTextDescription("monitor.dashboard."+tmpTitle);
					if(!StringUtils.isNull(unitMapping))
					{
						tmpTitle+="("+unitMapping+")";
					}
					trendObj.put("TITLE", tmpTitle);
					if(allInfos!=null && allInfos.size()>1 && graphType!=null && !isMeasureGraph)
					{
						JSONObject infosObj = new JSONObject();
						infosObj.put("METHOD_NAME", "infoChange");
						infosObj.put("PARAMS", ""+i);
						JSONArray infoArr = new JSONArray();
						for(int infocount=0;infocount<allInfos.size();infocount++)
						{
							JSONObject infoObj = new JSONObject();
							String selected="";
							String infoFromVector=(String)allInfos.get(infocount);
							String displayinfo=infoFromVector;
							if(displayinfo.indexOf("Memory Pool")>-1)
							displayinfo= displayinfo.substring(displayinfo.indexOf("_")+1,displayinfo.length());
							String minfo=info;
							if(sid!=null && !sid.equals(""))
							{
								infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"+","*");
								minfo=com.egurkha.util.StringUtils.replace(minfo,"+","*");
								infoFromVector=sid+infoFromVector;
								minfo=sid+minfo;
							}

							if(infoFromVector!=null && infoFromVector.equals(minfo))
							{
								infosObj.put("selectedInfos", infoFromVector);
								selected="selected";
							}
							infoObj.put("valueField", infoFromVector);
							infoObj.put("displayField", com.egurkha.util.StringUtils.replace(displayinfo,"+",""));
							infoArr.add(infoObj);
						}
						trendObj.put("INFOS", infoArr);
					}
					else if(allInfos!=null && allInfos.size()==1)
					{
						String infoFromVector=(String)allInfos.get(0);
						infoFromVector=com.egurkha.util.StringUtils.replace(infoFromVector,"+","");
						if((sid!=null && !sid.equals("")) && (infoFromVector!=null && !infoFromVector.equals("")))
						{
							infoFromVector=sid+"*"+infoFromVector;
						}
					}
					trendObj.put("SWF_PATH", "/final/FusionCharts/swf/MSLine.swf");
					trendObj.put("XML_DATA", xmlData);
					trendObj.put("minMaxtrendFullView", minMaxtrendFullView);
					//trendObj.put("FULL_VIEW_URL", minMaxtrendFullView);					
					hiddens.put("trend"+i, minMaxtrendFullView);
					trendObj.put("HIDDENS", minMaxtrendFullView+"|"+avgTrendFullView+"|"+sumTrendFullView);
				}
				else
				{
					noMeasureGraphCount++;
				}
			}
			graphCount++;
			if ( !measureObj.isEmpty() )
			{
				measureArr.add(measureObj);
			}
			if ( !summaryObj.isEmpty() )
			{
				summaryArr.add(summaryObj);
			}
			if ( !trendObj.isEmpty() )
			{
				trendArr.add(trendObj);
			}
		}
		if ( !measureArr.isEmpty() )
		{
			rootJson.put("MEASURE_GRAPHS", measureArr);
		}
		if ( !summaryArr.isEmpty() )
		{
			rootJson.put("SUMMARY_GRAPHS", summaryArr);
		}
		else if ( graphType.equalsIgnoreCase("summarygraph") )
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		if ( !trendArr.isEmpty() )
		{
			rootJson.put("TREND_GRAPHS", trendArr);
		}
		else if ( graphType.equalsIgnoreCase("trendgraph") )
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		if(!testsEnabled)
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		else if(noMeasureGraphCount==vec_timelineGraphTestMeasure.size())
		{
			JSONObject chartObj = new JSONObject();
			chartObj.put("NO_CHARTS", "true");
			chartObj.put("NO_CHARTS_MSG", mappingInfo.getTextDescription("monitor.common.No measures available ")+"!");
			rootJson.put("CHARTS", chartObj);
		}
		if(isFullView)
		{
			JSONObject fullViewObj = new JSONObject();
			fullViewObj.put("lastFullViewURL",lastFullViewURL);
			fullViewObj.put("fullViewGraphType",fullViewGraphType);
			rootJson.put("fullView", fullViewObj);
		}
	}
	hiddens.put("graphType", graphType);
//	System.out.println("rootJson1234----->"+rootJson);

if ( !hiddens.isEmpty() )
{
	rootJson.put("hiddens", hiddens);
}
if ( !screenLabels.isEmpty() )
{
	rootJson.put("screenLabels", screenLabels);
}

	String showLegStr = request.getParameter("showLegend");
	if(showLegStr == null || showLegStr.equals(""))
	{
		showLegStr = iniUI.getValue("CHART_TYPE","showLegendsInCharts");
		
	}
	rootJson.put("LegendInChart",showLegStr.toLowerCase());
out.println(rootJson.toString());
String requestData = ErUtils.prepareQueryString(request.getParameterMap());
if(requestData!=null)
{
	if(session!=null)
	{
		session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgDashboardController?from=list&"+requestData+"&comptype="+request.getParameter("compType")+"&subsystem="+subsystem+"&host="+compName+"&tab="+tab+"&graphType="+graphType+"&toDashBoardLayer=true");
		session.setAttribute("monitorDashBrdLastCompName",request.getParameter("hostName"));
	}
}
else
{
	if(session!=null)
	{
		session.setAttribute("monitorLastSession","/final/servlet/com.eg.EgDashboardController?from=list&tab="+tab+"&toDashBoardLayer=true");
		session.setAttribute("monitorDashBrdLastCompName",request.getParameter("hostName"));
	}
}
}
catch(Throwable ex)
{
	System.out.println("Exception in egDashboardHistoryJSON "+ex);
	ex.printStackTrace();
}
%>

