<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.adapter.AdapterGroupVO"%>
<%@ page import="com.eactive.eai.adapter.AdapterManager"%>
<%@ page import="com.eactive.eai.adapter.AdapterVO"%>

<%
    String flag = "";
    
    AdapterManager manager  = AdapterManager.getInstance();
    List grpList = manager.getAllAdapterGroupNames();

    String selectedName = request.getParameter("groupName");
    String selectedadp  = request.getParameter("adpName");
    if (selectedName == null && grpList.size() > 0) 
        selectedName = (String)grpList.get(0);
    
    AdapterGroupVO grpVO = manager.getAdapterGroupVO(selectedName);
    String[] adpNames    = grpVO.getAdapterNames();
    
    if (selectedadp == null && adpNames.length > 0) 
        selectedadp = adpNames[0];
        
    AdapterVO aVO = manager.getAdapterVO(selectedName,selectedadp );
        

    if ("S".equals(request.getParameter("flag"))) {
        grpVO = manager.getAdapterGroupVO(selectedName);
        adpNames = grpVO.getAdapterNames();
        selectedadp = adpNames[0];
        aVO = grpVO.getAdapterVO(selectedadp);
    }
        
    if (selectedName != null && selectedadp != null) {
        aVO = manager.getAdapterVO(selectedName, selectedadp);
    }
    
%>

<html>
    <head>
        <title>
            Adpater Informations
        </title>
        <script>
        function doAction() {
            document.frm.submit();
        }
        
        function doSelect() {
            document.frm.flag.value="S";
            document.frm.submit();
        }
        

        </script>
    </head>
    <body>
        <p style="font-size:12pt;">
        <b>어댑터 정보</b> <br><br>
        </p>
        <form name="frm" action="">
        <input type="hidden" name="flag" value="<%=flag%>">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
	        <tr bgcolor='white'>
	            <td align='right' width='220' bgcolor="#ccccff">어댑터 그룹명 :&nbsp;</td>
	            <td align='left'>&nbsp;<select name="groupName" onchange="doSelect();" style="width:98%;">
	            <%
	                for(int i=0;i < grpList.size(); i++) {
	            %>
	                <option value="<%= grpList.get(i) %>" <%= (grpList.get(i).equals(selectedName)) ? "selected" : "" %>><%= grpList.get(i) %>
	            <%           
	                }
	            %></select>
	            </td>
			</tr>
	        <tr bgcolor='white'>
	            <td align='right' width='220' bgcolor="#ccccff">어댑터 이름 :&nbsp;</td>
	            <td align='left'>&nbsp;<select name="adpName" onchange="doAction();" style="width:98%;">
	            <%
	                for(int i=0;i < adpNames.length; i++) {
	            %>
	                <option value="<%= adpNames[i] %>" <%= (adpNames[i].equals(selectedadp)) ? "selected" : "" %>><%= adpNames[i] %>
	            <%           
	                }
	            %></select>
	            </td>
	        </tr>
        </table><br>
        
        <%
            if (aVO != null) {
        %>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; 어뎁터업무 이름  : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="adptBwkNm" style="width:98%;" value="<%=aVO.getName()%>" readonly></td>
        </tr>      
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; 리스너클래스명  : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="listenerClass" style="width:98%;" value="<%=aVO.getListenerClass()%>"></td>
        </tr>  
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; 프라퍼티 그룹명  : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="propGroupName" style="width:98%;" value="<%=aVO.getPropGroupName()%>"></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; 테스터클래스명  : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="testCallClass" style="width:98%;" value="<%=aVO.getTestCallClass()%>"></td>
        </tr>  
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; 어뎁터 상태  : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<input type="text" name="status" style="width:98%;" value="<%=aVO.isStatus()%>"></td>
        </tr>  
        <tr bgcolor='white'>
            <td align='right' width='220' bgcolor="#ccccff">&nbsp; AdapterVO  : &nbsp;</td>
            <td align='left' style="height:40px;"><%=aVO.toString()%></td>
        </tr>  

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