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

import com.eactive.eai.rms.common.base.SqlMapClientTemplateDao;
import com.ibatis.sqlmap.client.event.RowHandler;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Vector;

@Repository("dashboardDao")
public class DashboardDaoImpl extends SqlMapClientTemplateDao
							  implements DashboardDAO {

	public Vector<String[]> getErrorInfo(String owner, String tableName, String logTime, String beforeTime) {
        final HashMap<String, String> paramMap = new HashMap<String, String>();
        paramMap.put("schemaId", owner);
        paramMap.put("tableName", tableName);
        paramMap.put("logTime", logTime);
        paramMap.put("beforeTime", beforeTime);
        final Vector<String[]> v = new Vector<String[]>();
    	template.queryWithRowHandler("Dashboard.getErrorInfo", paramMap,
    			new RowHandler(){
            		@SuppressWarnings("unchecked")
                    public void handleRow(Object valueObject) {
            			HashMap<String, String> rowMap = (HashMap<String, String>)valueObject;
            			String[] row = new String[11];
            			row[0] = rowMap.get("LogPrcssSerno");
            			row[1] = rowMap.get("GstatSysAdptrBzwkGroupName");
            			row[2] = rowMap.get("GstatSysAdptrEAIBzwkDstcd");
            			row[3] = rowMap.get("GstatSysAdptrBzwkDsticName");
            			row[4] = rowMap.get("PsvSysAdptrBzwkGroupName");
            			row[5] = rowMap.get("PsvSysAdptrEAIBzwkDstcd");
            			row[6] = rowMap.get("PsvSysAdptrBzwkDsticName");
            			row[7] = rowMap.get("EAIErrCd");
            			row[8] = rowMap.get("EAIErrCtnt");
            			row[9] = rowMap.get("EAISevrInstncName");
            			row[10]= rowMap.get("LgingSysID");
            			v.add(row);
        }});
    	
    	return v;
	}

}
