Subversion Repositories Integrator Subversion

Rev

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

Rev Author Line No. Line
449 blopes 1
package br.com.ec.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.SequenceGenerator;
13
import javax.persistence.Table;
14
import javax.persistence.Transient;
15
import javax.validation.constraints.NotNull;
16
 
17
import org.hibernate.annotations.ForeignKey;
18
 
19
import br.com.ec.core.interfaces.Alterar;
20
import br.com.ec.core.interfaces.Cadastrar;
21
import br.com.ec.core.util.VerificadorUtil;
22
 
452 blopes 23
@Entity
24
@Table(name="sec_notafiscal_produto", schema="sc_sec")
449 blopes 25
public class NotaFiscalProduto implements Serializable {
26
 
27
        private static final long serialVersionUID = 1L;
28
 
29
        private Long sequencial;
30
        private NotaFiscal notaFiscal;
468 blopes 31
        private CompraProduto compraProduto;
449 blopes 32
        private Integer quantidade;
485 blopes 33
        private Double valor;
449 blopes 34
 
35
        @Id
36
        @SequenceGenerator(name = "sq_notafiscalproduto")
37
        @GeneratedValue(strategy = GenerationType.IDENTITY)
38
        @Column(name="seq_notafiscalproduto", nullable=false)
39
        public Long getSequencial() {
40
                return sequencial;
41
        }
42
        public void setSequencial(Long sequencial) {
43
                this.sequencial = sequencial;
44
        }
468 blopes 45
 
449 blopes 46
        @ManyToOne
47
        @ForeignKey(name="fk_notafiscalproduto_notafiscal")
48
        @JoinColumn(name = "seq_nota_fiscal", referencedColumnName="seq_nota_fiscal", insertable=true, updatable=false, nullable=false)
49
        public NotaFiscal getNotaFiscal() {
50
                return notaFiscal;
51
        }
52
        public void setNotaFiscal(NotaFiscal notaFiscal) {
53
                this.notaFiscal = notaFiscal;
54
        }
55
 
56
        @ManyToOne
468 blopes 57
        @ForeignKey(name="fk_notafiscalproduto_compraproduto")
58
        @JoinColumn(name = "seq_compraproduto", referencedColumnName="seq_compraproduto", insertable=true, updatable=false, nullable=false)
59
        public CompraProduto getCompraProduto() {
60
                return compraProduto;
61
        }
62
        public void setCompraProduto(CompraProduto compraProduto) {
63
                this.compraProduto = compraProduto;
64
        }
65
 
66
        /*
67
        @ManyToOne
449 blopes 68
        @ForeignKey(name="fk_notafiscalproduto_produto")
69
        @JoinColumn(name = "seq_produto", insertable=true, updatable=false, nullable=false)
70
        public Produto getProduto() {
71
                return produto;
72
        }
73
        public void setProduto(Produto produto) {
74
                this.produto = produto;
75
        }
468 blopes 76
        */
449 blopes 77
 
78
        @NotNull(message = "Parâmetro obrigatório não preenchido: Quantidade de produtos", groups = {Cadastrar.class, Alterar.class})
79
        @Column(name="qtd_produto")
80
        public Integer getQuantidade() {
81
                return quantidade;
82
        }
83
        public void setQuantidade(Integer quantidade) {
84
                this.quantidade = quantidade;
85
        }
86
 
485 blopes 87
        @NotNull(message = "Parâmetro obrigatório não preenchido: Valor do produto", groups = {Cadastrar.class, Alterar.class})
88
        @Column(name="val_produto")
89
        public Double getValor() {
90
                return valor;
91
        }
92
        public void setValor(Double valor) {
93
                this.valor = valor;
94
        }
95
 
468 blopes 96
        /*
449 blopes 97
        @Transient
98
        public Long getSequencialDaNotaFiscal() {
99
                return VerificadorUtil.naoEstaNulo(notaFiscal)? notaFiscal.getSequencial() : null;
100
        }
101
 
102
        @Transient
103
        public Long getSequencialDoProduto() {
104
                return VerificadorUtil.naoEstaNulo(produto)? produto.getSequencial() : null;
105
        }
468 blopes 106
        */
449 blopes 107
 
108
        @Override
109
        public int hashCode() {
110
                final int prime = 31;
111
                int result = 1;
112
                result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode());
113
                return result;
114
        }
115
 
116
        @Override
117
        public boolean equals(Object obj) {
118
                if (this == obj)
119
                        return true;
120
                if (obj == null)
121
                        return false;
122
                if (getClass() != obj.getClass())
123
                        return false;
124
                NotaFiscalProduto other = (NotaFiscalProduto) obj;
125
                if (sequencial == null) {
126
                        if (other.sequencial != null)
127
                                return false;
128
                } else if (!sequencial.equals(other.sequencial))
129
                        return false;
130
                return true;
131
        }
132
 
133
}