/**
 * @(#)file    CommCodeDetailBiz.java
 * @(#)author  gyeongmo an
 * @(#)date    2014.08.01
 * @(#)Description: 기준코드 등록
 *
 * Copyright (c) www.udapsoft.co.kr, Inc.
 * All rights reserved.
 */
	    
package kr.co.udapsoft.ebid.buyer.sycs.code.biz;

import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.base.WAFLogger;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;

public class CommCodeDescBiz extends Biz {
	/**
	 * @param storage
	 */
	public CommCodeDescBiz(HandlerStorage storage) {

		super(storage);
	}

	public void doBiz() throws Exception {
        params.set("sheet1", getDescRowSet());
		storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
	}

    private RowSet getDescRowSet() {
    	
    	String tablenm = params.get("p_table_nm");
		String basecd = params.get("p_base_cd");

        Search search = new SearchImpl();
        RowSet rowSet = null;
        String sqlstr = "";

        try {
        	sqlstr = " SELECT    TABLE_NM,             	\n"
        		   + "           BASE_CD,      		  	\n"
        	       + "           COL_ENG,       		\n"
        	       + "           COL_KOR,       		\n"
        	       + "           CODE_ID,              	\n"
        	       + "           CRE_DATE,            \n"
        	       + "           CRE_BY,              \n"
        	       + "           COL_DESC               \n"
        	       + " FROM      TEST_COM912T        		\n"
        	       + " WHERE     1=1        		    \n";

        if (!tablenm.equals("")) {

			sqlstr += " AND    TABLE_NM LIKE '" + tablenm + "%'  \n";
		}
        if (!basecd.equals("")) {

			sqlstr += " AND    BASE_CD LIKE '" + basecd + "%'  \n";
		}
            sqlstr += " order by CODE_ID  \n";
        	search.setStatement(sqlstr);
            rowSet = search.execute();
        }
        catch(Exception e) {
   
            WAFLogger.error(this.getClass().getName() + " --> getDescRowSet() : " + e.getMessage());
            WAFLogger.error("SQL : " + search.getStatement());
            WAFLogger.error(e);
        }
        finally {

            if( rowSet == null ) rowSet = new RowSetImpl();
            return rowSet;
        }
        
    }
}
