
<%@ page import="java.io.*, java.util.*"%>
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ page import="com.eactive.eai.transformer.function.FunctionDefinition"%>
<%@ page import="com.eactive.eai.transformer.function.FunctionManager"%>
<%@ page import="com.eactive.eai.transformer.function.ParameterDefinition"%>
<%@ page import="com.eactive.eai.transformer.util.TransformKeys"%>
<%@ 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;
	}

%>

<%
    FunctionManager manager = FunctionManager.getInstance();
    String[]        alls    = manager.getAllFunctionNames();
    
    String selectedKey = request.getParameter("selectedKey");
    if(selectedKey == null && alls.length>=1) {
        selectedKey  = alls[0];
    }
   
    FunctionDefinition vo = null;
    ArrayList paramList = new ArrayList();
  
    if(selectedKey!=null) {
    	vo = manager.getFunctionDefinition(selectedKey);
        paramList = (ArrayList) vo.getParameterList();
    }
    
%>


<html>
    <head>
        <title>
            Transform 변환함수 Manager
        </title>
         <script>
        function doAction() {
            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="">
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td rowspan=2 align='right' width='350' bgcolor="#ccccff">변환함수명 :&nbsp;&nbsp;</td>
            <td align='left'><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 rowspan=2 align="center"><input type="button" name="search" value="search" onClick="doSearch()" /></td>
        </tr>
        <tr bgcolor='white'>
            <td align='left' ><input type="edit" name="searchTxt" onkeydown="enterEvent()" value="<%=selectedKey%>" style="width:98%" /></td> 
        </tr>
        </table><br>
        <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' width='350' 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; 변환함수명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getName()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환함수설명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getDescription()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환함수반환유형 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=TransformKeys.getType(vo.getReturnTypeId())%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환함수클래스명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=vo.getFunctionClass()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="#ccccff">&nbsp; 변환함수유형 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=TransformKeys.getFunctionType(vo.getFunctionTypeId())%></td>
        </tr>
        
<%
} else {
%>    
        <tr bgcolor='white'>
            <td align='center' colspan="2" >&nbsp; 요청하신 변환함수 정보가 없습니다. &nbsp;</td>
        </tr>

<%
}
%>
        </table>
    <br>
            <table width="800" border=0 bgcolor='black' cellpadding="1" cellspacing="1">
        <tr bgcolor='white'>
            <td align='right' colspan='2' width='350' bgcolor="#003366">&nbsp; <font color="yellow"><b>LayoutItem 정보</b> &nbsp;</font></td>            
        </tr>
<%
if (paramList != null && paramList.size() > 0) {
    
    int nCount = 0;
    String[] aBgColor = {"#ccccff", "#e9e1fd"};
    for (int i = 0; i < paramList.size(); i++) {
        ParameterDefinition param = (ParameterDefinition) paramList.get(i);
%>

        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="<%= aBgColor[nCount%2] %>">&nbsp; 변환함수파라미터일련번호 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=param.getSeqNo()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="<%= aBgColor[nCount%2] %>">&nbsp; 변환함수파라미터명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=param.getName()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="<%= aBgColor[nCount%2] %>">&nbsp; 변환함수파라미터설명 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=param.getDescription()%></td>
        </tr>
        <tr bgcolor='white'>
            <td align='right' width='350' bgcolor="<%= aBgColor[nCount%2] %>">&nbsp; 변환함수파라미터유형 : &nbsp;</td>
            <td align='left' style="height:40px;">&nbsp;<%=TransformKeys.getType(param.getTypeId())%></td>
        </tr>

<%
    nCount++;
    }
} else {
%>    
        <tr bgcolor='white'>
            <td align='center' colspan="2" >&nbsp; 요청하신 변환함수 파라메터 정보가 없습니다. &nbsp;</td>
        </tr>

<%
}
%>

        </table>
   </form>
    </body>
</html>
