package my.com.kfh.enterprise.services.ib109_icm;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import my.com.kfh.enterprise.services.common.CommonConstants;
import my.com.kfh.error.exception.IBGenericException;
import my.com.kfh.error.exception.IBServiceException;
import my.com.kfh.error.handler.CommonErrorCode;
import my.com.kfh.error.handler.IBErrorHandler;
import my.com.kfh.web.utils.DataValidator;
import my.com.kfh.web.utils.IBDynaBean;
import my.com.kfh.web.utils.IBDynaBeanManager;
import my.com.kfh.web.utils.IBLogger;
import my.com.kfh.web.utils.IBSessionObjects;
import my.com.kfh.web.utils.IBTimer;
import my.com.kfh.web.utils.constant.ServiceInfo;

public class IBIcmUpliftmentConfirmServices extends IBIcmGenericServices
{
	private static Class c_oClass = IBIcmUpliftmentConfirmServices.class;
	
	public IBIcmUpliftmentConfirmServices(IBSessionObjects m_oIBSessionObjects) {
		super(m_oIBSessionObjects);
	}

	public void executeServices() throws IBGenericException {
		
		String m_sMethodName = "executeServices";
		IBTimer m_oTimer = IBLogger.logBSFNMethodEnteringMessage (c_oClass, m_sMethodName);

		IBDynaBean m_oAccountBean = null;
		String m_sToAccount = null;
		String m_sToAccountDisplay = null;
		Map m_oToAccountMap = new LinkedHashMap();

		String m_sAmountDisplay = null;
		String m_sIsoCurrency = null;
		String m_sAvailableBalance = null;
		String m_sTerms = null;
		String m_sPeriod = "Month(s)";
		int m_iTerms = 0;

		String m_sInstructionMaturity = null;
		String m_sInstructionMaturityDisplay = null;
		Map m_oInstructionMaturityMap = new HashMap ();
		IBDynaBean m_oIcmUpliftmentView = null;

		try
		{
			m_oIcmUpliftmentView = (IBDynaBean)getIBDynaBean ().get (ICMConstants.ICM_UPLIFTMENT_VIEW);
			if (m_oIcmUpliftmentView == null)
			{
				m_oIcmUpliftmentView = IBDynaBeanManager.createIBDynaBean (ICMConstants.ICM_UPLIFTMENT_VIEW, getIBDynaBean ().getActionMapping ());
			}
			
			m_sToAccount = (String)getIBDynaBean ().get (ICMConstants.TO_ACCOUNT);
			m_oIcmUpliftmentView.set(ICMConstants.TO_ACCOUNT, m_sToAccount);
			m_oIcmUpliftmentView.set(ICMConstants.TO_ACCOUNT_DISPLAY, m_sToAccount);
			
						
			getIBDynaBean ().set (ICMConstants.ICM_UPLIFTMENT_VIEW, m_oIcmUpliftmentView);
			
			//Pixakarft Bank Negara Changes 30th Mar 2013 start
			IBDynaBean m_oServiceInfoBean = (IBDynaBean) m_oIcmUpliftmentView.get(ServiceInfo.SERVICE_INFO_BEAN);
			if (((Boolean) m_oServiceInfoBean.get (ServiceInfo.BEAN_ATT_TAC_REQUIRED)).booleanValue ())
			{
				IBDynaBean m_oSMSViewBean = (IBDynaBean) getIBSessionObjects().getHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN);
				String beneName = getIBSessionObjects().getVisitor().getName();
				m_oSMSViewBean.set(CommonConstants.AMOUNT, m_oIcmUpliftmentView.get(ICMConstants.UPLIFT_AMOUNT));
				if(!DataValidator.isEmptyString(beneName)){
					m_oSMSViewBean.set(CommonConstants.BENE_NAME, beneName.length()>18?beneName.substring(0, 18):beneName);
				}
				getIBSessionObjects().setHttpSessionAttrObject(CommonConstants.SMS_VIEW_BEAN, m_oSMSViewBean);
			}
			//Pixakarft Bank Negara Changes 30th Mar 2013 start
		}
		catch (Exception e)
		{
			e.printStackTrace();
			if (e instanceof IBGenericException)
			{
				throw (IBGenericException) e;
			}

			throw IBErrorHandler.createServiceException(IBServiceException.GENERAL_SERVICE_ERROR, true,
					new String[] {CommonErrorCode.GENERIC_CODE, "", "", "", IBErrorHandler.generateErrorMessage(e)}, c_oClass);
		}

		IBLogger.logBSFNMethodLeavingMessage (c_oClass, m_sMethodName, m_oTimer);
		
	}
	
	
}
