/*
 * 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.kintai.system.vo;

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

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPVo;
import jp.mosp.common.common.MospConst;
import jp.mosp.common.dto.CmCodeDto;

/**
 * @author yoshida
 *
 */
public class CmCodeListVo extends MosPVo {
	
	private static final long	serialVersionUID	= 123422132321L;
	
	// パラメータ名
	/**
	 * 
	 */
	public static final String	PRM_PLT_T_ID		= "pltTId";
	/**
	 * 
	 */
	public static final String	PRM_TXT_T_CODE		= "txtTCode";
	/**
	 * 
	 */
	public static final String	PRM_TXT_T_NAME		= "txtTName";
	/**
	 * 
	 */
	public static final String	PRM_TXT_VIEW_INDEX	= "txtViewIndex";
	/**
	 * 
	 */
	public static final String	PRM_PLT_DELETE		= "pltDelete";
	
	// フィールド
	private String[]			aryTId;
	private String[]			aryTIdName;
	private String[]			aryTCode;
	private String[]			aryTName;
	private String[]			aryViewIndex;
	private String[]			aryDelete;
	private String				pltTId;
	private String				txtTCode;
	private String				txtTName;
	private String				txtViewIndex;
	private String				pltDelete;
	
	// フィールド名及び制限
	/**
	 * 
	 */
	public String				NAM_CODE_ID;
	/**
	 * 
	 */
	public String				NAM_CODE;
	/**
	 * 
	 */
	public String				NAM_NAME;
	/**
	 * 
	 */
	public String				NAM_INDEX;
	/**
	 * 
	 */
	public String				NAM_DELETE;
	/**
	 * 
	 */
	public int					LEN_CODE_ID;
	/**
	 * 
	 */
	public int					LEN_CODE;
	/**
	 * 
	 */
	public int					LEN_NAME;
	
	// ソートキー
	/**
	 * 
	 */
	public final String			KEY_T_ID			= "keyTId";
	/**
	 * 
	 */
	public final String			KEY_T_CODE			= "keyTCode";
	/**
	 * 
	 */
	public final String			KEY_T_NAME			= "keyTName";
	/**
	 * 
	 */
	public final String			KEY_VIEWINDEX		= "keyViewIndex";
	/**
	 * 
	 */
	public final String			KEY_DELETE			= "keyDelete";
	
	// プルダウンリスト
	/**
	 * 
	 */
	public String[][]			aryPltTId;
	
	// モード(0：検索なし、1：検索あり)
	private int					searchmode;
	

	/**
	 * コンストラクタ
	 */
	public CmCodeListVo() {
		super();
		setViewPath(getClassName());
		pltTId = "";
		txtTCode = "";
		txtTName = "";
		txtViewIndex = "";
		pltDelete = "";
		aryTId = new String[0];
		aryTIdName = new String[0];
		aryTCode = new String[0];
		aryTName = new String[0];
		aryViewIndex = new String[0];
		aryDelete = new String[0];
		setFormerKey(KEY_T_ID);
	}
	
	@Override
	protected void setSubTitle() {
		subTitle = CommonConst.TTL_COMMON_CODE_MASTER;
		aryMenu = new String[][]{ { CMD_MENU_SYSTEM2, CommonConst.NAM_TO_MENU } };
	}
	
	@Override
	protected void setFieldsName() {
		NAM_CODE_ID = CommonConst.NAM_COMMON_CODE + CommonConst.NAM_COMMON_TYPE;
		NAM_CODE = CommonConst.NAM_COMMON_CODE;
		NAM_NAME = CommonConst.NAM_COMMON_MEISYO;
		NAM_INDEX = CommonConst.NAM_SHOW_ORDER;
		NAM_DELETE = CommonConst.NAM_DELETE_FLAG;
		LEN_CODE_ID = 10;
		LEN_CODE = 8;
		LEN_NAME = 16;
	}
	
	@Override
	public void setParams(HttpServletRequest request) {
		pltTId = request.getParameter(PRM_PLT_T_ID);
		txtTCode = request.getParameter(PRM_TXT_T_CODE);
		txtTName = request.getParameter(PRM_TXT_T_NAME);
		txtViewIndex = request.getParameter(PRM_TXT_VIEW_INDEX);
		pltDelete = request.getParameter(PRM_PLT_DELETE);
	}
	
	@Override
	public void setFields(List<?> listUmUser) {
		// リストの設定
		list = listUmUser;
		// データ総数の取得
		count = listUmUser.size();
		// 配列の初期化
		aryTId = new String[count];
		aryTCode = new String[count];
		aryTName = new String[count];
		aryViewIndex = new String[count];
		aryDelete = new String[count];
		// データの設定
		int i = 0;
		Iterator<?> it = listUmUser.iterator();
		while (it.hasNext()) {
			CmCodeDto dto = (CmCodeDto)it.next();
			aryTId[i] = escapeHTML(dto.getTId());
			aryTCode[i] = escapeHTML(dto.getTCode());
			aryTName[i] = escapeHTML(dto.getTName());
			aryViewIndex[i] = String.valueOf(dto.getViewIndex());
			aryDelete[i] = String.valueOf(dto.getDeleteFlag());
			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 aryTId
	 */
	public String[] getAryTId() {
		return aryTId.clone();
	}
	
	/**
	 * @return aryTIdName
	 */
	public String[] getAryTIdName() {
		return aryTIdName.clone();
	}
	
	/**
	 * @return aryTCode
	 */
	public String[] getAryTCode() {
		return aryTCode.clone();
	}
	
	/**
	 * @return aryTName
	 */
	public String[] getAryTName() {
		return aryTName.clone();
	}
	
	/**
	 * @return aryViewIndex
	 */
	public String[] getAryViewIndex() {
		return aryViewIndex.clone();
	}
	
	/**
	 * @return aryDelete
	 */
	public String[] getAryDelete() {
		return aryDelete.clone();
	}
	
	/**
	 * @return pltTId
	 */
	public String getPltTId() {
		return pltTId;
	}
	
	/**
	 * @return txtTCode
	 */
	public String getTxtTCode() {
		return txtTCode;
	}
	
	/**
	 * @return txtTName
	 */
	public String getTxtTName() {
		return txtTName;
	}
	
	/**
	 * @return txtViewIndex
	 */
	public String getTxtViewIndex() {
		return txtViewIndex;
	}
	
	/**
	 * @return pltDelete
	 */
	public String getPltDelete() {
		return pltDelete;
	}
	
	/**
	 * @return searchmode
	 */
	public int getSearchmode() {
		return searchmode;
	}
	
	/**
	 * @param aryTId セットする aryTId
	 */
	public void setAryTId(String[] aryTId) {
		this.aryTId = aryTId.clone();
	}
	
	/**
	 * @param aryTIdName セットする aryTIdName
	 */
	public void setAryTIdName(String[] aryTIdName) {
		this.aryTIdName = aryTIdName.clone();
	}
	
	/**
	 * @param aryTCode セットする aryTCode
	 */
	public void setAryTCode(String[] aryTCode) {
		this.aryTCode = aryTCode.clone();
	}
	
	/**
	 * @param aryTName セットする aryTName
	 */
	public void setAryTName(String[] aryTName) {
		this.aryTName = aryTName.clone();
	}
	
	/**
	 * @param aryViewIndex セットする aryViewIndex
	 */
	public void setAryViewIndex(String[] aryViewIndex) {
		this.aryViewIndex = aryViewIndex.clone();
	}
	
	/**
	 * @param aryDelete セットする aryDelete
	 */
	public void setAryDelete(String[] aryDelete) {
		this.aryDelete = aryDelete.clone();
	}
	
	/**
	 * @param pltTId セットする pltTId
	 */
	public void setPltTId(String pltTId) {
		this.pltTId = pltTId;
	}
	
	/**
	 * @param txtTCode セットする txtTCode
	 */
	public void setTxtTCode(String txtTCode) {
		this.txtTCode = txtTCode;
	}
	
	/**
	 * @param txtTName セットする txtTName
	 */
	public void setTxtTName(String txtTName) {
		this.txtTName = txtTName;
	}
	
	/**
	 * @param txtViewIndex セットする txtViewIndex
	 */
	public void setTxtViewIndex(String txtViewIndex) {
		this.txtViewIndex = txtViewIndex;
	}
	
	/**
	 * @param pltDelete セットする pltDelete
	 */
	public void setPltDelete(String pltDelete) {
		this.pltDelete = pltDelete;
	}
	
	/**
	 * @param searchmode セットする searchmode
	 */
	public void setSearchmode(int searchmode) {
		this.searchmode = searchmode;
	}
	
}
