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.srv.model;
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.GeneratedValue;
9
import javax.persistence.GenerationType;
10
import javax.persistence.Id;
11
import javax.persistence.JoinColumn;
12
import javax.persistence.ManyToOne;
13
import javax.persistence.SequenceGenerator;
14
import javax.persistence.Table;
15
import javax.persistence.Temporal;
16
import javax.persistence.TemporalType;
17
import javax.persistence.Transient;
18
import javax.validation.constraints.NotNull;
19
import br.gov.al.saude.framework.core.generic.identidade.Identidade;
20
import br.gov.al.saude.framework.core.interfaces.Alterar;
21
import br.gov.al.saude.framework.core.interfaces.Cadastrar;
22
import br.gov.al.saude.framework.core.util.VerificadorUtil;
23
import br.gov.al.saude.scg.model.Sexo;
24
import br.gov.al.saude.srv.model.enums.TipoParentesco;
25
 
26
@Entity
27
@Table(name = "srv_servidor_dependente", schema = "sc_srv")
28
public class ServidorDependente implements Serializable, Identidade, Comparable<ServidorDependente> {
29
        private static final long serialVersionUID = 1L;
30
 
31
        private Long sequencial;
32
        private String numeroCpf;
33
        private String nome;
34
        private String tipoSexo;
35
        private Date dataNascimento;
36
        private String tipoParentesco;
37
        private Servidor servidor;
38
 
39
 
40
        @Id
41
        @Column(name="seq_servidor_dependente", nullable=false)
42
        @GeneratedValue(generator = "SERVIDOR_DEPENDENTE_GENERATOR", strategy = GenerationType.SEQUENCE)
43
        @SequenceGenerator(name = "SERVIDOR_DEPENDENTE_GENERATOR", sequenceName = "sc_srv.sq_servidepend", initialValue = 1, allocationSize = 1)
44
        public Long getSequencial() {
45
                return sequencial;
46
        }
47
        public void setSequencial(Long sequencial) {
48
                this.sequencial = sequencial;
49
        }
50
 
51
 
52
        @Column(name="num_cpf_depentende", length=11)
53
        public String getNumeroCpf() {
54
                return numeroCpf;
55
        }
56
        public void setNumeroCpf(String numeroCpf) {
57
                this.numeroCpf = numeroCpf;
58
        }
59
 
60
 
61
        @Column(name="nom_dependente", length=100, nullable=false)
62
        @NotNull(message ="Obrigatório informar o nome.", groups={Cadastrar.class, Alterar.class})
63
        public String getNome() {
64
                return nome;
65
        }
66
        public void setNome(String nome) {
67
                this.nome = nome;
68
        }
69
 
70
 
71
        @Column(name="tip_sexo", length=1, nullable=false)
72
        @NotNull(message ="Obrigatório informar o sexo.", groups={Cadastrar.class, Alterar.class})
73
        public String getTipoSexo() {
74
                return tipoSexo;
75
        }
76
        public void setTipoSexo(String tipoSexo) {
77
                this.tipoSexo = tipoSexo;
78
        }
79
        public void setTipoSexo(Sexo sexo) {
80
                this.tipoSexo = sexo.getValue();
81
        }
82
 
83
        @Transient
84
        public String getDescricaoTipoSexo() {
85
                return VerificadorUtil.estaNulo(this.getTipoSexo())?null:Sexo.parse(this.getTipoSexo()).getDescricao();
86
        }
87
 
88
 
89
        @Temporal(TemporalType.DATE)
90
        @Column(name="dat_nascimento", nullable=false)
91
        public Date getDataNascimento() {
92
                return dataNascimento;
93
        }
94
        public void setDataNascimento(Date dataNascimento) {
95
                this.dataNascimento = dataNascimento;
96
        }
97
 
98
 
99
        @Column(name="tip_parentesco", length=1, nullable=false)
100
        @NotNull(message ="Obrigatório informar o parentesco.", groups={Cadastrar.class, Alterar.class})
101
        public String getTipoParentesco() {
102
                return tipoParentesco;
103
        }
104
        public void setTipoParentesco(String tipoParentesco) {
105
                this.tipoParentesco = tipoParentesco;
106
        }      
107
        public void setTipoParentesco(TipoParentesco tipoParentesco) {
108
                this.tipoParentesco = tipoParentesco.getValue();
109
        }
110
 
111
        @Transient
112
        public String getDescricaoTipoParentesco() {
113
                return TipoParentesco.parse(getTipoParentesco()).getDescricao();
114
        }
115
 
116
 
117
        @ManyToOne
118
        @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa_servidor", nullable=false)
119
        public Servidor getServidor() {
120
                return servidor;
121
        }
122
        public void setServidor(Servidor servidor) {
123
                this.servidor = servidor;
124
        }
125
 
126
 
127
        @Transient
128
        @Override
129
        public Object getId() {
130
                return this.sequencial;
131
        }
132
        @Override
133
        public void setId(Object id) {
134
                this.sequencial = (Long) id;
135
        }
136
 
137
 
138
        @Override
139
        public int hashCode() {
140
                final int prime = 31;
141
                int result = 1;
142
                result = prime * result
143
                                + ((dataNascimento == null) ? 0 : dataNascimento.hashCode());
144
                result = prime * result + ((nome == null) ? 0 : nome.hashCode());
145
                result = prime * result
146
                                + ((sequencial == null) ? 0 : sequencial.hashCode());
147
                result = prime * result
148
                                + ((tipoParentesco == null) ? 0 : tipoParentesco.hashCode());
149
                result = prime * result
150
                                + ((tipoSexo == null) ? 0 : tipoSexo.hashCode());
151
                return result;
152
        }
153
 
154
        @Override
155
        public boolean equals(Object obj) {
156
                if (this == obj)
157
                        return true;
158
                if (obj == null)
159
                        return false;
160
                if (getClass() != obj.getClass())
161
                        return false;
162
                ServidorDependente other = (ServidorDependente) obj;
163
                if (dataNascimento == null) {
164
                        if (other.dataNascimento != null)
165
                                return false;
166
                } else if (!dataNascimento.equals(other.dataNascimento))
167
                        return false;
168
                if (nome == null) {
169
                        if (other.nome != null)
170
                                return false;
171
                } else if (!nome.equals(other.nome))
172
                        return false;
173
                if (sequencial == null) {
174
                        if (other.sequencial != null)
175
                                return false;
176
                } else if (!sequencial.equals(other.sequencial))
177
                        return false;
178
                if (tipoParentesco == null) {
179
                        if (other.tipoParentesco != null)
180
                                return false;
181
                } else if (!tipoParentesco.equals(other.tipoParentesco))
182
                        return false;
183
                if (tipoSexo == null) {
184
                        if (other.tipoSexo != null)
185
                                return false;
186
                } else if (!tipoSexo.equals(other.tipoSexo))
187
                        return false;
188
                return true;
189
        }
190
 
191
        @Override
192
        public int compareTo(ServidorDependente sd) {
193
                return getNome().compareTo(sd.getNome());
194
        }
195
}