/*********************************************************************
*   All Rights reserved,Copyright (c) K-Opticom
**********************************************************************
*＜プログラム内容＞
*   システム名      ：eo顧客基幹システム
*   モジュール名    ：JPCejbJSCKBase
*   ソースファイル名：JPCejbJSCKBase.java
*   作成者          ：富士通
*   日付            ：2011年04月04日
*＜機能概要＞
*   状態遷移制約共通部品のスーパークラス
*＜修正履歴＞
*   バージョン  修正日      修正者      修正内容
*   v1.00.00    2011/04/04  富士通      新規作成
*
**********************************************************************/

package eo.ejb.common.entity;

/**
 * <p>
 * 状態遷移制約共通部品のスーパークラスです。
 * </p>
 * @author 富士通
 */
public abstract class JPCejbJSCKBase {

	/** 
	 * プライマリデータアクセス
	 */
	protected static final String DATA_PRIMARY = "1";

	/** 
	 * カレントデータアクセス
	 */
	protected static final String DATA_CURRENT = "2";

	/** 
	 * <p>
	 * 状態遷移定義の配列を取得します。
	 * </p>
	 * @return 状態遷移定義の配列
	 */
	protected abstract String[][] getContents();

	/** 
	 * <p>
	 * プライマリデータが検索対象か判定します。
	 * </p>
	 * @param templateID サービスインターフェースID
	 * @return プライマリデータが検索対象の場合はtrue
	 */
	protected boolean isPrimaryDataMode(String templateID)
	{
		String[][] contents = getContents();

		for (int i = 0; i < contents.length; i++)
		{
			if (!contents[i][0].equals(templateID))
			{
				continue;
			}

			if (DATA_PRIMARY.equals(contents[i][1]))
			{
				return true;
			}
		}

		return false;
	}

	/** 
	 * <p>
	 * カレントデータが検索対象か判定します。
	 * </p>
	 * @param templateID サービスインターフェースID
	 * @return カレントデータが検索対象の場合はtrue
	 */
	protected boolean isCurrentDataMode(String templateID)
	{
		String[][] contents = getContents();

		for (int i = 0; i < contents.length; i++)
		{
			if (!contents[i][0].equals(templateID))
			{
				continue;
			}

			if (DATA_CURRENT.equals(contents[i][1]))
			{
				return true;
			}
		}

		return false;
	}

	/** 
	 * <p>
	 * 状態遷移定義に定義されている遷移前ステータスか判定します。
	 * </p>
	 * @param templateID サービスインターフェースID
	 * @param status 遷移前データのステータス
	 * @return 状態遷移定義に定義されている遷移前ステータスの場合はtrue
	 */
	protected boolean isNormalStateTrans(String templateID, String status)
	{
		String[][] contents = getContents();

		for (int i = 0; i < contents.length; i++)
		{
			if (!contents[i][0].equals(templateID))
			{
				continue;
			}

			if (contents[i][2].equals(status))
			{
				return true;
			}
		}

		return false;
	}

}
