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.JoinColumn; |
||
| 11 | import javax.persistence.ManyToOne; |
||
| 12 | import javax.persistence.Table; |
||
| 13 | import javax.persistence.Transient; |
||
| 14 | import javax.validation.constraints.NotNull; |
||
| 15 | |||
| 16 | import org.hibernate.envers.AuditTable; |
||
| 17 | import org.hibernate.envers.Audited; |
||
| 18 | import org.hibernate.envers.RelationTargetAuditMode; |
||
| 19 | |||
| 20 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 21 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 22 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 23 | import br.edu.cesmac.sac.shared.views.CursoView; |
||
| 24 | import br.edu.cesmac.views.PessoaView; |
||
| 25 | |||
| 26 | @Audited |
||
| 27 | @AuditTable(value="sic_aud_avaliador", schema="admsic001") |
||
| 28 | @Entity |
||
| 29 | @Table(name="sic_avaliador", schema="admsic001") |
||
| 30 | public class Avaliador implements Serializable { |
||
| 31 | |||
| 32 | private static final long serialVersionUID = 1L; |
||
| 33 | |||
| 34 | private Long sequencial; |
||
| 35 | private PessoaView pessoa; |
||
| 36 | private CursoView curso; |
||
| 37 | private Area area; |
||
| 38 | private Boolean ativo; |
||
| 39 | |||
| 40 | @Id |
||
| 41 | @GeneratedValue(strategy=GenerationType.AUTO) |
||
| 42 | @Column(name="seq_avaliador", nullable=false) |
||
| 43 | public Long getSequencial() { |
||
| 44 | return sequencial; |
||
| 45 | } |
||
| 46 | |||
| 47 | public void setSequencial(Long sequencial) { |
||
| 48 | this.sequencial = sequencial; |
||
| 49 | } |
||
| 50 | |||
| 51 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 52 | @ManyToOne |
||
| 53 | @NotNull(message="Obrigatório informar a pessoa", groups={Cadastrar.class, Alterar.class}) |
||
| 54 | @JoinColumn(name="seq_pessoa", referencedColumnName="seq_pessoa") |
||
| 55 | public PessoaView getPessoa() { |
||
| 56 | return pessoa; |
||
| 57 | } |
||
| 58 | |||
| 59 | public void setPessoa(PessoaView pessoa) { |
||
| 60 | this.pessoa = pessoa; |
||
| 61 | } |
||
| 62 | |||
| 63 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 64 | @ManyToOne |
||
| 65 | @NotNull(message="Obrigatório informar o curso", groups={Cadastrar.class, Alterar.class}) |
||
| 66 | @JoinColumn(name="seq_curso", referencedColumnName="seq_curso") |
||
| 67 | public CursoView getCurso() { |
||
| 68 | return curso; |
||
| 69 | } |
||
| 70 | |||
| 71 | public void setCurso(CursoView curso) { |
||
| 72 | this.curso = curso; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 76 | @ManyToOne |
||
| 77 | @NotNull(message="Obrigatório informar a área", groups={Cadastrar.class, Alterar.class}) |
||
| 78 | @JoinColumn(name="cod_area", referencedColumnName="cod_area") |
||
| 79 | public Area getArea() { |
||
| 80 | return area; |
||
| 81 | } |
||
| 82 | |||
| 83 | public void setArea(Area area) { |
||
| 84 | this.area = area; |
||
| 85 | } |
||
| 86 | |||
| 87 | @NotNull(message="Obrigatório informar o indicador de ativo", groups={Cadastrar.class, Alterar.class}) |
||
| 88 | @Column(name="ind_ativo", nullable=false) |
||
| 89 | public Boolean getAtivo() { |
||
| 90 | return ativo; |
||
| 91 | } |
||
| 92 | |||
| 93 | public void setAtivo(Boolean ativo) { |
||
| 94 | this.ativo = ativo; |
||
| 95 | } |
||
| 96 | |||
| 97 | @Override |
||
| 98 | public int hashCode() { |
||
| 99 | final int prime = 31; |
||
| 100 | int result = 1; |
||
| 101 | result = prime * result + ((pessoa == null) ? 0 : pessoa.hashCode()); |
||
| 102 | return result; |
||
| 103 | } |
||
| 104 | |||
| 105 | @Override |
||
| 106 | public boolean equals(Object obj) { |
||
| 107 | if (this == obj) |
||
| 108 | return true; |
||
| 109 | if (obj == null) |
||
| 110 | return false; |
||
| 111 | if (getClass() != obj.getClass()) |
||
| 112 | return false; |
||
| 113 | Avaliador other = (Avaliador) obj; |
||
| 114 | if (pessoa == null) { |
||
| 115 | if (other.pessoa != null) |
||
| 116 | return false; |
||
| 117 | } else if (!pessoa.equals(other.pessoa)) |
||
| 118 | return false; |
||
| 119 | return true; |
||
| 120 | } |
||
| 121 | |||
| 122 | @Transient |
||
| 123 | public Long getSequencialDaPessoa() { |
||
| 124 | return VerificadorUtil.naoEstaNulo(getPessoa())? getPessoa().getSequencial() : null; |
||
| 125 | } |
||
| 126 | |||
| 127 | @Transient |
||
| 128 | public String getNomeDaPessoa() { |
||
| 129 | return VerificadorUtil.naoEstaNulo(getPessoa())? getPessoa().getNome() : null; |
||
| 130 | } |
||
| 131 | |||
| 132 | @Transient |
||
| 133 | public String getNumeroCpfDaPessoa() { |
||
| 134 | return VerificadorUtil.naoEstaNulo(getPessoa())? getPessoa().getNumeroCpf() : null; |
||
| 135 | } |
||
| 136 | |||
| 137 | @Transient |
||
| 138 | public String getEmailDaPessoa() { |
||
| 139 | return VerificadorUtil.naoEstaNulo(getPessoa())? getPessoa().getEmail() : null; |
||
| 140 | } |
||
| 141 | |||
| 142 | @Transient |
||
| 143 | public String getDescricaoDoCurso() { |
||
| 144 | return VerificadorUtil.naoEstaNulo(getCurso())? getCurso().getDescricao() : null; |
||
| 145 | } |
||
| 146 | |||
| 147 | @Transient |
||
| 148 | public String getDescricaoDaArea() { |
||
| 149 | return VerificadorUtil.naoEstaNulo(getArea())? getArea().getDescricao() : null; |
||
| 150 | } |
||
| 151 | |||
| 152 | } |