<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.b2bextractor.B2BExtractManager"%>
<%@ page import="com.eactive.eai.common.b2bextractor.B2BExtractVO"%>
<%@ 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;
	}
%>
<%
	B2BExtractManager manager = B2BExtractManager.getInstance();  
    String[]          alls    = manager.getAllKeyNames();
    String            action  = request.getParameter("actionType");
    
    String selectedKey = request.getParameter("selectedKey");
    int seq = 1;
    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
    if ("reload".equals(action)){
    	// 마지막 제거
    	manager.reload(selectedKey.substring(0,selectedKey.length()-1));
    }else if ("reloadAll".equals(action)){
    	manager.reload();
    }else {
    	;
    }
    B2BExtractVO vo   = null;
    if(selectedKey!=null) {
       vo = manager.getB2BExtract(selectedKey);
    }
    
%>


<html>
    <head>
    
        <title>
            B2BExtractManager
        </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.svcCd.value + document.frm.svcPssSeq.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="">
        <input type="hidden" name="actionSeq" value="">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
	        <tr bgcolor='white'>
	            <td align='right' width='350' bgcolor="#ccccff">IF서비스코드+IF서비스처리번호 :&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='right' bgcolor="#ccccff">IF서비스코드 :&nbsp;&nbsp;</td>
	        	<td align='left' >&nbsp;<input type="edit" name="svcCd" onkeydown="enterEvent()" style="width:98%" value="<%=vo.getEaiSvcCd()%>"  /></td> 
	            <td colspan=2 rowspan=2 align='center'><input type="button" name="search" value="search" onClick="doSearch()" /></td>
	        </tr>
	        <tr bgcolor='white'>
	        	<td align='right' bgcolor="#ccccff">IF서비스처리번호 :&nbsp;&nbsp;</td>
	        	<td align='left' >&nbsp;<input type="edit" name="svcPssSeq" onkeydown="enterEvent()" style="width:98%" value="<%=vo.getSvcPssSeq()%>"  /></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; IF서비스코드 : &nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%" value="<%=vo.getEaiSvcCd()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; IF서비스 처리번호 : &nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%" value="<%=vo.getSvcPssSeq()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 기관코드추출 CLASS : &nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="LOADSEQUENCE" style="width:98%" value="<%=vo.getRouteActionName()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 어댑터라우팅추출 CLASS : &nbsp;</td>
            <td align='left' style="height: 40;">&nbsp;<input type="text" name="LIFECYCLECLASS" style="width:98%" value="<%=vo.getAdapterActionName()%>"></td>
        </tr>
        
<%
}
%>    
        </table>
        </form>
    </body>
</html>