<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.b2badaptermapping.B2BAdapterMapManager"%>
<%@ page import="com.eactive.eai.common.b2badaptermapping.*"%>
<%@ page import="java.util.HashMap"%>

<%!
	/**
	* <pre>
	* 문자열을 받아서 널이면 제로스트링을, 아니면 트림된 문자열을 리턴.
	* </pre>
	* @param	String		변환 대상
	* @return	'String'
	*/
	public static String checkNull( String str ) {

		String sResult = new String();
		if ( str == null ) {
			sResult = "";
		}
		else {
			sResult = str.trim();
		}
		return sResult;
	}
%>
<%
    
	B2BAdapterMapManager manager = B2BAdapterMapManager.getInstance();  
    String               action  = request.getParameter("actionType");
    String[]             alls    = manager.getAllKeyNames();
    
    String selectedKey = request.getParameter("selectedKey");

    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
    if ("reload".equals(action)){
    	//manager.reload(selectedKey);
    }else if ("reloadAll".equals(action)){
    	manager.reload();
    }else {
    	;
    }
    B2BAdapterMapVO vo   = null;
  
    if(selectedKey!=null) {
       vo = manager.getB2BAdapterMap(selectedKey);
    }
    
%>


<html>
    <head>
    
        <title>
            B2BAdapterMapManager
        </title>
         <script>
        function doAction() {
            document.frm.submit();
        }
        function managerReload(){ 
        	document.frm.actionType.value="reload";
        	document.frm.submit();
        	
        }
        function managerReloadAll(){
        	document.frm.actionType.value="reloadAll";
        	document.frm.submit();
        }
        function doSearch(){
        	var searchValue = document.frm.searchTxt.value;
        	document.frm.selectedKey.value = searchValue;
        	document.frm.submit();
        }
        function enterEvent(){
        	if(window.event.keyCode==13){
        		doSearch();
        	}
        }
        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>라우팅 특정포트 매핑 관리</b> <br><br>
        </p>
        <form name="frm" action="">
        <input type="hidden" name="actionType" value="">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
	        <tr bgcolor='white'>
	            <td rowspan=2 align='right' width='350' bgcolor="#ccccff">EAI 서비스 코드 :&nbsp;&nbsp;</td>
	            <td align='left'>&nbsp;<select name="selectedKey" onchange="doAction();"style="width:98%" >
	            <%
	                for(int i=0;i<alls.length;i++) {
	            %>
	                <option value="<%=alls[i]%>" <%= (alls[i].equals(selectedKey)) ? "selected" : "" %> ><%=alls[i]%>
	            <%           
	                }
	            %></select>
	            </td>
	            <!-- td width='50'><input type="button" name="reload" value="reload" onClick="managerReload()" /></td -->
	            <td width='70'><input type="button" name="reloadAll" value="reloadAll" onClick="managerReloadAll()" /></td>
	            
	        </tr>
	        <tr bgcolor='white'>
	            <td align='left' >&nbsp;<input type="edit" style="width:98%;" name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>" style="width:98%"/></td> 
	            <td colspan=2 align="center"><input type="button" name="search" value="search" onClick="doSearch()" /></td>
	        </tr>
        </table><br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' bgcolor="#003366">&nbsp; <font color="yellow"><b>내용</b> &nbsp;</font></td>
            
        </tr>


<%
    if(vo != null ){
        
%>
		<tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; EAI서버인스턴스명  : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%"  value="<%=vo.getEaiInstCd()%>"></td>
        </tr>
        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; EAI서비스코드  : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%"  value="<%=vo.getEaiSvcCd()%>"></td>
        </tr>
<%
	String[] fkeys = vo.getAllKeyNames();
	for(int i=0; i< fkeys.length; i++) {
		B2BAdapterMapFldVO fld = vo.getB2BAdapterMapFld(fkeys[i]);
%>        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">MAP FIELD : (<%=fkeys[i]%>)&nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;</td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 기관코드  : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%"  value="<%=fld.getB2bExtnlInstiCd()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp;세부업무구분명 : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LOADSEQUENCE" style="width:98%"  value="<%=fld.getBzwkVal()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 어뎁터업무그룹명   : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%"  value="<%=fld.getAdapterGroupName()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 어뎁터업무이름   : &nbsp;</td>
            <td align='left' style="height: 40px;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%"  value="<%=fld.getAdapterName()%>"></td>
        </tr>
        
<%
	}
}
%>    
        </table>
        </form>
    </body>
</html>