package com.eactive.eai.batch.job.jobHandle;

//import com.eactive.eai.batch.doc.BatchDoc;
import java.util.ArrayList;
import java.util.HashMap;

import com.eactive.eai.batch.rule.phaseinfo.PhaseInfoVO;
import com.eactive.eai.common.util.Logger;


public class JobProcessData
{
	//파일로거
	private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);

    private static JobProcessData instance    = new JobProcessData();
    public static final String PROCDATA_PRE_TELEGRAM  = "PRE_TELEGRAM";
    public static final String PROCDATA_NEXTSTAGE     = "NEXT_STAGE";
    public static final String PROCDATA_BLOCKDATA     = "PROCDATA_BLOCKDATA";
    public static final String PROCDATA_MISSDATA  	  = "PROCDATA_MISSDATA";
    public static final String PROCDATA_FIRST_MISS	  = "PROCDATA_FIRST_MISS";
    public static final String PROCDATA_LAST_MISS	  = "PROCDATA_LAST_MISS";

	private HashMap<String, Object> hm_batchData;

    private JobProcessData() {
        hm_batchData = new HashMap<String, Object>();
    }

    public static JobProcessData getInstance() {
        return instance;
    }

	public synchronized void addBatchStageData(String strUUID, HashMap<String, ArrayList<PhaseInfoVO>> hmData)
    {
        Object obj = hm_batchData.get(strUUID);
        if (obj != null) {
            logger.warn("[JobProcessData] addBatchMsgDoc >> UUID["+strUUID+"] 에 이미 데이터가 있습니다." + obj);
            hm_batchData.remove(strUUID);
        }
        hm_batchData.put(strUUID, hmData);
    }

	@SuppressWarnings("unchecked")
	public synchronized  HashMap<String, Object> getBatchStageData(String strUUID)
    {
        return (HashMap<String, Object>)hm_batchData.get(strUUID);
    }

	public synchronized  void setBatchStageData(String strUUID, HashMap<String, Object> hm)
    {
        hm_batchData.remove(strUUID);
        hm_batchData.put(strUUID, hm);
    }

    public synchronized  void delBatchStageData(String strUUID)
    {
        this.hm_batchData.remove(strUUID);
    }

    public synchronized int getBatchStageDataCount() {
        return hm_batchData.size();
    }

}
