Subversion Repositories Integrator Subversion

Rev

Rev 495 | 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;
495 blopes 34
        private String xmlDetalheCompra;
449 blopes 35
 
36
        @Id
37
        @SequenceGenerator(name = "sq_notafiscalproduto")
38
        @GeneratedValue(strategy = GenerationType.IDENTITY)
39
        @Column(name="seq_notafiscalproduto", nullable=false)
40
        public Long getSequencial() {
41
                return sequencial;
42
        }
43
        public void setSequencial(Long sequencial) {
44
                this.sequencial = sequencial;
45
        }
468 blopes 46
 
449 blopes 47
        @ManyToOne
48
        @ForeignKey(name="fk_notafiscalproduto_notafiscal")
49
        @JoinColumn(name = "seq_nota_fiscal", referencedColumnName="seq_nota_fiscal", insertable=true, updatable=false, nullable=false)
50
        public NotaFiscal getNotaFiscal() {
51
                return notaFiscal;
52
        }
53
        public void setNotaFiscal(NotaFiscal notaFiscal) {
54
                this.notaFiscal = notaFiscal;
55
        }
56
 
57
        @ManyToOne
468 blopes 58
        @ForeignKey(name="fk_notafiscalproduto_compraproduto")
541 blopes 59
        @JoinColumn(name = "seq_compraproduto", referencedColumnName="seq_compraproduto", insertable=true, updatable=false, nullable=true)
468 blopes 60
        public CompraProduto getCompraProduto() {
61
                return compraProduto;
62
        }
63
        public void setCompraProduto(CompraProduto compraProduto) {
64
                this.compraProduto = compraProduto;
65
        }
66
 
67
        /*
68
        @ManyToOne
449 blopes 69
        @ForeignKey(name="fk_notafiscalproduto_produto")
70
        @JoinColumn(name = "seq_produto", insertable=true, updatable=false, nullable=false)
71
        public Produto getProduto() {
72
                return produto;
73
        }
74
        public void setProduto(Produto produto) {
75
                this.produto = produto;
76
        }
468 blopes 77
        */
449 blopes 78
 
79
        @NotNull(message = "Parâmetro obrigatório não preenchido: Quantidade de produtos", groups = {Cadastrar.class, Alterar.class})
80
        @Column(name="qtd_produto")
81
        public Integer getQuantidade() {
82
                return quantidade;
83
        }
84
        public void setQuantidade(Integer quantidade) {
85
                this.quantidade = quantidade;
86
        }
87
 
485 blopes 88
        @NotNull(message = "Parâmetro obrigatório não preenchido: Valor do produto", groups = {Cadastrar.class, Alterar.class})
89
        @Column(name="val_produto")
90
        public Double getValor() {
91
                return valor;
92
        }
93
        public void setValor(Double valor) {
94
                this.valor = valor;
95
        }
96
 
495 blopes 97
        @Column(name="txt_xml_detcompra")
98
        public String getXmlDetalheCompra() {
99
                return xmlDetalheCompra;
100
        }
101
        public void setXmlDetalheCompra(String xmlDetalheCompra) {
102
                this.xmlDetalheCompra = xmlDetalheCompra;
103
        }
104
 
468 blopes 105
        /*
449 blopes 106
        @Transient
107
        public Long getSequencialDaNotaFiscal() {
108
                return VerificadorUtil.naoEstaNulo(notaFiscal)? notaFiscal.getSequencial() : null;
109
        }
110
 
111
        @Transient
112
        public Long getSequencialDoProduto() {
113
                return VerificadorUtil.naoEstaNulo(produto)? produto.getSequencial() : null;
114
        }
468 blopes 115
        */
449 blopes 116
 
117
        @Override
118
        public int hashCode() {
119
                final int prime = 31;
120
                int result = 1;
121
                result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode());
122
                return result;
123
        }
124
 
125
        @Override
126
        public boolean equals(Object obj) {
127
                if (this == obj)
128
                        return true;
129
                if (obj == null)
130
                        return false;
131
                if (getClass() != obj.getClass())
132
                        return false;
133
                NotaFiscalProduto other = (NotaFiscalProduto) obj;
134
                if (sequencial == null) {
135
                        if (other.sequencial != null)
136
                                return false;
137
                } else if (!sequencial.equals(other.sequencial))
138
                        return false;
139
                return true;
140
        }
141
 
142
}