/*******************************************************************************
 *	All Rights reserved,Copyright (c) K-Opticom
 ********************************************************************************
 *＜プログラム内容＞
 *	システム名		：eo顧客基幹システム
 *	モジュール名	：JZMejbZM0041SecProc
 *	ソースファイル名：JZMejbZM0041SecProc.java
 *	作成者			：富士通
 *	日付			：2012年05月14日
 *＜機能概要＞
 *	権限グループに対する副次処理を行う部品です。
 *＜修正履歴＞
 *	バージョン	修正日		修正者		修正内容
 *	v3.00		2012/05/14	FJ) 北島	新規作成
 *	v3.00		2012/05/14	FJ) 北島	【SGY-2012-000006】統合認証対応
 *
 ********************************************************************************/

package eo.ejb.common.db;

import com.fujitsu.futurity.model.base.CAANException;
import com.fujitsu.futurity.model.base.CAANMsg;
import com.fujitsu.futurity.model.base.CAANRemoveException;

import com.fujitsu.futurity.model.ejb.common.fw.AgentDispatchContext;

import eo.ejb.cbm.entity.ZM0041ETMsg;
import eo.ejb.cbm.entity.ZM0041LE;
import eo.ejb.cbm.entity.ZM0091ETMsg;

/**
 * <p>
 * 権限グループに対する副次処理部品です。
 * </p>
 * @author 富士通
 */
public class JZMejbZM0041SecProc extends JPCejbDBABase
{
	/**
	 * <p>
	 * 新しいJZMejbZM0041SecProcを作成します。
	 * </p>
	 */
	public JZMejbZM0041SecProc()
	{
		super(ZM0041ETMsg.class.getName());
	}

	/**
	 * <p>
	 * 世代を管理するカラム名を取得します。
	 * </p>
	 * @return 世代を管理するカラム名
	 */
	protected String getGenerationColumn()
	{
		return null;
	}
	
	/**
	 * <p>
	 * 無効状態を管理するカラム名を取得します。
	 * </p>
	 * @return 無効状態を管理するカラム名
	 */
	protected String getInvalidColumn()
	{
		return ZM0041ETMsg.MK_FLG;
	}

	/**
	 * <p>
	 * 予約管理エンティティか判定します。
	 * </p>
	 * @return 予約管理エンティティの場合はtrue
	 */
	protected boolean isReserveMgr()
	{
		return false;
	}

	/**
	 * <p>
	 * 予約適用基準日となるカラム名を取得します。
	 * </p>
	 * @return 予約適用基準日となるカラム名
	 */
	protected String getCurrentColumn()
	{
		return null;
	}

	/**
	 * <p>
	 * 予約の状態を管理するエンティティか判定します。
	 * </p>
	 * @return 予約の状態を管理するエンティティの場合はtrue
	 */
	protected boolean isReserveStateMgr()
	{
		return false;
	}

	/**
	 * <p>
	 * 予約の状態を管理するカラム名を取得します。
	 * </p>
	 * @return 予約の状態を管理するカラム名
	 */
	protected String getReserveStateColumn()
	{
		return null;
	}

	/**
	 * <p>
	 * 指定した権限グループを物理削除します。
	 * </p>
	 * @param inCBSMsg 処理対象のメッセージキャリア
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param authorityGrpCd	      権限グループコード
	 * @return 処理が正常に完了した場合trueを返却
	 */
	public boolean deleteAuthorityGrp(CAANMsg inCBSMsg, AgentDispatchContext inContext, String authorityGrpCd)
	{
		String tmpAuthorityGrpCd = authorityGrpCd;
		
		// 検索条件の設定
		CAANMsg msg = new CAANMsg(ZM0041ETMsg.class.getName());
		msg.set(ZM0041ETMsg.KGGRP_CD, tmpAuthorityGrpCd);
		msg.set(ZM0041ETMsg.MK_FLG, "1");
		
		// 検索処理の実行
		CAANMsg[] ret = null;
		try 
		{
			ret = new ZM0041LE().findByCondition(msg);
		}
		catch (CAANException e1) 
		{
			throw new RuntimeException(e1);
		}

		int listCnt = ret.length;

		// レコード全件の物理削除を行います。
		try
		{
			for (int index = 0; index < listCnt; index++) 
			{
				CAANMsg target = ret[index];

				// 削除情報設定
				super.remove(target);
			}
		}
		catch (CAANRemoveException e1)
		{
			throw new RuntimeException(e1);
		}
		return true;
	}
}
