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