package com.eactive.eai.rms.onl.dashboard.service;

import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
import com.eactive.eai.rms.onl.server.repository.Repository;
import com.eactive.eai.rms.onl.server.repository.TransactionRepositoryService;
import com.eactive.eai.rms.onl.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * The Class DashboardServiceImpl.
 * <ul>
 * <li>1. Function :</li>
 * <li>2. Summary :</li>
 * <li>3. Notification :</li>
 * </ul>
 * 
 */
@Service("dashboardService")
public class DashboardServiceImpl implements DashboardService {
    
	/** The repository. */
	@Autowired
	@Qualifier("repository")
	private Repository repository;

	/** The transaction repository service. */
	@Autowired
	@Qualifier("transactionRepositoryService")
	private TransactionRepositoryService transactionRepositoryService;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findAdapterStatusList
	 * (java.util.List)
	 */
	public List<AdaptersVO> findAdapterStatusList(List serverList) {
		List<AdaptersVO> list = new ArrayList<AdaptersVO>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			String instanceName = (String) server.get("EAISVRINSTNM");
			String hostName = (String) server.get("HOSTNAME");

			AdaptersVO vo = (AdaptersVO) repository.getMonitorData(hostName,
					instanceName, AdaptersVO.class.getName());

			if (vo == null) {
				vo = new AdaptersVO();
				vo.setHostName(hostName);
				vo.setInstanceName(instanceName);
			}

			list.add(vo);
		}
		return list;
	}
	
	public List<RealTimeAdaptersVO> findRTAdapterStatusList(List serverList) {
		List<RealTimeAdaptersVO> list = new ArrayList<RealTimeAdaptersVO>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			String hostName = (String) server.get("HOSTNAME");
			String instanceName = (String) server.get("EAISVRINSTNM");

			RealTimeAdaptersVO vo = (RealTimeAdaptersVO) repository.getMonitorData(hostName,
					instanceName, RealTimeAdaptersVO.class.getName());

			if (vo == null) {
				vo = new RealTimeAdaptersVO();
				vo.setHostName(hostName);
				vo.setInstanceName(instanceName);
			}

			list.add(vo);
		}
		return list;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findAdapterStatus
	 * (com.eactive.eai.rms.vo.AdaptersVO)
	 */
	public AdaptersVO findAdapterStatus(AdaptersVO adaptersVO) {
		AdaptersVO vo = (AdaptersVO) repository.getMonitorData(adaptersVO
				.getHostName(), adaptersVO.getInstanceName(), AdaptersVO.class
				.getName());
		if (vo != null) {
			vo.setService(adaptersVO.getService());
		}
		return vo;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findEngineStatus
	 * (com.eactive.eai.rms.vo.EAIEngineStatusVo)
	 */
	public EAIEngineStatusVo findEngineStatus(EAIEngineStatusVo engineVO) {
		EAIEngineStatusVo vo = (EAIEngineStatusVo) repository.getMonitorData(
				engineVO.getHostName(), engineVO.getInstanceName(),
				EAIEngineStatusVo.class.getName());

		if (vo != null) {
			vo.setService(engineVO.getService());
			return vo;
		} else {
			return engineVO;
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findEngineStatus
	 * (java.util.List)
	 */
	public List<EAIEngineStatusVo> findEngineStatus(List serverList, boolean isFullList) {

		List<EAIEngineStatusVo> list = new ArrayList<EAIEngineStatusVo>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			String hostName = (String) server.get("HOSTNAME");
			String instanceName = (String) server.get("EAISVRINSTNM");

			EAIEngineStatusVo vo = (EAIEngineStatusVo) repository
					.getMonitorData(hostName, instanceName,
							EAIEngineStatusVo.class.getName());
			if (vo != null) {
				list.add(vo);
			} else {
				// 2008.08.11 YUN_DEBUG
				// Dashboard Main 화면에서 서버 인스턴스 상태 표시하는데,
				// 서버 인스턴스가 내려갔을때도 정확하게 표시되게 하기 위해서
				// 빈 객체를 추가한다.
				if (isFullList == true) {
					vo = new EAIEngineStatusVo();
					vo.setInstanceName(instanceName);
					vo.setHostName(hostName);
					list.add(vo);
				}
			}
		}
		return list;
	}
	
	public List<EAIEngineStatusVo> findEngineStatusforDashBoard(List serverList, boolean isFullList ,String service) {

		List<EAIEngineStatusVo> list = new ArrayList<EAIEngineStatusVo>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			String hostName = (String) server.get("HOSTNAME");
			String instanceName = (String) server.get("EAISVRINSTNM");

			if (DataSourceTypeManager.BAT.equals(service)){
				
				hostName = hostName + "_svc";
			}
			
			EAIEngineStatusVo vo = (EAIEngineStatusVo) repository
					.getMonitorData(hostName, instanceName,
							EAIEngineStatusVo.class.getName());
			if (vo != null) {
				list.add(vo);
			} else {
				// 2008.08.11 YUN_DEBUG
				// Dashboard Main 화면에서 서버 인스턴스 상태 표시하는데,
				// 서버 인스턴스가 내려갔을때도 정확하게 표시되게 하기 위해서
				// 빈 객체를 추가한다.
				if (isFullList == true) {
					vo = new EAIEngineStatusVo();
					vo.setInstanceName(instanceName);
					vo.setHostName(hostName);
					list.add(vo);
				}
			}
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findSmsList(java
	 * .util.List, java.lang.String)
	 */
	public List<SmsVO> findSmsList(List serverList, String service) {
		List<SmsVO> list = new ArrayList<SmsVO>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			String instanceName = (String) server.get("EAISVRINSTNM");
			String hostName = (String) server.get("HOSTNAME");
			SmsVO vo = (SmsVO) repository.getMonitorData(hostName,
					instanceName, SmsVO.class.getName());
			
			if (vo != null) {
				vo.setService(service);
				list.add(vo);
			}
		}
		return list;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findSms(com.eactive
	 * .eai.rms.vo.SmsVO)
	 */
	public SmsVO findSms(SmsVO original) {
		SmsVO smsVO = (SmsVO) repository.getMonitorData(original.getHostName(),
				original.getInstanceName(), original);
		if (smsVO != null) {
			return smsVO;
		} else {
			return original;
		}
	}
	
	/**
	 * set Sms break time
	 * @param time
	 */
	public void setSmsBreaker( String time ) {
		repository.setSmsBreaker( time );
	}
	
	/**
	 * get Sms break time
	 * @return
	 */
	public String getSmsBreaker( ) {
		return repository.getSmsBreaker();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findHostStatus(
	 * com.eactive.eai.rms.vo.HostStatusVo)
	 */
	public HostStatusVo findHostStatus(List serverList) {

        HostStatusVo ret = new HostStatusVo();
        
        // host 내 인스턴스 중에서 메모리값이 높은 VO 정보 채택
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
	        HostStatusVo original = new HostStatusVo();
	        original.setHostName((String) server.get("HOSTNAME"));
	        original.setInstanceName((String) server.get("EAISVRINSTNM"));
	        
			HostStatusVo vo = (HostStatusVo) repository.getMonitorData(
					original.getHostName(), original.getInstanceName(), original);
			if (vo != null) {
				// 임시로 Cpu 비교.
				// HostStatusAgent에서 Memory 정보 구하는 Command 수정하면 memory비교로 복구. 
//				if( ret.getMemory() < vo.getMemory() ) {
				if( ret.getCpu() < vo.getCpu() ) {
					ret.setCpu(vo.getCpu());
					ret.setMemory(vo.getMemory());
					ret.setDisk(vo.getDisk());
				}
			}
		}
		return ret;
	}

	public RealTimeAdaptersVO findRTAdapterStatusTotalList(List serverList) {

		List<RealTimeAdaptersVO> list = findRTAdapterStatusList(serverList);
		RealTimeAdaptersVO ret = new RealTimeAdaptersVO();

		int sna[] = { 0, 0, 0, 0 };
		int socket[] = { 0, 0, 0, 0 };
		int socket2[] = { 0, 0, 0, 0 };
		int tuxedo[] = { 0, 0, 0, 0 };
		int mq[] = { 0, 0, 0, 0 };
		int http[] = { 0, 0, 0, 0 };
		int ejb[] = { 0, 0, 0, 0 };

		int total = 3;
		for (AdaptersVO vo : list) {
			// total 설정
			// instance1, instance2
			// Rule1. 두 인스턴스의 상태가 동일 할 경우 상태변경 없음
			//    에러     ,     에러      == > 에러
			//    정상     ,     정상      == > 정상      
            // 부분정상     ,  부분정상      == > 부분정상
			
			// Rule2. 하나라도 정지인경우 나머지 상태를 따라감
			//    에러     ,     정지      == > 에러
			//    정상     ,     정지      == > 정상 
			//    정지     ,     정지      == > 정지
			
			// Rule3. 정지를 제외한 상태가 서로 다를 경우 부분정상
            //    에러     ,     정상      == > 부분정상     
            //    에러     ,  부분정상      == > 부분정상      
            //    정상     ,  부분정상      == > 부분정상
			if( total == 3 ) total = vo.getTotal(3);  // Rule2 
			else if( vo.getTotal(3) == 3 ) ;          // Rule2
			else if( total == vo.getTotal(3) ) ;      // Rule1
			else total = 1;                           // Rule3
			
			if (vo.getSna(3) == 0) { // error
				sna[0]++;
			} else if (vo.getSna(3) == 1) { // normal
				sna[1]++;
			} else if (vo.getSna(3) == 2) { // success
				sna[2]++;
			} else if (vo.getSna(3) == 3) { // no service
			}

			if (vo.getSocket(3) == 0) { // error
				socket[0]++;
			} else if (vo.getSocket(3) == 1) { // normal
				socket[1]++;
			} else if (vo.getSocket(3) == 2) { // success
				socket[2]++;
			} else if( vo.getSocket(3) == 3 ) { // no service
				
			}
			if (vo.getSocket2(3) == 0) { // error
				socket2[0]++;
			} else if (vo.getSocket2(3) == 1) { // normal
				socket2[1]++;
			} else if (vo.getSocket2(3) == 2) { // success
				socket2[2]++;
			} else if (vo.getSocket2(3) == 3 ) { // no service
				
			}

			if (vo.getTuxedo(3) == 0) { // error
				tuxedo[0]++;
			} else if (vo.getTuxedo(3) == 1) { // normal
				tuxedo[1]++;
			} else if (vo.getTuxedo(3) == 2) { // success
				tuxedo[2]++;
			} else if (vo.getSocket2(3) == 3) { // no service
				
			}

			if (vo.getMq(3) == 0) { // error
				mq[0]++;
			} else if (vo.getMq(3) == 1) { // normal
				mq[1]++;
			} else if (vo.getMq(3) == 2) { // success
				mq[2]++;
			} else if( vo.getMq(3) == 3 ) { // no service
				
			}

			if (vo.getHttp(3) == 0) { // error
				http[0]++;
			} else if (vo.getHttp(3) == 1) { // normal
				http[1]++;
			} else if (vo.getHttp(3) == 2) { // success
				http[2]++;
			} else if (vo.getHttp(3) == 3) { // no service
			}

			if (vo.getEjb(3) == 0) { // error
				ejb[0]++;
			} else if (vo.getEjb(3) == 1) { // normal
				ejb[1]++;
			} else if (vo.getEjb(3) == 2) { // success
				ejb[2]++;
			} else if (vo.getEjb(3) == 3) { // no service
			}
		}
				
		if (sna[0] > 0) {
			ret.setSna(3, 0);
		} else if (sna[1] > 0) {
			ret.setSna(3, 1);
		} else if (sna[2] == 0) {
			ret.setSna(3, 3); // no service
		} else {
			ret.setSna(3, 2); // success
		}
		
		if (socket[0] > 0) {
			ret.setSocket(3, 0);
		} else if (socket[1] > 0) {
			ret.setSocket(3, 1);
		} else if (socket[2] == 0) {
			ret.setSocket(3, 3); // no service
		} else {
			ret.setSocket(3, 2); // success
		}

		if (socket2[0] > 0) {
			ret.setSocket2(3, 0);
		} else if (socket2[1] > 0) {
			ret.setSocket2(3, 1);
		} else if (socket2[2] == 0) {
			ret.setSocket2(3, 3); // no service
		} else {
			ret.setSocket2(3, 2); // success
		}

		if (tuxedo[0] > 0) {
			ret.setTuxedo(3, 0);
		} else if (tuxedo[1] > 0) {
			ret.setTuxedo(3, 1);
		} else if (tuxedo[2] == 0) {
			ret.setTuxedo(3, 3); // no service
		} else {
			ret.setTuxedo(3, 2); // success
		}

		if (mq[0] > 0) {
			ret.setMq(3, 0);
		} else if (mq[1] > 0) {
			ret.setMq(3, 1);
		} else if (mq[2] == 0) {
			ret.setMq(3, 3); // no service
		} else {
			ret.setMq(3, 2); // success
		}

		if (http[0] > 0) {
			ret.setHttp(3, 0);
		} else if (http[1] > 0) {
			ret.setHttp(3, 1);
		} else if (http[2] == 0) {
			ret.setHttp(3, 3); // no service
		} else {
			ret.setHttp(3, 2); // success
		}

		if (ejb[0] > 0) {
			ret.setEjb(3, 0);
		} else if (ejb[1] > 0) {
			ret.setEjb(3, 1);
		} else if (ejb[2] == 0) {
			ret.setEjb(3, 3); // no service
		} else {
			ret.setEjb(3, 2); // success
		}
		
		// 2009.09.25 추가 지정 옵션
		// 없으면 3을 지정한다.
//		if( sna[0] == 0 && sna[1] == 0 && sna[2] == 0 ) {
//			ret.setSna(3, 3); // none
//		}
//
//		if( socket[0] == 0 && socket[1] == 0 && socket[2] == 0 ) {
//			ret.setSocket(3, 3); // none
//		}
//
//		if( socket2[0] == 0 && socket2[1] == 0 && socket2[2] == 0 ) {
//			ret.setSocket2(3, 3); // none
//		}
//
//		if( tuxedo[0] == 0 && tuxedo[1] == 0 && tuxedo[2] == 0 ) {
//			ret.setTuxedo(3, 3); // none
//		}
//
//		if( mq[0] == 0 && mq[1] == 0 && mq[2] == 0 ) {
//			ret.setMq(3, 3); // none
//		}
//
//		if( http[0] == 0 && http[1] == 0 && http[2] == 0 ) {
//			ret.setHttp(3, 3); // none
//		}
//
//		if( ejb[0] == 0 && ejb[1] == 0 && ejb[2] == 0 ) {
//			ret.setEjb(3, 3); // none
//		}

		ret.setTotal(3, total);
		return ret;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.eactive.eai.rms.dashboard.service.DashboardService#
	 * findAdapterStatusTotalList(java.util.List)
	 */
	public AdaptersVO findAdapterStatusTotalList(List serverList) {
//		호스트별 인스턴스 리스트 
		List<AdaptersVO> list = findAdapterStatusList(serverList);
//		상태값만 저장하는 VO
		AdaptersVO ret = new AdaptersVO();
//                      {에러, 부분정상, 정상, 정지}
		int sna[]     = { 0, 0, 0, 0 };
		int socket[]  = { 0, 0, 0, 0 };
		int socket2[] = { 0, 0, 0, 0 };
		int tuxedo[]  = { 0, 0, 0, 0 };
		int mq[]      = { 0, 0, 0, 0 };
		int http[]    = { 0, 0, 0, 0 };
		int ejb[]     = { 0, 0, 0, 0 };

		int total = 3;
		for (AdaptersVO vo : list) {
			// total 설정
			// instance1, instance2
			// Rule1. 두 인스턴스의 상태가 동일 할 경우 상태변경 없음
			//    에러     ,     에러      == > 에러
			//    정상     ,     정상      == > 정상      
            // 부분정상     ,  부분정상      == > 부분정상
			
			// Rule2. 하나라도 정지인경우 나머지 상태를 따라감
			//    에러     ,     정지      == > 에러
			//    정상     ,     정지      == > 정상 
			//    정지     ,     정지      == > 정지
			
			// Rule3. 정지를 제외한 상태가 서로 다를 경우 부분정상
            //    에러     ,     정상      == > 부분정상     
            //    에러     ,  부분정상      == > 부분정상      
            //    정상     ,  부분정상      == > 부분정상
			if( total == 3 ) total = vo.getTotal(3);  // Rule2 
			else if( vo.getTotal(3) == 3 ) ;          // Rule2
			else if( total == vo.getTotal(3) ) ;      // Rule1
			else total = 1;                           // Rule3
			
			if (vo.getSna(3) == 0) { // error
				sna[0]++;
			} else if (vo.getSna(3) == 1) { // normal
				sna[1]++;
			} else if (vo.getSna(3) == 2) { // success
				sna[2]++;
			} else if (vo.getSna(3) == 3) { // no service
			}

			if (vo.getSocket(3) == 0) { // error
				socket[0]++;
			} else if (vo.getSocket(3) == 1) { // normal
				socket[1]++;
			} else if (vo.getSocket(3) == 2) { // success
				socket[2]++;
			} else if( vo.getSocket(3) == 3 ) { // no service
				
			}
			if (vo.getSocket2(3) == 0) { // error
				socket2[0]++;
			} else if (vo.getSocket2(3) == 1) { // normal
				socket2[1]++;
			} else if (vo.getSocket2(3) == 2) { // success
				socket2[2]++;
			} else if (vo.getSocket2(3) == 3 ) { // no service
				
			}

			if (vo.getTuxedo(3) == 0) { // error
				tuxedo[0]++;
			} else if (vo.getTuxedo(3) == 1) { // normal
				tuxedo[1]++;
			} else if (vo.getTuxedo(3) == 2) { // success
				tuxedo[2]++;
			} else if (vo.getSocket2(3) == 3) { // no service
				
			}

			if (vo.getMq(3) == 0) { // error
				mq[0]++;
			} else if (vo.getMq(3) == 1) { // normal
				mq[1]++;
			} else if (vo.getMq(3) == 2) { // success
				mq[2]++;
			} else if( vo.getMq(3) == 3 ) { // no service
				
			}

			if (vo.getHttp(3) == 0) { // error
				http[0]++;
			} else if (vo.getHttp(3) == 1) { // normal
				http[1]++;
			} else if (vo.getHttp(3) == 2) { // success
				http[2]++;
			} else if (vo.getHttp(3) == 3) { // no service
			}

			if (vo.getEjb(3) == 0) { // error
				ejb[0]++;
			} else if (vo.getEjb(3) == 1) { // normal
				ejb[1]++;
			} else if (vo.getEjb(3) == 2) { // success
				ejb[2]++;
			} else if (vo.getEjb(3) == 3) { // no service
			}
		} // end for
				
		// 에러가 하나라도 있으면 에러 > 부분정상이 하나라도 있으면 부분정상 > 정상이 하나라도 있으면 정상
		if (sna[0] > 0) {
			ret.setSna(3, 0);
		} else if (sna[1] > 0) {
			ret.setSna(3, 1);
		} else if (sna[2] == 0) {
			ret.setSna(3, 3); // no service
		} else {
			ret.setSna(3, 2); // success
		}
		
		if (socket[0] > 0) {
			ret.setSocket(3, 0);
		} else if (socket[1] > 0) {
			ret.setSocket(3, 1);
		} else if (socket[2] == 0) {
			ret.setSocket(3, 3); // no service
		} else {
			ret.setSocket(3, 2); // success
		}

		if (socket2[0] > 0) {
			ret.setSocket2(3, 0);
		} else if (socket2[1] > 0) {
			ret.setSocket2(3, 1);
		} else if (socket2[2] == 0) {
			ret.setSocket2(3, 3); // no service
		} else {
			ret.setSocket2(3, 2); // success
		}

		if (tuxedo[0] > 0) {
			ret.setTuxedo(3, 0);
		} else if (tuxedo[1] > 0) {
			ret.setTuxedo(3, 1);
		} else if (tuxedo[2] == 0) {
			ret.setTuxedo(3, 3); // no service
		} else {
			ret.setTuxedo(3, 2); // success
		}

		if (mq[0] > 0) {
			ret.setMq(3, 0);
		} else if (mq[1] > 0) {
			ret.setMq(3, 1);
		} else if (mq[2] == 0) {
			ret.setMq(3, 3); // no service
		} else {
			ret.setMq(3, 2); // success
		}

		if (http[0] > 0) {
			ret.setHttp(3, 0);
		} else if (http[1] > 0) {
			ret.setHttp(3, 1);
		} else if (http[2] == 0) {
			ret.setHttp(3, 3); // no service
		} else {
			ret.setHttp(3, 2); // success
		}

		if (ejb[0] > 0) {
			ret.setEjb(3, 0);
		} else if (ejb[1] > 0) {
			ret.setEjb(3, 1);
		} else if (ejb[2] == 0) {
			ret.setEjb(3, 3); // no service
		} else {
			ret.setEjb(3, 2); // success
		}
		
		// 2009.09.25 추가 지정 옵션
		// 없으면 3을 지정한다.
//		if( sna[0] == 0 && sna[1] == 0 && sna[2] == 0 ) {
//			ret.setSna(3, 3); // none
//		}
//
//		if( socket[0] == 0 && socket[1] == 0 && socket[2] == 0 ) {
//			ret.setSocket(3, 3); // none
//		}
//
//		if( socket2[0] == 0 && socket2[1] == 0 && socket2[2] == 0 ) {
//			ret.setSocket2(3, 3); // none
//		}
//
//		if( tuxedo[0] == 0 && tuxedo[1] == 0 && tuxedo[2] == 0 ) {
//			ret.setTuxedo(3, 3); // none
//		}
//
//		if( mq[0] == 0 && mq[1] == 0 && mq[2] == 0 ) {
//			ret.setMq(3, 3); // none
//		}
//
//		if( http[0] == 0 && http[1] == 0 && http[2] == 0 ) {
//			ret.setHttp(3, 3); // none
//		}
//
//		if( ejb[0] == 0 && ejb[1] == 0 && ejb[2] == 0 ) {
//			ret.setEjb(3, 3); // none
//		}

		
		ret.setTotal(3, total);
		return ret;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.eactive.eai.rms.dashboard.service.DashboardService#findTransactionList
	 * (java.util.List, java.lang.String)
	 */
	public List<TransactionTrackingVo> findTransactionList(List serverList,
			String service) {

		TransactionTrackingVo origin = new TransactionTrackingVo();

		List<TransactionTrackingVo> list = new ArrayList<TransactionTrackingVo>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);

			origin.setHostName((String) server.get("HOSTNAME"));
			origin.setInstanceName((String) server.get("EAISVRINSTNM"));

			TransactionTrackingVo vo = (TransactionTrackingVo) transactionRepositoryService
					.getTrackingVo(origin);

			if (vo != null) {
				vo.setService(service);
				list.add(vo);
			}
		}
		return list;
	}

	public List<TransactionTrackingVo> findTransactionListByHost(
			List serverList, String hostName, boolean isFull) {
		TransactionTrackingVo origin = new TransactionTrackingVo();

		List<TransactionTrackingVo> list = new ArrayList<TransactionTrackingVo>();
		for (int i = 0; i < serverList.size(); i++) {
			Map server = (Map) serverList.get(i);
			origin.setHostName((String) server.get("HOSTNAME"));
			origin.setInstanceName((String) server.get("EAISVRINSTNM"));
			
			if( ! hostName.equals(origin.getHostName())) {
				continue;
			}

			TransactionTrackingVo vo = (TransactionTrackingVo) transactionRepositoryService
					.getTrackingVo(origin);
			
			if( vo != null ) {
				list.add(vo);
			} else {
				if( isFull ) {
					TransactionTrackingVo tmpVo = new TransactionTrackingVo();
					tmpVo.setHostName(origin.getHostName());
					tmpVo.setInstanceName(origin.getInstanceName());
					tmpVo.setTotalProc(0);
					tmpVo.setTotalError(0);
					list.add(tmpVo);
				}
			}
		}
		return list;
	}
}