Rev 771 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 760 | blopes | 1 | package br.com.sl.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | |||
| 5 | import javax.persistence.Column; |
||
| 6 | import javax.persistence.Entity; |
||
| 7 | import javax.persistence.GeneratedValue; |
||
| 8 | import javax.persistence.GenerationType; |
||
| 9 | import javax.persistence.Id; |
||
| 10 | import javax.persistence.SequenceGenerator; |
||
| 11 | import javax.persistence.Table; |
||
| 778 | blopes | 12 | import javax.persistence.Transient; |
| 13 | import javax.validation.constraints.NotNull; |
||
| 760 | blopes | 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; |
||
| 778 | blopes | 21 | import br.com.ec.core.util.VerificadorUtil; |
| 22 | import br.com.sl.domain.model.tipos.TipoTendencia; |
||
| 760 | blopes | 23 | |
| 24 | @Entity |
||
| 25 | @Table(name="slp_ativo", schema="sc_slp") |
||
| 26 | public class Ativo implements Serializable { |
||
| 27 | |||
| 28 | private static final long serialVersionUID = 1L; |
||
| 29 | |||
| 30 | private Long sequencial; |
||
| 31 | private String nome; |
||
| 778 | blopes | 32 | private String tipoTendencia; |
| 33 | private Boolean ativo; |
||
| 760 | blopes | 34 | |
| 771 | blopes | 35 | public Ativo() {} |
| 36 | |||
| 37 | public Ativo(Long sequencial, String nome) { |
||
| 38 | this.sequencial = sequencial; |
||
| 39 | this.nome = nome; |
||
| 40 | } |
||
| 41 | |||
| 760 | blopes | 42 | @Id |
| 43 | @SequenceGenerator(name = "sq_ativo") |
||
| 44 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
||
| 45 | @Column(name="seq_ativo", nullable=false) |
||
| 46 | public Long getSequencial() { |
||
| 47 | return sequencial; |
||
| 48 | } |
||
| 49 | public void setSequencial(Long sequencial) { |
||
| 50 | this.sequencial = sequencial; |
||
| 51 | } |
||
| 52 | |||
| 53 | @Column(name="dsc_ativo") |
||
| 54 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Nome do ativo") |
||
| 55 | @NotEmpty(message="Obrigatório informar o nome do ativo", groups={Cadastrar.class, Alterar.class}) |
||
| 56 | public String getNome() { |
||
| 57 | return nome; |
||
| 58 | } |
||
| 59 | public void setNome(String nome) { |
||
| 60 | this.nome = StringUtil.setarUpperCaseComTrim(nome); |
||
| 61 | } |
||
| 62 | |||
| 778 | blopes | 63 | @Column(name="tip_tendencia") |
| 64 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo de tendência", groups = {Cadastrar.class, Alterar.class}) |
||
| 65 | public String getTipoTendencia() { |
||
| 66 | return tipoTendencia; |
||
| 67 | } |
||
| 68 | public void setTipoTendencia(String tipoTendencia) { |
||
| 69 | this.tipoTendencia = tipoTendencia; |
||
| 70 | } |
||
| 71 | |||
| 72 | @Transient |
||
| 73 | public String getDescricaoDaTendencia() { |
||
| 74 | return VerificadorUtil.naoEstaNulo(getTipoTendencia())? TipoTendencia.parse(getTipoTendencia()).getDescricao() : ""; |
||
| 75 | } |
||
| 76 | |||
| 77 | @Column(name="ind_ativo", nullable=false) |
||
| 78 | public Boolean getAtivo() { |
||
| 79 | return ativo; |
||
| 80 | } |
||
| 81 | public void setAtivo(Boolean ativo) { |
||
| 82 | this.ativo = ativo; |
||
| 83 | } |
||
| 84 | |||
| 771 | blopes | 85 | @Override |
| 86 | public int hashCode() { |
||
| 87 | final int prime = 31; |
||
| 88 | int result = 1; |
||
| 89 | result = prime * result |
||
| 90 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 91 | return result; |
||
| 92 | } |
||
| 93 | |||
| 94 | @Override |
||
| 95 | public boolean equals(Object obj) { |
||
| 96 | if (this == obj) |
||
| 97 | return true; |
||
| 98 | if (obj == null) |
||
| 99 | return false; |
||
| 100 | if (getClass() != obj.getClass()) |
||
| 101 | return false; |
||
| 102 | Ativo other = (Ativo) obj; |
||
| 103 | if (sequencial == null) { |
||
| 104 | if (other.sequencial != null) |
||
| 105 | return false; |
||
| 106 | } else if (!sequencial.equals(other.sequencial)) |
||
| 107 | return false; |
||
| 108 | return true; |
||
| 109 | } |
||
| 110 | |||
| 760 | blopes | 111 | } |