Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
760 blopes 1
package br.com.sl.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.SequenceGenerator;
11
import javax.persistence.Table;
12
import javax.validation.constraints.Size;
13
 
14
import org.hibernate.validator.constraints.NotEmpty;
15
 
16
import br.com.ec.core.interfaces.Alterar;
17
import br.com.ec.core.interfaces.Cadastrar;
18
import br.com.ec.core.util.StringUtil;
19
import br.com.sl.domain.dto.PessoaDTO;
20
 
21
@Entity
22
@Table(name="slp_pessoa", schema="sc_slp")
23
public class Pessoa implements Serializable {
24
 
25
        private static final long serialVersionUID = 1L;
26
 
27
        private Long sequencial;
28
        private String nome;
29
        private boolean ativo;
30
 
31
        public Pessoa() {}
32
 
33
        public Pessoa(PessoaDTO pessoaDTO) {
34
                this.sequencial = pessoaDTO.getSequencial();
35
                this.nome = pessoaDTO.getNome();
36
        }
37
 
38
        public Pessoa(Long sequencialPessoa) {
39
                this.sequencial = sequencialPessoa;
40
        }
41
 
42
        @Id
43
        @SequenceGenerator(name = "sq_pessoa")
44
        @GeneratedValue(strategy=GenerationType.IDENTITY)
45
        @Column(name="seq_pessoa", nullable=false)
46
        public Long getSequencial() {
47
                return sequencial;
48
        }
49
        public void setSequencial(Long sequencial) {
50
                this.sequencial = sequencial;
51
        }
52
 
53
        @Column(name="dsc_nome")
54
        @Size(max = 120, message = "Limite de caracteres ultrapassado: Nome")
55
        @NotEmpty(message="Obrigatório informar o nome", groups={Cadastrar.class, Alterar.class})
56
        public String getNome() {
57
                return nome;
58
        }
59
        public void setNome(String nome) {
60
                this.nome = StringUtil.setarUpperCaseComTrim(nome);
61
        }
62
 
63
        /*******************************************************/
64
 
65
        @Override
66
        public int hashCode() {
67
                final int prime = 31;
68
                int result = 1;
69
                result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode());
70
                return result;
71
        }
72
 
73
        @Override
74
        public boolean equals(Object obj) {
75
                if (this == obj)
76
                        return true;
77
                if (obj == null)
78
                        return false;
79
                if (getClass() != obj.getClass())
80
                        return false;
81
                Pessoa other = (Pessoa) obj;
82
                if (sequencial == null) {
83
                        if (other.sequencial != null)
84
                                return false;
85
                } else if (!sequencial.equals(other.sequencial))
86
                        return false;
87
                return true;
88
        }
89
 
90
}