Rev 259 | Rev 526 | Go to most recent revision | Details | Compare with Previous | 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.SequenceGenerator; |
||
| 12 | import javax.persistence.Table; |
||
| 13 | import javax.validation.constraints.NotNull; |
||
| 14 | import javax.validation.constraints.Size; |
||
| 15 | |||
| 16 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 17 | |||
| 18 | import br.com.ec.core.interfaces.Alterar; |
||
| 19 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 20 | import br.com.ec.core.util.StringUtil; |
||
| 21 | |||
| 22 | @Entity |
||
| 23 | @Table(name="sec_vigencia", schema="sc_sec") |
||
| 24 | public class Vigencia implements Serializable { |
||
| 25 | |||
| 26 | private static final long serialVersionUID = 1L; |
||
| 27 | |||
| 28 | private Long sequencial; |
||
| 29 | private String descricao; |
||
| 30 | private Date dataInicio; |
||
| 31 | private Date dataFim; |
||
| 32 | |||
| 33 | public Vigencia() {} |
||
| 34 | |||
| 439 | espaco | 35 | public Vigencia(Long sequencial) { |
| 36 | this.sequencial = sequencial; |
||
| 37 | } |
||
| 38 | |||
| 259 | espaco | 39 | public Vigencia(Long sequencial, String descricao) { |
| 40 | this.sequencial = sequencial; |
||
| 41 | this.descricao = descricao; |
||
| 42 | } |
||
| 43 | |||
| 44 | @Id |
||
| 45 | @SequenceGenerator(name = "sq_vigencia") |
||
| 46 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 47 | @Column(name="seq_vigencia", nullable=false) |
||
| 48 | public Long getSequencial() { |
||
| 49 | return sequencial; |
||
| 50 | } |
||
| 51 | public void setSequencial(Long sequencial) { |
||
| 52 | this.sequencial = sequencial; |
||
| 53 | } |
||
| 54 | |||
| 55 | @Column(name="dsc_vigencia") |
||
| 56 | @Size(max = 10, message = "Limite de caracteres ultrapassado: Vigência") |
||
| 57 | @NotNull(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 58 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 59 | public String getDescricao() { |
||
| 60 | return descricao; |
||
| 61 | } |
||
| 62 | public void setDescricao(String descricao) { |
||
| 63 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 64 | } |
||
| 65 | |||
| 66 | @Column(name="dth_inicio") |
||
| 67 | @NotNull(message="Obrigatório informar a data de início", groups={Cadastrar.class, Alterar.class}) |
||
| 68 | public Date getDataInicio() { |
||
| 69 | return dataInicio; |
||
| 70 | } |
||
| 71 | public void setDataInicio(Date dataInicio) { |
||
| 72 | this.dataInicio = dataInicio; |
||
| 73 | } |
||
| 74 | |||
| 75 | @Column(name="dth_fim") |
||
| 76 | @NotNull(message="Obrigatório informar a data de fim", groups={Cadastrar.class, Alterar.class}) |
||
| 77 | public Date getDataFim() { |
||
| 78 | return dataFim; |
||
| 79 | } |
||
| 80 | public void setDataFim(Date dataFim) { |
||
| 81 | this.dataFim = dataFim; |
||
| 82 | } |
||
| 83 | |||
| 84 | @Override |
||
| 85 | public int hashCode() { |
||
| 86 | final int prime = 31; |
||
| 87 | int result = 1; |
||
| 88 | result = prime * result + ((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 | Vigencia other = (Vigencia) 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 | } |