/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) 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.mospcommon.system.vo;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPMenuConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.mospcommon.system.dto.CmLimitStandardDto;

/**
 * @author nakamura
 *
 */
public class LimitStandardMasterListVo extends MosPVo {
	
	private static final long	serialVersionUID	= -6494798631482617888L;
	
	// 定数
	/**
	 * 未検索
	 */
	public static final int		SEARCH_OFF			= 0;
	
	/**
	 * 検索済
	 */
	public static final int		SEARCH_ON			= 1;
	
	// パラメータ名
	/**
	 * 限度基準コード
	 */
	public static final String	PRM_TXT_LCODE		= "txtLCode";
	
	/**
	 * 限度基準名称
	 */
	public static final String	PRM_TXT_LNAME		= "txtLName";
	
	/**
	 * 削除フラグ
	 */
	public static final String	PRM_PLT_DELETE_FLAG	= "pltDeleteFlag";
	
	// フィールド
	private String[]			aryLCode;
	private String[]			aryLName;
	private String[]			aryDelete;
	private String				txtLCode;
	private String				txtLName;
	private String				pltDeleteFlag;
	
	// フィールド名及び制限
	/**
	 * 限度基準コード
	 */
	public String				NAM_LCODE;
	
	/**
	 * 限度基準名称
	 */
	public String				NAM_LNAME;
	
	/**
	 * 削除フラグ
	 */
	public String				NAM_DELETE_FLAG;
	
	/**
	 * 限度基準コード
	 */
	public int					LEN_LCODE;
	
	/**
	 * 限度基準名称
	 */
	public int					LEN_LNAME;
	
	// ソートキー
	/**
	 * 限度基準コード
	 */
	public final String			KEY_LCODE			= "keyLCode";
	
	/**
	 * 限度基準名称
	 */
	public final String			KEY_LNAME			= "keyLName";
	/**
	 * 有効・無効
	 */
	public final String			KEY_DELETE			= "keyDelete";
	
	// モード(0：検索なし、1：検索あり)
	private int					searchmode;
	

	/**
	 * コンストラクター
	 */
	public LimitStandardMasterListVo() {
		super();
		setViewPath(getClassName());
		aryLCode = new String[0];
		aryLName = new String[0];
		aryDelete = new String[0];
		txtLCode = "";
		txtLName = "";
		pltDeleteFlag = "";
		setFormerKey(KEY_LCODE);
	}
	
	@Override
	protected void setSubTitle() {
		subTitle = CommonConst.TTL_LIMIT_STANDARD;
		createAryMenu(CMD_MENU_SYSTEM2, MosPMenuConst.getMenuLaborAgreement());
	}
	
	@Override
	protected void setFieldsName() {
		NAM_LCODE = CommonConst.NAM_LIMIT_STANDARD + CommonConst.NAM_COMMON_CODE;
		NAM_LNAME = CommonConst.NAM_COMMON_MEISYO;
		NAM_DELETE_FLAG = CommonConst.NAM_DELETE_FLAG;
		LEN_LCODE = 10;
		LEN_LNAME = CommonConst.LEN_LIMIT_NAME;
	}
	
	@Override
	public void setParams(HttpServletRequest request) {
		txtLCode = request.getParameter(PRM_TXT_LCODE);
		txtLName = request.getParameter(PRM_TXT_LNAME);
		pltDeleteFlag = request.getParameter(PRM_PLT_DELETE_FLAG);
	}
	
	/**
	 * フィールド設定
	 * @param listLimitStandard 事業所リスト
	 */
	@Override
	public void setFields(List<?> listLimitStandard) {
		// リストの設定
		list = listLimitStandard;
		// データ総数の取得
		count = listLimitStandard.size();
		// 配列の初期化
		aryLCode = new String[count];
		aryLName = new String[count];
		aryDelete = new String[count];
		// データの設定
		int i = 0;
		Iterator<?> it = listLimitStandard.iterator();
		while (it.hasNext()) {
			CmLimitStandardDto dto = (CmLimitStandardDto)it.next();
			aryLCode[i] = escapeHTML(dto.getLimitCode());
			aryLName[i] = escapeHTML(dto.getLimitName());
			if (dto.getDeleteFlag() == MospConst.DELETE_FLAG_OFF) {
				aryDelete[i] = escapeHTML(MospConst.DELETE_FLAG_OFF_NAME);
			} else if (dto.getDeleteFlag() == MospConst.DELETE_FLAG_ON) {
				aryDelete[i] = escapeHTML(MospConst.DELETE_FLAG_ON_NAME);
			}
			i++;
		}
	}
	
	// アクセサメソッド
	/**
	 * @return 限度基準コード
	 */
	public String[] getEscAryLCode() {
		return aryLCode.clone();
	}
	
	/**
	 * @return 限度基準名称
	 */
	public String[] getEscAryLName() {
		return aryLName.clone();
	}
	
	/**
	 * @return 限度基準コード
	 */
	public String getTxtLCode() {
		return txtLCode;
	}
	
	/**
	 * @return 限度基準名称
	 */
	public String getTxtLName() {
		return txtLName;
	}
	
	/**
	 * @return 削除フラグ
	 */
	public String getPltDeleteFlag() {
		return pltDeleteFlag;
	}
	
	/**
	 * @return 限度基準コード
	 */
	public String getEscTxtLCode() {
		return escapeHTML(txtLCode);
	}
	
	/**
	 * @return 限度基準名称
	 */
	public String getEscTxtLName() {
		return escapeHTML(txtLName);
	}
	
	/**
	 * @return 検索モード
	 */
	public int getSearchmode() {
		return searchmode;
	}
	
	/**
	 * @param searchmode 検索モード
	 */
	public void setSearchmode(int searchmode) {
		this.searchmode = searchmode;
	}
	
	/** 
	 * @param pltDeleteFlag セットする pltDeleteFlag 
	 */
	public void setPltDelete(String pltDeleteFlag) {
		this.pltDeleteFlag = pltDeleteFlag;
	}
	
	/**
	 * @return aryDelete
	 */
	public String[] getAryDelete() {
		return aryDelete.clone();
	}
}
