package com.eactive.eai.rms.onl.loader.dao;

import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.stereotype.Repository;

import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;
import com.eactive.eai.rms.common.datasource.DataSourceType;

/**
 * The Class LayoutDao.
 * <ul>
 * <li>1. Function :</li>
 * <li>2. Summary :</li>
 * <li>3. Notification :</li>
 * </ul>
 */
@Repository("historyDao")
@SuppressWarnings("unchecked")
public class HistoryDaoImpl extends SqlMapClientTemplateDao implements HistoryDao {

	public ArrayList getEaiMessageList(DataSourceType dt, String userId) {
		DataSourceContextHolder.setDataSourceType(dt);
		
    	HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("userId", userId);
    	return (ArrayList) this.template.queryForList("History.getEaiMessageList", hm);
	}

	public ArrayList getLayoutList(DataSourceType dt, String userId) {
		DataSourceContextHolder.setDataSourceType(dt);
		
    	HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("userId", userId);
    	return (ArrayList) this.template.queryForList("History.getLayoutList", hm);
	}

	public ArrayList getTransformList(DataSourceType dt, String userId) {
		DataSourceContextHolder.setDataSourceType(dt);
		
    	HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("userId", userId);
    	return (ArrayList) this.template.queryForList("History.getTransformList", hm);
	}
    
	@Override
	public ArrayList getMessageListByInterface(DataSourceType dt, String interfaceId) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("interfaceId", interfaceId);
		return (ArrayList) this.template.queryForList("History.getMessageListByInterface", hm);
	}

	@Override
	public ArrayList getLayoutListByInterface(DataSourceType dt, String interfaceId) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("interfaceId", interfaceId);
		return (ArrayList) this.template.queryForList("History.getLayoutListByInterface", hm);
	}

	@Override
	public ArrayList getTransformListByInterface(DataSourceType dt, String interfaceId) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("interfaceId", interfaceId);
		return (ArrayList) this.template.queryForList("History.getTransformListByInterface", hm);
	}

	@Override
	public ArrayList getLayoutListByLyoutNames(DataSourceType dt, String[] eaiLoutNames) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("loutNames", eaiLoutNames);
		return (ArrayList) this.template.queryForList("History.getLayoutListByLyoutNames", hm);
	}

	@Override
	public ArrayList getTranstormListByTransformNames(DataSourceType dt, String[] cnvsnNames) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("cnvsnNames", cnvsnNames);
		return (ArrayList) this.template.queryForList("History.getTransformtListByCnvsnNames", hm);
	}
	
	@Override
	public ArrayList getAdapterListByAdapterNames(DataSourceType dt, String[] adapterNames) {
		DataSourceContextHolder.setDataSourceType(dt);
		HashMap hm = new HashMap();
		hm.put("schemaId", dt.getSchema());
		hm.put("adapterNames", adapterNames);
		return (ArrayList) this.template.queryForList("History.getAdapterListByAdapterNames", hm);
	}
}
