<%
/*****************************************************************************************************
*	Name			:	EgPrintThreshDetailView.jsp
*	Version			:	eG 4.0
*	Purpose			:	To display threshold details
  *****************************************************************************************************/
%>

<%@ include file = "../../EgTrackerA.jsp" %>

<%@ page import = "java.io.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "egurkha.*" %>
<%@ page import = "com.eg.IniFile" %>
<%@ page import = "com.eg.EgDiscInfo" %>
<%@ page import = "com.eg.EgRoleInfo" %>
<%@ page import = "com.eg.EgSpecsInfo" %>
<%@ page import = "com.eg.EgTesterInfo" %>
<%@ page import = "com.eg.EgTablesInfo" %>
<%@ page import = "com.eg.EgMappingInfo" %>
<%@ page import = "com.eg.EgInstallInfo" %>
<%@ page import = "com.eg.EgThresholdInfo" %>
<%@ page import = "com.eg.MappingNameSorter" %>
<%@ page import = "com.eg.EgServerGroupBean" %>
<%@ page import = "com.egurkha.ini.IniUI" %>
<%@ page import = "com.egurkha.util.*" %>
<%@ page import = "com.eg.EgConfigInfo"%>
<%@ page import = "com.eg.EgTopoInfo"%>
<%@ page import = "com.eg.EgGroupInfo"%>
<%@ page import = "com.eg.EgURLDecoder"%>
<%@ page import = "com.egurkha.util.StringUtils" %>
<%@ page import="com.eg.EgDbInfo"%>

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

<%!
	String[] criterias = {"Zone","Service","Segment","Component"};

	private ArrayList getAssociatedComponents(HttpSession session, User user,String view,String option)
	{
		ArrayList aListAssociatedComponents = new ArrayList();

		EgGroupInfo egGroupInfo = new EgGroupInfo();
		EgTopoInfo egTopoInfo = egGroupInfo.getTopoInfoObject();

		if (option != null)
		{
			try
			{
				option = EgURLDecoder.decode(option,"UTF-8");
			}
			catch (Exception e)
			{
			}
		}

		Vector vecUserOptions = null;
		Vector vecUserAssociatedComponents = new Vector(user.getServers(false));

		if (view != null && view.equalsIgnoreCase("Zone"))
		{
			List zoneList = user.getZones();

			//To fetch all components from user associated zones
			ArrayList aListComponentsFromZone = new ArrayList();
			if (zoneList != null && !zoneList.isEmpty())
			{
				vecUserOptions = new Vector(zoneList);
				Collections.sort(vecUserOptions,String.CASE_INSENSITIVE_ORDER);

				for (int i=0;i<vecUserOptions.size();i++)
				{
					String strZone = (String)vecUserOptions.get(i);
					aListComponentsFromZone.addAll(egGroupInfo.getAllComponentsUnderZone(strZone,true));
				}
			}

			if (aListComponentsFromZone != null && !aListComponentsFromZone.isEmpty())
			{
				boolean defaultZoneExists = false;
				for (int i=0;i<vecUserAssociatedComponents.size();i++)
				{
					String component = (String)vecUserAssociatedComponents.get(i);
					if (!aListComponentsFromZone.contains(component))
					{
						defaultZoneExists = true;
						break;
					}
				}

				if (defaultZoneExists)
				{
					vecUserOptions.add(0,"--Default--");
				}
			}
			else
			{
				if (vecUserAssociatedComponents != null && !vecUserAssociatedComponents.isEmpty())
				{
					vecUserOptions = new Vector();
					vecUserOptions.add("--Default--");
				}
			}

			if (option == null && vecUserOptions != null && !vecUserOptions.isEmpty())
			{
				option = (String)vecUserOptions.get(0);
			}

			if (option != null)
			{
				if (!option.equalsIgnoreCase("--Default--"))
				{
					aListAssociatedComponents = egGroupInfo.getAllComponentsUnderZone(option,true);
				}
				else
				{
					aListAssociatedComponents = new ArrayList();
					for (int i=0;i<vecUserAssociatedComponents.size();i++)
					{
						String userComponent = (String)vecUserAssociatedComponents.get(i);
						int index = aListComponentsFromZone.indexOf(userComponent);
						if (index == -1)
						{
							aListAssociatedComponents.add(userComponent);
						}
					}
				}
			}
		}
		else if (view != null && view.equalsIgnoreCase("Service"))
		{
			List serviceList = new ArrayList();
			serviceList.addAll(user.getServices());
			ArrayList aListSites = new ArrayList();
			aListSites.addAll(user.getSites());
			aListSites.removeAll(serviceList);
			serviceList.addAll(aListSites);
			if (serviceList != null && !serviceList.isEmpty())
			{
				vecUserOptions = new Vector(serviceList);
				Collections.sort(vecUserOptions,String.CASE_INSENSITIVE_ORDER);
			}

			if (option == null && vecUserOptions != null && !vecUserOptions.isEmpty())
			{
				option = (String)vecUserOptions.get(0);
			}

			if (option != null)
			{
				Vector vecServiceComponents = egTopoInfo.getAssociatesForSite(option);
				if (vecServiceComponents != null)
				{
					aListAssociatedComponents = new ArrayList(vecServiceComponents);
				}
			}
		}
		else if (view != null && view.equalsIgnoreCase("Segment"))
		{
			List segmentList = user.getSegments();
			if (segmentList != null && !segmentList.isEmpty())
			{
				vecUserOptions = new Vector(segmentList);
				Collections.sort(vecUserOptions,String.CASE_INSENSITIVE_ORDER);
			}

			if (option == null && vecUserOptions != null && !vecUserOptions.isEmpty())
			{
				option = (String)vecUserOptions.get(0);
			}
			if (option != null)
			{
				Vector vecSegmentComponents = egTopoInfo.getAssociatesForSegment(option,2);
				if (vecSegmentComponents != null)
				{
					aListAssociatedComponents = new ArrayList(vecSegmentComponents);
				}
			}
		}
		else
		{
			aListAssociatedComponents = new ArrayList(vecUserAssociatedComponents);
		}
		session.setAttribute("ec_criteria",view);
		session.setAttribute("ec_userOption",option);
		session.setAttribute("vecUserOptions",vecUserOptions);

		return aListAssociatedComponents;
	}
%>

<%
	response.setHeader("Cache-Control","no-store");
	response.setHeader("Pragma","no-cache");
	response.setDateHeader("Expires", -1);

	String result1 = "<LINK href=\"../../../";
	String result2 = "admin/eg_styles/adminstyle_" + _user.getAdminSkin();
	String result3 = ".css\" type=\"text/css\" rel=\"stylesheet\">";
	String strStyleSheet = result1 + result2 + result3;

	EgThresholdInfo threshInfo = new EgThresholdInfo("manager"); 
	EgDiscInfo disc_info = new EgDiscInfo("manager");
	EgSpecsInfo specs_info = new EgSpecsInfo("manager");
	EgServerGroupBean descGrp = new EgServerGroupBean();
	EgTesterInfo testerInfo=new EgTesterInfo("manager");
	EgTablesInfo tablesInfo = new EgTablesInfo("manager");
	ArrayList globalThresholds=testerInfo.getGlobalThresholds();

	String uiFile = "eg_ui.ini";
	String iniFileDir = EgInstallInfo.getInstallDir()+ "/manager/config/";
	IniFile egUI = new IniFile(iniFileDir + uiFile);
	String currentDateFormat = egUI.getValue("CURRENT_DATE_FORMAT","selectedDateFormat");
	Date date = new Date(System.currentTimeMillis());
	String currentDateTime = DateUtil.formatDate(date,currentDateFormat+" HH:mm:ss");

	String userLanguage = _user.getLanguage();
	IniUI iniUI = IniUI.getInstance();
	if (userLanguage == null)
	{
		userLanguage = iniUI.getDefaultLanguage();
	}
	EgMappingInfo mappingInfo = new EgMappingInfo(userLanguage);
	MappingNameSorter sorter = new MappingNameSorter(userLanguage);
	EgRoleInfo egRoleInfo=EgRoleInfo.getInstance(session.getId(),(String)session.getAttribute("sess_userid"));//by JJ

	String s_threshType = (String) session.getAttribute("eg_threshType");
	String s_compType = (String) session.getAttribute("eg_compType");
	String s_host = (String) session.getAttribute("eg_host");
	String req_test = (String) session.getAttribute("eg_test");
	String fromCompType = (String) session.getAttribute("fromCT");
	fromCompType=(fromCompType==null?"true":fromCompType);

	String print= (String) request.getParameter("print");
	String s_forPdfTitle="";

	s_threshType = (!StringUtils.isNull(s_threshType) && s_threshType.length()>0 ? s_threshType:"");
	s_compType = (!StringUtils.isNull(s_compType) && s_compType.length()>0 ? s_compType:"");
	s_host = (!StringUtils.isNull(s_host) && s_host.length()>0 ? s_host:"");
	req_test = (!StringUtils.isNull(req_test) && req_test.length()>0 ? req_test:"");

	EgDbInfo dbInfo = new EgDbInfo("manager");
	String fontStyle = "";
	if (dbInfo.doubleByteEnabled || !userLanguage.equals("en_US"))
	{
		fontStyle = "multi_font";
	}

	boolean isShowMeasWithoutThresholds = false;
	String showMeasWithoutThreshVal = egUI.getValue("MISC_ARGS","SHOW_MEASURES_WITHOUT_THRESHOLDS");
	if(!StringUtils.isNull(showMeasWithoutThreshVal) && showMeasWithoutThreshVal.equalsIgnoreCase("yes"))
	{
		isShowMeasWithoutThresholds = true;
	}


	if(fromCompType.equalsIgnoreCase("true"))
	{
		s_threshType = "All";
	}

	String criteria = request.getParameter("criteria");
	if (criteria == null)
	{
		criteria = "Component";
	}

	Vector vecCriterias = new Vector();
	for (int g=0;g<criterias.length;g++)
	{
		String strCriteria = criterias[g];
		vecCriterias.add(strCriteria);
	}

	String userOption = request.getParameter("userOption");
	if (StringUtils.isNull(userOption) || userOption.equals("-1"))
	{
		userOption = null;
	}

	String arr_threshTypes[] = {"All","Global","Default","Group","Component","Descriptor"};
	ArrayList thresholdTypes = new ArrayList(Arrays.asList(arr_threshTypes));

	Vector v_allComps = new Vector(disc_info.getAllManagedComponents());
	Vector v_compTypes = new Vector();
	Vector v_components = new Vector();
	Vector v_matchTypes = new Vector();
	ArrayList commonList = null;

	boolean isGlobalContainTest = false;
	boolean isGlobalContainAllTest = false;
	boolean isGlobalConSpecificTest = false;
	boolean isReqTestAll = req_test.equalsIgnoreCase("All");
	boolean global = (globalThresholds!=null && globalThresholds.size()>0);
	ArrayList serverList = null;
	
	String[] compTypes = egRoleInfo.getServerTypes();
	if (compTypes != null && compTypes.length >0)
	{
		for (int i=0;i<compTypes.length;i++)
		{
			ArrayList aListEnabledPTestForCompType = new ArrayList();
			aListEnabledPTestForCompType = specs_info.getEnabledTests(compTypes[i],false);
			if (aListEnabledPTestForCompType.size()>0 && !v_compTypes.contains(compTypes[i]))
			{
				v_compTypes.add(compTypes[i]);
			}
		}
	}

	HashSet vec_componentTypes = new HashSet();
	Vector allcomps = new Vector();
	Vector vec_components = new Vector();
	boolean isValidCompType = (!s_compType.equals("") && !s_compType.equals("-1"));

	ArrayList associatedComponents = getAssociatedComponents(session, _user, criteria, userOption);

	if (!criteria.equals("Component"))
	{
		allcomps.addAll(associatedComponents);
		if (!allcomps.isEmpty())
		{
			for (int i=0;i<allcomps.size();i++)
			{
				String str = (String) allcomps.get(i);
				String component_type = str.substring(0,str.indexOf(":"));
				vec_componentTypes.add(component_type);
				String component_name = str.substring(str.indexOf(":")+1);
				if (isValidCompType && str.startsWith(s_compType))
				{
					vec_components.add(str);
				}
			}
		}

		Vector vecUserOptions = (Vector)session.getAttribute("vecUserOptions");
		if (StringUtils.isNull(userOption) && vecUserOptions != null && !vecUserOptions.isEmpty())
		{
			userOption = (String)vecUserOptions.get(0);
		}

		// filtering server types...
		v_compTypes = new Vector();
		if (vec_componentTypes != null && !vec_componentTypes.isEmpty())
		{
			v_compTypes.addAll(vec_componentTypes);
			//v_compTypes = sorter.getSortedCompTypeList(vec_componentTypes);
		}
	}
	if (v_compTypes != null && v_compTypes.size() > 0)
	{
		serverList = new ArrayList(v_compTypes);
		serverList = sorter.getSortedCompTypeList(serverList);
	}

	//boolean isCompTypeAll = (s_compType != null && s_compType.equalsIgnoreCase("All"));
	if(!StringUtils.isNull(s_compType)  && !s_compType.equals("-1"))
	{
		if(global)
		{
			//if(!isCompTypeAll)
			{
				if(isReqTestAll)
				{
					String tests[] = specs_info.getTestsForServer(s_compType);
					commonList = new ArrayList(Arrays.asList(tests));
					isGlobalContainAllTest = globalThresholds.containsAll(commonList);
					isGlobalConSpecificTest = isListContainsTest(globalThresholds,commonList);
					isGlobalConSpecificTest = !isGlobalConSpecificTest;
				}
				else
				{
					isGlobalContainTest = globalThresholds.contains(req_test);
					isGlobalConSpecificTest = !isGlobalContainTest;
				}
				if(isGlobalContainAllTest || isGlobalContainTest)
				{
					thresholdTypes.clear();
					thresholdTypes.add("Global");
				}
				if(isGlobalConSpecificTest)
				{
					thresholdTypes.remove(thresholdTypes.indexOf("Global"));
				}
			}
		}
		else
		{
			thresholdTypes.remove(thresholdTypes.indexOf("Global"));
		}
	}

	if (!StringUtils.isNull(s_compType) && s_compType.equalsIgnoreCase("ALL"))
	{
		commonList = egRoleInfo.getAllServers();
	}
	else if(!StringUtils.isNull(s_compType) && !s_compType.equals("-1"))
	{
		String[] compsforType = egRoleInfo.getAllServersOfType(s_compType);
		commonList = new ArrayList(Arrays.asList(compsforType));
	}

	if (!criteria.equals("Component"))
	{
		commonList = new ArrayList();
		commonList.addAll(vec_components);
	}

	if(commonList != null && commonList.size() > 0)
	{
		for(int i = 0;i < commonList.size();i++)
		{
			String temp = (String)commonList.get(i);
			int ind = temp.indexOf(":");
			String s_compTy = temp.substring(0,ind);
			String s_compName = temp.substring(ind+1);
			v_components.add(s_compName);
			v_matchTypes.add(s_compTy+'#'+s_compName);
		}
	}

	Collections.sort(v_components,String.CASE_INSENSITIVE_ORDER);
	if (s_host == null)
	{
		if (v_components != null && v_components.size() > 0)
		{
			s_host = (String)v_components.get(0);
		}
		else
		{
			s_host = "All";
		}
	}
	Vector v_allTests = new Vector();
	boolean isAllCompType = false;

	if (!StringUtils.isNull(s_compType) && s_compType.equalsIgnoreCase("All"))
	{
		isAllCompType = true;
		for (int i=0; i<v_compTypes.size();i++)
		{
			String arr_tests[]= specs_info.getTestsForServer((String)v_compTypes.get(i));
			if (arr_tests !=null && arr_tests.length > 0)
			{
				for(int j=0;j<arr_tests.length;j++)
				{
					if(!v_allTests.contains(arr_tests[j]))
					{
						v_allTests.add(arr_tests[j]);
					}
				}
			}
		}
	}
	else if(!StringUtils.isNull(s_compType) && !s_compType.equals("-1"))
	{
		String arr_tests[]= specs_info.getTestsForServer(s_compType);
		if (arr_tests !=null && arr_tests.length > 0)
		{
			for(int j=0;j<arr_tests.length;j++)
			{
				if(!v_allTests.contains(arr_tests[j]))
				{
					v_allTests.add(arr_tests[j]);
				}
			}
		}
	}

	//remove config tests
	TestBean testBean = new TestBean(true);
	ArrayList configTests = testBean.getAllConfigTests();
	v_allTests.removeAll(configTests);
	TreeMap tm_threshData = new TreeMap();

	boolean isAllThresh = s_threshType.equalsIgnoreCase("All");
	boolean isDefaultThresh = s_threshType.equalsIgnoreCase("Default");
	boolean isDefThreshTemp = isDefaultThresh;
	boolean isSpecificThresh = s_threshType.equalsIgnoreCase("Specific");
	boolean isGroupThresh = s_threshType.equalsIgnoreCase("Group");
	boolean isDescThresh = s_threshType.equalsIgnoreCase("Descriptor");
	boolean isDefaultDescriptorThresh = isDefaultThresh; //s_threshType.equalsIgnoreCase("Default descriptor");
	boolean isFixedThresh = s_threshType.equalsIgnoreCase("Global");
	boolean isFixThreshTemp =isFixedThresh;

	//***************For PDF Sub Title*****************
	boolean isCompTypeEnabled = (!StringUtils.isNull(s_compType) && !s_compType.equalsIgnoreCase("All"));
	boolean isCompNameEnabled = (!StringUtils.isNull(s_host) && !s_host.equalsIgnoreCase("All")) && isCompTypeEnabled;
	boolean isTestNameEnabled = (!StringUtils.isNull(req_test) && !req_test.equalsIgnoreCase("All")) && isCompNameEnabled;

	if (isAllThresh)
	{
		if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +": "+_mapping.getTestDescription(req_test)+" ("+ currentDateTime +")";
		else if (isCompNameEnabled && isCompTypeEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+ ":" +removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompNameEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component")+"  : " +removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompTypeEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component Type")+"  : " +_mapping.getComponentTypeDescription(s_compType) +" ("+ currentDateTime +")";
		else
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.All Components")+" ("+ currentDateTime +")";
	}
	else if(isDefaultThresh)
	{
		if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Settings for")+" "+_mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +": "+_mapping.getTestDescription(req_test)+" ("+ currentDateTime +")";
		else if (isCompNameEnabled && isCompTypeEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Settings for")+" "+_mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompNameEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Settings for Component")+" "+ removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompTypeEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Settings for Component Type")+" "+ _mapping.getComponentTypeDescription(s_compType) +" ("+ currentDateTime +")";
		else
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Settings")+" ("+ currentDateTime +")";
	}
	else if(isSpecificThresh)
	{
		if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +": "+_mapping.getTestDescription(req_test)+" ("+ currentDateTime +")";
		else if (isCompNameEnabled && isCompTypeEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+":"+ removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompNameEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component")+"  : "+ removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompTypeEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component Type")+"  : "+ _mapping.getComponentTypeDescription(s_compType) +" ("+ currentDateTime +")";
		else
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.All Specific Components")+" ("+ currentDateTime +")";
	}
	else if(isDescThresh)
	{
		if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +": "+_mapping.getTestDescription(req_test)+" ("+ currentDateTime +")";
		else if (isCompNameEnabled && isCompTypeEnabled)
			s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+":"+ removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompNameEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component")+"  : "+ removeNull(s_host) +" ("+ currentDateTime +")";
		else if(isCompTypeEnabled)
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Component Type")+"  : "+ _mapping.getComponentTypeDescription(s_compType) +" ("+ currentDateTime +")";
		else
			s_forPdfTitle = _mapping.getTextDescription("admin.threshold.All Descriptor Components")+" ("+ currentDateTime +")";
	}
	//else if(isDefaultDescriptorThresh)
	//{
		//if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled)
			//s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+ ":" + removeNull(s_host) +": "+_mapping.getTestDescription(req_test)+" ("+ currentDateTime +")";
		//else if (isCompNameEnabled && isCompTypeEnabled)
			//s_forPdfTitle = _mapping.getComponentTypeDescription(s_compType)+":"+ removeNull(s_host) +" ("+ currentDateTime +")";
		//else if(isCompNameEnabled)
			//s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Descriptor Settings for Component Type")+"  : "+ removeNull(s_host) +" ("+ currentDateTime +")";
		//else if(isCompTypeEnabled)
			//s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Descriptor Settings for Component Type")+"  : "+ _mapping.getComponentTypeDescription(s_compType) +" ("+ currentDateTime +")";
		//else
			//s_forPdfTitle = _mapping.getTextDescription("admin.threshold.Default Descriptor Settings")+" ("+ currentDateTime +")";
	//}
	else
	{
		s_forPdfTitle =  _mapping.getTextDescription("admin.threshold.Threshold Report")+" ("+ currentDateTime +")";
	}

	if(isCompNameEnabled && isCompTypeEnabled && isTestNameEnabled && s_forPdfTitle.length()>80)
	{
		s_forPdfTitle=s_forPdfTitle.substring(0,s_forPdfTitle.lastIndexOf("("))+"\n ("+ currentDateTime +")";
	}

	ArrayList selectedTests = new ArrayList(v_allTests);
	if(!StringUtils.isNull(req_test) && !req_test.equalsIgnoreCase("All"))
	{
		v_allTests.clear();
		v_allTests.add(req_test);
	}

	String[] userThreshvariables = null;
	if(isSpecificThresh || (isAllThresh))
	{
		userThreshvariables =  threshInfo.getUserThresholds();
	}

	String finn = (String) session.getAttribute("fin");
	boolean isAllCompsSelected = (s_host.equalsIgnoreCase("All"));
	Hashtable ht = new Hashtable();

	if (finn != null && finn.equals("yes"))
	{
		ArrayList descriptorList = new ArrayList();
		for(int i=0;i<v_allTests.size();i++)
		{
			String s_test = (String)v_allTests.get(i);
			boolean contain = global && globalThresholds.contains(s_test);
			boolean isAvailThreshVal = false;
			Vector defaultThreshComps = new Vector();

			Vector v_data= new Vector();
			if(isAllThresh)
			{
				if(contain)
				{
					isFixedThresh = true;
					isDescThresh = false;
					isDefaultThresh = false;
					isSpecificThresh = false;
					isGroupThresh = false;
					isDefaultDescriptorThresh = false;
				}
				else
				{
					isDescThresh = true;
					isDefaultThresh = true;
					isSpecificThresh = true;
					isGroupThresh = true;
					isDefaultDescriptorThresh = true;
					isFixedThresh = false;
				}
			}
			else if (!isFixedThresh && contain)
			{
				continue;
			}
			//for Global Threshold (17 Jul 2007)
			if(isFixedThresh)
			{
				if(contain)
				{
					String s_val = threshInfo.getDefaultThresholdValue(s_test);
					if(s_val !=null && !s_val.equals(""))
					{
						isAvailThreshVal = isSetThresholdValues(s_val);
						if(isShowMeasWithoutThresholds || isAvailThreshVal)
						{
							v_data.add("Global thresholds");
							v_data.add(s_val);
						}
					}
				}
			}

			if(isSpecificThresh || isDescThresh || isGroupThresh)// || isDefaultDescriptorThresh)
			{
				Vector v_comps = null;
				if(!s_host.equalsIgnoreCase("All"))
				{
					v_comps = new Vector();
					v_comps.add(s_host);
				}
				else
				{
					v_comps =(Vector) v_components.clone();
				}
				Vector v_specData = new Vector();
				//Vector v_defaultDescData = new Vector();
				Vector v_descData = new Vector();
				Vector v_allData = new Vector();
				for(int j=0;j<v_comps.size();j++)
				{
					if (j>=v_matchTypes.size())
						break;
					if (isAllCompType)
					{
						String t = (String) v_matchTypes.get(j);
						int ind = t.indexOf('#');
						t = t.substring(0,ind);
						if (!specs_info.isTestRelevantForServer (t,s_test) ||contain)
						{
							continue;
						}
					}
					String s_component = (String)v_comps.get(j);
					String s_userThreshKey = s_test;
					String s_descThreshKey = s_test;
					boolean hasCompSpecificThresh = false;

					StringTokenizer st = new StringTokenizer(s_component,":");
					String s_cmp = st.nextToken();
					String s_port = st.nextToken();

					String s_sid = null;
					if(st.hasMoreTokens())
						s_sid = st.nextToken();

					boolean isPortRelevantForTest =specs_info.isPortRelevantForTest(s_test);
					boolean isInfoRelevantForTest =false;

					if (s_compType.equalsIgnoreCase("All"))
					{
						isInfoRelevantForTest = (s_sid!=null && specs_info.isInfoRelevantForTest(s_test));
					}
					else
					{
						isInfoRelevantForTest = (s_sid!=null && specs_info.isInfoRelevantForTest(s_test,s_compType));
					}
					if(isSpecificThresh)
					{
						String s_key = s_cmp;
						if(isPortRelevantForTest)
							s_key += ":" + s_port;
						if(isInfoRelevantForTest)
							s_key += ":" + s_sid;

						String s_title = s_key;
						if(v_specData.contains(s_title))
							continue;
						s_key = s_test + ":" + s_key;
						//************june 24******
						String s_val = "";

						//new change
						boolean check = false;
						if(userThreshvariables != null)
						{
							for(int inc=0; inc <userThreshvariables.length; inc++)
							{
								String localvar = userThreshvariables[inc];
								if(localvar != null && localvar.equals(s_key))
								{
									check = true;
									break;
								}
							}
						}
						//end
						if(check)
						{
							s_val = threshInfo.getUserThresholdValue(s_key);
						}
						//if(s_val == null || s_val.equals(""))
						//{
						//	s_val = descGrp.getThresholdsFromInfoGroupIni(s_key,false);
						//}
						//***********
						if(s_val!=null && !s_val.equals(""))
						{
							hasCompSpecificThresh = true; // for getting default thresh following comps

							s_title = removeNull(s_title);
							//if(isAllThresh)
							{
								s_title =s_title+" [Component]" ;
							}
							isAvailThreshVal = isSetThresholdValues(s_val);
							if(isShowMeasWithoutThresholds || isAvailThreshVal)
							{
								v_specData.add(s_title);
								v_specData.add(s_val);
							}
						}
					}

					if(isDescThresh)
					{
						String s_key = s_cmp;
						String all_key="";
						String all_val="";
						String all_title="";
						if(isPortRelevantForTest)
							s_key += ":" + s_port;
						else
							s_key += ":NULL";
						if(isInfoRelevantForTest)
							s_key += ":" + s_sid;
						String s_title = "";//s_key;
						String inf = "";
						all_title = s_key;
						Vector v_info = threshInfo.getInfosForThresholds(s_test, s_key);
						s_key = s_test + ":" + s_key;
						all_key = s_key;
						if(v_info!=null && v_info.size()>0)
						{
							for(int k=0;k<v_info.size();k++)
							{
								String s_info = (String)v_info.get(k);
								if(s_info.indexOf('+')!=-1)
									s_info = s_info.substring(s_info.indexOf('+')+1);

								String s_orgKey = s_key + "#" + s_info;
								String s_val = "";
								s_val = threshInfo.getDescThresholdValue(s_orgKey);
								//if(s_val == null || s_val.equals(""))
								//{
								//	s_val = descGrp.getThresholdsFromInfoGroupIni(s_orgKey,false);
								//}
								if(s_val!=null && !s_val.equals(""))
								{
									s_title = s_key.substring(s_key.indexOf(":")+1);
									s_title = removeNull(s_title);
									String tmpInfo = s_info;
									if (tmpInfo.indexOf("0eGHash1") > -1)
									{
										tmpInfo = StringUtils.replace(tmpInfo,"0eGHash1","#");
									}
									s_title = s_title+"#" + tmpInfo;
									//if(isAllThresh)
									{
										s_title =s_title+" [Descriptor]";
									}
									isAvailThreshVal = isSetThresholdValues(s_val);
									if(isShowMeasWithoutThresholds || isAvailThreshVal)
									{
										v_descData.add(s_title);
										v_descData.add(s_val);
									}
								}
							}
						}
						//if(v_allData.contains(all_title))
						//	continue;
						//all_val = descGrp.getThresholdsFromInfoGroupIni(all_key,false);
						//if(all_val!=null && !all_val.equals(""))
						//{
						//	all_title = removeNull(all_title);
						//	all_title =all_title+" [Group]";
						//	v_allData.add(all_title);
						//	v_allData.add(all_val);
						//}
					}// end of isDescThresh

					if(isGroupThresh)
					{
						String s_key = s_cmp;
						String grp_key="";
						String grp_val="";
						String grp_title="";
						if(isPortRelevantForTest)
							s_key += ":" + s_port;
						else
							s_key += ":NULL";
						if(isInfoRelevantForTest)
							s_key += ":" + s_sid;
						String s_title = "";//s_key;
						String inf = "";
						grp_title = s_key;
						Vector v_info = threshInfo.getInfosForThresholds(s_test, s_key);
						s_key = s_test + ":" + s_key;
						grp_key = s_key;
						
						if(v_allData.contains(grp_title))
							continue;

						if(v_info!=null && v_info.size()>0)
						{
							for(int k=0;k<v_info.size();k++)
							{
								String s_info = (String)v_info.get(k);
								if(s_info.indexOf('+')!=-1)
									s_info = s_info.substring(s_info.indexOf('+')+1);

								String s_orgKey = s_key + "#" + s_info;
								String s_val = "";
								s_val = descGrp.getThresholdsFromInfoGroupIni(s_orgKey,false);

								if(s_val!=null && !s_val.equals(""))
								{
									s_title = s_key.substring(s_key.indexOf(":")+1);
									s_title = removeNull(s_title);
									String tmpInfo = s_info;
									if (tmpInfo.indexOf("0eGHash1") > -1)
									{
										tmpInfo = StringUtils.replace(tmpInfo,"0eGHash1","#");
									}
									s_title = s_title+"#" + tmpInfo;
									//if(isAllThresh)
									{
										s_title =s_title+" [Group - Descriptor]";
									}
									isAvailThreshVal = isSetThresholdValues(s_val);
									if(isShowMeasWithoutThresholds || isAvailThreshVal)
									{
										v_descData.add(s_title);
										v_descData.add(s_val);
									}
								}
								//else
								//{
									//grp_val = descGrp.getThresholdsFromInfoGroupIni(grp_key,false);

									//if(grp_val!=null && !grp_val.equals(""))
									//{
										//grp_title = removeNull(grp_title);
										//grp_title =grp_title+" [Group]";
										//isAvailThreshVal = isSetThresholdValues(grp_val);
										//if(isShowMeasWithoutThresholds || isAvailThreshVal)
										//{
											//v_allData.add(grp_title);
											//v_allData.add(grp_val);
										//}
									//}
								//}
							}
						}

						grp_val = descGrp.getThresholdsFromInfoGroupIni(grp_key,false);
						if(grp_val!=null && !grp_val.equals(""))
						{
							hasCompSpecificThresh = true; // for getting default thresh following comps

							grp_title = removeNull(grp_title);
							grp_title =grp_title+" [Group]";
							isAvailThreshVal = isSetThresholdValues(grp_val);
							if(isShowMeasWithoutThresholds || isAvailThreshVal)
							{
								v_allData.add(grp_title);
								v_allData.add(grp_val);
							}
						}
					}// end of isDescThresh

					//if(isDefaultDescriptorThresh)
					//{
						//String s_key = s_test;
						//String s_title = "";//s_key;
						//Vector v_info = threshInfo.getInfosForDefaultDescThresholds(s_test);
						//if(v_info!=null && v_info.size()>0)
						//{
							//for(int k=0;k<v_info.size();k++)
							//{
								//String s_info = (String)v_info.get(k);
								//if (descriptorList != null && descriptorList.contains(s_info))
								//{
									//continue;
								//}
								//String s_orgKey = s_key + ":" + s_info;
								//String s_val = "";
								//s_val = threshInfo.getDescDefaultThresholdValue(s_orgKey);
								//if(s_val!=null && !s_val.equals(""))
								//{
									//s_title = _mapping.getTestDescription(s_test)+":"+s_info;
									////if(isAllThresh)
									//{
										//s_title = s_title+" [Default descriptor]";
									//}
									//isAvailThreshVal = isSetThresholdValues(s_val);
									//if(isShowMeasWithoutThresholds || isAvailThreshVal)
									//{
										//descriptorList.add(s_info);
										//v_defaultDescData.add(s_title);
										//v_defaultDescData.add(s_val);
									//}
								//}
							//}
						//}
					//}// end of isDefaultDescriptorThresh

					if (!hasCompSpecificThresh) // for getting default thresh following comps
					{
						defaultThreshComps.add(s_cmp);
					}

				}

				if(v_descData.size()>0) v_data.addAll(v_descData);
				if(v_specData.size()>0) v_data.addAll(v_specData);
				if(v_allData.size()>0) v_data.addAll(v_allData);
				//if(v_defaultDescData.size()>0) v_data.addAll(v_defaultDescData);
			}

			if(isDefaultThresh)
			{
				if (defaultThreshComps != null && !defaultThreshComps.isEmpty())
				{
					ht.put(s_test,defaultThreshComps);
				}
				String s_val = threshInfo.getDefaultThresholdValue(s_test);
				if(s_val!=null && !s_val.equals(""))
				{
					isAvailThreshVal = isSetThresholdValues(s_val);
					if(isShowMeasWithoutThresholds || isAvailThreshVal)
					{
						v_data.add("Default thresholds");
						v_data.add(s_val);
					}
				}

				// starts isDefaultDescriptorThresh
				Vector v_defaultDescData = new Vector();
				if(isDefaultDescriptorThresh)
				{
					String s_key = s_test;
					String s_title = "";//s_key;
					Vector v_info = threshInfo.getInfosForDefaultDescThresholds(s_test);
					if(v_info!=null && v_info.size()>0)
					{
						for(int k=0;k<v_info.size();k++)
						{
							String s_info = (String)v_info.get(k);
							if (descriptorList != null && descriptorList.contains(s_info))
							{
								continue;
							}
							String s_orgKey = s_key + ":" + s_info;
							String s_descval = "";
							s_descval = threshInfo.getDescDefaultThresholdValue(s_orgKey);
							if(s_descval!=null && !s_descval.equals(""))
							{
								s_title = _mapping.getTestDescription(s_test)+":"+s_info;
								//if(isAllThresh)
								{
									s_title = s_title+" [Descriptor default]";
								}
								isAvailThreshVal = isSetThresholdValues(s_descval);
								if(isShowMeasWithoutThresholds || isAvailThreshVal)
								{
									descriptorList.add(s_info);
									v_defaultDescData.add(s_title);
									v_defaultDescData.add(s_descval);
								}
							}
						}
					}
				}
				if(v_defaultDescData.size()>0) v_data.addAll(v_defaultDescData);
				// ends isDefaultDescriptorThresh
			}

			if(v_data.size() > 0)
			{
				tm_threshData.put(s_test,v_data);
				for (int x=1;x<v_data.size();x+=2)
				{
					Vector v_tokens = new Vector();
					String tok = (String) v_data.get(x);
					v_data.setElementAt(tok,x);
				}
			}
		}
	}

	String logo=iniUI.getMonitorHomeLogo();
	if(iniUI.isHKTThemeEnabled())
	{
		logo = iniUI.getHKTReporterLogo();
	}
%>
<html>
<head>
<%//=strStyleSheet%>
<title>Threshold Report</title>

<%
	if (print!=null && print.equalsIgnoreCase("printpage"))
	{
%>
<link rel="stylesheet" type="text/css" href="/final/styles/eGLightTheme.css" />
<link rel="stylesheet" type="text/css" href="/final/styles/eGLightThemeIcons.css" />
<%
	}
%>

<style>

@media print {body {-webkit-print-color-adjust: exact;}}


@font-face{font-family:'LucidaGrandeRegular';src:url('/final/fonts/6216/6216.woff') format('woff')}
@font-face{font-family:'LucidaGrandeBold';src:url('/final/fonts/6215/6215.woff') format('woff')}

body{font-size:11px;line-height:1.5em;color:#2a292a;}
header{font-size:15px;}
.formLabel {font-size:12px;}
.formValue {font-weight:500;font-size:12px;}
b{font-weight:500;font-size:11px;}
table tr td{font-size:11px;padding:4px;}

.printTable{border: 1px solid #c3c3c3; border-collapse: collapse;}
.printTable tr td{border: 1px solid #c3c3c3;}

.printTableHeader{font-weight:500;border: 1px solid #c3c3c3;text-align:center;background-color:#cdcdcd;padding:4px;}

</style>

<script language="JavaScript">
	function printData()
	{
		window.print();
	}
</script>


</head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<body  style="padding:10px">
<form action="EgPrintThreshDetailView.jsp">

<table align="center" cellspacing="0" cellpadding="0" width="100%" border="0">
	<tr>
		<td>
<%
		//if(print!=null && print.equalsIgnoreCase("pdfpage"))
		{
%>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
				<tr>
					<td style="padding:5px 10px 10px 10px"><img src='<%=logo%>' border="0" /></td>
				</tr>
			</table>
<%
		}
%>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"  style="border-bottom:1px solid #999;">
				<tr>
					<td style="padding:2px">
						<div style="float:left" > <header><egui:intnl text="admin.threshold.Threshold Report"/></header></div>
				
<%
		if(print!=null && print.equalsIgnoreCase("printpage"))
		{
%>
						<div style="float:right"><img class="iconPrinter mouse" src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" border="0" onClick="javascript:printData()" alt='<egui:intnl text="reporter.common.PRINT"/>' title='<egui:intnl text="reporter.common.PRINT"/>'/></div>

<%
		}
%>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="eg_blankspace" height="6">&nbsp;</td>
	</tr>
	<tr>
		<td>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" style="border-bottom:1px solid #ccc;">
				<tr>
					<td class="formValue" width="100%" align="center"><%=s_forPdfTitle%></td>
				</tr>
				<tr>
					<td class="eg_blankspace" height="6">&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="eg_blankspace" height="12">&nbsp;</td>
	</tr>
<%
	if (finn != null && finn.equals("yes"))
	{
		if(tm_threshData.size() > 0)
		{
			Iterator itr = tm_threshData.keySet().iterator();
			while(itr.hasNext())
			{
				String key = (String) itr.next();
				String HYPHEN = "";
				Vector v_title =(Vector) tm_threshData.get(key);
				if(v_title.size() == 2)
				{
					HYPHEN = " - ";
				}
%>
	<tr>
		<td nowrap>
			<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" class="printTable">
				<tr>
					<td width="100%" align="left" class="printTableHeader" style="padding:4px"> <egui:intnl test="<%=key%>" /></td>
				</tr>

<%
				for (int x=0;x<v_title.size();x+=2)
				{
%>
						
<%
					String title = (String) v_title.get(x);
					if(title.equalsIgnoreCase("Default"))
						title = mappingInfo.getTestDescription(key);
					else if (title.equalsIgnoreCase("Global"))
						title = mappingInfo.getTestDescription(key)+" ["+_mapping.getTextDescription("admin.threshold.Global")+"]";
					else
						title = mappingInfo.getTestDescription(key) + ":" +title;
					//if(v_title.size() > 2)

					String tmpStr = ((String)v_title.get(x));
					boolean isDefaultDescriptor = false;
					if (!StringUtils.isNull(tmpStr) && tmpStr.indexOf(":") != -1 && tmpStr.endsWith("[Default descriptor]"))
					{
						isDefaultDescriptor = true;
					}
					boolean isDefaultThresholdBlock = false;

					if (!StringUtils.isNull(tmpStr) && tmpStr.equalsIgnoreCase("Default Thresholds"))
					{
						isDefaultThresholdBlock = true;
					}

						if (x > 0)
						{
%>
				<tr><td>&nbsp;</td></tr>
<%
						}
				if (isDefaultDescriptor)
				{
					String tempDispTest = tmpStr.substring(0,tmpStr.indexOf(":"));
					String tempInfo = tmpStr.substring(tmpStr.indexOf(":"),tmpStr.indexOf("["));
					String tempThreshType = tmpStr.substring(tmpStr.indexOf(" [")+1);
					tmpStr = tempDispTest.toUpperCase()+tempInfo+tempThreshType.toUpperCase();

%>
					<tr><td width='95%' nowrap ><strong><%=tmpStr%></strong></td></tr>
<%
				}
				else
				{
%>
					<tr>
						<td  width="95%" nowrap ><strong><%=tmpStr.toUpperCase()%></strong></td>
					</tr>
<%
				}
				String v_data1 = (String)v_title.get(x+1);
%>


				<tr>
					<td style="padding:10px">
						<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" class="printTable"><col width="20%"><col width="65%"><col width="15%">
<%
		boolean heading_flag = false;
		ArrayList aListTestWithNoThresholds = new ArrayList();
		boolean cellFlag = false;
		StringTokenizer st = new StringTokenizer(v_data1,",");
		boolean isMeasureWithThresholds = false;
		while (st.hasMoreTokens())
		{
			String strTok = st.nextToken();
			StringTokenizer st1 = new StringTokenizer(strTok,":");
			while (st1.hasMoreTokens())
			{
				String measure = st1.nextToken();
				String policy = st1.nextToken();
				String min = st1.nextToken();
				String max = st1.nextToken();
				String alarmPolicy = st1.nextToken();
				String lastToken = st1.nextToken();

				String absMinCritical = "-";
				String relMinCritical = "-";

				String absMinMajor = "-";
				String relMinMajor = "-";

				String absMinMinor = "-";
				String relMinMinor = "-";

				String absMaxCritical = "-";
				String relMaxCritical = "-";

				String absMaxMajor = "-";
				String relMaxMajor = "-";

				String absMaxMinor = "-";
				String relMaxMinor = "-";

				if (policy.equalsIgnoreCase("none"))
				{
					policy = "mix";
				}
				else if (policy.equalsIgnoreCase("absolute"))
				{
					if (!min.equals("-1"))
					{
						StringTokenizer stAbsMin = new StringTokenizer(min,"/");
						absMinCritical = stAbsMin.nextToken();
						absMinMajor = stAbsMin.nextToken();
						absMinMinor = stAbsMin.nextToken();
					}

					if (!max.equals("-1"))
					{
						StringTokenizer stAbsMax = new StringTokenizer(max,"/");
						absMaxCritical = stAbsMax.nextToken();
						absMaxMajor = stAbsMax.nextToken();
						absMaxMinor = stAbsMax.nextToken();
					}
				}
				else if (policy.equalsIgnoreCase("relative"))
				{
					if (!min.equals("-1"))
					{
						StringTokenizer stRelMin = new StringTokenizer(min,"/");
						relMinCritical = stRelMin.nextToken();
						relMinMajor = stRelMin.nextToken();
						relMinMinor = stRelMin.nextToken();
					}

					if (!max.equals("-1"))
					{
						StringTokenizer stRelMax = new StringTokenizer(max,"/");
						relMaxCritical = stRelMax.nextToken();
						relMaxMajor = stRelMax.nextToken();
						relMaxMinor = stRelMax.nextToken();
					}
				}
				else if (policy.equalsIgnoreCase("mix"))
				{
					Vector vec = getAbsAndRel(min);
					String absA = (String) vec.get(0);
					String relA = (String) vec.get(1);
					Vector vec1 = getAbsAndRel(max);
					String absB = (String) vec1.get(0);
					String relB = (String) vec1.get(1);

					if (!absA.equals("none"))
					{
						StringTokenizer stmixMin = new StringTokenizer(absA,"/");
						absMinCritical = stmixMin.nextToken();
						absMinMajor = stmixMin.nextToken();
						absMinMinor = stmixMin.nextToken();
					}

					if (!absB.equals("none"))
					{
						StringTokenizer stmixMax = new StringTokenizer(absB,"/");
						absMaxCritical = stmixMax.nextToken();
						absMaxMajor = stmixMax.nextToken();
						absMaxMinor = stmixMax.nextToken();
					}

					if (!relA.equals("none"))
					{
						StringTokenizer stRelMin = new StringTokenizer(relA,"/");
						relMinCritical = stRelMin.nextToken();
						relMinMajor = stRelMin.nextToken();
						relMinMinor = stRelMin.nextToken();
					}

					if (!relB.equals("none"))
					{
						StringTokenizer stmixMax = new StringTokenizer(relB,"/");
						relMaxCritical = stmixMax.nextToken();
						relMaxMajor = stmixMax.nextToken();
						relMaxMinor = stmixMax.nextToken();
					}
				}

				String minCritical = getThresholdValue("min",absMinCritical,relMinCritical);
				String minMajor = getThresholdValue("min",absMinMajor,relMinMajor);
				String minMinor = getThresholdValue("min",absMinMinor,relMinMinor);

				String maxCritical = getThresholdValue("max",absMaxCritical,relMaxCritical);
				String maxMajor = getThresholdValue("max",absMaxMajor,relMaxMajor);
				String maxMinor = getThresholdValue("max",absMaxMinor,relMaxMinor);

				if (minCritical.equals("-") && minMajor.equals("-") && minMinor.equals("-") && 
					maxCritical.equals("-") && maxMajor.equals("-") && maxMinor.equals("-"))
				{
					aListTestWithNoThresholds.add(measure);
					cellFlag = !cellFlag;
					continue;
				}

				if (!heading_flag)
				{
					heading_flag = true;
%>
				<!-- Heading -->
							<tr>
								<td align="center" class="printTableHeader">Measure</td>
								<td align="center"  class="printTableHeader">
									<table cellpadding="0" cellspacing="0" border="0" width="100%" ><col width="19%"><col width="27%"><col width="27%"><col width="27%">
										<tr>
											<td align="center" class="printTableHeader">Min/Max</td>
											<td align="center" class="printTableHeader">Critical</td>
											<td align="center" class="printTableHeader">Major</td>
											<td align="center" class="printTableHeader">Minor</td>
										</tr>
									</table>
								</td>
								<td  align="center"  class="printTableHeader">Alarm Policy</td>
							</tr>
<%
				}
				String unit = tablesInfo.getUnitForMeasure(key,measure);
%>
							<tr>
								<td align="left" valign="middle" >
									<div style="float:left"><%=mappingInfo.getMeasureDescription(key,measure)%></div><div style="float:right" >&nbsp;<i>(<%=unit%>)</i>&nbsp;</div>
								</td>
								<td align="left" valign="top">
									<table cellpadding="0" cellspacing="0" border="0" width="100%" class="printTable"><col width="19%"><col width="27%"><col width="27%"><col width="27%" >
<%
				if(!minCritical.equals("-") || !minMajor.equals("-") || !minMinor.equals("-"))
				{
%>
										<tr>
											<td align="center"><b>Min</b></td>
											<td align="center"><%=minCritical%></td>
											<td align="center"><%=minMajor%></td>
											<td align="center"><%=minMinor%></td>
										</tr>
<%
				}

				if(!maxCritical.equals("-") || !maxMajor.equals("-") || !maxMinor.equals("-"))
				{
%>
										<tr>
											<td align="center"><b>Max</b></td>
											<td align="center"><%=maxCritical%></td>
											<td align="center"><%=maxMajor%></td>
											<td align="center"><%=maxMinor%></td>
										</tr>
<%
				}
%>
									</table>
								</td>
								<td valign="middle" title="<%=alarmPolicy%>"><egui:display name="<%=alarmPolicy%>" length="<%=Integer.toString(alarmPolicyLength)%>"/></td>
							</tr>
<%
			}
			isMeasureWithThresholds = true;
			cellFlag = !cellFlag;
		}
%>
						</table>
<%
		if(isShowMeasWithoutThresholds)
		{
			if (aListTestWithNoThresholds != null && !aListTestWithNoThresholds.isEmpty())
			{
				if (isMeasureWithThresholds) 
				{
%>
					<br/>
<%
				}
%>
						<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0" class="printTable">
							<tr>
								<td colspan="3" height="20" class="printTableHeader">Measures without thresholds</td>
							</tr>
<%
				for (int d=0; d<aListTestWithNoThresholds.size(); d=d+3)
				{
%>
							<tr>
<%
					for (int e=d; e<d+3; e++)
					{
						if (e<aListTestWithNoThresholds.size())
						{
							String strMeasure = (String)aListTestWithNoThresholds.get(e);
%>
								<td width="25%" >
												<%=mappingInfo.getMeasureDescription(key,strMeasure)%>
								</td>
<%
						}
						else
						{
%>
								<td width="25%" >&nbsp;</td>
<%
						}
					}
%>
							</tr>
<%
				}
%>
						</table>
<%
			}
		}
				if (isAllCompsSelected && isDefaultThresholdBlock)
				{
					Vector defaultThreshComps = (Vector) ht.get(key);

					if (defaultThreshComps != null && defaultThreshComps.size() > 0)
					{
%>
						<br/>
						<!-- <tr><td style="padding:10px">
 -->						<table align='center' width='100%' cellspacing='0' cellpadding='0' ><tr><td height='20' class='padding4 table_head'>Applicable Components</td></tr><tr><td width='100%'><table width='100%' cellspacing='0' cellpadding='0' border='0' class='printTable' style='border-collapse: collapse;'><col width='33%'><col width='33%'><col width='34%'>
<%
						for (int c=0; c<defaultThreshComps.size(); c=c+3)
						{
%>
							<tr>
<%
							int rec=1;
							for (int e=c; e<c+3; e++)
							{
								//JSONObject threshNoMeasureObj = new JSONObject();

								if (e<defaultThreshComps.size())
								{
									String strCompName = (String)defaultThreshComps.get(e);

									String tmpStyple="";
									if(rec==1)
									{
										tmpStyple="border-left-width:1px";
										rec++;
									}
%>
									<td valign='top' align='left' ><%=strCompName%></td>
<%
								}
								else
								{
%>
									<td class='tdbor der_ad' >&nbsp;</td>
<%
								}
							}
%>
							</tr>
<%
						}
%>
						</table></td></tr></table>
						<!-- </td></tr>
 --><%
					}

				}
		}

%>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td id="eg_blnkspace" height="10">&nbsp;</td>
	</tr>
<%
			}
		}
		else
		{
%>
	<tr>
		<td colspan="7" align="center" valign="middle"  height="200" class="eg_subhead">
			<img src="/final/admin/eg_images/<%=admin_Skin%>/exclamation-icon.gif"><br> &nbsp;&nbsp;&nbsp;<egui:intnl text="admin.threshold.No Data Available For The Combination Chosen"/>
		</td>
	</tr>
<%
		}
	}
%>
		
</table>
</form>
</body>
</html>

<%!
	public boolean isListContainsTest(ArrayList a1,ArrayList a2)
	{
		boolean b = false;
		for(int i=0;i<a2.size();i++)
		{
			String temp = (String)a2.get(i);
			if(a1.contains(temp))
			{
				b = true;
				break;
			}
		}
		return b;
	}
%>
<%
	if(request.getQueryString()!=null)
	{
		session.setAttribute("adminLastAccessedURL","/final/admin/EgViewThreshold.jsp?"+request.getQueryString());
	}
	else
	{
		session.setAttribute("adminLastAccessedURL","/final/admin/EgViewThreshold.jsp");
	}
%>

<%!
	int alarmPolicyLength = 15;

	private String get1(String H)
	{
		String h;
		if (!(H.equals("-")))
		{
			if (H.indexOf("&") > -1)
			{
				StringTokenizer st = new StringTokenizer(H,"&");
				H = st.nextToken();
				h = st.nextToken();
			}
			else
			{
				if (H.indexOf("sqc") > -1)
				{
					h = H;
					H = "-";
				}
				else
				{
					h = "-";
				}
			}
		}
		else
		{
			h = "-";
		}
		return(H+"_"+h);
	}

	private Vector getAbsAndRel(String format)
	{
		Vector vect = new Vector();
		StringTokenizer stok1 = new StringTokenizer(format,"/");
		if (!format.equals("-1") && stok1.countTokens() == 3)
		{
			String H1 = stok1.nextToken();
			String h2=get1(H1);
			String M = stok1.nextToken();
			String m1=get1(M);
			String L = stok1.nextToken();
			String l1=get1(L);
			StringTokenizer h1 = new StringTokenizer(h2,"_");
			String High= h1.nextToken();
			String high = h1.nextToken();
			StringTokenizer m = new StringTokenizer(m1,"_");
			String Mid = m.nextToken();
			String mid = m.nextToken();
			StringTokenizer l = new StringTokenizer(l1,"_");
			String Low = l.nextToken();
			String low = l.nextToken();
			StringBuffer sb2 = new StringBuffer();
			StringBuffer sb1 = new StringBuffer();
			String s1 = null;
			if (High.equals("-") && Mid.equals("-") && Low.equals("-"))
			{
				s1 = "none";
			}
			else
			{
				sb1.append(High);
				sb1.append("/");
				sb1.append(Mid);
				sb1.append("/");
				sb1.append(Low);
				s1 = sb1.toString();
			}
			String s2 = null;
			if (high.equals("-") && mid.equals("-") && low.equals("-"))
			{
				vect.add(s1);
				vect.add("none");
			}
			else
			{
				sb2.append(high);
				sb2.append("/");
				sb2.append(mid);
				sb2.append("/");
				sb2.append(low);
				s2 = sb2.toString();
				vect.add(s1);
				vect.add(s2);
			}
		}
		else
		{
			vect.add("none");
			vect.add("none");
		}
		return vect;
	}

	private String getThresholdValue(String grpFunction, String absValue,String relValue)
	{
		String strValue = "-";

		if (absValue.equals("-") && relValue.equals("-"))
		{
			strValue = "-";
		}
		else if (!absValue.equals("-") && !relValue.equals("-"))
		{
			strValue = grpFunction+"("+absValue+", "+getRelativeThreshold(relValue)+")";
		}
		else if (!absValue.equals("-"))
		{
			strValue = absValue;
		}
		else if (!relValue.equals("-"))
		{
			strValue = getRelativeThreshold(relValue);
		}
		return strValue;
	}

	private String getRelativeThreshold(String relValue)
	{
		//relValue: 3*sqc
		String strValue = "";
		if (relValue.indexOf("*") != -1)
		{
			int idx = relValue.indexOf("*");
			String s1 = relValue.substring(0,idx);
			double d_value = Double.valueOf(s1.trim()).doubleValue();
			d_value = d_value * 100;
			int i_value = (new Double(d_value)).intValue();
			strValue = Integer.toString(i_value) + "% of auto";
		}
		else
		{
			strValue = "auto";
		}
		return strValue;
	}

	public String removeNull(String compName)
	{
		if (compName != null && compName.length()>0)
		{
			return (compName.endsWith(":NULL"))?compName.substring(0,compName.indexOf(":NULL")):compName;
		}
		else
		{
			return "";
		}
	}

	public boolean isSetThresholdValues(String str)
	{
		boolean isThreshVal = false;
		StringTokenizer st = new StringTokenizer(str,",");
		while(st.hasMoreElements())
		{
			String tmpVal = st.nextToken();
			StringTokenizer st1 = new StringTokenizer(tmpVal,":");
			String measName = st1.nextToken();
			String measType = st1.nextToken();
			String minVal = st1.nextToken();
			String maxVal = st1.nextToken();
			if(!minVal.equals("-1") || !maxVal.equals("-1"))
			{
				isThreshVal = true;
				break;
			}
		}
		return isThreshVal;
	}

%>