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