Rev 106 | 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 | 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 | import javax.validation.constraints.Size; |
||
| 18 | |||
| 19 | import org.hibernate.annotations.ForeignKey; |
||
| 20 | |||
| 195 | espaco | 21 | import br.com.ec.core.generic.identidade.Identidade; |
| 22 | import br.com.ec.core.interfaces.Alterar; |
||
| 23 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 24 | import br.com.ec.core.util.StringUtil; |
||
| 25 | import br.com.ec.core.util.VerificadorUtil; |
||
| 106 | espaco | 26 | |
| 27 | @Entity |
||
| 28 | @Table(name="sec_banco_horas", schema="sc_sec") |
||
| 29 | public class BancoHoras implements Serializable, Identidade { |
||
| 30 | |||
| 31 | private static final long serialVersionUID = 1L; |
||
| 32 | |||
| 33 | private Long sequencial; |
||
| 34 | private Funcionario funcionario; |
||
| 35 | private Date data; |
||
| 36 | private Double valor; |
||
| 37 | private String observacao; |
||
| 38 | |||
| 39 | @Override |
||
| 40 | @Transient |
||
| 41 | public Object getId() { |
||
| 42 | return this.getSequencial(); |
||
| 43 | } |
||
| 44 | @Override |
||
| 45 | public void setId(Object id) { |
||
| 46 | this.sequencial = (Long) id; |
||
| 47 | } |
||
| 48 | |||
| 49 | @Id |
||
| 50 | @SequenceGenerator(name = "sq_bancohoras") |
||
| 51 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 52 | @Column(name="seq_banco_horas", nullable=false) |
||
| 53 | public Long getSequencial() { |
||
| 54 | return sequencial; |
||
| 55 | } |
||
| 56 | public void setSequencial(Long sequencial) { |
||
| 57 | this.sequencial = sequencial; |
||
| 58 | } |
||
| 59 | |||
| 60 | @ManyToOne |
||
| 61 | @ForeignKey(name="fk_bancohoras_funcionario") |
||
| 62 | @JoinColumn(name = "seq_funcionario", nullable=false) |
||
| 63 | @NotNull(message="Obrigatório informar o funcionário", groups={Cadastrar.class, Alterar.class}) |
||
| 64 | public Funcionario getFuncionario() { |
||
| 65 | return funcionario; |
||
| 66 | } |
||
| 67 | public void setFuncionario(Funcionario funcionario) { |
||
| 68 | this.funcionario = funcionario; |
||
| 69 | } |
||
| 70 | |||
| 71 | @NotNull(message="Obrigatório informar a data", groups={Cadastrar.class, Alterar.class}) |
||
| 72 | @Column(name="dat_banco_horas") |
||
| 73 | public Date getData() { |
||
| 74 | return data; |
||
| 75 | } |
||
| 76 | public void setData(Date data) { |
||
| 77 | this.data = data; |
||
| 78 | } |
||
| 79 | |||
| 80 | @Column(name="val_banco_horas") |
||
| 81 | public Double getValor() { |
||
| 82 | return valor; |
||
| 83 | } |
||
| 84 | public void setValor(Double valor) { |
||
| 85 | this.valor = valor; |
||
| 86 | } |
||
| 87 | |||
| 88 | @Column(name="dsc_observacao") |
||
| 89 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Observação") |
||
| 90 | public String getObservacao() { |
||
| 91 | return observacao; |
||
| 92 | } |
||
| 93 | public void setObservacao(String observacao) { |
||
| 94 | this.observacao = StringUtil.setarUpperCaseComTrim(observacao); |
||
| 95 | } |
||
| 96 | |||
| 97 | @Transient |
||
| 98 | public String nomeDoFuncionario() { |
||
| 99 | return VerificadorUtil.naoEstaNulo(getFuncionario())? getFuncionario().getNomeDaPessoa() : null; |
||
| 100 | } |
||
| 101 | |||
| 102 | @Override |
||
| 103 | public int hashCode() { |
||
| 104 | final int prime = 31; |
||
| 105 | int result = 1; |
||
| 106 | result = prime * result |
||
| 107 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 108 | return result; |
||
| 109 | } |
||
| 110 | |||
| 111 | @Override |
||
| 112 | public boolean equals(Object obj) { |
||
| 113 | if (this == obj) |
||
| 114 | return true; |
||
| 115 | if (obj == null) |
||
| 116 | return false; |
||
| 117 | if (getClass() != obj.getClass()) |
||
| 118 | return false; |
||
| 119 | BancoHoras other = (BancoHoras) obj; |
||
| 120 | if (sequencial == null) { |
||
| 121 | if (other.sequencial != null) |
||
| 122 | return false; |
||
| 123 | } else if (!sequencial.equals(other.sequencial)) |
||
| 124 | return false; |
||
| 125 | return true; |
||
| 126 | } |
||
| 127 | |||
| 128 | } |