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