Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 259 | 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.validation.constraints.NotNull; |
||
| 16 | import javax.validation.constraints.Size; |
||
| 17 | |||
| 18 | import org.hibernate.annotations.ForeignKey; |
||
| 19 | |||
| 20 | import br.com.ec.core.interfaces.Alterar; |
||
| 21 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 22 | import br.com.ec.core.util.StringUtil; |
||
| 23 | |||
| 24 | @Entity |
||
| 25 | @Table(name="sec_compra", schema="sc_sec") |
||
| 26 | public class Compra implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private Loja loja; |
||
| 32 | private Fornecedor fornecedor; |
||
| 33 | private Conta conta; |
||
| 34 | private Date dataCompra; |
||
| 35 | private Date dataEntrada; |
||
| 36 | private String observacao; |
||
| 37 | private Double valorTotal; |
||
| 38 | private NotaFiscal notaFiscal; |
||
| 39 | private Boolean indicadorVerificada; |
||
| 40 | private Boolean indicadorAtivo; |
||
| 41 | |||
| 42 | // private Set<CompraProduto> listaProdutosDaCompra; |
||
| 43 | |||
| 44 | public Compra() { |
||
| 45 | // listaProdutosDaCompra = new HashSet<CompraProduto>(); |
||
| 46 | } |
||
| 47 | |||
| 48 | @Id |
||
| 49 | @SequenceGenerator(name = "sq_compra") |
||
| 50 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 51 | @Column(name="seq_compra", nullable=false) |
||
| 52 | public Long getSequencial() { |
||
| 53 | return sequencial; |
||
| 54 | } |
||
| 55 | public void setSequencial(Long sequencial) { |
||
| 56 | this.sequencial = sequencial; |
||
| 57 | } |
||
| 58 | |||
| 59 | @ManyToOne |
||
| 60 | @ForeignKey(name = "fk_compra_loja") |
||
| 61 | @JoinColumn(name="seq_loja", referencedColumnName="seq_loja") |
||
| 62 | public Loja getLoja() { |
||
| 63 | return loja; |
||
| 64 | } |
||
| 65 | public void setLoja(Loja loja) { |
||
| 66 | this.loja = loja; |
||
| 67 | } |
||
| 68 | |||
| 69 | @ManyToOne |
||
| 70 | @ForeignKey(name = "fk_compra_fornecedor") |
||
| 71 | @JoinColumn(name="seq_fornecedor", referencedColumnName="seq_fornecedor", nullable=true) |
||
| 72 | public Fornecedor getFornecedor() { |
||
| 73 | return fornecedor; |
||
| 74 | } |
||
| 75 | public void setFornecedor(Fornecedor fornecedor) { |
||
| 76 | this.fornecedor = fornecedor; |
||
| 77 | } |
||
| 78 | |||
| 79 | @ManyToOne |
||
| 80 | @ForeignKey(name = "fk_compra_conta") |
||
| 81 | @JoinColumn(name="seq_conta", referencedColumnName="seq_conta", nullable=true) |
||
| 82 | public Conta getConta() { |
||
| 83 | return conta; |
||
| 84 | } |
||
| 85 | public void setConta(Conta conta) { |
||
| 86 | this.conta = conta; |
||
| 87 | } |
||
| 88 | |||
| 89 | @NotNull(message = "Parâmetro obrigatório não preenchido: Data da Compra", groups = {Cadastrar.class, Alterar.class}) |
||
| 90 | @Column(name="dat_compra", nullable=false) |
||
| 91 | public Date getDataCompra() { |
||
| 92 | return dataCompra; |
||
| 93 | } |
||
| 94 | public void setDataCompra(Date dataCompra) { |
||
| 95 | this.dataCompra = dataCompra; |
||
| 96 | } |
||
| 97 | |||
| 98 | @Column(name="dat_entrada", nullable=false) |
||
| 99 | public Date getDataEntrada() { |
||
| 100 | return dataEntrada; |
||
| 101 | } |
||
| 102 | public void setDataEntrada(Date dataEntrada) { |
||
| 103 | this.dataEntrada = dataEntrada; |
||
| 104 | } |
||
| 105 | |||
| 106 | @Column(name="dsc_observacao") |
||
| 107 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Observação") |
||
| 108 | public String getObservacao() { |
||
| 109 | return observacao; |
||
| 110 | } |
||
| 111 | public void setObservacao(String observacao) { |
||
| 112 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 113 | } |
||
| 114 | |||
| 115 | @Column(name="val_total") |
||
| 116 | public Double getValorTotal() { |
||
| 117 | return valorTotal; |
||
| 118 | } |
||
| 119 | public void setValorTotal(Double valorTotal) { |
||
| 120 | this.valorTotal = valorTotal; |
||
| 121 | } |
||
| 122 | |||
| 123 | @ManyToOne |
||
| 124 | @ForeignKey(name = "fk_compra_notafiscal") |
||
| 125 | @JoinColumn(name="seq_nota_fiscal", referencedColumnName="seq_nota_fiscal") |
||
| 126 | public NotaFiscal getNotaFiscal() { |
||
| 127 | return notaFiscal; |
||
| 128 | } |
||
| 129 | public void setNotaFiscal(NotaFiscal notaFiscal) { |
||
| 130 | this.notaFiscal = notaFiscal; |
||
| 131 | } |
||
| 132 | |||
| 133 | @Column(name="ind_ativo") |
||
| 134 | public Boolean getIndicadorAtivo() { |
||
| 135 | return indicadorAtivo; |
||
| 136 | } |
||
| 137 | public void setIndicadorAtivo(Boolean indicadorAtivo) { |
||
| 138 | this.indicadorAtivo = indicadorAtivo; |
||
| 139 | } |
||
| 140 | |||
| 141 | @Column(name="ind_verificada") |
||
| 142 | public Boolean getIndicadorVerificada() { |
||
| 143 | return indicadorVerificada; |
||
| 144 | } |
||
| 145 | public void setIndicadorVerificada(Boolean indicadorVerificada) { |
||
| 146 | this.indicadorVerificada = indicadorVerificada; |
||
| 147 | } |
||
| 148 | |||
| 149 | /* |
||
| 150 | @OneToMany(mappedBy="compra", cascade=CascadeType.ALL, fetch=FetchType.LAZY, orphanRemoval=true) |
||
| 151 | public Set<CompraProduto> getListaProdutosDaCompra() { |
||
| 152 | return listaProdutosDaCompra; |
||
| 153 | } |
||
| 154 | public void setListaProdutosDaCompra(Set<CompraProduto> listaProdutosDaCompra) { |
||
| 155 | this.listaProdutosDaCompra = listaProdutosDaCompra; |
||
| 156 | } |
||
| 157 | */ |
||
| 158 | |||
| 159 | @Override |
||
| 160 | public int hashCode() { |
||
| 161 | final int prime = 31; |
||
| 162 | int result = 1; |
||
| 163 | result = prime * result |
||
| 164 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 165 | return result; |
||
| 166 | } |
||
| 167 | |||
| 168 | @Override |
||
| 169 | public boolean equals(Object obj) { |
||
| 170 | if (this == obj) |
||
| 171 | return true; |
||
| 172 | if (obj == null) |
||
| 173 | return false; |
||
| 174 | if (getClass() != obj.getClass()) |
||
| 175 | return false; |
||
| 176 | Compra other = (Compra) obj; |
||
| 177 | if (sequencial == null) { |
||
| 178 | if (other.sequencial != null) |
||
| 179 | return false; |
||
| 180 | } else if (!sequencial.equals(other.sequencial)) |
||
| 181 | return false; |
||
| 182 | return true; |
||
| 183 | } |
||
| 184 | |||
| 185 | } |