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