Go to most recent revision | Details | 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 | |||
| 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; |
||
| 12 | import javax.persistence.Transient; |
||
| 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.domain.model.tipos.TipoPlanoVivo; |
||
| 19 | import br.com.ec.domain.model.tipos.TipoServicoVivo; |
||
| 20 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 21 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 22 | import br.edu.cesmac.core.util.StringUtil; |
||
| 23 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 24 | |||
| 25 | @Entity |
||
| 26 | @Table(name="sec_produto_vivo", schema="sc_sec") |
||
| 27 | public class ProdutoVivo implements Serializable { |
||
| 28 | |||
| 29 | private static final long serialVersionUID = 1L; |
||
| 30 | |||
| 31 | private Long sequencial; |
||
| 32 | private String codigoServico; |
||
| 33 | private String descricao; |
||
| 34 | private Double valorAssinatura; |
||
| 35 | private Double valorComissao; |
||
| 36 | private String detalhes; |
||
| 37 | private String tipoServico; |
||
| 38 | private String tipoPlano; |
||
| 39 | private Boolean indicadorPortifolio; |
||
| 40 | |||
| 41 | @Id |
||
| 42 | @SequenceGenerator(name = "sq_produtovivo") |
||
| 43 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 44 | @Column(name="seq_produto_vivo", 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="cod_servico") |
||
| 53 | @Size(max = 20, message = "Limite de caracteres ultrapassado: Código do Serviço") |
||
| 54 | public String getCodigoServico() { |
||
| 55 | return codigoServico; |
||
| 56 | } |
||
| 57 | public void setCodigoServico(String codigoServico) { |
||
| 58 | this.codigoServico = codigoServico; |
||
| 59 | } |
||
| 60 | |||
| 61 | @Column(name="dsc_produto") |
||
| 62 | @Size(max = 250, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 63 | @NotNull(message = "Parâmetro obrigatório não preenchido: Descrição do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 64 | @NotEmpty(message = "Parâmetro obrigatório não preenchido: Descrição do produto", groups = {Cadastrar.class, Alterar.class}) |
||
| 65 | public String getDescricao() { |
||
| 66 | return descricao; |
||
| 67 | } |
||
| 68 | public void setDescricao(String descricao) { |
||
| 69 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 70 | } |
||
| 71 | |||
| 72 | @Column(name="val_assinatura") |
||
| 73 | @NotNull(message = "Parâmetro obrigatório não preenchido: Valor da Assinatura", groups = {Cadastrar.class, Alterar.class}) |
||
| 74 | public Double getValorAssinatura() { |
||
| 75 | return valorAssinatura; |
||
| 76 | } |
||
| 77 | public void setValorAssinatura(Double valorAssinatura) { |
||
| 78 | this.valorAssinatura = valorAssinatura; |
||
| 79 | } |
||
| 80 | |||
| 81 | @Column(name="val_comissao") |
||
| 82 | public Double getValorComissao() { |
||
| 83 | return valorComissao; |
||
| 84 | } |
||
| 85 | public void setValorComissao(Double valorComissao) { |
||
| 86 | this.valorComissao = valorComissao; |
||
| 87 | } |
||
| 88 | |||
| 89 | @Column(name="dsc_detalhes") |
||
| 90 | @Size(max = 2000, message = "Limite de caracteres ultrapassado: Detalhes") |
||
| 91 | public String getDetalhes() { |
||
| 92 | return detalhes; |
||
| 93 | } |
||
| 94 | public void setDetalhes(String detalhes) { |
||
| 95 | this.detalhes = StringUtil.setarUpperCaseComTrim(detalhes); |
||
| 96 | } |
||
| 97 | |||
| 98 | @Column(name="tip_servico") |
||
| 99 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo do serviço", groups = {Cadastrar.class, Alterar.class}) |
||
| 100 | public String getTipoServico() { |
||
| 101 | return tipoServico; |
||
| 102 | } |
||
| 103 | public void setTipoServico(String tipoServico) { |
||
| 104 | this.tipoServico = tipoServico; |
||
| 105 | } |
||
| 106 | |||
| 107 | @Column(name="tip_plano") |
||
| 108 | @NotNull(message = "Parâmetro obrigatório não preenchido: Tipo do plano", groups = {Cadastrar.class, Alterar.class}) |
||
| 109 | public String getTipoPlano() { |
||
| 110 | return tipoPlano; |
||
| 111 | } |
||
| 112 | public void setTipoPlano(String tipoPlano) { |
||
| 113 | this.tipoPlano = tipoPlano; |
||
| 114 | } |
||
| 115 | |||
| 116 | @Column(name="ind_portifolio") |
||
| 117 | public Boolean getIndicadorPortifolio() { |
||
| 118 | return indicadorPortifolio; |
||
| 119 | } |
||
| 120 | public void setIndicadorPortifolio(Boolean indicadorPortifolio) { |
||
| 121 | this.indicadorPortifolio = indicadorPortifolio; |
||
| 122 | } |
||
| 123 | |||
| 124 | /***************************************************************/ |
||
| 125 | |||
| 126 | @Transient |
||
| 127 | public String getDescricaoDoTipoServico() { |
||
| 128 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoServico())? TipoServicoVivo.parse(getTipoServico()).getDescricao() : null; |
||
| 129 | } |
||
| 130 | |||
| 131 | @Transient |
||
| 132 | public String getDescricaoDoTipoPlano() { |
||
| 133 | return VerificadorUtil.naoEstaNuloOuVazio(getTipoPlano())? TipoPlanoVivo.parse(getTipoPlano()).getDescricao() : null; |
||
| 134 | } |
||
| 135 | |||
| 136 | @Transient |
||
| 137 | public String getDescricaoCompleta() { |
||
| 138 | return getDescricaoDoTipoServico() + " - " + getDescricaoDoTipoPlano() + " - " + getDescricao(); |
||
| 139 | } |
||
| 140 | |||
| 141 | @Override |
||
| 142 | public int hashCode() { |
||
| 143 | final int prime = 31; |
||
| 144 | int result = 1; |
||
| 145 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 146 | return result; |
||
| 147 | } |
||
| 148 | |||
| 149 | @Override |
||
| 150 | public boolean equals(Object obj) { |
||
| 151 | if (this == obj) |
||
| 152 | return true; |
||
| 153 | if (obj == null) |
||
| 154 | return false; |
||
| 155 | if (getClass() != obj.getClass()) |
||
| 156 | return false; |
||
| 157 | ProdutoVivo other = (ProdutoVivo) obj; |
||
| 158 | if (sequencial == null) { |
||
| 159 | if (other.sequencial != null) |
||
| 160 | return false; |
||
| 161 | } else if (!sequencial.equals(other.sequencial)) |
||
| 162 | return false; |
||
| 163 | return true; |
||
| 164 | } |
||
| 165 | |||
| 166 | } |