Rev 114 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 112 | 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.persistence.Transient; |
||
| 16 | import javax.validation.constraints.NotNull; |
||
| 17 | |||
| 18 | import org.hibernate.annotations.ForeignKey; |
||
| 19 | |||
| 195 | espaco | 20 | import br.com.ec.core.generic.identidade.Identidade; |
| 21 | import br.com.ec.core.interfaces.Alterar; |
||
| 22 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 112 | espaco | 23 | |
| 24 | @Entity |
||
| 25 | @Table(name="sec_orcamento", schema="sc_sec") |
||
| 26 | public class Orcamento implements Serializable, Identidade, Cloneable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private Categoria categoria; |
||
| 114 | espaco | 32 | private String tipoCategoria; |
| 112 | espaco | 33 | private Date dataOrcado; |
| 34 | private Double valor; |
||
| 35 | |||
| 36 | @Override |
||
| 37 | @Transient |
||
| 38 | public Object getId() { |
||
| 39 | return this.getSequencial(); |
||
| 40 | } |
||
| 41 | @Override |
||
| 42 | public void setId(Object id) { |
||
| 43 | this.sequencial = (Long) id; |
||
| 44 | } |
||
| 45 | |||
| 46 | @Id |
||
| 47 | @SequenceGenerator(name = "sq_orcamento") |
||
| 48 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 49 | @Column(name="seq_orcamento", nullable=false) |
||
| 50 | public Long getSequencial() { |
||
| 51 | return sequencial; |
||
| 52 | } |
||
| 53 | public void setSequencial(Long sequencial) { |
||
| 54 | this.sequencial = sequencial; |
||
| 55 | } |
||
| 56 | |||
| 57 | @ManyToOne |
||
| 58 | @ForeignKey(name="fk_orcamento_categoria") |
||
| 59 | @JoinColumn(name="seq_categoria") |
||
| 60 | public Categoria getCategoria() { |
||
| 61 | return categoria; |
||
| 62 | } |
||
| 63 | public void setCategoria(Categoria categoria) { |
||
| 64 | this.categoria = categoria; |
||
| 65 | } |
||
| 114 | espaco | 66 | |
| 67 | @Column(name="tip_categoria", nullable=false) |
||
| 68 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo categoria", groups = {Cadastrar.class, Alterar.class}) |
||
| 69 | public String getTipoCategoria() { |
||
| 70 | return tipoCategoria; |
||
| 71 | } |
||
| 72 | public void setTipoCategoria(String tipoCategoria) { |
||
| 73 | this.tipoCategoria = tipoCategoria; |
||
| 74 | } |
||
| 112 | espaco | 75 | |
| 76 | @Column(name="dat_orcado", nullable=false) |
||
| 77 | public Date getDataOrcado() { |
||
| 78 | return dataOrcado; |
||
| 79 | } |
||
| 80 | public void setDataOrcado(Date dataOrcado) { |
||
| 81 | this.dataOrcado = dataOrcado; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Column(name="val_orcado", nullable=true) |
||
| 85 | @NotNull(message = "Parâmetro obrigatório não preenchido: Valor orçado", groups = {Cadastrar.class, Alterar.class}) |
||
| 86 | public Double getValor() { |
||
| 87 | return valor; |
||
| 88 | } |
||
| 89 | public void setValor(Double valor) { |
||
| 90 | this.valor = valor; |
||
| 91 | } |
||
| 92 | |||
| 93 | @Override |
||
| 94 | public int hashCode() { |
||
| 95 | final int prime = 31; |
||
| 96 | int result = 1; |
||
| 97 | result = prime * result |
||
| 98 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 99 | return result; |
||
| 100 | } |
||
| 101 | |||
| 102 | @Override |
||
| 103 | public boolean equals(Object obj) { |
||
| 104 | if (this == obj) |
||
| 105 | return true; |
||
| 106 | if (obj == null) |
||
| 107 | return false; |
||
| 108 | if (getClass() != obj.getClass()) |
||
| 109 | return false; |
||
| 110 | Orcamento other = (Orcamento) obj; |
||
| 111 | if (sequencial == null) { |
||
| 112 | if (other.sequencial != null) |
||
| 113 | return false; |
||
| 114 | } else if (!sequencial.equals(other.sequencial)) |
||
| 115 | return false; |
||
| 116 | return true; |
||
| 117 | } |
||
| 118 | |||
| 119 | @Override |
||
| 120 | public Orcamento clone() throws CloneNotSupportedException { |
||
| 121 | return (Orcamento) super.clone(); |
||
| 122 | } |
||
| 123 | |||
| 124 | } |