package jp.agentec.sinaburocast.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.StandardToStringStyle;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name="m_answer")
public class Answer extends AbstractEntity {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "answer_id")
	public Integer answerId;

	@Column(name = "enquete_id")
	public Integer enqueteId;

	@Column(name = "question_id")
	public Integer questionId;

	@Column(name = "answer_no")
	public Integer answerNo;
	public String answer;

	@Column(name = "free_text_flg")
	public Integer freeTextFlg;

	@Column(name = "free_text_col_width")
	public Short freeTextColWidth;

	@Column(name = "free_text_row_num")
	public Short freeTextRowNum;

	@Column(name = "free_text_limit")
	public Integer freeTextLimit;

	@Column(name = "del_flg")
	public Short delFlg;
	
	@Column(name = "default_flg")
	public int defaultFlg;
	
    /** MEnquete関連プロパティ */
    @ManyToOne
    @JoinColumn(name = "enquete_id", referencedColumnName = "enquete_id")
    public Enquete enquete;

    /** MQuestion関連プロパティ */
    @ManyToOne
    @JoinColumn(name = "question_id", referencedColumnName = "question_id")
    public Question question;

    /** TReplyList関連プロパティ */
    @OneToMany(mappedBy = "answerReply")
    public List<Reply> replyList;
    
    /**
     * テーブル関連外カラム
     */
    
	@Override
	public String toString() {
		
		return ToStringBuilder.reflectionToString(this, StandardToStringStyle.DEFAULT_STYLE).toString();
	}
	
	/**
	 * 回答内容チェックボックス、ラジオボタン、テキストエリア、テキストフィールド
	 */	
    @Transient
    public String answerIdValue="";

    /**
     * 回答内容自由入力欄のみ
     */
    @Transient
    public String  answerValue="";
    
}