<%--
 Copyright : All Rights Reserved. Copyright (C) 2006, Hitachi, Ltd.
 Title     : ServerConductor WebConsole
 Version   : 08-00
 Name      : inventoryList.jsp
 Date      : 2006/04/12
 Author	   : Praveen P
 --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<%@ page language = "java" %>
<%@ page session = "false" %>
<%@ page errorPage = "errorDialog.jsp" %>
<%@ page import = "JP.co.Hitachi.soft.System_Manager.webconsole.common.Const" %>
<%@ page import = 
"JP.co.Hitachi.soft.System_Manager.webconsole.model.bean.InventoryListBean" %>
<%@ page import = 
"JP.co.Hitachi.soft.System_Manager.webconsole.common.InventoryProcess" %>
<%@ page import = "java.util.Vector" %>
<%@ page import = "java.net.URLEncoder" %>
<%@ page contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %> 
<%@ taglib prefix = "bean"  uri = "/WEB-INF/struts-bean.tld" %>
<%@ taglib prefix = "html"  uri = "/WEB-INF/struts-html.tld" %>
<%@ taglib prefix = "util"  uri = "/WEB-INF/common-tags.tld" %>
<%-- <% response.addHeader("Cache-control","NO CACHE"); %> --%>					<% // 800WA_WEBCONSOLE308 %>
<% response.addHeader("Cache-control","no-cache"); %> 							<% // 800WA_WEBCONSOLE308 %>
<util:checkURL/>

<%-- Get icons from the const.java file and set it into the pageContext implicit
	 object as an attribute --%>
<util:set name = "PlusIcon">
	<%= Const.PATH_IMAGES %><%= Const.SEPARATOR_FILE %><%= Const.IMAGE_PLUS %>
</util:set>

<util:set name = "MinusIcon">
	<%= Const.PATH_IMAGES %><%= Const.SEPARATOR_FILE %><%= Const.IMAGE_MINUS %>
</util:set>

<util:set name = "SpaceIcon1">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE1 %>
</util:set>

<util:set name = "SpaceIcon2">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE2 %>
</util:set>

<util:set name = "SpaceIcon3">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE3 %>
</util:set>

<util:set name = "SpaceIcon4">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE4 %>
</util:set>

<util:set name = "SpaceIcon5">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE5 %>
</util:set>

<util:set name = "SpaceIcon6">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SPACE6 %>
</util:set>

<util:set name = "ServerIcon">
	<%= Const.PATH_IMAGES %><%= Const.IMAGE_SERVER_NORMAL %>
</util:set>


<jsp:useBean id="InventoryListBean" class = 
"JP.co.Hitachi.soft.System_Manager.webconsole.model.bean.InventoryListBean"
scope = "request"/>
<%
	Vector l_vtListTree = new Vector();
	String l_stLeafNode = null;
	String l_stFlag = "false";													// 800WA_WEBCONSOLE293
	// Assinging value to tree menu vector by calling 
	// the getter method of the list bean
	l_vtListTree = InventoryListBean.getListTree();
%>
<html:html locale = "true">
	<head>
		<link rel = "stylesheet" type = "text/css" href = "css/common.css">
		<script src = "js/listTree.js"></script>
		<script src = "js/common.js"></script>
	</head>
	<%-- <body>	--%>															<% // 800WA_WEBCONSOLE088 %>
	<%-- <body class = "nowrap"> --%>											<% // 800WA_WEBCONSOLE088 // 800WA_WEBCONSOLE089 %>
	<%-- <body class = "nowrap" onload = "agent.focus()"> --%>                  <% // 800WA_WEBCONSOLE089 %><% // 800WA_WEBCONSOLE445 %>
	<%-- <body class = "nowrap" onload = "agent.focus()" 							
	 onclick = "releaseSelection()"> --%>                                       <% // 800WA_WEBCONSOLE445 %> <% // 800WA_WEBCONSOLE457 %>
	<body class = "nowrap" onclick = "releaseSelection()">						<% // 800WA_WEBCONSOLE457 %>
	<div id="treeData" style="visibility:hidden">								<% // 800WA_WEBCONSOLE457 %>
		<%--Displaying the plus icon for the agent name in inventory 
			tree block --%>
		<util:set name = "FuncListTree">
		javaScript:listTree('Hierarchy01', 
			'<%= pageContext.getAttribute("PlusIcon") %>', 
			'<%= pageContext.getAttribute("MinusIcon") %>')
		</util:set>
		<html:img src = "<%= pageContext.getAttribute("PlusIcon").toString() %>" 
			styleId = "Hierarchy01img" border = "0" onclick = 
			"<%= pageContext.getAttribute("FuncListTree").toString() %>"/>
			
		<%-- To display the icon for each node --%>
		<html:img src = '<%= pageContext
			.getAttribute("ServerIcon").toString() %>'/>
		
		<%-- Performing tree operation for the agent name --%>

		<util:set name = "FuncParentAgent">
		javascript:parentNode('Hierarchy01',
			'<%= pageContext.getAttribute("PlusIcon").toString() %>', 
		<%--'<%= pageContext.getAttribute("MinusIcon")
				 .toString() %>','detail','') --%>								<% // 800WA_WEBCONSOLE098 %>
		<%--'<%= pageContext.getAttribute("MinusIcon")
				.toString() %>','detail','jsp/default.html')--%>				<% // 800WA_WEBCONSOLE098 %><% // 800WA_WEBCONSOLE293 %>
			'<%= pageContext.getAttribute("MinusIcon").toString() %>','detail',
				'jsp/default.html','','<%= l_stFlag %>')						<% // 800WA_WEBCONSOLE293 %>
		</util:set>

		<%-- <html:link styleClass = "middle" href = 
		"<%= pageContext.getAttribute("FuncParentAgent").toString() %>"> --%>	<% // 800WA_WEBCONSOLE089 %>
		<%-- <html:link styleClass = "middle" styleId = "agent" href = 
		"<%= pageContext.getAttribute("FuncParentAgent").toString() %>">        <% // 800WA_WEBCONSOLE089 %>--%><%-- 800WA_WEBCONSOLE445 --%>
		<html:link styleClass = "middle" styleId = "agent" href = 
		"<%= pageContext.getAttribute("FuncParentAgent").toString() %>"        
		onclick = "linkClicked(this)">                                          <%-- 800WA_WEBCONSOLE445 --%>
			<%= request.getParameter("agentName") %>
		</html:link>
		<br>
		<div id = "Hierarchy01" style = "display:none">

		<%
			// Declaration and Initialisation 
			String l_stTemp = null;
			Vector l_vtCurrentNode = null;
			Vector l_vtNextNode = null;
			String l_stSpaceImg = null;
			int l_iIndent = 0; 
			StringBuffer l_sbQueryString = new StringBuffer();

			// Generating DIV tag for each node in the list tree
			for(int l_iCnt = 0;l_iCnt < l_vtListTree.size();l_iCnt++) { 
				// Storing Current node and next node data
				l_vtCurrentNode = ((Vector)l_vtListTree.get(l_iCnt));
				l_stFlag = "false";												// 800WA_WEBCONSOLE293
				if (l_iCnt < l_vtListTree.size() - 1) {
					l_vtNextNode = ((Vector)l_vtListTree.get(l_iCnt + 1));
					l_stTemp = l_vtNextNode.get(0).toString();
				}
				else {
					l_stTemp = l_vtCurrentNode.get(0).toString();
				}

				// Obtaining spaces image file path according to the 
				// position of node in tree
				if(l_iIndent == 0) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon1");
				}
				else if(l_iIndent == 1) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon2");
				}
				else if(l_iIndent == 2) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon3");
				}
				else if(l_iIndent == 3) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon4");
				}
				else if(l_iIndent == 4) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon5");
				}
				else if(l_iIndent == 5) {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon6");
				}
				else {
					l_stSpaceImg = (String) pageContext
						.getAttribute("SpaceIcon1");
				}
				%>																<%-- 800WA_WEBCONSOLE293 --%>  	
			    <input type = "hidden"                            
			           name = "<%= l_vtCurrentNode.get(0)+ "node" %>" 
			           value = "<%= l_vtCurrentNode.get(1) %>" />               <%-- 800WA_WEBCONSOLE293 --%>  	
				<%																// 800WA_WEBCONSOLE293  	
				// Check if the current node is not the leaf node
				if (!(l_vtCurrentNode.get(0).toString().
					endsWith(Const.LEAF_NODE))) {
					%>

					<%-- To display the number of spaces for the node --%>
					<html:img src = "<%= l_stSpaceImg %>"/>
					
					<%-- To display the Plus icon for the parent nodes.
						 On click of Plus icon, treeMenu function is called --%>

					<util:set name = "FunclistTree">
						javaScript:listTree('<%= l_stTemp %>', 
						'<%= pageContext.getAttribute("PlusIcon").toString() %>' 
						,'<%= pageContext.
							getAttribute("MinusIcon").toString() %>')
					</util:set>



					<html:img src = "<%= pageContext.
						getAttribute("PlusIcon").toString() %>"
						styleId = "<%= l_stTemp + "img" %>" border = "0" 
						onclick = "<%= pageContext.
							getAttribute("FunclistTree").toString() %>"/>

					<%-- To display the icon for each node --%>
					<html:img src = '<%= l_vtCurrentNode.get(2).toString() %>' 
						alt = '<%= l_vtCurrentNode.get(3).toString() %>'/>

					<util:set name = "ActionClass">
						<util:rewrite action = "inventoryDetail" />
					</util:set>
					
					<% l_sbQueryString.delete(0,l_sbQueryString.length());

					String l_stFuncName = l_vtCurrentNode.get(0).toString();
				//	if(!(l_stFuncName.startsWith(InventoryProcess.SCSI_ROOT) && // 800WA_WEBCONSOLE476 
		        //			l_stFuncName.length() == 							// 800WA_WEBCONSOLE476 
		        //			InventoryProcess.SCSIADAPTER.length())){			// 800WA_WEBCONSOLE476 
					if(!((l_stFuncName.startsWith(InventoryProcess.SCSI_ROOT) &&// 800WA_WEBCONSOLE476 
		        			l_stFuncName.length() == 							// 800WA_WEBCONSOLE476 
		        			InventoryProcess.SCSIADAPTER.length()) || 			// 800WA_WEBCONSOLE476 
		        			(l_stFuncName.equals(InventoryProcess.PCI))  )){	// 800WA_WEBCONSOLE476 
		        				l_sbQueryString.append("jsp/default.html");
		        				
		        	}
		        	else {
		        	l_stFlag = "true";											// 800WA_WEBCONSOLE293 	
					l_sbQueryString.append(pageContext
						.getAttribute("ActionClass").toString());
					l_sbQueryString.append("?nodeId=");
					l_sbQueryString.append(request.getParameter("nodeId"));
					l_sbQueryString.append("&functionalNodeName=");
					l_sbQueryString.append(l_vtCurrentNode.get(0).toString());  // 800WA_WEBCONSOLE041
					//l_sbQueryString.append("&nodeName=");						800WA_WEBCONSOLE293 	
					//l_sbQueryString.append(l_vtCurrentNode.get(1).toString());800WA_WEBCONSOLE293 
					}
					%>
					
					<util:set name = "FuncParentNode">
						javascript:parentNode('<%= l_stTemp %>', 
						'<%= pageContext.getAttribute("PlusIcon").toString() %>' 
						, '<%= pageContext.
							getAttribute("MinusIcon").toString() %>','detail',
						<%-- '<%= l_sbQueryString %>') --%>						<%-- 800WA_WEBCONSOLE293 --%>  		
						'<%= l_sbQueryString %>','<%= l_vtCurrentNode.get(0).
								toString()%>','<%= l_stFlag %>')				<%-- 800WA_WEBCONSOLE293 --%>
					</util:set>
					<%-- On click of node name, parent function is called --%>
					<html:link styleClass = "middle" href = 
					"<%= pageContext.getAttribute
						("FuncParentNode").toString()%>"
						onclick = "linkClicked(this)">                          <% // 800WA_WEBCONSOLE445 %>                        
						<%= l_vtCurrentNode.get(1).toString() %>
					</html:link>
					<br>
					
					<%-- Check if l_stTemp node is the leaf node --%>
					<% if ((l_stTemp.endsWith(Const.LEAF_NODE)) || 
						(l_stTemp.length()) > ((l_vtCurrentNode.get(0).
							toString()).length()))  {

						// Indentation is increased.
						l_iIndent = l_iIndent + 1 ; %>
						
						<%-- Generate a DIV tag for l_stTemp node --%>
						<div id = "<%= l_stTemp %>" style = "display:none">
					<% }
				}
				else
				{ 
					// Storing the current leaf node name 
					l_stLeafNode = l_vtCurrentNode.get(1).toString(); %>
					<util:set name = "LeafNode">
					<%= l_stLeafNode %>
					</util:set>
										
					<%-- To display the number of spaces for the node --%>
					<html:img src = "<%= l_stSpaceImg%>"/>
					<html:img src = "<%= pageContext.
						getAttribute("SpaceIcon1").toString() %>"/>
					<%-- To display the icon for each node --%>					
					<html:img src = '<%= l_vtCurrentNode.get(2).toString() %>' 
						alt = '<%= l_vtCurrentNode.get(3).toString() %>'/>

					<% l_sbQueryString.delete(0,l_sbQueryString.length());
        			String l_stFuncName = l_vtCurrentNode.get(0).toString();
	        		if(l_stFuncName.equals(InventoryProcess.EISA) || 
		        		l_stFuncName.length() == 
		        			InventoryProcess.SCSI_ROOT.length() + 1 ||
		        		l_stFuncName.length() == 
		        			InventoryProcess.SCSIBUS.length() + 1) {
	        			l_sbQueryString.append("jsp/default.html");
	        			l_stFlag = "false";										// 800WA_WEBCONSOLE293 
	        		}
	        		
	        		else {
	        		l_stFlag = "true";											// 800WA_WEBCONSOLE293 
					l_sbQueryString.append(pageContext
						.getAttribute("ActionClass").toString());
					l_sbQueryString.append("?nodeId=");
					l_sbQueryString.append(request.getParameter("nodeId"));
					l_sbQueryString.append("&functionalNodeName=");
					l_sbQueryString.append(l_vtCurrentNode.get(0).toString());%><% // 800WA_WEBCONSOLE041 %>
					<% 
					//l_sbQueryString.append("&nodeName=");						// 800WA_WEBCONSOLE293 
					//String l_stNodeName = l_vtCurrentNode.get(1).toString();	// 800WA_WEBCONSOLE293 
					//if(l_stNodeName.endsWith(":\\")) {						// 800WA_WEBCONSOLE293 
					//l_stNodeName = String.valueOf(l_stNodeName.charAt(0));	// 800WA_WEBCONSOLE293 
					//}															// 800WA_WEBCONSOLE293 
					//l_sbQueryString.append(l_stNodeName);  					// 800WA_WEBCONSOLE293 
					}
					%>

					<%--On click of node name,Detail window is opened --%>
					
					<%-- <util:set name = "FuncWindowOpen">
						javaScript:window.open('<%= l_sbQueryString
							.toString() %>', 'detail')					
					</util:set> --%>											<%-- 800WA_WEBCONSOLE293 --%>
					
					<util:set name = "FuncWindowOpen">
						targetOpen('detail', '<%= l_sbQueryString %>',
						'<%= l_vtCurrentNode.get(0).toString() %>',
						'<%= l_stFlag %>');linkClicked(this);	
					</util:set>													<%-- 800WA_WEBCONSOLE293 --%>
					
					<a name = '<%= l_vtCurrentNode.get(0) %>link'> </a>
					<html:link styleClass = "middle" 
						href = "#<%= l_vtCurrentNode.get(0) %>link" 
						onclick = "<%= pageContext.getAttribute("FuncWindowOpen")
						.toString()%>"> <%= l_vtCurrentNode.get(1) %>
					</html:link>
					<br>
				
					<% 
					// Check if l_sttemp node is not the leaf node
					if (!(l_stTemp.endsWith(Const.LEAF_NODE))) {
						
						// Generate Closing DIV tag
						for (int l_iTempCnt = l_stTemp.length()+1 ; 
						l_iTempCnt < (((l_vtCurrentNode.get(0))
						//.toString()).length()); l_iTempCnt = l_iTempCnt++ ) { 800WA_WEBCONSOLE076
						.toString()).length()); l_iTempCnt = l_iTempCnt + 2 ){  // 800WA_WEBCONSOLE076
							l_iIndent = l_iIndent - 1; %>
							</div>
					<% }
					}
					else if ((l_stTemp.length()) < (((l_vtCurrentNode.get(0))	// 800WA_WEBCONSOLE076
						.toString()).length())) {								// 800WA_WEBCONSOLE076
																				// 800WA_WEBCONSOLE076
						// Generate Closing DIV tag								// 800WA_WEBCONSOLE076
						for (int l_iTempCnt = l_stTemp.length()+1 ; 			// 800WA_WEBCONSOLE076
						l_iTempCnt <= (((l_vtCurrentNode.get(0))				// 800WA_WEBCONSOLE076
						.toString()).length()); l_iTempCnt = l_iTempCnt + 2 ) {	// 800WA_WEBCONSOLE076
							l_iIndent = l_iIndent - 1; %>						<% // 800WA_WEBCONSOLE076 %>
							</div>												<% // 800WA_WEBCONSOLE076 %>
					<% }														// 800WA_WEBCONSOLE076
					}
				}
			}	
			%>
		</div>	
	</div>																		<% // 800WA_WEBCONSOLE457 %>
	</body>
<script>																		<% // 800WA_WEBCONSOLE457 %>
	function enable()															// 800WA_WEBCONSOLE457
	{																			// 800WA_WEBCONSOLE457
		document.getElementById("treeData").style.visibility = 'visible';		// 800WA_WEBCONSOLE457
		document.getElementById("agent").focus();								// 800WA_WEBCONSOLE457
	}																			// 800WA_WEBCONSOLE457
	addOnloadEvent(enable);														// 800WA_WEBCONSOLE457
</script>																		<% // 800WA_WEBCONSOLE457 %>
</html:html>