Subversion Repositories Integrator Subversion

Rev

Rev 526 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 526 Rev 528
Line 2... Line 2...
2
2
3
import java.io.File;
3
import java.io.File;
4
import java.io.FileOutputStream;
-
 
5
4
6
import javax.faces.context.FacesContext;
5
import javax.faces.context.FacesContext;
7
import javax.inject.Named;
6
import javax.inject.Named;
8
import javax.servlet.ServletContext;
7
import javax.servlet.ServletContext;
9
8
10
import org.primefaces.event.FileUploadEvent;
-
 
11
import org.primefaces.model.file.UploadedFile;
9
import org.primefaces.model.file.UploadedFile;
12
import org.springframework.context.annotation.Scope;
10
import org.springframework.context.annotation.Scope;
13
11
14
import br.com.ec.core.util.VerificadorUtil;
-
 
15
import br.com.ec.domain.dto.FotoDTO;
-
 
16
import br.com.ec.domain.dto.ProdutoDTO;
-
 
17
import br.com.ec.domain.dto.VigenciaDTO;
-
 
18
import br.com.ec.domain.model.Produto;
-
 
-
 
12
import br.com.ec.domain.dto.ImagemDTO;
19
import br.com.ec.domain.shared.ConstantesSEC;
13
import br.com.ec.domain.shared.ConstantesSEC;
20
import br.com.ec.web.exception.VerificadorLancamentoException;
-
 
21
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
-
 
22
import br.com.ec.web.message.LancadorMensagem;
-
 
23
14
24
@Named
15
@Named
25
@Scope("view")
16
@Scope("view")
26
public class ImagemBean {
17
public class ImagemBean {
27
       
18
       
28
        private FotoDTO fotoNova;
-
 
29
        private UploadedFile imagemParaUpload;
-
 
-
 
19
        private ImagemDTO imagemDTO;
-
 
20
        private UploadedFile imagemParaUpload;
30
       
21
       
31
        public FotoDTO getFotoNova() {
-
 
32
                return fotoNova;
-
 
-
 
22
        public ImagemDTO getImagemDTO() {
-
 
23
                return imagemDTO;
33
        }
24
        }
34
        public void setFotoNova(FotoDTO fotoNova) {
-
 
35
                this.fotoNova = fotoNova;
-
 
-
 
25
        public void setImagemDTO(ImagemDTO imagemDTO) {
-
 
26
                this.imagemDTO = imagemDTO;
36
        }
27
        }
37
       
28
       
38
        public UploadedFile getImagemParaUpload() {
29
        public UploadedFile getImagemParaUpload() {
39
                return imagemParaUpload;
30
                return imagemParaUpload;
40
        }
31
        }
41
        public void setImagemParaUpload(UploadedFile imagemParaUpload) {
32
        public void setImagemParaUpload(UploadedFile imagemParaUpload) {
42
                this.imagemParaUpload = imagemParaUpload;
33
                this.imagemParaUpload = imagemParaUpload;
43
        }
34
        }
44
       
35
       
45
        /**********************************************/
36
        /**********************************************/
-
 
37
       
46
       
38
       
47
       
39
       
48
        /**********************************************/
40
        /**********************************************/
-
 
41
        /*
49
       
42
       
50
        public void uploadImagem(final FileUploadEvent e) {
43
        public void uploadImagem(final FileUploadEvent e) {
51
        new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
44
        new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
52
                        public void execute() {
45
                        public void execute() {
53
//                              FotoDTO arquivoGerado = gerarArquivo(e.getFile());
46
//                              FotoDTO arquivoGerado = gerarArquivo(e.getFile());
Line 72... Line 65...
72
                        e1.printStackTrace();
65
                        e1.printStackTrace();
73
                }
66
                }
74
        }
67
        }
75
       
68
       
76
       
69
       
77
        public String getCaminhoPadraoImagens() {
-
 
78
                return ConstantesSEC.TESTE_EMISSAO_LOCAL? ConstantesSEC.Imagem.CAMINHO_PADRAO_IMAGEM_LOCAL : ConstantesSEC.Imagem.CAMINHO_PADRAO_IMAGEM_SERVIDOR;
-
 
79
        }
-
 
80
       
70
       
81
        public String getCaminhoPastaImagens() {
-
 
82
                ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
-
 
83
                return ConstantesSEC.TESTE_EMISSAO_LOCAL?
-
 
84
                                servletContext.getRealPath("") + File.separator + "imagens" + File.separator :
-
 
85
                                servletContext.getRealPath("") + File.separator + ".." + File.separator + "imagens" + File.separator;
-
 
86
        }
-
 
87
       
71
       
88
        public String fotoPadraoProdutoDTO(ProdutoDTO produtoDTO) {
72
        public String fotoPadraoProdutoDTO(ProdutoDTO produtoDTO) {
89
                try {
73
                try {
90
                        if (VerificadorUtil.naoEstaNulo(produtoDTO)) {
74
                        if (VerificadorUtil.naoEstaNulo(produtoDTO)) {
91
                                if (VerificadorUtil.naoEstaNuloOuVazio(produtoDTO.getCodigo())) {
75
                                if (VerificadorUtil.naoEstaNuloOuVazio(produtoDTO.getCodigo())) {
Line 117... Line 101...
117
                        e.printStackTrace();
101
                        e.printStackTrace();
118
                }
102
                }
119
                return getCaminhoPadraoImagens() + "SEM_FOTO.jpg";
103
                return getCaminhoPadraoImagens() + "SEM_FOTO.jpg";
120
        }
104
        }
121
       
105
       
122
        /**********************************************
-
 
-
 
106
        *********************************************
123
       
107
       
124
        @Transient
108
        @Transient
125
        public List<String> fotosProdutoComFotoPadrao(Produto produto) {
109
        public List<String> fotosProdutoComFotoPadrao(Produto produto) {
126
                List<String> fotos = new ArrayList<String>();
110
                List<String> fotos = new ArrayList<String>();
127
                if (VerificadorUtil.naoEstaNulo(produto)) {
111
                if (VerificadorUtil.naoEstaNulo(produto)) {