<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.eactive.eai.adapter.AdapterGroupVO"%>
<%@ page import="com.eactive.eai.adapter.AdapterVO"%>
<?xml version="1.0" encoding="euc-kr"?>
<Dataset>
    <Columns>
          <Column Name="eaiSvrInstNm" Type="string" Size="50" />
          <Column Name="adapterGroupName" Type="string" Size="50" />
          <Column Name="adapterName" Type="string" Size="50" />
          <Column Name="adapterGroupDesc" Type="string" Size="50" />
          <Column Name="adapterKind" Type="string" Size="20" />
          <Column Name="adapterStatus" Type="string" Size="20" />
          <Column Name="adapterStartStatus" Type="string" Size="20" />
          <Column Name="adapterStartStop" Type="string" Size="20" />
          <Column Name="adapterGroupSimple" Type="string" Size="50" />        
    </Columns>
    <Rows>
<%
    String eaiSvrInstNm = request.getParameter("eaiSvrInstNm");
    String adapterType = request.getParameter("adapterType");

    if (eaiSvrInstNm == null)
      eaiSvrInstNm = "";
    if (adapterType == null)
      adapterType = "";


    String stateColor = "";
    String stateText = "";

    String startColor = "";
    String startText = "";
    String startStop = "";
    
    boolean bAdded = false ;

    com.eactive.eai.adapter.AdapterManager manager = com.eactive.eai.adapter.AdapterManager.getInstance();
    java.util.HashMap voMap = manager.getAllAdapterGroupVO();

    Iterator it = voMap.keySet().iterator();
    String[] groupNames = new String[voMap.size()];
    for (int i = 0; it.hasNext(); i++) {
      groupNames[i] = (String) it.next();
    }
    Arrays.sort(groupNames);

    for (int i = 0; i < groupNames.length; i++) {
      AdapterGroupVO gvo = manager.getAdapterGroupVO(groupNames[i]);

      if(gvo == null)
        continue;

      // YUN_DEBUG (20080619) : 천기숙 과장 요청 사항
      // YUN_DEBUG (20080623) : 최준호 과장 요청 사항
      if ( adapterType.equals(gvo.getType()) || 
           ( adapterType.equals("HTT") && "HQS".equals(gvo.getType())) ||
           ( adapterType.equals("HTT") && "HXC".equals(gvo.getType())) 
         ) {

        Iterator it2 = gvo.getAdapters();

        for (int j = 0; it2.hasNext(); j++) {
          AdapterVO vo = (AdapterVO) it2.next();

          if(vo == null)
            continue;

          if (vo.isStatus()) {
            stateColor = "BLUE";
            stateText = "normal";
          } else {
            stateColor = "RED";
            stateText = "abnormal";
          }

          if (vo.isStarted()) {
            startColor = "BLUE";
            startText = "starting";
            startStop = "03";
          } else {
            startColor = "RED";
            startText = "stop";
            startStop = "01";
          }
%>
<Row>
  <Data><%=eaiSvrInstNm%></Data>
  <Data><%=gvo.getName() + " [" + String.valueOf(gvo.currentTx()) + "]"%></Data>
  <Data><%=vo.getName()%></Data>
  <Data><%=gvo.getDescription()%></Data>
  <Data><%=gvo.getGubun()%></Data>
  <Data><%=stateText%></Data>
  <Data><%=startText%></Data>
  <Data><%=startStop%></Data>
  <Data><%=gvo.getName()%></Data>
</Row>
<%
            bAdded = true ;
        } //for
      } // if
    } // for
    
    if( bAdded == false ) {
        %>
        <Row>
            <Data><%=eaiSvrInstNm%></Data>
            <Data></Data>
            <Data></Data>
            <Data></Data>
            <Data></Data>
            <Data></Data>
            <Data></Data>
            <Data></Data>   
            <Data></Data>
        </Row>
        <%
    }
%>
    </Rows>
</Dataset>