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 | import java.util.ArrayList; |
||
| 5 | import java.util.Collections; |
||
| 6 | import java.util.Comparator; |
||
| 7 | import java.util.List; |
||
| 8 | |||
| 9 | import javax.persistence.Column; |
||
| 10 | import javax.persistence.EmbeddedId; |
||
| 11 | import javax.persistence.Entity; |
||
| 12 | import javax.persistence.JoinColumn; |
||
| 13 | import javax.persistence.JoinColumns; |
||
| 14 | import javax.persistence.ManyToOne; |
||
| 15 | import javax.persistence.Table; |
||
| 16 | import javax.persistence.Transient; |
||
| 17 | import javax.validation.constraints.NotNull; |
||
| 18 | |||
| 19 | import org.hibernate.envers.AuditTable; |
||
| 20 | import org.hibernate.envers.Audited; |
||
| 21 | import org.hibernate.envers.RelationTargetAuditMode; |
||
| 22 | |||
| 23 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 24 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 25 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 26 | import br.edu.cesmac.sic.core.domain.model.dto.TopicoQuestaoDTO; |
||
| 27 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoTopico; |
||
| 28 | |||
| 29 | @Audited |
||
| 30 | @AuditTable(value="sic_aud_resposta", schema="admsic001") |
||
| 31 | @Entity |
||
| 32 | @Table(name="sic_resposta", schema="admsic001") |
||
| 33 | public class Resposta implements Serializable { |
||
| 34 | |||
| 35 | private static final long serialVersionUID = 1L; |
||
| 36 | |||
| 37 | private RespostaId respostaId = new RespostaId(); |
||
| 38 | private Questao questao; |
||
| 39 | private Avaliacao avaliacao; |
||
| 40 | private Double valorPontuacao; |
||
| 41 | |||
| 42 | @EmbeddedId |
||
| 43 | public RespostaId getRespostaId() { |
||
| 44 | return respostaId; |
||
| 45 | } |
||
| 46 | |||
| 47 | public void setRespostaId(RespostaId respostaId) { |
||
| 48 | this.respostaId = respostaId; |
||
| 49 | } |
||
| 50 | |||
| 51 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 52 | @ManyToOne |
||
| 53 | @JoinColumn(name="seq_questao", referencedColumnName="seq_questao", nullable=false, insertable=false, updatable=false) |
||
| 54 | public Questao getQuestao() { |
||
| 55 | return questao; |
||
| 56 | } |
||
| 57 | |||
| 58 | public void setQuestao(Questao questao) { |
||
| 59 | if (VerificadorUtil.naoEstaNulo(questao)) { |
||
| 60 | respostaId.setSequencialQuestao(questao.getSequencial()); |
||
| 61 | } |
||
| 62 | this.questao = questao; |
||
| 63 | } |
||
| 64 | |||
| 65 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 66 | @ManyToOne |
||
| 67 | @JoinColumns(value={ |
||
| 68 | @JoinColumn(name="seq_projeto_pesquisa", referencedColumnName="seq_projeto_pesquisa", nullable=false, insertable=false, updatable=false), |
||
| 69 | @JoinColumn(name="seq_avaliador", referencedColumnName="seq_avaliador", nullable=false, insertable=false, updatable=false) |
||
| 70 | }) |
||
| 71 | public Avaliacao getAvaliacao() { |
||
| 72 | return avaliacao; |
||
| 73 | } |
||
| 74 | |||
| 75 | public void setAvaliacao(Avaliacao avaliacao) { |
||
| 76 | if (VerificadorUtil.naoEstaNulo(avaliacao)) { |
||
| 77 | respostaId.setSequencialProjetoPesquisa(avaliacao.getSequencialDoProjetoPesquisa()); |
||
| 78 | respostaId.setSequencialAvaliador(avaliacao.getSequencialDoAvaliador()); |
||
| 79 | } |
||
| 80 | this.avaliacao = avaliacao; |
||
| 81 | } |
||
| 82 | |||
| 83 | @NotNull(message="Obrigatório informar a pontuação", groups={Cadastrar.class, Alterar.class}) |
||
| 84 | @Column(name="val_pontuacao", nullable=false) |
||
| 85 | public Double getValorPontuacao() { |
||
| 86 | return valorPontuacao; |
||
| 87 | } |
||
| 88 | |||
| 89 | public void setValorPontuacao(Double valorPontuacao) { |
||
| 90 | this.valorPontuacao = valorPontuacao; |
||
| 91 | } |
||
| 92 | |||
| 93 | @Override |
||
| 94 | public int hashCode() { |
||
| 95 | final int prime = 31; |
||
| 96 | int result = 1; |
||
| 97 | result = prime * result + ((respostaId == null) ? 0 : respostaId.hashCode()); |
||
| 98 | return result; |
||
| 99 | } |
||
| 100 | |||
| 101 | @Override |
||
| 102 | public boolean equals(Object obj) { |
||
| 103 | if (this == obj) |
||
| 104 | return true; |
||
| 105 | if (obj == null) |
||
| 106 | return false; |
||
| 107 | if (getClass() != obj.getClass()) |
||
| 108 | return false; |
||
| 109 | Resposta other = (Resposta) obj; |
||
| 110 | if (respostaId == null) { |
||
| 111 | if (other.respostaId != null) |
||
| 112 | return false; |
||
| 113 | } else if (!respostaId.equals(other.respostaId)) |
||
| 114 | return false; |
||
| 115 | return true; |
||
| 116 | } |
||
| 117 | |||
| 118 | } |