Rev 439 | Rev 528 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 439 | Rev 526 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | package br.com.ec.domain.model; |
1 | package br.com.ec.domain.model; |
| 2 | 2 | ||
| - | 3 | import java.beans.Transient; |
|
| - | 4 | import java.io.File; |
|
| 3 | import java.io.Serializable; |
5 | import java.io.Serializable; |
| 4 | import java.util.Date; |
6 | import java.util.Date; |
| 5 | 7 | ||
| - | 8 | import javax.faces.context.FacesContext; |
|
| 6 | import javax.persistence.Column; |
9 | import javax.persistence.Column; |
| 7 | import javax.persistence.Entity; |
10 | import javax.persistence.Entity; |
| 8 | import javax.persistence.GeneratedValue; |
11 | import javax.persistence.GeneratedValue; |
| 9 | import javax.persistence.GenerationType; |
12 | import javax.persistence.GenerationType; |
| 10 | import javax.persistence.Id; |
13 | import javax.persistence.Id; |
| 11 | import javax.persistence.SequenceGenerator; |
14 | import javax.persistence.SequenceGenerator; |
| 12 | import javax.persistence.Table; |
15 | import javax.persistence.Table; |
| - | 16 | import javax.servlet.ServletContext; |
|
| 13 | import javax.validation.constraints.NotNull; |
17 | import javax.validation.constraints.NotNull; |
| 14 | import javax.validation.constraints.Size; |
18 | import javax.validation.constraints.Size; |
| 15 | 19 | ||
| 16 | import org.hibernate.validator.constraints.NotEmpty; |
20 | import org.hibernate.validator.constraints.NotEmpty; |
| 17 | 21 | ||
| 18 | import br.com.ec.core.interfaces.Alterar; |
22 | import br.com.ec.core.interfaces.Alterar; |
| 19 | import br.com.ec.core.interfaces.Cadastrar; |
23 | import br.com.ec.core.interfaces.Cadastrar; |
| 20 | import br.com.ec.core.util.StringUtil; |
24 | import br.com.ec.core.util.StringUtil; |
| - | 25 | import br.com.ec.domain.shared.ConstantesSEC; |
|
| 21 | 26 | ||
| 22 | @Entity |
27 | @Entity |
| 23 | @Table(name="sec_vigencia", schema="sc_sec") |
28 | @Table(name="sec_vigencia", schema="sc_sec") |
| 24 | public class Vigencia implements Serializable { |
29 | public class Vigencia implements Serializable { |
| 25 | 30 | ||
| Line 102... | Line 107... | ||
| 102 | if (other.sequencial != null) |
107 | if (other.sequencial != null) |
| 103 | return false; |
108 | return false; |
| 104 | } else if (!sequencial.equals(other.sequencial)) |
109 | } else if (!sequencial.equals(other.sequencial)) |
| 105 | return false; |
110 | return false; |
| 106 | return true; |
111 | return true; |
| - | 112 | }
|
|
| - | 113 | ||
| - | 114 | /********************************************/
|
|
| - | 115 | ||
| - | 116 | @Transient |
|
| - | 117 | public String caminhoPadraoImagens() { |
|
| - | 118 | return ConstantesSEC.TESTE_EMISSAO_LOCAL? ConstantesSEC.Imagem.CAMINHO_PADRAO_IMAGEM_LOCAL : ConstantesSEC.Imagem.CAMINHO_PADRAO_IMAGEM_SERVIDOR; |
|
| - | 119 | }
|
|
| - | 120 | ||
| - | 121 | @Transient |
|
| - | 122 | public String caminhoPastaImagens() { |
|
| - | 123 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
|
| - | 124 | return ConstantesSEC.TESTE_EMISSAO_LOCAL? |
|
| - | 125 | servletContext.getRealPath("") + File.separator + ConstantesSEC.Imagem.NOME_PASTA_PADRAO + File.separator : |
|
| - | 126 | servletContext.getRealPath("") + File.separator + ".." + File.separator + ConstantesSEC.Imagem.NOME_PASTA_PADRAO + File.separator; |
|
| - | 127 | }
|
|
| - | 128 | ||
| - | 129 | @Transient |
|
| - | 130 | public String imagemPromocao() { |
|
| - | 131 | return retornarImagemPngOuJpg("promocoes_"); |
|
| - | 132 | }
|
|
| - | 133 | ||
| - | 134 | @Transient |
|
| - | 135 | public String imagemEscala() { |
|
| - | 136 | return retornarImagemPngOuJpg("escala_"); |
|
| - | 137 | }
|
|
| - | 138 | ||
| - | 139 | private String retornarImagemPngOuJpg(String pasta) { |
|
| - | 140 | File foto = new File(caminhoPastaImagens() + pasta + getSequencial() + ".jpg"); |
|
| - | 141 | if (foto.exists()) { |
|
| - | 142 | return caminhoPadraoImagens() + pasta + getSequencial() + ".jpg"; |
|
| - | 143 | }
|
|
| - | 144 | if (!foto.exists()) { |
|
| - | 145 | foto = new File(caminhoPastaImagens() + pasta + getSequencial() + ".png"); |
|
| - | 146 | }
|
|
| - | 147 | return foto.exists()? caminhoPadraoImagens() + pasta + getSequencial() + ".png" : caminhoPadraoImagens() + "SEM_IMAGEM.png"; |
|
| 107 | }
|
148 | }
|
| 108 | 149 | ||
| 109 | }
|
150 | }
|