/*********************************************************************
*	All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JKKCrsChgShijishoAddCC
*	ソースファイル名：JKKCrsChgShijishoAddCC.java
*	作成者			：FJ
*	日付			：2012年06月29日
*＜機能概要＞ 
*	コース変更指示書登録の共通コンポーネント
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	v3.00.00	2012/06/29	FJ)神吉		新規作成（【ST1-2012-0000117】コース変更指示書登録対応）
*	v4.00.00	2013/03/25	FJ)神吉		【IT1-2013-0000634】指示書登録値設定不具合対応
**********************************************************************/
package com.fujitsu.futurity.bp.custom.common;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.fujitsu.futurity.bp.x21.bpm.ServiceComponentRequestInvoker;
import com.fujitsu.futurity.bp.x21.bpm.db.SessionHandle;
import com.fujitsu.futurity.bp.x21.bpm.exception.RequestParameterException;
import com.fujitsu.futurity.bp.x21.bpm.parameter.IRequestParameterReadWrite;
import com.fujitsu.futurity.bp.x21.cc.AbstractCommonComponent;
import com.fujitsu.futurity.bp.x21.cc.exception.SCCallException;
import com.fujitsu.futurity.common.JCMConstants;
import com.fujitsu.futurity.common.x01.sc.SCControlMapKeys;
import com.fujitsu.futurity.mapping.bp.common.TemplateErrorUtil;
import com.fujitsu.futurity.model.base.CAANMsg;
import com.fujitsu.futurity.model.common.JCMAPLConstMgr;

import eo.ejb.cbs.cbsmsg.ECK0151D010CBSMsg;

/**
 * バッチで抽出した指示書情報を登録します。<p>
 * <BR>
 * @author 富士通
 *
 */
public class JKKCrsChgShijishoAddCC extends AbstractCommonComponent
{
	/**
	 * テンプレートID(指示書登録)
	 */
	private static final String TEMPLATE_ID_ECK0151D010 = "ECK0151D010";
	
	/**
	 * 空文字
	 */
	private static final String EMPTY = "";
	

	/**
	 * 指示書の登録処理を行います。
	 * 
	 * @param handle
	 * @param param
	 * @param fixedText
	 * @return IRequestParameterReadWrite
	 * @throws Exception
	 */
	public IRequestParameterReadWrite shijishoAdd(SessionHandle handle, 
												IRequestParameterReadWrite param, 
												String fixedText) throws Exception
	{
		Map<?, ?> result = null;
		
		// 認証ID情報生成
		HashMap<String, Object> ninshoIdMap = new HashMap<String, Object>();
		
		// サービス契約情報生成
		HashMap<String, Object> svcKeiMap = new HashMap<String, Object>();
		
		// SC呼び出し部品のインスタンス生成
		ServiceComponentRequestInvoker scCall = new ServiceComponentRequestInvoker();
		
		// ユーザデータ情報
		HashMap<String, Object> dataMap = (HashMap<String, Object>)param.getData(fixedText);
		
		// 認証IDマップ情報取得
		ninshoIdMap = (HashMap<String, Object>)dataMap.get("ninshoIdMap");
		
		// 認証IDマップが「null」でなく且つ、認証IDマップの処理対象SYSIDが空でない場合
		if (!isNull(ninshoIdMap) && !isEmpty((String)ninshoIdMap.get("tran_trgt_sysid")))
		{
			// 指示書登録（認証ID情報）
			// ◇ 上りマッピング処理
			HashMap<String, Object> paramMap = editInMsg_NinshoIdInfo(param, ninshoIdMap);
			
			// ◇ SC呼出実行
			result = scCall.run(paramMap, handle);
			
			// ◇ 下りマッピング処理
			editOutMsg_NinshoIdInfo(result, param, fixedText);
		}
		
		// サービス契約マップ情報取得
		svcKeiMap = (HashMap<String, Object>)dataMap.get("svcKeiMap");
		
		// 指示書登録（サービス契約情報）
		// ◇ 上りマッピング処理
		HashMap<String, Object> svcParamMap = editInMsg_SvcKeiInfo(param, svcKeiMap);
		
		// ◇ SC呼出実行
		result = scCall.run(svcParamMap, handle);
		
		// ◇ 下りマッピング処理
		editOutMsg_SvcKeiInfo(result, param, fixedText);
		
		return param;
	}

	/**
	 * 指示書登録（認証ID情報）用のメッセージを作成します。
	 * 
	 * @param param
	 * @param inMap
	 * @return paramMap
	 * @throws RequestParameterException
	 */
	private HashMap<String, Object> editInMsg_NinshoIdInfo(IRequestParameterReadWrite param,
															HashMap<String, Object> inMap) throws RequestParameterException
	{
		// 共通部の設定
		HashMap<String, Object> paramMap = editInMsg(param);
		
		CAANMsg template = new CAANMsg(ECK0151D010CBSMsg.class.getName());

		// テンプレートID
		template.set(ECK0151D010CBSMsg.TEMPLATEID, TEMPLATE_ID_ECK0151D010);
		
		// 機能コード
		template.set(ECK0151D010CBSMsg.FUNC_CODE, "1");

		// オペレータID
		Object operatorId = param.getControlMapData(SCControlMapKeys.OPERATOR_ID);
		template.set(JCMConstants.OPERATOR_ID_KEY, operatorId);

		// 運用日付
		Object operateDate = param.getControlMapData(SCControlMapKeys.OPE_DATE);
		template.set(JCMConstants.OPERATE_DATE_KEY, operateDate);

		// 運用日時
		Object operateDateTime = param.getControlMapData(SCControlMapKeys.OPE_TIME);
		template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime);
		
		// ◇ 業務データの設定
		// 固定値の設定
		template.set(ECK0151D010CBSMsg.TRN_CD, "N01");					// 処理コード
		template.set(ECK0151D010CBSMsg.TRGT_TABLE_ID, "TNM00050");		// 対象テーブルID
		template.set(ECK0151D010CBSMsg.RSLT_FLG, "0");					// 結果フラグ
		template.set(ECK0151D010CBSMsg.PARAMETER_YK_CNT, "14");			// パラメータ有効数
		template.set(ECK0151D010CBSMsg.PARAMETER_2, "05");				// パラメータ2
		template.set(ECK0151D010CBSMsg.PARAMETER_3, "1");				// パラメータ3
		template.setNull(ECK0151D010CBSMsg.PARAMETER_7);				// パラメータ7
		template.setNull(ECK0151D010CBSMsg.PARAMETER_11);				// パラメータ11
		template.setNull(ECK0151D010CBSMsg.PARAMETER_14);				// パラメータ14
		template.setNull(ECK0151D010CBSMsg.PARAMETER_15);				// パラメータ15
		template.setNull(ECK0151D010CBSMsg.PARAMETER_16);				// パラメータ16
		template.setNull(ECK0151D010CBSMsg.PARAMETER_17);				// パラメータ17
		template.setNull(ECK0151D010CBSMsg.PARAMETER_18);				// パラメータ18
		template.setNull(ECK0151D010CBSMsg.PARAMETER_19);				// パラメータ19
		template.setNull(ECK0151D010CBSMsg.PARAMETER_20);				// パラメータ20
		template.setNull(ECK0151D010CBSMsg.PARAMETER_21);				// パラメータ21
		template.setNull(ECK0151D010CBSMsg.PARAMETER_22);				// パラメータ22
		template.setNull(ECK0151D010CBSMsg.PARAMETER_23);				// パラメータ23
		template.setNull(ECK0151D010CBSMsg.PARAMETER_24);				// パラメータ24
		template.setNull(ECK0151D010CBSMsg.PARAMETER_25);				// パラメータ25
		template.setNull(ECK0151D010CBSMsg.PARAMETER_26);				// パラメータ26
		template.setNull(ECK0151D010CBSMsg.PARAMETER_27);				// パラメータ27
		template.setNull(ECK0151D010CBSMsg.PARAMETER_28);				// パラメータ28
		template.setNull(ECK0151D010CBSMsg.PARAMETER_29);				// パラメータ29
		template.setNull(ECK0151D010CBSMsg.PARAMETER_30);				// パラメータ30
		template.setNull(ECK0151D010CBSMsg.PARAMETER_31);				// パラメータ31
		template.setNull(ECK0151D010CBSMsg.PARAMETER_32);				// パラメータ32
		template.setNull(ECK0151D010CBSMsg.PARAMETER_33);				// パラメータ33
		template.setNull(ECK0151D010CBSMsg.PARAMETER_34);				// パラメータ34
		template.setNull(ECK0151D010CBSMsg.PARAMETER_35);				// パラメータ35
		template.setNull(ECK0151D010CBSMsg.PARAMETER_36);				// パラメータ36
		template.setNull(ECK0151D010CBSMsg.PARAMETER_37);				// パラメータ37
		template.setNull(ECK0151D010CBSMsg.PARAMETER_38);				// パラメータ38
		template.setNull(ECK0151D010CBSMsg.PARAMETER_39);				// パラメータ39
		template.setNull(ECK0151D010CBSMsg.PARAMETER_40);				// パラメータ40
		template.setNull(ECK0151D010CBSMsg.PARAMETER_41);				// パラメータ41
		template.setNull(ECK0151D010CBSMsg.PARAMETER_42);				// パラメータ42
		template.setNull(ECK0151D010CBSMsg.PARAMETER_43);				// パラメータ43
		template.setNull(ECK0151D010CBSMsg.PARAMETER_44);				// パラメータ44
		template.setNull(ECK0151D010CBSMsg.PARAMETER_45);				// パラメータ45
		template.setNull(ECK0151D010CBSMsg.PARAMETER_46);				// パラメータ46
		template.setNull(ECK0151D010CBSMsg.PARAMETER_47);				// パラメータ47
		template.setNull(ECK0151D010CBSMsg.PARAMETER_48);				// パラメータ48
		template.setNull(ECK0151D010CBSMsg.PARAMETER_49);				// パラメータ49
		template.setNull(ECK0151D010CBSMsg.PARAMETER_50);				// パラメータ50
		
		// 可変値の設定
		setParam(template, inMap, ECK0151D010CBSMsg.TRAN_TRGT_SYSID, "tran_trgt_sysid");	// 処理対象SYSID
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_1, "svc_kei_no");				// パラメータ1（サービス契約番号）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_4, "isp_ninsho");				// パラメータ4（ISP認証ID）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_5, "aply_sta_ymd");			// パラメータ5（適用開始年月日）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_6, "aply_end_ymd");			// パラメータ6（適用終了年月日）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_8, "mk_flg");					// パラメータ8（無効フラグ）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_9, "add_dtm");				// パラメータ9（登録年月日時分秒）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_10, "add_opeacnt");			// パラメータ10（登録オペレータアカウント）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_12, "upd_dtm");				// パラメータ12（更新年月日時分秒）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_13, "upd_opeacnt");			// パラメータ13（更新オペレータアカウント）
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		return paramMap;
	}
	
	/**
	 * 指示書登録（サービス契約情報）用のメッセージを作成します。
	 * 
	 * @param param
	 * @param inMap
	 * @return paramMap
	 * @throws RequestParameterException
	 */
	private HashMap<String, Object> editInMsg_SvcKeiInfo(IRequestParameterReadWrite param,
															HashMap<String, Object> inMap) throws RequestParameterException
	{
		// 共通部の設定
		HashMap<String, Object> paramMap = editInMsg(param);
		
		CAANMsg template = new CAANMsg(ECK0151D010CBSMsg.class.getName());

		// テンプレートID
		template.set(ECK0151D010CBSMsg.TEMPLATEID, TEMPLATE_ID_ECK0151D010);
		
		// 機能コード
		template.set(ECK0151D010CBSMsg.FUNC_CODE, "1");

		// オペレータID
		Object operatorId = param.getControlMapData(SCControlMapKeys.OPERATOR_ID);
		template.set(JCMConstants.OPERATOR_ID_KEY, operatorId);

		// 運用日付
		Object operateDate = param.getControlMapData(SCControlMapKeys.OPE_DATE);
		template.set(JCMConstants.OPERATE_DATE_KEY, operateDate);

		// 運用日時
		Object operateDateTime = param.getControlMapData(SCControlMapKeys.OPE_TIME);
		template.set(JCMConstants.OPERATE_DATETIME_KEY, operateDateTime);
		
		// ◇ 業務データの設定
		// 固定値の設定
		template.set(ECK0151D010CBSMsg.TRN_CD, "N01");					// 処理コード
		template.set(ECK0151D010CBSMsg.TRGT_TABLE_ID, "TNM00040");		// 対象テーブルID
		template.set(ECK0151D010CBSMsg.RSLT_FLG, "0");					// 結果フラグ
		template.set(ECK0151D010CBSMsg.PARAMETER_YK_CNT, "13");			// パラメータ有効数
		template.setNull(ECK0151D010CBSMsg.PARAMETER_8);				// パラメータ8
		template.setNull(ECK0151D010CBSMsg.PARAMETER_11);				// パラメータ11
		template.setNull(ECK0151D010CBSMsg.PARAMETER_14);				// パラメータ14
		template.setNull(ECK0151D010CBSMsg.PARAMETER_15);				// パラメータ15
		template.setNull(ECK0151D010CBSMsg.PARAMETER_16);				// パラメータ16
		template.setNull(ECK0151D010CBSMsg.PARAMETER_17);				// パラメータ17
		template.setNull(ECK0151D010CBSMsg.PARAMETER_18);				// パラメータ18
		template.setNull(ECK0151D010CBSMsg.PARAMETER_19);				// パラメータ19
		template.setNull(ECK0151D010CBSMsg.PARAMETER_20);				// パラメータ20
		template.setNull(ECK0151D010CBSMsg.PARAMETER_21);				// パラメータ21
		template.setNull(ECK0151D010CBSMsg.PARAMETER_22);				// パラメータ22
		template.setNull(ECK0151D010CBSMsg.PARAMETER_23);				// パラメータ23
		template.setNull(ECK0151D010CBSMsg.PARAMETER_24);				// パラメータ24
		template.setNull(ECK0151D010CBSMsg.PARAMETER_25);				// パラメータ25
		template.setNull(ECK0151D010CBSMsg.PARAMETER_26);				// パラメータ26
		template.setNull(ECK0151D010CBSMsg.PARAMETER_27);				// パラメータ27
		template.setNull(ECK0151D010CBSMsg.PARAMETER_28);				// パラメータ28
		template.setNull(ECK0151D010CBSMsg.PARAMETER_29);				// パラメータ29
		template.setNull(ECK0151D010CBSMsg.PARAMETER_30);				// パラメータ30
		template.setNull(ECK0151D010CBSMsg.PARAMETER_31);				// パラメータ31
		template.setNull(ECK0151D010CBSMsg.PARAMETER_32);				// パラメータ32
		template.setNull(ECK0151D010CBSMsg.PARAMETER_33);				// パラメータ33
		template.setNull(ECK0151D010CBSMsg.PARAMETER_34);				// パラメータ34
		template.setNull(ECK0151D010CBSMsg.PARAMETER_35);				// パラメータ35
		template.setNull(ECK0151D010CBSMsg.PARAMETER_36);				// パラメータ36
		template.setNull(ECK0151D010CBSMsg.PARAMETER_37);				// パラメータ37
		template.setNull(ECK0151D010CBSMsg.PARAMETER_38);				// パラメータ38
		template.setNull(ECK0151D010CBSMsg.PARAMETER_39);				// パラメータ39
		template.setNull(ECK0151D010CBSMsg.PARAMETER_40);				// パラメータ40
		template.setNull(ECK0151D010CBSMsg.PARAMETER_41);				// パラメータ41
		template.setNull(ECK0151D010CBSMsg.PARAMETER_42);				// パラメータ42
		template.setNull(ECK0151D010CBSMsg.PARAMETER_43);				// パラメータ43
		template.setNull(ECK0151D010CBSMsg.PARAMETER_44);				// パラメータ44
		template.setNull(ECK0151D010CBSMsg.PARAMETER_45);				// パラメータ45
		template.setNull(ECK0151D010CBSMsg.PARAMETER_46);				// パラメータ46
		template.setNull(ECK0151D010CBSMsg.PARAMETER_47);				// パラメータ47
		template.setNull(ECK0151D010CBSMsg.PARAMETER_48);				// パラメータ48
		template.setNull(ECK0151D010CBSMsg.PARAMETER_49);				// パラメータ49
		template.setNull(ECK0151D010CBSMsg.PARAMETER_50);				// パラメータ50
		
		// 可変値の設定
		setParam(template, inMap, ECK0151D010CBSMsg.TRAN_TRGT_SYSID, "tran_trgt_sysid");	// 処理対象SYSID(SYSID)
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_1, "sys_id");					// パラメータ1（SYSID）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_2, "svc_kei_no");				// パラメータ2（サービス契約番号）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_3, "aply_sta_ymd");			// パラメータ3（適用開始年月日）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_4, "aply_end_ymd");			// パラメータ4（適用終了年月日）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_5, "mk_flg");					// パラメータ5（無効フラグ）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_6, "add_dtm");				// パラメータ6（登録年月日時分秒）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_7, "add_opeacnt");			// パラメータ7（登録オペレータアカウント）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_9, "upd_dtm");				// パラメータ8（更新年月日時分秒）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_10, "upd_opeacnt");			// パラメータ10（更新オペレータアカウント）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_12, "svc_kei_cd");			// パラメータ12（契約種別コード）
		setParam(template, inMap, ECK0151D010CBSMsg.PARAMETER_13, "old_ics_svc_kei_cd");	// パラメータ13（旧ICS契約サービスコード）
		
		CAANMsg[] templates = new CAANMsg[1];
		templates[0] = template;
		paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);
		
		return paramMap;
	}

	/**
	 * 共通部のメッセージを作成します。
	 * 
	 * @param param
	 * @return HashMap<String, Object>
	 * @throws RequestParameterException
	 */
	private HashMap<String, Object> editInMsg(IRequestParameterReadWrite param) throws RequestParameterException
	{
		HashMap<String, Object> paramMap = new HashMap<String, Object>();

		// 【取得元：電文ヘッダ(ヘッダ)】
		// 電文ID
		paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID());
		// ユースケースID
		paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID());
		// オペレーションID
		paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID());
		// サービス呼び出し区分
		paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType());

		// 【取得元：ユーザエリア(コントロールマップ)】
		// 依頼先ホスト名
		paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME));
		// 依頼元IPアドレス
		paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP));
		// 依頼元画面ID
		paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID));
		// オペレータID
		paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID));

		return paramMap;
	}
	
	/**
	 * 
	 * @param msgList
	 * @param param
	 * @param fixedText
	 * 
	 * @return IRequestParameterReadWrite
	 * 
	 * @throws RequestParameterException
	 */
	private IRequestParameterReadWrite editOutMsg_NinshoIdInfo(Map<?, ?> msgList,
																IRequestParameterReadWrite param,
																String fixedText) throws Exception
	{
		// SCからの戻り値からCAANMsgを取得する
		CAANMsg[] templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY);
		
		/* ◇処理結果の判定*/
		// 取得したリターンコード、ステータスの内容を見て異常かどうかの判断をする。
		// リターンコード取得
		String rtnCode = msgList.get(JCMConstants.RET_CD_INT_KEY).toString();
		int status = templates[0].getInt(JCMConstants.STATUS_INT_KEY);
		
		// エラー情報の設定
		IRequestParameterReadWrite retParam = this.editErrorInfo_NinshoId(param, templates, Integer.parseInt(rtnCode), fixedText);
		
		//エラー情報のマップを取得
		ArrayList<Object> errList = (ArrayList<Object>)retParam.getControlMapData(SCControlMapKeys.ERROR_INFO);
		if (errList == null)
		{
			errList = new ArrayList<Object>();
		}
		
		// コントロールマップに設定
		retParam.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList));
		
		// 異常の場合、SCCallExceptionを生成してスローする
		if(!("0".equals(rtnCode) && 0 == status))
		{
			SCCallException scCallEx = new SCCallException("戻り値不正", rtnCode, status);
			throw scCallEx;
		}
		
		return retParam;
	}

	/**
	 * 
	 * @param msgList
	 * @param param
	 * @param fixedText
	 * 
	 * @return IRequestParameterReadWrite
	 * 
	 * @throws RequestParameterException
	 */
	private IRequestParameterReadWrite editOutMsg_SvcKeiInfo(Map<?, ?> msgList,
																IRequestParameterReadWrite param,
																String fixedText) throws Exception
	{
		// SCからの戻り値からCAANMsgを取得する
		CAANMsg[] templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY);
		
		/* ◇処理結果の判定*/
		// 取得したリターンコード、ステータスの内容を見て異常かどうかの判断をする。
		// リターンコード取得
		String rtnCode = msgList.get(JCMConstants.RET_CD_INT_KEY).toString();
		int status = templates[0].getInt(JCMConstants.STATUS_INT_KEY);
		
		// エラー情報の設定
		IRequestParameterReadWrite retParam = this.editErrorInfo_SvcKei(param, templates, Integer.parseInt(rtnCode), fixedText);
		
		//エラー情報のマップを取得
		ArrayList<Object> errList = (ArrayList<Object>)retParam.getControlMapData(SCControlMapKeys.ERROR_INFO);
		if (errList == null)
		{
			errList = new ArrayList<Object>();
		}
		
		// コントロールマップに設定
		retParam.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList));
		
		// 異常の場合、SCCallExceptionを生成してスローする
		if(!("0".equals(rtnCode) && 0 == status))
		{
			SCCallException scCallEx = new SCCallException("戻り値不正", rtnCode, status);
			throw scCallEx;
		}
		
		return retParam;
	}

	/**
	 * 
	 * @param param
	 * @param templates
	 * @param returnCode
	 * @param fixedText
	 * @return IRequestParameterReadWrite
	 * @throws RequestParameterException
	 */
	private IRequestParameterReadWrite editErrorInfo_NinshoId(IRequestParameterReadWrite param, 
														CAANMsg[] templates,
														int returnCode,
														String fixedText) throws RequestParameterException
	{
		CAANMsg template = templates[0];

		int templateStatus = template.getInt(ECK0151D010CBSMsg.STATUS);
		if (returnCode != 0)
		{
			templateStatus = 9000;
		}

		if (JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null)
		{
			templateStatus = 0;
		}

		int bpStatus = 0;
		Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE);
		if (obj == null)
		{
			bpStatus = -1;
		}
		else
		{
			bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE));
		}

		if (templateStatus > bpStatus)
		{
			// BPにサービスコンポーネントのステータスを設定する。
			String formatStatus = String.format("%1$04d", templateStatus);
			String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message);
		}
		
		// ユーザデータ情報
		HashMap<String, String> inMap = (HashMap<String, String>)param.getData(fixedText);
		
		// エラー情報の設定
		setErr(template, inMap, ECK0151D010CBSMsg.TRN_CD_ERR, "tran_cd_err");								// 処理コード
		setErr(template, inMap, ECK0151D010CBSMsg.TRGT_TABLE_ID_ERR, "trgt_table_id_err");					// 対象テーブルID
		setErr(template, inMap, ECK0151D010CBSMsg.RSLT_FLG_ERR, "rslt_flg_err");							// 結果フラグ
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_YK_CNT_ERR, "parameter_yk_cnt_err");			// パラメータ有効数
		setErr(template, inMap, ECK0151D010CBSMsg.TRAN_TRGT_SYSID_ERR, "tran_trgt_sysid_err");				// 処理対象SYSID
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_1_ERR, "svc_kei_no_err");				// パラメータ1（サービス契約番号)
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_2_ERR, "svc_kei_cd_err");						// パラメータ2（サービス契約コード）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_3_ERR, "svc_kei_cd_seq_err");					// パラメータ3（サービス契約コード通番）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_4_ERR, "isp_ninsho_id_err");				// パラメータ4（ISP認証ID）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_5_ERR, "svc_sta_ymd_err");				// パラメータ5（サービス開始年月日）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_6_ERR, "svc_endymd_err");				// パラメータ6（サービス終了年月日)
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_8_ERR, "mk_flg_err");					// パラメータ8（無効フラグ）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_9_ERR, "add_dtm_err");					// パラメータ9（登録年月日時分秒）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_10_ERR, "add_opeacnt_err");				// パラメータ10（登録オペレータアカウント）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_12_ERR, "upd_dtm_err");					// パラメータ12（更新年月日時分秒）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_13_ERR, "upd_opeacnt_err");				// パラメータ13（更新オペレータアカウント）
		
		return param;
	}
	
	/**
	 * 
	 * @param param
	 * @param templates
	 * @param returnCode
	 * @param fixedText
	 * @return IRequestParameterReadWrite
	 * @throws RequestParameterException
	 */
	private IRequestParameterReadWrite editErrorInfo_SvcKei(IRequestParameterReadWrite param, 
														CAANMsg[] templates,
														int returnCode,
														String fixedText) throws RequestParameterException
	{
		CAANMsg template = templates[0];

		int templateStatus = template.getInt(ECK0151D010CBSMsg.STATUS);
		if (returnCode != 0)
		{
			templateStatus = 9000;
		}

		if (JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null)
		{
			templateStatus = 0;
		}

		int bpStatus = 0;
		Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE);
		if (obj == null)
		{
			bpStatus = -1;
		}
		else
		{
			bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE));
		}

		if (templateStatus > bpStatus)
		{
			// BPにサービスコンポーネントのステータスを設定する。
			String formatStatus = String.format("%1$04d", templateStatus);
			String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus);
			param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message);
		}
		
		// ユーザデータ情報
		HashMap<String, String> inMap = (HashMap<String, String>)param.getData(fixedText);
		
		// エラー情報の設定
		setErr(template, inMap, ECK0151D010CBSMsg.TRN_CD_ERR, "tran_cd_err");								// 処理コード
		setErr(template, inMap, ECK0151D010CBSMsg.TRGT_TABLE_ID_ERR, "trgt_table_id_err");					// 対象テーブルID
		setErr(template, inMap, ECK0151D010CBSMsg.RSLT_FLG_ERR, "rslt_flg_err");							// 結果フラグ
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_YK_CNT_ERR, "parameter_yk_cnt_err");			// パラメータ有効数
		setErr(template, inMap, ECK0151D010CBSMsg.TRAN_TRGT_SYSID_ERR, "tran_trgt_sysiderr");		// 処理対象SYSID
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_1_ERR, "sysid_err");						// パラメータ1（サービス契約番号)
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_2_ERR, "svc_kei_no_err");				// パラメータ2（サービス契約コード）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_3_ERR, "svc_sta_ymd_err");				// パラメータ3（サービス開始年月日）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_4_ERR, "svc_endymd_err");				// パラメータ4（サービス終了年月日）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_5_ERR, "mk_flg_err");					// パラメータ5（無効フラグ）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_6_ERR, "add_dtm_err");					// パラメータ6（登録年月日時分秒）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_7_ERR, "add_opeacnt_err");				// パラメータ7（登録オペレータアカウント）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_9_ERR, "upd_dtm_err");					// パラメータ9（更新年月日時分秒）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_10_ERR, "upd_opeacnt_err");				// パラメータ10（更新オペレータアカウント）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_12_ERR, "svc_kei_cd_err");				// パラメータ12（サービスコード）
		setErr(template, inMap, ECK0151D010CBSMsg.PARAMETER_13_ERR, "old_ics_svc_kei_cd_err");		// パラメータ13（旧ICS契約サービスコード）
		
		return param;
	}
	
	/**
	 * パラメータを設定します。
	 * @param template
	 * @param map
	 * @param item
	 * @param key
	 * @return 判定結果
	 */
	private void setParam(CAANMsg template, HashMap map, String item, String key)
	{
		String value = null;
		
		if(isNull(map))
		{
			template.setNull(item);
		}
		else
		{
			value = (String)map.get(key);
			if(isEmpty(value))
			{
				template.setNull(item);
			}
			else
			{
				template.set(item, value);
			}
		}
	}
	
	/**
	 * エラー情報を設定します。
	 * @param template
	 * @param inMap
	 * @param item
	 * @param key
	 * @return 判定結果
	 */
	private void setErr(CAANMsg template, HashMap<String, String> inMap, String item, String key)
	{
		
		if (!template.isNull(item))
		{
			if (!inMap.containsKey(key))
			{
				inMap.put(key, template.getString(item));
			}
		}
	}
	
	/**
	 * 引数のNULL判定を行います。
	 * @param param
	 * @return 判定結果
	 */
	private boolean isNull(Object param)
	{
		if(param == null)
		{
			return true;
		}
		return false;
	}
	
	/**
	 * 引数の空文字判定を行います。
	 * @param param
	 * @return 判定結果
	 */
	private boolean isEmpty(String param)
	{
		if(param == null || "".equals(param))
		{
			return true;
		}
		return false;
	}
}
