/**
 * @(#)file    SYSInputStandardCodeListBiz.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.base.WAFLogger;
import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.sql.RowSetImpl;
import kr.co.hsnc.common.sql.WAFSQLException;
import kr.co.hsnc.common.sql.search.Search;
import kr.co.hsnc.common.sql.search.SearchImpl;
import kr.co.hsnc.common.util.ValueObject;

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

public class SYSInputStandardCodeListBiz extends Biz {

	public SYSInputStandardCodeListBiz(HandlerStorage storage) {
		super(storage);
	}

	/* (non-Javadoc)
	 * @see kr.co.hwenc.system.Biz#doBiz()
	 */
	public void doBiz() throws Exception {
		params.set("sheet1", getListRowSet(params));
		storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
	}

	public RowSet getListRowSet(ValueObject Params) throws Exception {               
		Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sql  = new StringBuffer();
        try {
        	// SORT_METHOD,1,'순번', 2,'코드명', 3,'한글명', 4,'영문명', 5,'등록일시
        	
        	sql.append("     SELECT 			\n");
        	sql.append("     	BASECD			\n");
        	sql.append("	 	, BASENM		\n");
        	sql.append("     	, SORT_METHOD	\n");
        	sql.append("     	, BASELENGTH	\n");
        	sql.append("     	, REMARK		\n");
        	sql.append("    FROM EBID_COM910T	\n");
        	sql.append("    WHERE 1=1			\n");
        	if(!"".equals(params.get("p_basenm"))) {
        		sql.append("    AND BASENM LIKE '%' || UPPER(?) || '%'	\n");
        		search.addParameter(params.get("p_basenm"));
        	}
        	sql.append("     ORDER BY BASECD	\n");
        	
            search.setStatement(sql.toString());
            WAFLogger.debug(sql.toString());
            rowSet = search.execute();
        }
        catch (WAFSQLException se) {
            super.doException(se);
            this.storage.setSuccess(false);
            this.storage.setMessage(se.getMessage());
            storage.setDetailMessage(se);
        }
        finally {    
            if(rowSet == null) rowSet = new RowSetImpl();
            return rowSet;
        }
    }
}
