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

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

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

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        (rs.getString("BjobMsgDstcd"             ));
                vo.setMsgDstName        (rs.getString("BjobMsgDsticName"         ));
                vo.setBatchCode         (rs.getString("BjobBzwkDstcd"            ));
                vo.setJobTranDstcd      (rs.getString("BjobTranDstcdName"        ));
                vo.setSendUseYN         (rs.getString("EAIFileSendUseYn"         ));
                vo.setRecvUseYN         (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             (rs.getString("SysCd"                    ));
                vo.setUapplCd           (rs.getString("UapplCd"                  ));
                vo.setSndrcvFileName    (rs.getString("SndrcvFileName"           ));
                vo.setIntfID            (rs.getString("IntfID"                   ));
                String chrgIDs = rs.getString("ThisMsgChrgIDs");
                if ( chrgIDs != null ){
                	String[] arr = chrgIDs.split(",");
                	vo.setChrgIDs(arr);
                }
                vo.setRecvNotiUseYn     (rs.getString("RecvNotiUseYn"            ));
                al.add(vo);
            }

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