package jp.ne.mki.wedge.rule.client.event;

import java.util.Vector;

import jp.ne.mki.wedge.rule.base.AbstractClient;
import jp.ne.mki.wedge.run.client.data.Item;
import jp.ne.mki.wedge.run.client.executer.ExecutionExecuter;

/**
 *   <h2>アイテムのAfterイベントを実行する。</h2>
 *   <p>アイテムに設定されたAfterイベントを実行します。<br>
 *      このロジッククラスにより実行リスト処理をブロック化するイメージで、いろいろなタイミング
 *      にて実行することが可能になります。<br>
 *      このロジッククラスを使用することにより、一連の処理中に 複数の 「ブロック化した実行リスト」が実行可能なため
 *      フォーカス移動処理は含まれていません。<br>
 *      (一連の処理にて、処理後にフォーカスを当てる処理は一番最後に行われます。これはイベント処理が
 *       "入れ子"にならないようにしているためです。このロジッククラスにより実行された 「ブロック化した実行リスト」
 *       終了時は "一連の処理の最後とは限らない" ためにわざとフォーカス移動処理は行っていません)
 *      <br>
 *      つまり、SetFocusロジッククラスなどのようなフォーカス移動を行う処理はブロック化した処理の
 *      中には含めないように注意してください。<br>
 *      <br>
 *      フォーカス移動を行う処理はブロック化せず、実行イベントの実行リストに記述するように
 *      切り分けてご使用ください。<br>
 *   </p>
 *
 * <br/>
 * <h4>[I/O RECORD]</h4>
 * <table border="1" cellpadding="3" cellspacing="0" width="100%">
 *  <tr bgcolor="#EEEEFF" class="TableSubHeadingColor">
 *      <th style="width:50%;">InputRecord</th>
 *      <th>OutputRecord</th>
 *  </tr><tr bgcolor="#EEEEFF" class="TableRowColor">
 *      <td>
 *      <!--  InputRecordの内容を記述   -->
 *
 *      <!--  ここまで   -->
 *      </td>
 *      <td>
 *      <!-- OutputRecordの内容を記述    -->
 *      Afterイベントが設定されているコンポーネント(複数指定可)
 *      <!--  ここまで   -->
 *      </td>
 *  </tr></table>
 *
 * <h4>[RULE PARAMETER]</h4>
 * <table border="1" cellpadding="3" cellspacing="0" width="100%">
 *  <tr>
 *      <th style="width:100px;" class="TableSubHeadingColor">Parameter</th>
 *      <td class="TableRowColor">
 *      <!-- Parameterの内容を記述    -->
 *      <!--ここまで   -->
 *      </td>
 *  </tr></table>
 *
 * @author mki
 * @version 1.0
 * @see jp.ne.mki.wedge.rule.client.control.ExecuteAfterTakeOver
 */
public class ExecuteAfterEvent extends AbstractClient {
	/**
	 * IOパラメータ取得。{@link #execute() execute} の前に実行される。
	 * @return int OK=処理続行、ERROR=異常終了、CANCEL=処理を中断(正常終了)
	 */
	public int getIOParameter() {
		return OK;
	}
	/**
	 * 入力可に変更する処理を実行。OutputRecordに指定されているもの全てを処理する。
	 * @return int BusinessRuleの戻り値を参照
	 */
	public int execute() {
		loopOutItem();
		return OK;
	}

	public int loopOutItemSub(Item outItem,int index){
		Vector afterExecutions = outItem.getAfterExecutions();
		int ret = ExecutionExecuter.runExecutions(afterExecutions,getManager());
		return ret;
	}
	/**
	 * 終了処理。保持していた変数などを開放する処理を記述します。<br/>
	 * {@link #execute() execute} の後に実行されます。<br/>正常終了・異常終了などに関わらず必ず実行されます。
	 */
	public void exit() {
	}

}