/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 MIND Co., Ltd.  http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.common.vo;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.dto.CmAspUserDto;
import jp.mosp.common.dto.CmUserDto;

public abstract class MosPWorkFlowVo extends MosPVo {

	private static final long serialVersionUID = -1733626895330281082L;

	// パラメータ名
	public static final String PRM_HID_VOUCHER	 		= "hidVoucher";
	public static final String PRM_TXT_COMMENT	 		= "txtComment";

	// フィールド
	private String 		hidVoucher;
	private String 		txtComment;

	private String[][] aryComments;
	private String 		lblComment;

	// フィールド名及び制限
	public static final String NAM_CHANGE_COMMENT = CommonConst.NAM_CHANGING + CommonConst.NAM_COMMENT;
	public static final String NAM_AUTHOR_COMMENT = CommonConst.NAM_APPROVER + "からの" + CommonConst.NAM_COMMENT;

	public static final int	LEN_COMMENT	= 20;

	/**
	 * コンストラクタ
	 */
	public MosPWorkFlowVo(
			Properties cfg,
			Properties msg,
			Properties nam,
			String cmd,
			CmAspUserDto aspUser,
			CmUserDto user
	) {
		super(cfg, msg, nam, cmd, aspUser, user);
		hidVoucher		= "";
		txtComment		= "";
		aryComments 	= new String[0][0];
	}

	/**
	 * パラメータ設定
	 */
	public void setParams(HttpServletRequest request) {
		hidVoucher = request.getParameter(PRM_HID_VOUCHER);
		txtComment = request.getParameter(PRM_TXT_COMMENT);
	}

	/**
	 * 差戻コメント一覧
	 * @param aryComments	コメント配列
	 */
	public void setCommentFields(String[][] aryComments) {
		for (int i = 0; i < aryComments.length; i++) {
			aryComments[i][0] = escapeHTML(aryComments[i][0]);
			aryComments[i][1] = escapeHTML(aryComments[i][1]);
		}
		this.aryComments = aryComments.clone();
	}

	/**
	 * JavaScript設定
	 * @param cls 情報取得クラス
	 * @throws IllegalAccessException
	 */
	@Override
	public String getDirectJs(Class cls) throws IllegalAccessException {
		StringBuffer sb = new StringBuffer();
		sb.append(super.getDirectJs(cls));
		return sb.toString();
	}

	// アクセサメソッド
	public String 	getHidVoucher() 	{ return hidVoucher					; }
	public String 	getEscHidVoucher() 	{ return escapeHTML(hidVoucher)		; }

	public void 	setHidVoucher(String hidVoucher) { this.hidVoucher 	= hidVoucher; }

	public String getTxtComment() { return txtComment; }
	public String getEscTxtComment() { return escapeHTML(txtComment); }

	public void setTxtComment(String txtComment) { this.txtComment = txtComment; }

	public String[][] getEscAryComments() { return aryComments.clone(); }

	public String getEscLblComment() { return escapeHTML(lblComment); }
	public void setLblComment(String lblComment) { this.lblComment = lblComment; }

}
