Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.edu.cesmac.sic.core.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.GeneratedValue; |
||
| 8 | import javax.persistence.GenerationType; |
||
| 9 | import javax.persistence.Id; |
||
| 10 | import javax.persistence.Table; |
||
| 11 | import javax.persistence.Transient; |
||
| 12 | import javax.validation.constraints.NotNull; |
||
| 13 | |||
| 14 | import org.hibernate.envers.AuditTable; |
||
| 15 | import org.hibernate.envers.Audited; |
||
| 16 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 17 | |||
| 18 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 19 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 20 | import br.edu.cesmac.core.util.StringUtil; |
||
| 21 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 22 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoTopico; |
||
| 23 | |||
| 24 | @Audited |
||
| 25 | @AuditTable(value="sic_aud_questao", schema="admsic001") |
||
| 26 | @Entity |
||
| 27 | @Table(name="sic_questao", schema="admsic001") |
||
| 28 | public class Questao implements Serializable { |
||
| 29 | |||
| 30 | private static final long serialVersionUID = 1L; |
||
| 31 | |||
| 32 | private Long sequencial; |
||
| 33 | private Integer numeroQuestao; |
||
| 34 | private String descricao; |
||
| 35 | private Double valorPontuacaoMaxima; |
||
| 36 | private String tipoTopico; |
||
| 37 | private Boolean ativo; |
||
| 38 | |||
| 39 | @Id |
||
| 40 | @GeneratedValue(strategy=GenerationType.AUTO) |
||
| 41 | @Column(name="seq_questao", nullable=false) |
||
| 42 | public Long getSequencial() { |
||
| 43 | return sequencial; |
||
| 44 | } |
||
| 45 | |||
| 46 | public void setSequencial(Long sequencial) { |
||
| 47 | this.sequencial = sequencial; |
||
| 48 | } |
||
| 49 | |||
| 50 | @NotNull(message="Obrigatório informar o número da questão", groups={Cadastrar.class, Alterar.class}) |
||
| 51 | @Column(name="num_questao", nullable=false) |
||
| 52 | public Integer getNumeroQuestao() { |
||
| 53 | return numeroQuestao; |
||
| 54 | } |
||
| 55 | |||
| 56 | public void setNumeroQuestao(Integer numeroQuestao) { |
||
| 57 | this.numeroQuestao = numeroQuestao; |
||
| 58 | } |
||
| 59 | |||
| 60 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 61 | @Column(name="dsc_questao", nullable=false) |
||
| 62 | public String getDescricao() { |
||
| 63 | return descricao; |
||
| 64 | } |
||
| 65 | |||
| 66 | public void setDescricao(String descricao) { |
||
| 67 | this.descricao = StringUtil.setarUpperCase(descricao); |
||
| 68 | } |
||
| 69 | |||
| 70 | @NotNull(message="Obrigatório informar a pontuação máxima", groups={Cadastrar.class, Alterar.class}) |
||
| 71 | @Column(name="val_pontuacao_maxima", nullable=false) |
||
| 72 | public Double getValorPontuacaoMaxima() { |
||
| 73 | return valorPontuacaoMaxima; |
||
| 74 | } |
||
| 75 | |||
| 76 | public void setValorPontuacaoMaxima(Double valorPontuacaoMaxima) { |
||
| 77 | this.valorPontuacaoMaxima = valorPontuacaoMaxima; |
||
| 78 | } |
||
| 79 | |||
| 80 | @Column(name="tip_topico") |
||
| 81 | public String getTipoTopico() { |
||
| 82 | return tipoTopico; |
||
| 83 | } |
||
| 84 | |||
| 85 | public void setTipoTopico(String tipoTopico) { |
||
| 86 | this.tipoTopico = tipoTopico; |
||
| 87 | } |
||
| 88 | |||
| 89 | @NotNull(message="Obrigatório informar o indicador de ativo", groups={Cadastrar.class, Alterar.class}) |
||
| 90 | @Column(name="ind_ativo", nullable=false) |
||
| 91 | public Boolean getAtivo() { |
||
| 92 | return ativo; |
||
| 93 | } |
||
| 94 | |||
| 95 | public void setAtivo(Boolean ativo) { |
||
| 96 | this.ativo = ativo; |
||
| 97 | } |
||
| 98 | |||
| 99 | @Override |
||
| 100 | public int hashCode() { |
||
| 101 | final int prime = 31; |
||
| 102 | int result = 1; |
||
| 103 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 104 | return result; |
||
| 105 | } |
||
| 106 | |||
| 107 | @Override |
||
| 108 | public boolean equals(Object obj) { |
||
| 109 | if (this == obj) |
||
| 110 | return true; |
||
| 111 | if (obj == null) |
||
| 112 | return false; |
||
| 113 | if (getClass() != obj.getClass()) |
||
| 114 | return false; |
||
| 115 | Questao other = (Questao) obj; |
||
| 116 | if (sequencial == null) { |
||
| 117 | if (other.sequencial != null) |
||
| 118 | return false; |
||
| 119 | } else if (!sequencial.equals(other.sequencial)) |
||
| 120 | return false; |
||
| 121 | return true; |
||
| 122 | } |
||
| 123 | |||
| 124 | @Transient |
||
| 125 | public String getDescricaoDoTopico() { |
||
| 126 | return VerificadorUtil.naoEstaNulo(getTipoTopico())? TipoTopico.parse(getTipoTopico()).getDescricao() : null; |
||
| 127 | } |
||
| 128 | |||
| 129 | } |