Subversion Repositories Integrator Subversion

Rev

Rev 114 | Go to most recent revision | Details | 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
 
20
import br.edu.cesmac.core.generic.identidade.Identidade;
21
import br.edu.cesmac.core.interfaces.Alterar;
22
import br.edu.cesmac.core.interfaces.Cadastrar;
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;
32
        private Date dataOrcado;
33
        private Double valor;
34
 
35
        @Override
36
        @Transient
37
        public Object getId() {
38
                return this.getSequencial();
39
        }
40
        @Override
41
        public void setId(Object id) {
42
                this.sequencial = (Long) id;
43
        }
44
 
45
        @Id
46
        @SequenceGenerator(name = "sq_orcamento")
47
        @GeneratedValue(strategy = GenerationType.IDENTITY)
48
        @Column(name="seq_orcamento", nullable=false)
49
        public Long getSequencial() {
50
                return sequencial;
51
        }
52
        public void setSequencial(Long sequencial) {
53
                this.sequencial = sequencial;
54
        }
55
 
56
        @ManyToOne
57
        @ForeignKey(name="fk_orcamento_categoria")
58
        @JoinColumn(name="seq_categoria")
59
        public Categoria getCategoria() {
60
                return categoria;
61
        }
62
        public void setCategoria(Categoria categoria) {
63
                this.categoria = categoria;
64
        }
65
 
66
        @Column(name="dat_orcado", nullable=false)
67
        public Date getDataOrcado() {
68
                return dataOrcado;
69
        }
70
        public void setDataOrcado(Date dataOrcado) {
71
                this.dataOrcado = dataOrcado;
72
        }
73
 
74
        @Column(name="val_orcado", nullable=true)
75
        @NotNull(message = "Parâmetro obrigatório não preenchido: Valor orçado", groups = {Cadastrar.class, Alterar.class})
76
        public Double getValor() {
77
                return valor;
78
        }
79
        public void setValor(Double valor) {
80
                this.valor = valor;
81
        }
82
 
83
        @Override
84
        public int hashCode() {
85
                final int prime = 31;
86
                int result = 1;
87
                result = prime * result
88
                                + ((sequencial == null) ? 0 : sequencial.hashCode());
89
                return result;
90
        }
91
 
92
        @Override
93
        public boolean equals(Object obj) {
94
                if (this == obj)
95
                        return true;
96
                if (obj == null)
97
                        return false;
98
                if (getClass() != obj.getClass())
99
                        return false;
100
                Orcamento other = (Orcamento) obj;
101
                if (sequencial == null) {
102
                        if (other.sequencial != null)
103
                                return false;
104
                } else if (!sequencial.equals(other.sequencial))
105
                        return false;
106
                return true;
107
        }
108
 
109
        @Override
110
        public Orcamento clone() throws CloneNotSupportedException {
111
                return (Orcamento) super.clone();
112
        }
113
 
114
}