package com.eactive.eai.batch.rule.dirInfo;

import java.sql.ResultSet;
import java.util.ArrayList;

import com.eactive.eai.batch.common.StringUtil;
import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;

public class DirInfoDAO extends BaseDAO implements DirInfoQuery
{

    public ArrayList<BatchJobInfoVO> getAllFileInfo() throws DAOException
    {
        ArrayList<BatchJobInfoVO> al = new ArrayList<BatchJobInfoVO>();
        ResultSet rs = null;
        BatchJobInfoVO vo = null;
        try
        {
            this.connect(GET_BIZ_CODE_INFO);
            rs = this.executeQuery();
            while(rs.next())  {
                vo = new BatchJobInfoVO();

                vo.setMsgDstCode        (StringUtil.nvl(rs.getString("BjobMsgDstcd"             )));
                vo.setMsgDstName        (StringUtil.nvl(rs.getString("BjobMsgDsticName"         )));
                vo.setBatchCode         (StringUtil.nvl(rs.getString("BjobBzwkDstcd"            )));
                vo.setJobTranDstcd      (StringUtil.nvl(rs.getString("BjobTranDstcdName"        )));
                vo.setSendUseYN         (StringUtil.nvl(rs.getString("EAIFileSendUseYn"         )));
                vo.setRecvUseYN         (StringUtil.nvl(rs.getString("EAIFileRecvUseYn"         )));
				vo.setFileHeaderLogSize (rs.getLong  ("BjobTelgmHdrSize"         ));
				vo.setFileRecSize       (rs.getLong  ("BjobTelgmRecSize"         ));
				vo.setFileTrailerLogSize(rs.getLong  ("BjobTelgmTrailSize"       ));
                vo.setPriority          (rs.getInt   ("MsgPrcssPrity"            ));
                vo.setSysCd             (StringUtil.nvl(rs.getString("SysCd"                    )));
                vo.setUapplCd           (StringUtil.nvl(rs.getString("UapplCd"                  )));
                vo.setSndrcvFileName    (StringUtil.nvl(rs.getString("SndrcvFileName"           )));
                vo.setIntfID            (StringUtil.nvl(rs.getString("IntfID"                   )));
                String chrgIDs = rs.getString("ThisMsgChrgIDs");
                if ( chrgIDs != null ){
                	String[] arr = chrgIDs.split(",");
                	vo.setChrgIDs(arr);
                }
                vo.setRecvNotiUseYn     (StringUtil.nvl(rs.getString("RecvNotiUseYn"            )));
                al.add(vo);
            }

        } catch(Exception e) {
            throw new DAOException(ExceptionUtil.getErrorCode(e,"BECEAIMFR012"));
        } finally {
            this.disconnect();
        }
        return al;
    }
}
