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

import java.sql.ResultSet;
import java.util.HashMap;

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

public class TelegramInfoDAO extends BaseDAO implements TelegramInfoQuery
{
    /**
     * HashMap getAllTelegramInfos()
     *      모든 텔레그램 정보를 구해서 해쉬맵으로 리턴해준다.
     */
    public HashMap<String, TelegramInfoVO> getAllTelegramInfos() throws DAOException
    {
    	HashMap<String, TelegramInfoVO> all = new HashMap<String, TelegramInfoVO>();
        ResultSet rs = null;
        TelegramInfoVO pvo = null;
        try
        {
            this.connect(GET_ALL_TELEGRAM_INFO);
            rs = this.executeQuery();

            while(rs.next())
            {
                pvo = new TelegramInfoVO();
                pvo.setTelegramID(rs.getString(1).trim());
                pvo.setMsgMetaDstcd(rs.getString(2).trim());
                pvo.setTelegramClsName(rs.getString(3).trim());
                all.put(pvo.getTelegramID(), pvo);
            }
        } catch(Exception e) {
            throw new DAOException(ExceptionUtil.getErrorCode(e,"BECEAIMFR033"));
        } finally {
            this.disconnect();
        }
        return all;
    }
}
