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