Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
package br.gov.al.saude.scs.model.view;
2
 
3
import java.io.Serializable;
4
import java.util.Date;
5
 
6
import javax.persistence.Column;
7
import javax.persistence.Entity;
8
import javax.persistence.Id;
9
import javax.persistence.JoinColumn;
10
import javax.persistence.OneToOne;
11
import javax.persistence.Table;
12
import javax.persistence.Temporal;
13
import javax.persistence.TemporalType;
14
import javax.persistence.Transient;
15
 
16
import org.hibernate.annotations.ForeignKey;
17
 
18
import br.gov.al.saude.framework.core.generic.identidade.Identidade;
19
import br.gov.al.saude.scg.model.view.PessoaFisicaView;
20
 
21
@Entity
22
@Table(name = "vw_servidor", schema = "sc_srv")
23
public class ServidorView implements Serializable, Identidade, Comparable<ServidorView> {
24
 
25
        private static final long serialVersionUID = 1L;
26
 
27
        private PessoaFisicaView pessoa;
28
 
29
        private String nome;
30
        private String cpf;
31
        private String sexo;
32
        private Date dataNascimento;
33
        private String email;
34
        private String nacionalidade;
35
        private String tipoGrauInstrucao;
36
 
37
        @Id
38
        @OneToOne
39
        @ForeignKey(name="fk_servidor_pessoa")
40
        @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa")
41
        public PessoaFisicaView getPessoa() {
42
                return pessoa;
43
        }
44
 
45
        public void setPessoa(PessoaFisicaView pessoa) {
46
                this.pessoa = pessoa;
47
        }
48
 
49
        @Column(name="nom_pessoa")
50
        public String getNome() {
51
                return nome;
52
        }
53
 
54
        public void setNome(String nome) {
55
                this.nome = nome;
56
        }
57
 
58
        @Column(name="num_cpf")
59
        public String getCpf() {
60
                return cpf;
61
        }
62
 
63
        public void setCpf(String cpf) {
64
                this.cpf = cpf;
65
        }
66
 
67
        @Column(name="tip_sexo")
68
        public String getSexo() {
69
                return sexo;
70
        }
71
 
72
        public void setSexo(String sexo) {
73
                this.sexo = sexo;
74
        }
75
 
76
        @Temporal(TemporalType.DATE)
77
        @Column(name="dat_nascimento")
78
        public Date getDataNascimento() {
79
                return dataNascimento;
80
        }
81
 
82
        public void setDataNascimento(Date dataNascimento) {
83
                this.dataNascimento = dataNascimento;
84
        }
85
 
86
        @Column(name="dsc_email")
87
        public String getEmail() {
88
                return email;
89
        }
90
 
91
        public void setEmail(String email) {
92
                this.email = email;
93
        }
94
 
95
        @Column(name="dsc_nacionalidade")
96
        public String getNacionalidade() {
97
                return nacionalidade;
98
        }
99
 
100
        public void setNacionalidade(String nacionalidade) {
101
                this.nacionalidade = nacionalidade;
102
        }
103
 
104
        @Column(name="tip_grau_instrucao")
105
        public String getTipoGrauInstrucao() {
106
                return tipoGrauInstrucao;
107
        }
108
 
109
        public void setTipoGrauInstrucao(String tipoGrauInstrucao) {
110
                this.tipoGrauInstrucao = tipoGrauInstrucao;
111
        }
112
 
113
        @Override
114
        @Transient
115
        public Object getId() {
116
                return pessoa.getId();
117
        }
118
 
119
        @Override
120
        public void setId(Object id) {
121
                this.pessoa.setId((Long) id);
122
        }
123
 
124
        @Transient
125
        public String getSexoPorExtenso() {
126
                if("M".equals(sexo))
127
                        return "Masculino";
128
                if("F".equals(sexo))
129
                        return "Feminino";
130
                return null;
131
        }
132
 
133
        @Transient
134
        public Long getSequencialDaPessoa() {
135
                return pessoa != null ? pessoa.getSequencialPessoa() : null;
136
        }
137
 
138
        @Override
139
        public int hashCode() {
140
                final int prime = 31;
141
                int result = 1;
142
                result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
143
                return result;
144
        }
145
 
146
        @Override
147
        public boolean equals(Object obj) {
148
                if (this == obj)
149
                        return true;
150
                if (obj == null)
151
                        return false;
152
                if (getClass() != obj.getClass())
153
                        return false;
154
                ServidorView other = (ServidorView) obj;
155
                if (getId() == null) {
156
                        if (other.getId() != null)
157
                                return false;
158
                } else if (!getId().equals(other.getId()))
159
                        return false;
160
                return true;
161
        }
162
 
163
        @Override
164
        public int compareTo(ServidorView o) {
165
                return getNome().compareToIgnoreCase(o.getNome());
166
        }
167
 
168
}