Subversion Repositories Integrator Subversion

Rev

Rev 106 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
106 espaco 1
package br.com.ec.domain.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.Transient;
16
import javax.validation.constraints.NotNull;
17
import javax.validation.constraints.Size;
18
 
19
import org.hibernate.annotations.ForeignKey;
20
import org.hibernate.validator.constraints.NotEmpty;
21
 
195 espaco 22
import br.com.ec.core.generic.identidade.Identidade;
23
import br.com.ec.core.interfaces.Alterar;
24
import br.com.ec.core.interfaces.Cadastrar;
25
import br.com.ec.core.util.StringUtil;
26
import br.com.ec.core.util.VerificadorUtil;
106 espaco 27
 
28
@Entity
29
@Table(name="sec_pagamento", schema="sc_sec")
30
public class Pagamento implements Serializable, Identidade {
31
 
32
        private static final long serialVersionUID = 1L;
33
 
34
        private Long sequencial;
35
        private Loja loja;
36
        private String descricao;
37
        private Double valor;
38
        private Date data;
39
        private Boolean lancado;
40
        private Usuario usuario;
41
 
42
        @Override
43
        @Transient
44
        public Object getId() {
45
                return this.getSequencial();
46
        }
47
        @Override
48
        public void setId(Object id) {
49
                this.sequencial = (Long) id;
50
        }
51
 
52
        @Id
53
        @SequenceGenerator(name = "sq_pagamento")
54
        @GeneratedValue(strategy = GenerationType.IDENTITY)
55
        @Column(name="seq_pagamento", nullable=false)
56
        public Long getSequencial() {
57
                return sequencial;
58
        }
59
        public void setSequencial(Long sequencial) {
60
                this.sequencial = sequencial;
61
        }
62
 
63
        @ManyToOne
64
        @ForeignKey(name="fk_pagamento_loja")
65
        @JoinColumn(name = "seq_loja", nullable = false)
66
        public Loja getLoja() {
67
                return loja;
68
        }
69
        public void setLoja(Loja loja) {
70
                this.loja = loja;
71
        }
72
 
73
        @Column(name="dsc_pagamento")
74
        @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição")
75
        @NotEmpty(message = "Parâmetro obrigatório não preenchido: Descrição", groups = {Cadastrar.class, Alterar.class})
76
        @NotNull(message = "Parâmetro obrigatório não preenchido: Descrição", groups = {Cadastrar.class, Alterar.class})
77
        public String getDescricao() {
78
                return descricao;
79
        }
80
        public void setDescricao(String descricao) {
81
                this.descricao = StringUtil.setarUpperCaseComTrim(descricao);
82
        }
83
 
84
        @NotNull(message = "Parâmetro obrigatório não preenchido: Valor", groups = {Cadastrar.class, Alterar.class})
85
        @Column(name="val_pagamento")
86
        public Double getValor() {
87
                return valor;
88
        }
89
        public void setValor(Double valor) {
90
                this.valor = valor;
91
        }
92
 
93
        @NotNull(message = "Parâmetro obrigatório não preenchido: Data", groups = {Cadastrar.class, Alterar.class})
94
        @Column(name="dat_pagamento", nullable=false)
95
        public Date getData() {
96
                return data;
97
        }
98
        public void setData(Date data) {
99
                this.data = data;
100
        }
101
 
102
        @Column(name="ind_lancado", nullable=false)
103
        public Boolean getLancado() {
104
                return lancado;
105
        }
106
        public void setLancado(Boolean lancado) {
107
                this.lancado = lancado;
108
        }
109
 
110
        @ManyToOne
111
        @ForeignKey(name="fk_pagamento_usuario")
112
        @JoinColumn(name = "seq_usuario", nullable=true)
113
        public Usuario getUsuario() {
114
                return usuario;
115
        }
116
        public void setUsuario(Usuario usuario) {
117
                this.usuario = usuario;
118
        }
119
 
120
        @Transient
121
        public Long getSequencialDaLoja() {
122
                return VerificadorUtil.naoEstaNulo(getLoja()) ? getLoja().getSequencial() : null;
123
        }
124
        @Override
125
        public int hashCode() {
126
                final int prime = 31;
127
                int result = 1;
128
                result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode());
129
                return result;
130
        }
131
        @Override
132
        public boolean equals(Object obj) {
133
                if (this == obj)
134
                        return true;
135
                if (obj == null)
136
                        return false;
137
                if (getClass() != obj.getClass())
138
                        return false;
139
                Pagamento other = (Pagamento) obj;
140
                if (sequencial == null) {
141
                        if (other.sequencial != null)
142
                                return false;
143
                } else if (!sequencial.equals(other.sequencial))
144
                        return false;
145
                return true;
146
        }
147
 
148
}