Rev 534 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 325 | 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.JoinColumn; |
||
| 11 | import javax.persistence.ManyToOne; |
||
| 12 | import javax.persistence.Table; |
||
| 13 | import javax.validation.constraints.NotNull; |
||
| 14 | import javax.validation.constraints.Size; |
||
| 15 | |||
| 16 | import org.hibernate.annotations.ForeignKey; |
||
| 17 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 18 | |||
| 19 | import br.com.ec.core.interfaces.Alterar; |
||
| 20 | import br.com.ec.core.interfaces.Cadastrar; |
||
| 21 | import br.com.ec.core.util.StringUtil; |
||
| 22 | |||
| 23 | @Entity |
||
| 24 | @Table(name="sec_estampa", schema="sc_sec") |
||
| 25 | public class Estampa implements Serializable { |
||
| 26 | |||
| 27 | private static final long serialVersionUID = 1L; |
||
| 28 | |||
| 29 | private Long sequencial; |
||
| 30 | private TemaEstampa temaEstampa; |
||
| 31 | private String descricao; |
||
| 32 | private String codigo; |
||
| 33 | private String extensao; |
||
| 34 | private Double valor; |
||
| 35 | private Boolean ativo; |
||
| 36 | |||
| 37 | @Id |
||
| 38 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
||
| 39 | @Column(name="seq_estampa", nullable=false) |
||
| 40 | public Long getSequencial() { |
||
| 41 | return sequencial; |
||
| 42 | } |
||
| 43 | public void setSequencial(Long sequencial) { |
||
| 44 | this.sequencial = sequencial; |
||
| 45 | } |
||
| 46 | |||
| 47 | @ManyToOne |
||
| 48 | @ForeignKey(name = "fk_estampa_temaestampa") |
||
| 543 | blopes | 49 | @JoinColumn(name="seq_temaestampa", referencedColumnName="seq_temaestampa", insertable=true, updatable=true) |
| 325 | espaco | 50 | public TemaEstampa getTemaEstampa() { |
| 51 | return temaEstampa; |
||
| 52 | } |
||
| 53 | public void setTemaEstampa(TemaEstampa temaEstampa) { |
||
| 54 | this.temaEstampa = temaEstampa; |
||
| 55 | } |
||
| 56 | |||
| 57 | @Column(name="dsc_estampa") |
||
| 58 | @Size(max = 120, message = "Limite de caracteres ultrapassado: Descrição") |
||
| 59 | @NotEmpty(message="Obrigatório informar a descrição", groups={Cadastrar.class, Alterar.class}) |
||
| 60 | public String getDescricao() { |
||
| 61 | return descricao; |
||
| 62 | } |
||
| 63 | public void setDescricao(String descricao) { |
||
| 64 | this.descricao = StringUtil.setarUpperCaseComTrim(descricao); |
||
| 65 | } |
||
| 66 | |||
| 67 | @Column(name="cod_estampa") |
||
| 68 | @Size(max = 8, message = "Limite de caracteres ultrapassado: Código da Estampa") |
||
| 69 | @NotEmpty(message="Obrigatório informar o código", groups={Cadastrar.class, Alterar.class}) |
||
| 70 | public String getCodigo() { |
||
| 71 | return codigo; |
||
| 72 | } |
||
| 73 | public void setCodigo(String codigo) { |
||
| 74 | this.codigo = StringUtil.setarUpperCaseComTrim(codigo); |
||
| 75 | } |
||
| 76 | |||
| 77 | @Column(name="dsc_extensao") |
||
| 78 | @Size(max = 6, message = "Limite de caracteres ultrapassado: Extensão da Estampa") |
||
| 79 | public String getExtensao() { |
||
| 80 | return extensao; |
||
| 81 | } |
||
| 82 | public void setExtensao(String extensao) { |
||
| 534 | blopes | 83 | this.extensao = extensao; |
| 325 | espaco | 84 | } |
| 85 | |||
| 86 | @Column(name="val_estampa") |
||
| 87 | @NotNull(message="Obrigatório informar o valor", groups={Cadastrar.class, Alterar.class}) |
||
| 88 | public Double getValor() { |
||
| 89 | return valor; |
||
| 90 | } |
||
| 91 | public void setValor(Double valor) { |
||
| 92 | this.valor = valor; |
||
| 93 | } |
||
| 94 | |||
| 95 | @Column(name="ind_ativo") |
||
| 96 | public Boolean getAtivo() { |
||
| 97 | return ativo; |
||
| 98 | } |
||
| 99 | public void setAtivo(Boolean ativo) { |
||
| 100 | this.ativo = ativo; |
||
| 101 | } |
||
| 102 | |||
| 103 | @Override |
||
| 104 | public int hashCode() { |
||
| 105 | final int prime = 31; |
||
| 106 | int result = 1; |
||
| 107 | result = prime * result + ((codigo == null) ? 0 : codigo.hashCode()); |
||
| 108 | return result; |
||
| 109 | } |
||
| 110 | |||
| 111 | @Override |
||
| 112 | public boolean equals(Object obj) { |
||
| 113 | if (this == obj) |
||
| 114 | return true; |
||
| 115 | if (obj == null) |
||
| 116 | return false; |
||
| 117 | if (getClass() != obj.getClass()) |
||
| 118 | return false; |
||
| 119 | Estampa other = (Estampa) obj; |
||
| 120 | if (codigo == null) { |
||
| 121 | if (other.codigo != null) |
||
| 122 | return false; |
||
| 123 | } else if (!codigo.equals(other.codigo)) |
||
| 124 | return false; |
||
| 125 | return true; |
||
| 126 | } |
||
| 127 | |||
| 530 | blopes | 128 | /*******************************************/ |
| 325 | espaco | 129 | |
| 530 | blopes | 130 | public String identificadorEstampa() { |
| 131 | return "#" + getTemaEstampa().getCodigo() + getCodigo(); |
||
| 132 | } |
||
| 133 | |||
| 531 | blopes | 134 | public String identificadorImagemEstampa() { |
| 135 | return getTemaEstampa().getCodigo() + getCodigo(); |
||
| 136 | } |
||
| 137 | |||
| 138 | /******************/ |
||
| 139 | |||
| 325 | espaco | 140 | } |