<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.common.EAITable"%>
<%@ page import="com.eactive.eai.common.message.EAIMessage"%>
<%@ page import="com.eactive.eai.common.message.ServiceMessage"%>
<%@ page import="com.eactive.eai.common.message.EAIMessageManager"%>
<%@ 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;
	}
%>
<%
    
    EAIMessageManager manager  = EAIMessageManager.getInstance();    
    String[]          alls     = manager.getAllEAISvcCd();
    String            action   = request.getParameter("actionType");
    String            eaiSvcCd = checkNull(request.getParameter("id"));
    

    String selectedKey = request.getParameter("selectedKey");
    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
    
    if(eaiSvcCd.length() > 0){
        selectedKey = eaiSvcCd;
    }
   
    List<ServiceMessage> listVo = null;
    
    if(selectedKey!=null) {
    	listVo = manager.getEAIMessage(selectedKey).getSvcMsgs();        
    }
%>


<html>
    <head>
        <title>
            EAI ServiceMessage Manager
        </title>
        <script>
        function doAction() {
            document.frm.submit();
        }
        
       
        function openRefMsgID(id){
            var url = 'refmsgid.jsp?svcCds='+id;
            msgWindow=window.open(url);
        }
        
        function openCondPerRtgInfo(id, seq){
            var url = '_condperrtginfo.jsp?id='+id+'seq'+seq;
            msgWindow=window.open(url);
        }
        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>EAI ServiceMessage Configuration</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='180' bgcolor="#ccccff">EAI서비스코드</td>
            <td align='left'>&nbsp;<select name="selectedKey" onchange="doAction();">
            <%
                for(int i=0;i<alls.length;i++) {
            %>
                <option value="<%=alls[i]%>" <%= (alls[i].equals(selectedKey)) ? "selected" : "" %>><%=alls[i]%>
            <%           
                }
            %></select>
            </td>
        </tr>
         -->
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">EAI서비스코드</td>
            <td align='left'>&nbsp;<input type="text" name="selectedKey" value="<%=selectedKey%>" style="width:98%"/>
            </td>
        </tr>
        </table>
        </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(listVo != null) {
        int size = listVo.size();
        for(int i=0; i<size; i++) {
            ServiceMessage sm =  (ServiceMessage)listVo.get(i);  
%>
        <tr bgcolor='white'>
            <td align='right' width="350" height="5" bgcolor="#003366" colspan="2">&nbsp;<font color="yellow"><b>Field[<%= i %>]</b> &nbsp;</font></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="svcPssSeq" style="width:98%" value="<%=sm.getSvcPssSeq()%>"></td>
        </tr>
        
         <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 수동인터페이스유형 : &nbsp;</td>                                                                           
            <td align='left' style="height:40px;">
            &nbsp;<select name="psvItfTp" style="width:98%">                                                                                                                                
            <%                                                                                                                                                   
                int psvItfTpLength = EAITable.PSV_ITF_TYPE.length;                                                                                                   
                                                                                                                                                               
                for(int j=0; j<psvItfTpLength; j++) {                                                                                                             
            %>                                                                                                                                                   
            <option value="<%=EAITable.PSV_ITF_TYPE[j]%>" <%= (EAITable.PSV_ITF_TYPE[j].equals(sm.getPsvItfTp())) ? "selected" : "" %>><%=EAITable.PSV_ITF_TYPE[j]%>
            <%                                                                                                                                                   
                }                                                                                                                                                
            %>                                                                                                                                                   
            </select>                                                                                                                                            
            </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="psvBwkSysNm" style="width:98%" value="<%=sm.getPsvBwkSysNm()%>"></td>
        </tr>
        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 수동시스템ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="psvSysID" style="width:98%" value="<%=sm.getPsvSysID()%>"></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="psvSysSvcCd" style="width:98%" value="<%=sm.getPsvSysSvcCd()%>"></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="psvSysItfTp" style="width:98%" value="<%=sm.getPsvSysItfTp()%>"></td>
        </tr>
        

        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; FailOver여부 : &nbsp;</td>                                                                           
            <td align='left' style="height:40px;">
            &nbsp;<select name="flOvrCls" style="width:98%">                                                                                                                                
            <%                                                                                                                                                   
                int flOvrClsLength = EAITable.FAIL_OVER_CLS.length;                                                                                                   
                                                                                                                                                                 
                for(int j=0; j<flOvrClsLength; j++) {                                                                                                             
            %>                                                                                                                                                   
            <option value="<%=EAITable.FAIL_OVER_CLS[j]%>" <%= (EAITable.FAIL_OVER_CLS[j].equals(sm.getFlOvrCls())) ? "selected" : "" %>><%=EAITable.FAIL_OVER_CLS[j]%>
            <%                                                                                                                                                   
                }                                                                                                                                                
            %>                                                                                                                                                   
            </select>                                                                                                                                            
            </td>                                                                                                                                                
        </tr>
        
        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환유무 : &nbsp;</td>                                                                           
            <td align='left' style="height:40px;">
            &nbsp;<select name="cnvEn" style="width:98%">                                                                                                                                
            <%                                                                                                                                                   
                int cnvEnLength = EAITable.CNV_EXIST_NOT.length;                                                                                                   
                                                                                                                                                                 
                for(int j=0; j<cnvEnLength; j++) {                                                                                                             
            %>                                                                                                                                                   
            <option value="<%=EAITable.CNV_EXIST_NOT[j]%>" <%= (EAITable.CNV_EXIST_NOT[j].equals(sm.getCnvEn())) ? "selected" : "" %>><%=EAITable.CNV_EXIST_NOT[j]%>
            <%                                                                                                                                                   
                }                                                                                                                                                
            %>                                                                                                                                                   
            </select>                                                                                                                                            
            </td>                                                                                                                                                
        </tr>
        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환메시지ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="cnvMsgID" style="width:98%" value="<%=sm.getCnvMsgID()%>"></td>
        </tr>
        <!--
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 응답메시지ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="rspMsgRefID" style="width:98%" value="<%=sm.getRspMsgRefID()%>"></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="bsRspMsgCprVl" style="width:98%" value="<%=sm.getBsRspMsgCprVl()%>"></td>
        </tr>

        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 기본응답변환유무 : &nbsp;</td>                                                                           
            <td align='left' style="height:40px;">
            &nbsp;<select name="bsRspCnvEn" style="width:98%">                                                                                                                                
            <%                                                                                                                                                   
                int bsRspCnvEnLength = EAITable.BS_RSP_CNV_EXIST_NOT.length;                                                                                                   
                                                                                                                                                                 
                for(int j=0; j<bsRspCnvEnLength; j++) {                                                                                                             
            %>                                                                                                                                                   
            <option value="<%=EAITable.BS_RSP_CNV_EXIST_NOT[j]%>" <%= (EAITable.BS_RSP_CNV_EXIST_NOT[j].equals(sm.getBsRspCnvEn())) ? "selected" : "" %>><%=EAITable.BS_RSP_CNV_EXIST_NOT[j]%>
            <%                                                                                                                                                   
                }                                                                                                                                                
            %>                                                                                                                                                   
            </select>                                                                                                                                            
            </td>                                                                                                                                                
        </tr>
        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 기본응답변환메시지ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="bsRspCnvMsgID" style="width:98%" value="<%=sm.getBsRspCnvMsgID()%>"></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="errRspMsgCprVl" style="width:98%" value="<%=sm.getErrRspMsgCprVl()%>"></td>
        </tr>
        
        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 오류응답변환유무 : &nbsp;</td>                                                                           
            <td align='left' style="height:40px;">
            &nbsp;<select name="errRspCnvEn" style="width:98%">                                                                                                                                
            <%                                                                                                                                                   
                int errRspCnvEnLength = EAITable.ERR_RSP_CNV_EXIST_NOT.length;                                                                                                   
                                                                                                                                                                 
                for(int j=0; j<errRspCnvEnLength; j++) {                                                                                                             
            %>                                                                                                                                                   
            <option value="<%=EAITable.ERR_RSP_CNV_EXIST_NOT[j]%>" <%= (EAITable.ERR_RSP_CNV_EXIST_NOT[j].equals(sm.getErrRspCnvEn())) ? "selected" : "" %>><%=EAITable.ERR_RSP_CNV_EXIST_NOT[j]%>
            <%                                                                                                                                                   
                }                                                                                                                                                
            %>                                                                                                                                                   
            </select>                                                                                                                                            
            </td>                                                                                                                                                
        </tr>
        
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 오류응답변환메시지ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="errRspCnvMsgID" style="width:98%" value="<%=sm.getErrRspCnvMsgID()%>"></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="keyMgtMsgVl" style="width:98%" value="<%=sm.getKeyMgtMsgVl()%>"></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="nxtSvcPssSeq" style="width:98%" value="<%=sm.getNxtSvcPssSeq()%>"></td>
        </tr>

        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; Outbound라우팅명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="outbRtnNm" style="width:98%" value="<%=sm.getOutbRtnNm()%>"></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="tmoVl" style="width:98%" value="<%=sm.getTmoVl()%>"></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="cpnsSvcPssCd" style="width:98%" value="<%=sm.getCpnsSvcPssCd()%>"></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="cpnsSvcPssCd" style="width:98%" value="<%=sm.getSupplDelYn()%>"></td>
        </tr>

        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 헤더제어구분코드 - [01/02]삭제추가/추가삭제 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="cpnsSvcPssCd" style="width:98%" value="<%=sm.getHdrCtrlDstcd()%>"></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="cpnsSvcPssCd" style="width:98%" value="<%=sm.getHdrRefClsName()%>"></td>
        </tr>

        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 타이머참고메시지ID : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="tmRefMsgID" style="width:98%" value="<%=sm.getTmRefMsgID()%>"></td>
        </tr>
        

        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">참조메시지IDS</td>                                                                              
<%
		if(sm.getRefMsgIDs() == null || sm.getRefMsgIDs().length <= 0) {			
%> 
			<td align='left' style="height:40px;">&nbsp; 0건 입니다. &nbsp; </td>                         
<%
		}
		else {
%>                                                             

            <td align='left' >&nbsp;<a href="javascript:openRefMsgID('<%=sm.getEAISvcCd() %>');"><%=sm.getRefMsgIDs().length%>&nbsp; 건 &nbsp;</a> </td>                         
<%
		}
%>       
        </tr>
        
        <!-------------------------------------------------------------->
        
        <tr bgcolor='white'>                                                                                                                                     
            <td align='right' width='350' bgcolor="#ccccff">조건부라우팅정보테이블</td>                                                                              
<%
		if(sm.getCondPerRtgInfo() == null || sm.getCondPerRtgInfo().size() <= 0) {			
%> 
			<td align='left' style="height:40px;">&nbsp; 0건 입니다. &nbsp; </td>                         
<%
		}
		else {
%>                                                             

            <td align='left' >&nbsp;<a href="javascript:openCondPerRtgInfo('<%=sm.getEAISvcCd() %>','<%=sm.getSvcPssSeq()%>');"><%=sm.getCondPerRtgInfo().size()%>&nbsp; 건 &nbsp;</a> </td>                         
<%
		}
%>       
        </tr>
        
<% 
        } 

    } 
   
%>    
        </table>
        </form>
    </body>
</html>