/////////////////////////////////////////////////////////////////
//Copyright (C) 2005 NTT CORPORATION.
//
//	アサイン更新処理　Assignmentsテーブルへの追加を行い、追加後の情報をクライアント側のアプレットに返すActionクラス
//
//		変更履歴
//			2005.02.16  新規作成  氏名 石崎賢太郎
//
//	機能
//
//	Assignmentsテーブルへの追加を行い、追加後の情報をクライアント側のアプレットに返すActionクラスです。
//
/////////////////////////////////////////////////////////////////
package jp.co.ntt.lms.xmf.actions.lo.method.methodassignments;

import java.util.Date;
import java.util.Hashtable;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jp.co.ntt.lms.xmf.xmo.Com.ConstTree;
import jp.co.ntt.lms.xmo.Assignments.AssignmentsClient;
import jp.co.ntt.lms.xmo.Groups.GroupsClient;
import jp.co.ntt.lms.xmo.Lo.LoClient;
import jp.co.ntt.lms.xmo.People.PeopleClient;
import jp.co.ntt.lms.xmo.util.HtmlEscape;
import jp.co.ntt.lms.xmo.util.XMODate;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;

/**
 * Assignmentsテーブルへの追加処理を行い、その結果をアプレットに返すActionクラスです。
 * 
 * @author Kentaro Ishizaki (UNITEC)
 * @version 1.0
 */
public class MethodAssignmentsUpdateActionAction extends Action
{
	/**
	 * strutsフレームワークから呼ばれるメソッドです。
	 * 
	 * @param mapping マッピングオブジェクト。
	 * @param form アクションフォームオブジェクト。
	 * @param request リクエストオブジェクト。
	 * @param response レスポンスオブジェクト。
	 * @return ActionForward アクションフォワードオブジェクト。
	 * @throws Exception
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		///////////////////////////////////////////
		// パラメータ取得
		// 	・parentID		親グループのID	必須
		// 	・selectID		グループのID	必須
		// 	・ParentLoID	親LOID			必須
		// 	・LOID			LOID			必須
		// 	・insert_mode	登録処理モード	必須
		//  ・SendMailFlag  メール送信フラグ
		///////////////////////////////////////////
		String strTreeViewType = request.getParameter("tree_view_type");	// ツリータイプ("1":Group,"2":Lo)
		String strMode = request.getParameter("Mode");						// 処理モード("insert"/"delete")
		String strParentID = request.getParameter("ParentID");				// 親グループのID
		String strSelectID = request.getParameter("SelectID");				// 選択されたグループor人のID
		String strParentLoID = request.getParameter("ParentLoID");			// 親LOID
		String strLoID = request.getParameter("LoID");						// LOID
		String strInsertMode = request.getParameter("insert_mode");			// 登録処理の場合の処理モード
		String strLearnAuthority = request.getParameter("LearnAuthority");			// 学習アサイン
		String strManagementAuthority = request.getParameter("ManageAuthority");	// 管理アサイン
		String strSendMailFlag = request.getParameter("SendMailFlag");				// メール送信フラグ

		String strUserID = (String)request.getSession().getAttribute("userId");					// アサイン者

		// メッセージリソース取得
		MessageResources resources = getResources(request, "msg.xmf.lo.Method.MethodAssignments.MessageResources");
		
		///////////////////////////////////////////
		// パラメータチェック
		///////////////////////////////////////////
		if( strTreeViewType == null || strTreeViewType.equals( "" ) ) {
			String strMessage = resources.getMessage("M062009");
			String strDetail = resources.getMessage("D062009");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strMode == null || strMode.equals( "" ) ) {
			String strMessage = resources.getMessage("M062005");
			String strDetail = resources.getMessage("D062005");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strParentID == null || strParentID.equals( "" ) ) {
			String strMessage = resources.getMessage("M062001");
			String strDetail = resources.getMessage("D062001");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strSelectID == null || strSelectID.equals( "" ) ) {
			String strMessage = resources.getMessage("M062002");
			String strDetail = resources.getMessage("D062002");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strParentLoID == null || strParentLoID.equals( "" ) ) {
			String strMessage = resources.getMessage("M062006");
			String strDetail = resources.getMessage("D062006");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strLoID == null || strLoID.equals( "" ) ) {
			String strMessage = resources.getMessage("M062007");
			String strDetail = resources.getMessage("D062007");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strUserID == null || strUserID.equals( "" ) ) {
			String strMessage = resources.getMessage("M062010");
			String strDetail = resources.getMessage("D062010");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strLearnAuthority == null || strLearnAuthority.equals( "" ) ) {
			String strMessage = resources.getMessage("M062011");
			String strDetail = resources.getMessage("D062011");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		if( strManagementAuthority == null || strManagementAuthority.equals( "" ) ) {
			String strMessage = resources.getMessage("M062012");
			String strDetail = resources.getMessage("D062012");
			request.setAttribute("message", strMessage);
			request.setAttribute("detail", strDetail);
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}

		String strMemberShipID = null; 				// メンバーシップID
		if( strParentID.equals( MethodAssignmentsConstants.GROUP_TREE_ROOT )) {
			Hashtable htbRootInfo = (Hashtable)request.getSession().getAttribute( MethodAssignmentsConstants.ASSIGN_ROOT_INFO );
			strMemberShipID = (String)htbRootInfo.get( strSelectID ) + strSelectID; 					// メンバーシップID
		}
		else {
			strMemberShipID = strParentID + strSelectID;
		}
		String strMaterialID = null;										// マテリアルID
		if( strParentLoID.equals( MethodAssignmentsConstants.LO_TREE_ROOT )) {
			Hashtable htbRootInfo = (Hashtable)request.getSession().getAttribute( MethodAssignmentsConstants.ASSIGN_ROOT_INFO );
			strMaterialID = (String)htbRootInfo.get( strLoID ) + strLoID; 					// マテリアルID
		}
		else {
			strMaterialID = strParentLoID + strLoID;
		}
		String strStartDate = XMODate.parseTime(new Date());			// 学習開始日
		String strEndDate = XMODate.parseTime(new Date());				// 学習終了日

		
		if( strMode.equals( "insert" ) ) {
			////////////////////////////////////
			// 登録処理
			////////////////////////////////////
			AssignmentsClient objAssignments = new AssignmentsClient();

			// パラメータ設定
			objAssignments.setMemberShipID( strMemberShipID );	// メンバーシップID
			objAssignments.setMaterialID( strMaterialID );		// マテリアルID
			objAssignments.setStudyStartDate( strStartDate );	// 学習開始日
			objAssignments.setEndDate( strEndDate );			// 学習終了日
			objAssignments.setAssigner( strUserID );						// アサイン者
			objAssignments.setLearnAuthority( strLearnAuthority );			// 学習アサイン
			objAssignments.setManagementAuthority( strManagementAuthority );// 管理アサイン
			objAssignments.setSendMailFlag( strSendMailFlag );
			objAssignments.setValue(AssignmentsClient.METHOD_FLAG, "1");

			// 登録メソッド実行
			if( !objAssignments.insert() ) {
				// 登録がうまくいかなかった場合
				if( objAssignments.isErr() ) {
					// エラーの場合
					request.setAttribute("message", "");
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", objAssignments.getURL());
					return mapping.findForward("error");
				}
				else {
					String strMessage =  objAssignments.getMessage();
					request.setAttribute("message", strMessage);
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", "");
					return mapping.findForward("error");
				}
			}

			Vector vctAssUserList = null;
			// 登録ユーザ情報を取得する
			if( objAssignments.next() ) {
				vctAssUserList = objAssignments.getAssignUserList();
			}

			//サーブレットにJump
			if(vctAssUserList != null && strSendMailFlag.equals("1"))
			{
				HttpSession objSession = request.getSession();
				objSession.setAttribute("USER_LIST", vctAssUserList);
				objSession.setAttribute("IUSERID", strUserID);
			}
		}
		else if( strMode.equals( "update" ) ) {
			////////////////////////////////////
			// 更新処理
			////////////////////////////////////
			AssignmentsClient objAssignments = new AssignmentsClient();

			// パラメータ設定
			objAssignments.setMemberShipID( strMemberShipID );	// メンバーシップID
			objAssignments.setMaterialID( strMaterialID );		// マテリアルID
			// 検索条件
			objAssignments.setWhereMemberShipID( strMemberShipID );	// メンバーシップID
			objAssignments.setWhereMaterialID( strMaterialID );		// マテリアルID
			// 更新情報
			objAssignments.setAssigner( strUserID );						// アサイン者
			objAssignments.setLearnAuthority( strLearnAuthority );			// 学習アサイン
			objAssignments.setManagementAuthority( strManagementAuthority );// 管理アサイン
			objAssignments.setSendMailFlag( strSendMailFlag );
			objAssignments.setValue(AssignmentsClient.METHOD_FLAG, "1");

			// 更新メソッド実行
			if( !objAssignments.update() ) {
				// 更新がうまくいかなかった場合
				if( objAssignments.isErr() ) {
					// エラーの場合
					request.setAttribute("message", "");
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", objAssignments.getURL());
					return mapping.findForward("error");
				}
				else {
					String strMessage =  objAssignments.getMessage();
					request.setAttribute("message", strMessage);
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", "");
					return mapping.findForward("error");
				}
			}
		}
		else {
			////////////////////////////////////
			// 削除処理
			////////////////////////////////////
			AssignmentsClient objAssignments = new AssignmentsClient();

			// 削除条件設定
			objAssignments.setWhereMemberShipID( strMemberShipID );		// メンバーシップID
			objAssignments.setWhereMaterialID( strMaterialID );			// マテリアルID

			// 削除メソッド実行
			if( !objAssignments.delete() ) {
				// 削除がうまくいかなかった場合
				if( objAssignments.isErr() ) {
					// エラーの場合
					request.setAttribute("message", "");
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", objAssignments.getURL());
					return mapping.findForward("error");
				}
				else {
					String strMessage =  objAssignments.getMessage();
					request.setAttribute("message", strMessage);
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", "");
					return mapping.findForward("error");
				}
			}
		}

	
		try {
			if( strTreeViewType.equals( "1" ) ) {
				//更新したLo情報をデータベースから取得する。
				LoClient objLo = new LoClient();

				// 検索条件の設定
				objLo.setWhereLoID( strLoID );
				if( !objLo.select() ) {
					// 検索がうまくいかなかった場合
					if( objLo.isErr() ) {
						// エラーの場合
						request.setAttribute("message", "");
						request.setAttribute("detail", "");
						request.setAttribute("close", "on");
						request.setAttribute("errorurl", objLo.getURL());
						return mapping.findForward("error");
					}
					else {
						String strMessage =  objLo.getMessage();
						request.setAttribute("message", strMessage);
						request.setAttribute("detail", "");
						request.setAttribute("close", "on");
						request.setAttribute("errorurl", "");
						return mapping.findForward("error");
					}
				}
				///////////////////////////////
				// 更新するLo情報の取得
				///////////////////////////////
				String strLoTytle = "";
				String strLoType = "";
				if( objLo.next() ) {
					// タイトル
					strLoTytle = objLo.getLoTytle();
					// ＬＯタイプ
					strLoType = objLo.getLoType();
				}
				else {
					//Lo名が存在しない場合エラーを出力する
					String strMessage =  "LO名が存在しません。";
					request.setAttribute("message", strMessage);
					request.setAttribute("detail", "");
					request.setAttribute("close", "on");
					request.setAttribute("errorurl", "");
					return mapping.findForward("error");
				}

				StringBuffer strGetLine = new StringBuffer();
				String strIconName = "";
				String strIconGif = "";

				if(strLoType.equals("0") || strLoType.equals("1")) {
					strIconGif = "icon_lo_type_" + strLoType + "_h.gif";
					strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
					strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH +" cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
					strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
					strGetLine.append( "'width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
					strGetLine.append( strIconName );
					strGetLine.append( "' name='name/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "'onclick=\"getSubGroup('/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "', '" );
					strGetLine.append( strLoID );
					strGetLine.append( "'); return false\" class=\"hand\"></td><td ID='label/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "'><label onclick=\"select_name('" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "', '" );
					strGetLine.append( strLoID );
					strGetLine.append( "', '" );
					strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strLoTytle)) );
					strGetLine.append( "');popupDocument('" );
					strGetLine.append( strLearnAuthority );
					strGetLine.append( "','");
					strGetLine.append( strManagementAuthority+"');\" class=\"hand\">" + ConstTree.ICON_SPACE);
					strGetLine.append( "<font size=\"" );
					strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
					strGetLine.append( "\">" );
					strGetLine.append( HtmlEscape.escape(strLoTytle) );
					strGetLine.append( "</font>" );
					strGetLine.append( "</label></td></tr></table><DIV id=/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "Child style=\"display:none\"></DIV>");
				} else {
					strIconGif = "icon_lo_type_" + strLoType + "_f.gif";
					strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
					strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH + " cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
					strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
					strGetLine.append( "' width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
					strGetLine.append( strIconName );
					strGetLine.append( "' name='name/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "'class=\"hand\"></td><td ID='label/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "'><label onclick=\"select_name('" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "', '" );
					strGetLine.append( strLoID );
					strGetLine.append( "', '" );
					strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strLoTytle)) );
					strGetLine.append( "');popupDocument('" );
					strGetLine.append( strLearnAuthority );
					strGetLine.append( "','" );
					strGetLine.append( strManagementAuthority+"');\" class=\"hand\">" + ConstTree.ICON_SPACE);
					strGetLine.append( "<font size=\"" );
					strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
					strGetLine.append( "\">" );
					strGetLine.append( HtmlEscape.escape(strLoTytle) );
					strGetLine.append( "</font>" );
					strGetLine.append( "</label></td></tr></table><DIV id=/" );
					strGetLine.append( strParentLoID );
					strGetLine.append( "/" );
					strGetLine.append( strLoID );
					strGetLine.append( "Child ></DIV>");
				}

				request.setAttribute("strUpdateAction", strGetLine.toString());
			} else {
				if( strSelectID.substring( 0, 2 ).equals( "GR" ) ) {
					// 更新したグループ情報をデータベースから取得する。
					GroupsClient objGroups = new GroupsClient();

					// 検索条件の設定
					objGroups.setWhereGroupID( strSelectID );
					if( !objGroups.select() ) {
						// 検索がうまくいかなかった場合
						if( objGroups.isErr() ) {
							// エラーの場合
							request.setAttribute("message", "");
							request.setAttribute("detail", "");
							request.setAttribute("close", "on");
							request.setAttribute("errorurl", objGroups.getURL());
							return mapping.findForward("error");
						}
						else {
							String strMessage =  objGroups.getMessage();
							request.setAttribute("message", strMessage);
							request.setAttribute("detail", "");
							request.setAttribute("close", "on");
							request.setAttribute("errorurl", "");
							return mapping.findForward("error");
						}
					}
					///////////////////////////////
					// グループ情報の取得
					///////////////////////////////
					String strGroupName = "";
					String strGroupType = "";
					if( objGroups.next() ) {
						// グループ名
						strGroupName = objGroups.getGroupName();
						strGroupType = objGroups.getGroupType();
					}
					else {
						// グループ名が存在しない場合エラーを出力する
						String strMessage =  "グループ存在しません。";
						request.setAttribute("message", strMessage);
						request.setAttribute("detail", "");
						request.setAttribute("close", "on");
						request.setAttribute("errorurl", "");
						return mapping.findForward("error");
					}
					StringBuffer strGetLine = new StringBuffer();
					String strIconGif = "icon_group_type_" + strGroupType + ".gif";
					String strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
					strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH + " cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
					strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
					strGetLine.append( "' width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
					strGetLine.append( strIconName );
					strGetLine.append( "' name='name/" );
					strGetLine.append( strParentID );
					strGetLine.append( "/" );
					strGetLine.append( strSelectID );
					strGetLine.append( "'></td><td ID='label/" );
					strGetLine.append( strParentID );
					strGetLine.append( "/" );
					strGetLine.append( strSelectID );
					strGetLine.append( "'><label onclick=\"select_name('" );
					strGetLine.append( strParentID );
					strGetLine.append( "', '" );
					strGetLine.append( strSelectID );
					strGetLine.append( "', '" );
					strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strGroupName)) );
					strGetLine.append( "');popupDocument('" );
					strGetLine.append( strLearnAuthority );
					strGetLine.append( "','" );
					strGetLine.append( strManagementAuthority+"');\">" + ConstTree.ICON_SPACE);
					strGetLine.append( "<font size=\"" );
					strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
					strGetLine.append( "\">" );
					strGetLine.append( HtmlEscape.escape(strGroupName) );
					strGetLine.append( "</font>" );
					strGetLine.append( "</label></td></tr></table><DIV id=/" );
					strGetLine.append( strParentID );
					strGetLine.append( "/" );
					strGetLine.append( strSelectID );
					strGetLine.append( "Child ></DIV>");
					
					request.setAttribute("strUpdateAction", strGetLine.toString());
				} else {
					// 更新したユーザ情報をデータベースから取得する。
					PeopleClient objPeople = new PeopleClient();

					// 検索条件の設定
					objPeople.setWhereUserID( strSelectID );
					if( !objPeople.select() ) {
						// 検索がうまくいかなかった場合
						if( objPeople.isErr() ) {
							// エラーの場合
							request.setAttribute("message", "");
							request.setAttribute("detail", "");
							request.setAttribute("close", "on");
							request.setAttribute("errorurl", objPeople.getURL());
							return mapping.findForward("error");
						}
						else {
							String strMessage =  objPeople.getMessage();
							request.setAttribute("message", strMessage);
							request.setAttribute("detail", "");
							request.setAttribute("close", "on");
							request.setAttribute("errorurl", "");
							return mapping.findForward("error");
						}
					}
					///////////////////////////////
					// ユーザ情報の取得
					///////////////////////////////
					String strUserName = "";
					String strSex = "";
					String strUserType = "";
					if( objPeople.next() ) {
						// ユーザ名
						strUserName = objPeople.getUserName();
						strSex = objPeople.getSex();
						strUserType = objPeople.getUserType();
					}
					else {
						// ユーザ名が存在しない場合エラーを出力する
						String strMessage =  "ユーザ存在しません。";
						request.setAttribute("message", strMessage);
						request.setAttribute("detail", "");
						request.setAttribute("close", "on");
						request.setAttribute("errorurl", "");
						return mapping.findForward("error");
					}

					StringBuffer strGetLine = new StringBuffer();
					String strIconName = "";
					String strIconGif = "";

					if(strSex.equals("1")){
						strIconGif = MethodAssignmentsConstants.IMG_MAN_DISP + strUserType + ".gif";
						strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
						strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH + " cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
						strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
						strGetLine.append( "' width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
						strGetLine.append( strIconName );
						strGetLine.append( "' name='name/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'></td><td ID='label/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'><label onclick=\"select_name('" );
						strGetLine.append( strParentID );
						strGetLine.append( "', '" );
						strGetLine.append( strSelectID );
						strGetLine.append( "', '" );
						strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strUserName)) );
						strGetLine.append( "');popupDocument('" );
						strGetLine.append( strLearnAuthority );
						strGetLine.append( "','" );
						strGetLine.append( strManagementAuthority );
						strGetLine.append( "');\">" + ConstTree.ICON_SPACE);
					strGetLine.append( "<font size=\"" );
					strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
					strGetLine.append( "\">" );
						strGetLine.append( HtmlEscape.escape(strUserName) );
					strGetLine.append( "</font>" );
						strGetLine.append( "</label></td></tr></table><DIV id=/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "Child ></DIV>");
					}
					else if(strSex.equals("2")){
						strIconGif = MethodAssignmentsConstants.IMG_WOMEN_DISP + strUserType + ".gif";
						strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
						strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH + " cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
						strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
						strGetLine.append( "' width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
						strGetLine.append( strIconName );
						strGetLine.append( "' name='name/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'></td><td ID='label/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'><label onclick=\"select_name('" );
						strGetLine.append( strParentID );
						strGetLine.append( "', '" );
						strGetLine.append( strSelectID );
						strGetLine.append( "', '" );
						strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strUserName)) );
						strGetLine.append( "');popupDocument('" );
						strGetLine.append( strLearnAuthority );
						strGetLine.append( "','" );
						strGetLine.append( strManagementAuthority );
						strGetLine.append( "');\">" + ConstTree.ICON_SPACE);
						strGetLine.append( "<font size=\"" );
						strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
						strGetLine.append( "\">" );
						strGetLine.append( HtmlEscape.escape(strUserName) );
						strGetLine.append( "</font>" );
						strGetLine.append( "</label></td></tr></table><DIV id=/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "Child ></DIV>");
					}
					else if(strSex.equals("3")){
						strIconGif = MethodAssignmentsConstants.IMG_UNKNOWN_DISP + strUserType + ".gif";
						strIconName = ConstTree.TREE_GIF_ICON_PATH + strIconGif;
						strGetLine.append( "<table cellspacing=" + ConstTree.ICON_PITCH + " cellpadding=" + ConstTree.ICON_PITCH + " ><tr><td><IMG src='../../../image/xmo/Base/jpn/" );
						strGetLine.append( MethodAssignmentsConstants.IMG_SPACE_o );
						strGetLine.append( "' width=" + ConstTree.INDENT_ASSIGN_CONTAINER + " height=5></td><td><IMG src='" );
						strGetLine.append( strIconName );
						strGetLine.append( "' name='name/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'></td><td ID='label/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "'><label onclick=\"select_name('" );
						strGetLine.append( strParentID );
						strGetLine.append( "', '" );
						strGetLine.append( strSelectID );
						strGetLine.append( "', '" );
						strGetLine.append( HtmlEscape.escapeSinglequoteYen(HtmlEscape.escape(strUserName)) );
						strGetLine.append( "');popupDocument('" );
						strGetLine.append( strLearnAuthority );
						strGetLine.append( "','" );
						strGetLine.append( strManagementAuthority );
						strGetLine.append( "');\">" + ConstTree.ICON_SPACE);
						strGetLine.append( "<font size=\"" );
						strGetLine.append( ConstTree.DISPLAY_FONT_SIZE );
						strGetLine.append( "\">" );
						strGetLine.append( HtmlEscape.escape(strUserName) );
						strGetLine.append( "</font>" );
						strGetLine.append( "</label></td></tr></table><DIV id=/" );
						strGetLine.append( strParentID );
						strGetLine.append( "/" );
						strGetLine.append( strSelectID );
						strGetLine.append( "Child ></DIV>");
					}
					
					request.setAttribute("strUpdateAction", strGetLine.toString());
				}
			}
			
			return mapping.findForward("success");
		}
		catch( Exception e ) {
			e.printStackTrace();
			request.setAttribute("message", "err");
			request.setAttribute("detail", e.getMessage());
			request.setAttribute("close", "on");
			request.setAttribute("errorurl", "");
			return mapping.findForward("error");
		}
		
	}
}
