package jp.agentec.sinaburocast.entity; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; 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.StringUtils; @Entity @Table(name="m_question") public class Question extends AbstractEntity { /** * */ private static final long serialVersionUID = 1L; @Id @Column(name = "question_id") public Integer questionId; @Column(name = "enquete_id") public Integer enqueteId; @Column(name = "question_no") public Integer questionNo; @Column(name = "question_name") public String questionName; @Column(name = "question") public String question; public String explanation; public String help; @Column(name = "required_flg") public Integer requiredFlg; //NOではなくIDを設定している。 @Column(name = "cond_required_question_no") public Integer condRequiredQuestionNo; @Column(name = "cond_required_answer") public String condRequiredAnswer; @Column(name = "control_id") public Integer controlId; @Column(name = "max_select_num") public Integer maxSelectNum; @Column(name = "min_select_num") public Integer minSelectNum; @Column(name = "col_num") public Integer colNum; @Column(name = "del_flg") public Integer delFlg; @Column(name = "disp_witdth") public Integer dispWitdth; @Column(name = "rowCount") public Integer rowCount; @Column(name = "min_input_text") public Integer minInputText; @Column(name = "max_input_text") public Integer maxInputText; @Column(name = "input_text_limit") public Integer inputTextLimit; @Column(name = "blank_add") public Integer blankAdd; // @Column(name = "sel_candidate") // public Short selCandidate; // @Column(name = "sel_candidate_def") // public String selCandidateDef; @Column(name = "startymd") public String startymd; @Column(name = "endymd") public String endymd; @Column(name = "mail_type") public Integer mailType = 0; /** MAnswerList関連プロパティ */ @OneToMany(mappedBy = "question") public List<Answer> answerList; /** MEnquete関連プロパティ */ @ManyToOne @JoinColumn(name = "enquete_id", referencedColumnName = "enquete_id") public Enquete enquete; /** TReplyList関連プロパティ */ @OneToMany(mappedBy = "question") public List<Reply> replyList; @Transient public Integer answerCount; public String getYearRange() { StringBuffer sb = new StringBuffer(); if (StringUtils.isEmpty(startymd)) { sb.append("c-10"); } else { sb.append(startymd.substring(0, 4)); } sb.append(":"); if (StringUtils.isEmpty(endymd)) { sb.append("c+10"); } else { sb.append(endymd.substring(0, 4)); } return sb.toString(); } }