/***********************************************************************************
 * @@ Program Name : HttpDeptList.java Description : 기관에속한 부서들의 목록 Author : 강원중 Create Date : 2003-12-16 History :
 * @@
 ***********************************************************************************/

package kr.co.kihyun.beans.user;

//import java.io.IOException;
//import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
//import java.util.ArrayList;
import java.util.List;
//import javax.jdo.JDOObjectNotFoundException;
//import javax.jdo.PersistenceManager;
//import javax.jdo.Transaction;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import kr.co.kihyun.beans.entity.MDept;
//import kr.co.kihyun.beans.entity.MUser;
//import kr.co.kihyun.beans.entity.UserPart;
//import kr.co.kihyun.beans.entity.util.MPersistenceManager;
//import kr.co.kihyun.beans.entity.util.PMF;
//import kr.co.kihyun.beans.totsys.report.Report;
import kr.co.kihyun.db.DBManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RecogGet extends DBManager {

    private  List<String> recogid;
    private ResultSet rs = null;
   	private static final Logger LOG = LoggerFactory.getLogger(RecogGet.class);

   	private String[] ID = null;
   	private String[] RECOG = null;
   	private String[] RECOG_NUM = null;
   	private String[] RECOG_USER_ID = null;
   	private String[] REPORT_ID = null;
   	private String[] RECOGFLAG = null;
    private String[] ACCEPTFLAG = null;
    private String[] USERNAME = null;
    private String[] HISTORY = null;
    private int tCount;


      /******** tmpName 구해오기 ********/
	public void getrecogID(Long reportID) {
		StringBuilder sql = new StringBuilder(250);
        int count = 0;


		try {

           sql.append("SELECT A.ID,A.RECOG,A.RECOG_NUM ")
              .append(",A.RECOG_USER_ID,A.REPORT_ID,A.RECOGFLAG")
              .append(",A.ACCEPTFLAG,A.HISTORY,B.NAME")
              .append(" FROM MOUMI_REPOADM A ")
              .append(" ,MOUMI_MUSER B ")
              .append(" WHERE A.REPORT_ID = '"+reportID+"' ")
              .append(" AND A.RECOG_USER_ID = B.ID ")
              .append(" ORDER BY A.RECOG_NUM ASC ");

			rs = execQuery(sql);
			if (rs != null) {
				rs.last();
				count = rs.getRow();
				rs.beforeFirst();
			} else {
				return;
			}

                ID  = new String[count];
                RECOG  = new String[count];
                RECOG_NUM  = new String[count];
                RECOG_USER_ID  = new String[count];
                REPORT_ID  = new String[count];
                RECOGFLAG  = new String[count];
                ACCEPTFLAG = new String[count];
                HISTORY = new String[count];
                USERNAME = new String[count];
                tCount    = count;

			for (int i = 0; rs.next(); i++) {
                ID[i] = rs.getString(1);
                RECOG[i] = rs.getString(2);
                RECOG_NUM[i] = rs.getString(3);
                RECOG_USER_ID[i] = rs.getString(4);
                REPORT_ID[i] = rs.getString(5);
                RECOGFLAG[i] = rs.getString(6);
                ACCEPTFLAG[i] = rs.getString(7);
                HISTORY[i] = rs.getString(8);
                USERNAME[i] = rs.getString(9);

			}
          //System.out.println(sql);
		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
			new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage()});
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			try {
                if (con != null)
                    con.close();
            } catch (SQLException ex) {
                //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                ex.printStackTrace();
                //++++++++++++++++++++++++++++++++++++++++++++++++
            }
            try {
                    if (pstmt != null)
                    	pstmt.close();
                } catch (SQLException ex) {
                    //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                    ex.printStackTrace();
                    //++++++++++++++++++++++++++++++++++++++++++++++++
                }
            try {
                    if (rs != null)
                        rs.close();
                } catch (SQLException ex) {
                    //31.오류 상황 대응 부재_CWE-390 Add by YOUNGJUN,CHO
                    ex.printStackTrace();
                    //++++++++++++++++++++++++++++++++++++++++++++++++
                }
		}
	}

    public String[] getID() {
            //24.Public 메소드로부터 반환된 Private배열_CWE-495 : Update by KWON,HAN
	    //	return ID;

            String[] ret = null;
            if( this.ID != null) {
                ret = new String[ID.length];
                for (int i=0; i<ID.length; i++) {
                    ret[i] = this.ID[i];
                }
            }
            return ret;
            //====================================================================
	}

    public String[] getRecog() {
	    //	return RECOG;

            String[] ret = null;
            if( this.RECOG != null) {
                ret = new String[RECOG.length];
                for (int i=0; i<RECOG.length; i++) {
                    ret[i] = this.RECOG[i];
                }
            }
            return ret;
	}

    public String[] getRecogNum() {
	    //	return RECOG_NUM;

            String[] ret = null;
            if( this.RECOG_NUM != null) {
                ret = new String[RECOG_NUM.length];
                for (int i=0; i<RECOG_NUM.length; i++) {
                    ret[i] = this.RECOG_NUM[i];
                }
            }
            return ret;
	}

    public String[] getRecogUserId() {
	    //	return RECOG_USER_ID;

            String[] ret = null;
            if( this.RECOG_USER_ID != null) {
                ret = new String[RECOG_USER_ID.length];
                for (int i=0; i<RECOG_USER_ID.length; i++) {
                    ret[i] = this.RECOG_USER_ID[i];
                }
            }
            return ret;
	}

    public String[] getReportId() {
	    //	return REPORT_ID;

            String[] ret = null;
            if( this.REPORT_ID != null) {
                ret = new String[REPORT_ID.length];
                for (int i=0; i<REPORT_ID.length; i++) {
                    ret[i] = this.REPORT_ID[i];
                }
            }
            return ret;
	}

    public String[] getRecogFlag() {
	    //	return RECOGFLAG;

            String[] ret = null;
            if( this.RECOGFLAG != null) {
                ret = new String[RECOGFLAG.length];
                for (int i=0; i<RECOGFLAG.length; i++) {
                    ret[i] = this.RECOGFLAG[i];
                }
            }
            return ret;
	}

    public String[] getAcceptFlag() {
	    //	return ACCEPTFLAG;

            String[] ret = null;
            if( this.ACCEPTFLAG != null) {
                ret = new String[ACCEPTFLAG.length];
                for (int i=0; i<ACCEPTFLAG.length; i++) {
                    ret[i] = this.ACCEPTFLAG[i];
                }
            }
            return ret;
	}

    public String[] getHistory() {
	    //	return HISTORY;

            String[] ret = null;
            if( this.HISTORY != null) {
                ret = new String[HISTORY.length];
                for (int i=0; i<HISTORY.length; i++) {
                    ret[i] = this.HISTORY[i];
                }
            }
            return ret;
	}

    public String[] getUserName() {
	    //	return USERNAME;

            String[] ret = null;
            if( this.USERNAME != null) {
                ret = new String[USERNAME.length];
                for (int i=0; i<USERNAME.length; i++) {
                    ret[i] = this.USERNAME[i];
                }
            }
            return ret;
	}

    public int  getTcount(){
        return tCount;
    }

}
