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