package com.eactive.eai.inbound.remote;

import com.eactive.eai.common.dao.DAOFactory;

import java.util.ArrayList;

public class RemoteServerManager
{

	//singleton 객체 생성
	private static RemoteServerManager instance = new RemoteServerManager();
	//singleton 객체 리턴
    public static RemoteServerManager getInstance() {
        return instance;
    }

	//생성자 (다른 클래스에서 new 불가)
	private RemoteServerManager() {}



	public RemoteServerVO getRemoteServerByPath(String remotePath) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        return dao.getRemoteServerByPath(remotePath);
	}

	public RemoteServerVO detailRemoteServer(String remoteServerId) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        ArrayList<RemoteServerVO> alist = dao.selectRemoteServer("", "SERVER_ID", remoteServerId);
		if (alist.size() == 0) return null;
		return alist.get(0);
	}

	public ArrayList<RemoteServerVO> searchRemoteServer(String searchProcessCode, String searchType, String searchText) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        return dao.selectRemoteServer(searchProcessCode, searchType, searchText);
	}

	public int insertRemoteServer(RemoteServerVO remoteServerVO) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        return dao.insertRemoteServer(remoteServerVO);
	}

	public int updatetRemoteServer(RemoteServerVO remoteServerVO) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        return dao.updatetRemoteServer(remoteServerVO);
	}

	public int deletetRemoteServer(String remoteServerId) throws Exception {
		RemoteServerDAO dao = (RemoteServerDAO)DAOFactory.newInstance().create(RemoteServerDAO.class);
        return dao.deleteRemoteServer(remoteServerId);
	}

}
