package com.eactive.eai.control;

import com.eactive.eai.common.util.Logger;
import com.eactive.eai.transformer.TransformService;

public class Transform {
	static final long serialVersionUID = 1L;
	
	static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
	static Logger esbLogger = Logger.getLogger(Logger.LOGGER_ESBFW);
	/**
	 * 
	 * isMath 는 대량 입력/출력 일때 참조를 무시
	 * @param infoKey
	 * @param isReq
	 * @param transformName
	 * @param sources
	 * @param isMath
	 * @return
	 * @throws java.lang.Exception
	 */
    public static Object transform(String infoKey, boolean isReq, String transformName, Object[] sources, boolean isMass)
    throws java.lang.Exception {
    	if(esbLogger.isInfo()) esbLogger.info(infoKey +" Transform START: " + transformName);
    	Object obj = TransformService.transform(infoKey, isReq, transformName, sources,isMass);
    	if(esbLogger.isInfo()) esbLogger.info(infoKey +" Transform End: " + transformName);
    	return obj;
    }
    
    public static Object transformSingleForMass(String infoKey, boolean isReq, String transformName, Object sources) throws Exception{
    	return transform(infoKey, isReq, transformName,new Object[]{sources},true);   
    }
    public static Object transformSingle(String infoKey, boolean isReq, String transformName, Object sources)
    throws java.lang.Exception {    	
    	return transform(infoKey, isReq, transformName,new Object[]{sources},false);        
    }
    
    public static Object transformComp(String infoKey, boolean isReq, String transformName, Object[] sources, String[] layoutNames)
    throws Exception {
    	if(esbLogger.isInfo()) esbLogger.info(infoKey +" Transform START : " + transformName);
    	Object obj = TransformService.transformComp(infoKey, isReq, transformName, sources, layoutNames);
    	if(esbLogger.isInfo()) esbLogger.info(infoKey +" Transform END : " + transformName);
    	return obj;
    }
}
