/**
 * @(#)file    CommMatlCodeSectListBiz
 * @(#)author  lsm
 * @(#)version 1.0
 * @(#)date    2014. 3. 5
 * @(#)since   JDK1.4.1
 *
 * Copyright (c) 2002-2003 www.hwenc.com, Inc.  
 * All rights reserved.
 * This software is the proprietary information of hwenc, Inc.
 */
package kr.co.udapsoft.ebid.buyer.sycs.common.biz;

import com.udapsoft.modular.web.ibsheet7.IBSheet7Factory;
import com.udapsoft.modular.web.ibsheet7.util.IBSheet7Utils;
import com.udapsoft.waf.common.ui.HTMLMaker;
import kr.co.udapsoft.ebid.buyer.sycs.security.biz.SYSRightCommon;
import com.udapsoft.waf.system.Biz;
import com.udapsoft.waf.system.HandlerStorage;
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.sql.util.RowSetUtility;
import kr.co.hsnc.common.util.ValueObject;

public class CommGongCodeTreeList extends Biz {
    
    public CommGongCodeTreeList(HandlerStorage storage) {

        super(storage);        
    }
    public void doBiz() throws Exception {

        String systemId   = params.get("system_id");
        
        if(storage.getEvent().equals("GET_CODE_LIST"))
        {
        	params.set("sheet1", getMatlCodeSectList(params));
            storage.addObject("ibsheet7Data", IBSheet7Factory.createIBSheet7(params, storage.request));
        }
    }
    
    
    
    private RowSet getMatlCodeSectList(ValueObject Params) throws Exception{
        Search search = new SearchImpl();
        RowSet rowSet = new RowSetImpl();
        StringBuffer sqlstr = new StringBuffer();
        try {           
            
        	sqlstr.append(" SELECT A.ITEM_NAME KIND_BIG, B.ITEM_NAME KIND_MID                          \n")
        	      .append("   FROM                                                                     \n")
        	      .append("        (SELECT ITEM_CD, KIND_BIG, KIND_MID, ITEM_NAME, DEPTH, PARENT_LEVEL \n")
        	      .append("           FROM OUT_ITEM                                                    \n")
        	      .append("          WHERE DEPTH = 1) A,                                               \n")
        	      .append("        (SELECT ITEM_CD, KIND_BIG, KIND_MID, ITEM_NAME, DEPTH, PARENT_LEVEL \n")
        	      .append("           FROM OUT_ITEM                                                    \n")
        	  	  .append("          WHERE DEPTH = 2) B                                                \n")
        		  .append("  WHERE A.ITEM_CD = B.KIND_BIG                                              \n")
        		  .append("  ORDER BY A.ITEM_CD, B.ITEM_CD                                             \n");
            
            System.out.println(sqlstr.toString());
            System.out.println(search.getParameters());
            
            search.setStatement(sqlstr);
            rowSet = search.execute();
        }
        catch(Exception e) {

            System.out.println(this.getClass().getName() + " --> getMatlCodeSectList() : " + e.getMessage());
            System.out.println("SQL : " + search.getStatement());
            System.out.println(e);
            return null;
        }
        finally {    
             if(rowSet == null) rowSet = new RowSetImpl();
             return rowSet;
        }
    }
}
