Commit b3585ae10f35f758c68baa714a01bc40088a96e3
1 parent
c8d1f4f9
Exists in
master
Novas funcionalidades.
Showing
10 changed files
with
168 additions
and
96 deletions
Show diff stats
WebContent/WEB-INF/jsp/formularioOrgao/formularioOrgao.jsp
@@ -43,13 +43,13 @@ | @@ -43,13 +43,13 @@ | ||
43 | <fieldset class="layoutCampos"> | 43 | <fieldset class="layoutCampos"> |
44 | <legend>Responsável pelo Preenchimento</legend> | 44 | <legend>Responsável pelo Preenchimento</legend> |
45 | <input type="hidden" name="hNomePessoa" value="2"/><label for="nomePessoa" class="obrigatorio">Nome completo:</label> | 45 | <input type="hidden" name="hNomePessoa" value="2"/><label for="nomePessoa" class="obrigatorio">Nome completo:</label> |
46 | - <input type="text" name="nomePessoa" id="nomePessoa" size="50" maxlength="50" value="${nomePessoa}" required><br><br> | 46 | + <input type="text" name="nomePessoa" id="nomePessoa" size="50" maxlength="50" value="${questionario.responsavel}" readonly="readonly"><br><br> |
47 | <label for="cargo" class="obrigatorio">Cargo que ocupa:</label> | 47 | <label for="cargo" class="obrigatorio">Cargo que ocupa:</label> |
48 | - <input type="hidden" name="hCargo" value="3"/><input type="text" name="cargo" id="cargo" size="70" maxlength="70" value="${cargo}" required><br><br> | 48 | + <input type="hidden" name="hCargo" value="3"/><input type="text" name="cargo" id="cargo" size="70" maxlength="70" value="${questionario.cargoResponsavel}" readonly="readonly"><br><br> |
49 | <label for="telefone" class="obrigatorio">Telefone (com DDD):</label> | 49 | <label for="telefone" class="obrigatorio">Telefone (com DDD):</label> |
50 | - <input type="hidden" name="hTelefone" value="4"/><input type="tel" name="telefone" id="telefone" size="50" maxlength="50" value="${telefone}" required><br><br> | 50 | + <input type="hidden" name="hTelefone" value="4"/><input type="tel" name="telefone" id="telefone" size="50" maxlength="50" value="${questionario.telefone}" readonly="readonly"><br><br> |
51 | <label for="email" class="obrigatorio">E-mail:</label> | 51 | <label for="email" class="obrigatorio">E-mail:</label> |
52 | - <input type="hidden" name="hEmail" value="5"/><input type="email" name="email" id="email" size="50" maxlength="50" value="${email}" required> | 52 | + <input type="hidden" name="hEmail" value="5"/><input type="email" name="email" id="email" size="50" maxlength="50" value="${questionario.emailDestinoOrgao}" readonly="readonly"> |
53 | </fieldset><br> | 53 | </fieldset><br> |
54 | 54 | ||
55 | <fieldset id="ambiente" class="layoutCampos"> | 55 | <fieldset id="ambiente" class="layoutCampos"> |
WebContent/WEB-INF/jsp/login/login.jsp
@@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
77 | <fieldset id="entrarFieldset"> | 77 | <fieldset id="entrarFieldset"> |
78 | <legend><strong>Entrar</strong></legend> | 78 | <legend><strong>Entrar</strong></legend> |
79 | <label for="valorHash">Código de Acesso:</label><br> | 79 | <label for="valorHash">Código de Acesso:</label><br> |
80 | - <input type="text" name="valorHash" id="valorHash" size="60" maxlength="60" required><br> | 80 | + <input type="password" name="valorHash" id="valorHash" size="60" maxlength="60" required><br> |
81 | </fieldset><br> | 81 | </fieldset><br> |
82 | <input type="submit" class="button" id="botaoAcesso" value="Entrar"> | 82 | <input type="submit" class="button" id="botaoAcesso" value="Entrar"> |
83 | </form> | 83 | </form> |
WebContent/WEB-INF/jsp/planoTrabalho/planoTrabalho.jsp
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | <legend>Plano de Trabalho</legend> | 32 | <legend>Plano de Trabalho</legend> |
33 | <label for="valorHash">Código de acesso: </label> | 33 | <label for="valorHash">Código de acesso: </label> |
34 | <input type="text" id="valorHash" name="valorHash" size="60" maxlength="60" required><br><br> | 34 | <input type="text" id="valorHash" name="valorHash" size="60" maxlength="60" required><br><br> |
35 | - <label for="file">Arquivo: </label> | 35 | + <label for="file">Arquivo: (tamanho máximo: 50Mb) </label> |
36 | <input type="file" id="file" name="file" accept= | 36 | <input type="file" id="file" name="file" accept= |
37 | "application/msword, application/vnd.ms-excel, application/vnd.oasis.opendocument.text , | 37 | "application/msword, application/vnd.ms-excel, application/vnd.oasis.opendocument.text , |
38 | text/plain, application/pdf, image/*" required><br><br> | 38 | text/plain, application/pdf, image/*" required><br><br> |
WebContent/WEB-INF/mail.properties
@@ -7,4 +7,4 @@ prop.email.authpass = "" | @@ -7,4 +7,4 @@ prop.email.authpass = "" | ||
7 | prop.email.auth = false | 7 | prop.email.auth = false |
8 | prop.email.to = govbr@planejamento.gov.br | 8 | prop.email.to = govbr@planejamento.gov.br |
9 | prop.email.from = govbr@planejamento.gov.br | 9 | prop.email.from = govbr@planejamento.gov.br |
10 | -prop.email.copiaEmailTo = gibran.sodre@planejamento.gov.br | ||
11 | \ No newline at end of file | 10 | \ No newline at end of file |
11 | +prop.email.copiaEmailTo = fabricio.souza@planejamento.gov.br | ||
12 | \ No newline at end of file | 12 | \ No newline at end of file |
WebContent/WEB-INF/respostaFormulario.properties
1 | -dataInicio = 2016-10-01 | ||
2 | -dataFim = 2016-12-31 | 1 | +dataInicio = 2016-11-21 |
2 | +dataFim = 2017-01-02 | ||
3 | enderecoFad = http://fad.governoeletronico.gov.br/fad | 3 | enderecoFad = http://fad.governoeletronico.gov.br/fad |
4 | enderecoContato= http://fad.governoeletronico.gov.br/fad/contato/contato-site | 4 | enderecoContato= http://fad.governoeletronico.gov.br/fad/contato/contato-site |
5 | emailContato = govbr@planejamento.gov.br | 5 | emailContato = govbr@planejamento.gov.br |
WebContent/WEB-INF/web.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> | 2 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> |
3 | <display-name>Formulario Acessibilidade</display-name> | 3 | <display-name>Formulario Acessibilidade</display-name> |
4 | + | ||
4 | <filter> | 5 | <filter> |
5 | <filter-name>vraptor</filter-name> | 6 | <filter-name>vraptor</filter-name> |
6 | <filter-class>br.com.caelum.vraptor.VRaptor</filter-class> | 7 | <filter-class>br.com.caelum.vraptor.VRaptor</filter-class> |
7 | </filter> | 8 | </filter> |
8 | - <context-param> | ||
9 | - <param-name>br.com.caelum.vraptor.encoding</param-name> | ||
10 | - <param-value>UTF-8</param-value> | ||
11 | - </context-param> | 9 | + |
10 | + <context-param> | ||
11 | + <param-name>br.com.caelum.vraptor.encoding</param-name> | ||
12 | + <param-value>UTF-8</param-value> | ||
13 | + </context-param> | ||
14 | + <context-param> | ||
15 | + <description>Limite máximo em bytes</description> | ||
16 | + <param-name>br.com.caelum.vraptor.interceptor.multipart.UPLOAD_SIZE_LIMIT</param-name> | ||
17 | + <param-value>52428800</param-value> | ||
18 | + </context-param> | ||
19 | + | ||
12 | <filter-mapping> | 20 | <filter-mapping> |
13 | <filter-name>vraptor</filter-name> | 21 | <filter-name>vraptor</filter-name> |
14 | <url-pattern>/*</url-pattern> | 22 | <url-pattern>/*</url-pattern> |
15 | <dispatcher>FORWARD</dispatcher> | 23 | <dispatcher>FORWARD</dispatcher> |
16 | <dispatcher>REQUEST</dispatcher> | 24 | <dispatcher>REQUEST</dispatcher> |
17 | </filter-mapping> | 25 | </filter-mapping> |
18 | - | ||
19 | - | ||
20 | </web-app> | 26 | </web-app> |
21 | \ No newline at end of file | 27 | \ No newline at end of file |
src/br/com/controller/PlanoTrabalhoController.java
1 | package br.com.controller; | 1 | package br.com.controller; |
2 | 2 | ||
3 | -import java.io.FileOutputStream; | ||
4 | import java.io.IOException; | 3 | import java.io.IOException; |
5 | -import java.io.InputStream; | ||
6 | -import java.sql.ResultSet; | ||
7 | 4 | ||
8 | import javax.servlet.ServletContext; | 5 | import javax.servlet.ServletContext; |
9 | import javax.servlet.ServletOutputStream; | 6 | import javax.servlet.ServletOutputStream; |
@@ -11,18 +8,20 @@ import javax.servlet.http.HttpServletResponse; | @@ -11,18 +8,20 @@ import javax.servlet.http.HttpServletResponse; | ||
11 | 8 | ||
12 | import br.com.caelum.vraptor.Get; | 9 | import br.com.caelum.vraptor.Get; |
13 | import br.com.caelum.vraptor.Path; | 10 | import br.com.caelum.vraptor.Path; |
14 | -import br.com.caelum.vraptor.Post; | ||
15 | import br.com.caelum.vraptor.Resource; | 11 | import br.com.caelum.vraptor.Resource; |
16 | import br.com.caelum.vraptor.Result; | 12 | import br.com.caelum.vraptor.Result; |
17 | import br.com.caelum.vraptor.Validator; | 13 | import br.com.caelum.vraptor.Validator; |
14 | +import br.com.caelum.vraptor.interceptor.multipart.DefaultMultipartConfig; | ||
18 | import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; | 15 | import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; |
19 | import br.com.caelum.vraptor.validator.ValidationMessage; | 16 | import br.com.caelum.vraptor.validator.ValidationMessage; |
20 | import br.com.dao.HashDao; | 17 | import br.com.dao.HashDao; |
21 | import br.com.dao.PlanoTrabalhoDao; | 18 | import br.com.dao.PlanoTrabalhoDao; |
19 | +import br.com.model.entity.PlanoTrabalho; | ||
22 | import br.com.model.entity.Questionario; | 20 | import br.com.model.entity.Questionario; |
23 | 21 | ||
22 | + | ||
24 | @Resource | 23 | @Resource |
25 | -public class PlanoTrabalhoController { | 24 | +public class PlanoTrabalhoController extends DefaultMultipartConfig { |
26 | 25 | ||
27 | private Validator validator; | 26 | private Validator validator; |
28 | private Result result; | 27 | private Result result; |
@@ -35,6 +34,11 @@ public class PlanoTrabalhoController { | @@ -35,6 +34,11 @@ public class PlanoTrabalhoController { | ||
35 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; | 34 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; |
36 | this.result = result; | 35 | this.result = result; |
37 | } | 36 | } |
37 | + | ||
38 | + // alteramos o tamanho total do upload para 50MB | ||
39 | + public long getSizeLimit() { | ||
40 | + return 50 * 1024 * 1024; | ||
41 | + } | ||
38 | 42 | ||
39 | @Path("/planoTrabalho-site") | 43 | @Path("/planoTrabalho-site") |
40 | public void planoTrabalho() { | 44 | public void planoTrabalho() { |
@@ -46,97 +50,105 @@ public class PlanoTrabalhoController { | @@ -46,97 +50,105 @@ public class PlanoTrabalhoController { | ||
46 | 50 | ||
47 | } | 51 | } |
48 | 52 | ||
49 | - @Path("/salvar-plano-trabalho") | 53 | + |
54 | + @Path("/salvar-plano-trabalho") | ||
50 | public void enviarPlanoTrabalho(String valorHash, UploadedFile file) { | 55 | public void enviarPlanoTrabalho(String valorHash, UploadedFile file) { |
51 | - | ||
52 | - String tipoArquivo = file.getContentType(); | 56 | + |
53 | String mensagem = "Não foi possível enviar o plano de trabalho!"; | 57 | String mensagem = "Não foi possível enviar o plano de trabalho!"; |
54 | boolean status = false; | 58 | boolean status = false; |
55 | - int idPlanoTrabalho = -1; | ||
56 | 59 | ||
60 | + if(file != null) | ||
61 | + { | ||
62 | + String tipoArquivo = file.getContentType(); | ||
63 | + | ||
64 | + int idPlanoTrabalho = -1; | ||
65 | + | ||
57 | if (!tipoArquivo.equalsIgnoreCase("application/msword") | 66 | if (!tipoArquivo.equalsIgnoreCase("application/msword") |
58 | && !tipoArquivo.equalsIgnoreCase("application/vnd.ms-excel") | 67 | && !tipoArquivo.equalsIgnoreCase("application/vnd.ms-excel") |
59 | && !tipoArquivo.equalsIgnoreCase("application/vnd.oasis.opendocument.text") | 68 | && !tipoArquivo.equalsIgnoreCase("application/vnd.oasis.opendocument.text") |
60 | && !tipoArquivo.equalsIgnoreCase("text/plain") | 69 | && !tipoArquivo.equalsIgnoreCase("text/plain") |
61 | && !tipoArquivo.equalsIgnoreCase("application/pdf") | 70 | && !tipoArquivo.equalsIgnoreCase("application/pdf") |
62 | - && !tipoArquivo.equalsIgnoreCase("image/png") | ||
63 | - && !tipoArquivo.equalsIgnoreCase("image/gif") | 71 | + && !tipoArquivo.equalsIgnoreCase("image/png") && !tipoArquivo.equalsIgnoreCase("image/gif") |
64 | && !tipoArquivo.equalsIgnoreCase("image/jpeg")) { | 72 | && !tipoArquivo.equalsIgnoreCase("image/jpeg")) { |
65 | 73 | ||
66 | mensagem = "Formato de Arquivo inválido!"; | 74 | mensagem = "Formato de Arquivo inválido!"; |
67 | status = false; | 75 | status = false; |
68 | - | 76 | + |
69 | } else { | 77 | } else { |
70 | HashDao hashDao = new HashDao(); | 78 | HashDao hashDao = new HashDao(); |
71 | Questionario questionario = new Questionario(); | 79 | Questionario questionario = new Questionario(); |
72 | questionario = hashDao.verificarHash(path, valorHash); | 80 | questionario = hashDao.verificarHash(path, valorHash); |
81 | + String nomeExtensao = file.getFileName(); | ||
82 | + | ||
83 | + if (questionario != null && questionario.getDtInicioQuestionario() != null) { | ||
84 | + PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
73 | 85 | ||
86 | + idPlanoTrabalho = | ||
87 | + planoTrabalhoDao.verificaPlanoTrabalho(path, questionario.getIdQuestionario()); | ||
74 | 88 | ||
75 | - if (questionario != null && questionario.getDtInicioQuestionario() != null) { | ||
76 | - PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
77 | - | ||
78 | - idPlanoTrabalho = planoTrabalhoDao.verificaPlanoTrabalho(path, questionario.getIdQuestionario()); | ||
79 | - | ||
80 | - if(idPlanoTrabalho == -1) | ||
81 | - { | ||
82 | - if (planoTrabalhoDao.salvarPlanoTrabalho(path, file.getFile(), questionario)) { | ||
83 | - mensagem = "Plano de trabalho enviado com sucesso!"; | ||
84 | - status = true; | ||
85 | - } | ||
86 | - else { | ||
87 | - mensagem = "Não foi possível enviar o plano de trabalho!"; | ||
88 | - } | ||
89 | - }else | ||
90 | - { | ||
91 | - if (planoTrabalhoDao.atualizarPlanoTrabalho(path, file.getFile(), questionario, idPlanoTrabalho)) { | ||
92 | - mensagem = "Plano de trabalho enviado com sucesso!"; | ||
93 | - status = true; | ||
94 | - } | ||
95 | - else { | ||
96 | - mensagem = "Não foi possível enviar o plano de trabalho!"; | 89 | + if (idPlanoTrabalho == -1) { |
90 | + if (planoTrabalhoDao.salvarPlanoTrabalho(path, file.getFile(), questionario, | ||
91 | + nomeExtensao)) { | ||
92 | + mensagem = "Plano de trabalho enviado com sucesso!"; | ||
93 | + status = true; | ||
94 | + } else { | ||
95 | + mensagem = "Não foi possível enviar o plano de trabalho!"; | ||
96 | + } | ||
97 | + } else { | ||
98 | + if (planoTrabalhoDao.atualizarPlanoTrabalho(path, file.getFile(), questionario, | ||
99 | + idPlanoTrabalho, nomeExtensao)) { | ||
100 | + mensagem = "Plano de trabalho enviado com sucesso!"; | ||
101 | + status = true; | ||
102 | + } else { | ||
103 | + mensagem = "Não foi possível enviar o plano de trabalho!"; | ||
104 | + } | ||
97 | } | 105 | } |
106 | + | ||
107 | + } else { | ||
108 | + mensagem = "Favor verificar o Código de Acesso!"; | ||
98 | } | 109 | } |
99 | - | ||
100 | - } | ||
101 | - else | ||
102 | - { | ||
103 | - mensagem = "Favor verificar o Código de Acesso!"; | ||
104 | - } | 110 | + |
111 | + } | ||
112 | + } | ||
113 | + else | ||
114 | + { | ||
115 | + mensagem = "O arquivo não pode ser maior que 50Mb!"; | ||
105 | } | 116 | } |
106 | result.include("mensagem", mensagem); | 117 | result.include("mensagem", mensagem); |
107 | result.include("status", status); | 118 | result.include("status", status); |
108 | this.validator.add(new ValidationMessage("", "")); | 119 | this.validator.add(new ValidationMessage("", "")); |
109 | this.validator.onErrorUsePageOf(PlanoTrabalhoController.class).planoTrabalhoConfirmacao(); | 120 | this.validator.onErrorUsePageOf(PlanoTrabalhoController.class).planoTrabalhoConfirmacao(); |
110 | } | 121 | } |
111 | - | ||
112 | - @Get("/recuperar-plano-trabalho/{id}") | ||
113 | - public void recuperarPlanoTrabalho(int id, HttpServletResponse response)throws IOException { | ||
114 | - | ||
115 | -Questionario questionario = new Questionario(path, id); | ||
116 | - | 122 | + |
123 | + @Get("/recuperar-plano-trabalho/{id}") | ||
124 | + public void recuperarPlanoTrabalho(int id, HttpServletResponse response) throws IOException { | ||
125 | + | ||
126 | + Questionario questionario = new Questionario(path, id); | ||
127 | + | ||
117 | PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | 128 | PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); |
118 | - | 129 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); |
130 | + | ||
119 | byte[] dados = null; | 131 | byte[] dados = null; |
120 | - | ||
121 | - if(questionario != null && questionario.getIdQuestionario() > 0) | ||
122 | - { | ||
123 | - dados = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
124 | - } | ||
125 | - | ||
126 | - String nome = "plano de trabalho"; | ||
127 | - //FileOutputStream fileOut = new FileOutputStream(nome); | ||
128 | - //fileOut.write(dados); | ||
129 | - //fileOut.flush(); | ||
130 | - //fileOut.close(); | ||
131 | - response.setContentType("inline/download"); | ||
132 | - String arq = "attachment;filename=" + nome; | ||
133 | - response.setHeader("Content-Disposition", arq); | ||
134 | - ServletOutputStream os = response.getOutputStream(); | ||
135 | - os.write(dados); | ||
136 | - os.flush(); | ||
137 | - os.close(); | ||
138 | - | ||
139 | - | ||
140 | - | 132 | + |
133 | + if (questionario != null && questionario.getIdQuestionario() > 0) { | ||
134 | + planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
135 | + | ||
136 | + if(planoTrabalho != null) | ||
137 | + { | ||
138 | + try { | ||
139 | + String nome = planoTrabalho.getNomeExtensao(); | ||
140 | + dados = planoTrabalho.getArquivoPlanoTrabalho(); | ||
141 | + response.setContentType("inline/download"); | ||
142 | + String arq = "attachment;filename=" + nome; | ||
143 | + response.setHeader("Content-Disposition", arq); | ||
144 | + ServletOutputStream os = response.getOutputStream(); | ||
145 | + os.write(dados); | ||
146 | + os.flush(); | ||
147 | + os.close(); | ||
148 | + } catch (Exception e) { | ||
149 | + | ||
150 | + } | ||
151 | + } | ||
152 | + } | ||
141 | } | 153 | } |
142 | } | 154 | } |
src/br/com/dao/HashDao.java
@@ -25,8 +25,11 @@ public class HashDao { | @@ -25,8 +25,11 @@ public class HashDao { | ||
25 | estado = con.createStatement(); | 25 | estado = con.createStatement(); |
26 | 26 | ||
27 | estado.execute(sql.toString()); | 27 | estado.execute(sql.toString()); |
28 | - sql.append("SELECT id_questionario, dt_inicio_questionario, dt_fim_questionario,"); | ||
29 | - sql.append("no_orgao, hash_autenticacao, questionario_respondido"); | 28 | + |
29 | + sql.append(" SELECT id_questionario, dt_inicio_questionario, dt_fim_questionario, "); | ||
30 | + sql.append(" no_orgao, hash_autenticacao, questionario_respondido, email_destino_orgao, "); | ||
31 | + sql.append(" responsavel, cargo_responsavel, telefone, data_recebimento_email, "); | ||
32 | + sql.append(" idautorizacao, data_resposta_email "); | ||
30 | sql.append(" FROM questionario where hash_autenticacao = '" + valorHash + "'"); | 33 | sql.append(" FROM questionario where hash_autenticacao = '" + valorHash + "'"); |
31 | sql.append(" and (dt_inicio_questionario <= '" + DateUtil.dataHoraAtual() + "')"); | 34 | sql.append(" and (dt_inicio_questionario <= '" + DateUtil.dataHoraAtual() + "')"); |
32 | sql.append(" and (dt_fim_questionario >= '" + DateUtil.dataHoraAtual() + "');"); | 35 | sql.append(" and (dt_fim_questionario >= '" + DateUtil.dataHoraAtual() + "');"); |
@@ -35,12 +38,17 @@ public class HashDao { | @@ -35,12 +38,17 @@ public class HashDao { | ||
35 | 38 | ||
36 | while (rset.next()) { | 39 | while (rset.next()) { |
37 | questionario.setIdQuestionario(rset.getInt("id_questionario")); | 40 | questionario.setIdQuestionario(rset.getInt("id_questionario")); |
41 | + | ||
38 | questionario.setDtFimQuestionario(rset.getString("dt_fim_questionario")); | 42 | questionario.setDtFimQuestionario(rset.getString("dt_fim_questionario")); |
39 | questionario.setDtInicioQuestionario(rset.getString("dt_inicio_questionario")); | 43 | questionario.setDtInicioQuestionario(rset.getString("dt_inicio_questionario")); |
40 | questionario.setHashAutenticacao(rset.getString("hash_autenticacao")); | 44 | questionario.setHashAutenticacao(rset.getString("hash_autenticacao")); |
41 | questionario.setNoOrgao(rset.getString("no_orgao").replace("</br>", "").replace("<br>", "")); | 45 | questionario.setNoOrgao(rset.getString("no_orgao").replace("</br>", "").replace("<br>", "")); |
42 | questionario.setHashAutenticacao(rset.getString("hash_autenticacao")); | 46 | questionario.setHashAutenticacao(rset.getString("hash_autenticacao")); |
43 | questionario.setQuestionario_respondido(rset.getBoolean("questionario_respondido")); | 47 | questionario.setQuestionario_respondido(rset.getBoolean("questionario_respondido")); |
48 | + questionario.setResponsavel(rset.getString("responsavel")); | ||
49 | + questionario.setCargoResponsavel(rset.getString("cargo_responsavel")); | ||
50 | + questionario.setTelefone(rset.getString("telefone")); | ||
51 | + questionario.setEmailDestinoOrgao(rset.getString("email_destino_orgao")); | ||
44 | } | 52 | } |
45 | 53 | ||
46 | } catch (SQLException e) { | 54 | } catch (SQLException e) { |
src/br/com/dao/PlanoTrabalhoDao.java
@@ -12,6 +12,7 @@ import java.sql.SQLException; | @@ -12,6 +12,7 @@ import java.sql.SQLException; | ||
12 | import java.sql.Statement; | 12 | import java.sql.Statement; |
13 | import java.util.Properties; | 13 | import java.util.Properties; |
14 | 14 | ||
15 | +import br.com.model.entity.PlanoTrabalho; | ||
15 | import br.com.model.entity.Questionario; | 16 | import br.com.model.entity.Questionario; |
16 | import br.com.model.utilities.ManagerProperties; | 17 | import br.com.model.utilities.ManagerProperties; |
17 | 18 | ||
@@ -59,7 +60,7 @@ public class PlanoTrabalhoDao { | @@ -59,7 +60,7 @@ public class PlanoTrabalhoDao { | ||
59 | return idPlanoTrabalho; | 60 | return idPlanoTrabalho; |
60 | } | 61 | } |
61 | 62 | ||
62 | - public boolean salvarPlanoTrabalho(String path, InputStream file, Questionario questionario) | 63 | + public boolean salvarPlanoTrabalho(String path, InputStream file, Questionario questionario, String nomeExtensao) |
63 | { | 64 | { |
64 | 65 | ||
65 | StringBuffer sql = new StringBuffer(); | 66 | StringBuffer sql = new StringBuffer(); |
@@ -71,12 +72,13 @@ public class PlanoTrabalhoDao { | @@ -71,12 +72,13 @@ public class PlanoTrabalhoDao { | ||
71 | try { | 72 | try { |
72 | 73 | ||
73 | sql = new StringBuffer(); | 74 | sql = new StringBuffer(); |
74 | - sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); | 75 | + sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho, nome_extensao) VALUES (?, ?, ?); "); |
75 | 76 | ||
76 | estado = con.prepareStatement(sql.toString()); | 77 | estado = con.prepareStatement(sql.toString()); |
77 | 78 | ||
78 | estado.setInt(1, questionario.getIdQuestionario()); | 79 | estado.setInt(1, questionario.getIdQuestionario()); |
79 | estado.setBinaryStream(2, file); | 80 | estado.setBinaryStream(2, file); |
81 | + estado.setString(3, nomeExtensao); | ||
80 | 82 | ||
81 | resultado = estado.executeUpdate(); | 83 | resultado = estado.executeUpdate(); |
82 | 84 | ||
@@ -95,7 +97,7 @@ public class PlanoTrabalhoDao { | @@ -95,7 +97,7 @@ public class PlanoTrabalhoDao { | ||
95 | return salvoComSucesso; | 97 | return salvoComSucesso; |
96 | } | 98 | } |
97 | 99 | ||
98 | - public boolean atualizarPlanoTrabalho(String path, InputStream file, Questionario questionario, int idPlanoTrabalho) | 100 | + public boolean atualizarPlanoTrabalho(String path, InputStream file, Questionario questionario, int idPlanoTrabalho, String nomeExtensao) |
99 | { | 101 | { |
100 | 102 | ||
101 | StringBuffer sql = new StringBuffer(); | 103 | StringBuffer sql = new StringBuffer(); |
@@ -109,13 +111,16 @@ public class PlanoTrabalhoDao { | @@ -109,13 +111,16 @@ public class PlanoTrabalhoDao { | ||
109 | sql = new StringBuffer(); | 111 | sql = new StringBuffer(); |
110 | //sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); | 112 | //sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); |
111 | sql.append(" UPDATE public.plano_trabalho"); | 113 | sql.append(" UPDATE public.plano_trabalho"); |
112 | - sql.append(" SET arquivo_plano_trabalho=?"); | ||
113 | - sql.append(" WHERE id_plano_trabalho= "+ idPlanoTrabalho +";"); | 114 | + sql.append(" SET arquivo_plano_trabalho=?,"); |
115 | + sql.append( " nome_extensao =? "); | ||
116 | + sql.append(" WHERE id_plano_trabalho=?;"); | ||
114 | 117 | ||
115 | estado = con.prepareStatement(sql.toString()); | 118 | estado = con.prepareStatement(sql.toString()); |
116 | 119 | ||
117 | //estado.setInt(1, questionario.getIdQuestionario()); | 120 | //estado.setInt(1, questionario.getIdQuestionario()); |
118 | - estado.setBinaryStream(1, file); | 121 | + estado.setBinaryStream(1, file); |
122 | + estado.setString(2, nomeExtensao); | ||
123 | + estado.setInt(3, idPlanoTrabalho); | ||
119 | 124 | ||
120 | resultado = estado.executeUpdate(); | 125 | resultado = estado.executeUpdate(); |
121 | 126 | ||
@@ -134,7 +139,7 @@ public class PlanoTrabalhoDao { | @@ -134,7 +139,7 @@ public class PlanoTrabalhoDao { | ||
134 | return salvoComSucesso; | 139 | return salvoComSucesso; |
135 | } | 140 | } |
136 | 141 | ||
137 | - public byte[] recuperarPlanoTrabalho(String path, Questionario questionario) | 142 | + public PlanoTrabalho recuperarPlanoTrabalho(String path, Questionario questionario) |
138 | { | 143 | { |
139 | 144 | ||
140 | 145 | ||
@@ -143,6 +148,8 @@ public class PlanoTrabalhoDao { | @@ -143,6 +148,8 @@ public class PlanoTrabalhoDao { | ||
143 | Statement estado; | 148 | Statement estado; |
144 | ResultSet rset = null; | 149 | ResultSet rset = null; |
145 | byte[] imgBytes = null; | 150 | byte[] imgBytes = null; |
151 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | ||
152 | + | ||
146 | 153 | ||
147 | try { | 154 | try { |
148 | 155 | ||
@@ -154,8 +161,11 @@ public class PlanoTrabalhoDao { | @@ -154,8 +161,11 @@ public class PlanoTrabalhoDao { | ||
154 | 161 | ||
155 | rset = estado.executeQuery(sql); | 162 | rset = estado.executeQuery(sql); |
156 | 163 | ||
157 | - while (rset.next()) { | ||
158 | - imgBytes = rset.getBytes("arquivo_plano_trabalho"); | 164 | + while (rset.next()) { |
165 | + planoTrabalho.setArquivoPlanoTrabalho(rset.getBytes("arquivo_plano_trabalho")); | ||
166 | + planoTrabalho.setIdPlanoTrabalho(rset.getInt("id_plano_trabalho")); | ||
167 | + planoTrabalho.setNomeExtensao(rset.getString("nome_extensao")); | ||
168 | + planoTrabalho.setQuestionario(questionario); | ||
159 | } | 169 | } |
160 | 170 | ||
161 | } catch (SQLException e) { | 171 | } catch (SQLException e) { |
@@ -171,7 +181,7 @@ public class PlanoTrabalhoDao { | @@ -171,7 +181,7 @@ public class PlanoTrabalhoDao { | ||
171 | } | 181 | } |
172 | } | 182 | } |
173 | 183 | ||
174 | - return imgBytes; | 184 | + return planoTrabalho; |
175 | } | 185 | } |
176 | 186 | ||
177 | } | 187 | } |
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +package br.com.model.entity; | ||
2 | + | ||
3 | +public class PlanoTrabalho { | ||
4 | + | ||
5 | + private int idPlanoTrabalho; | ||
6 | + private byte[] arquivoPlanoTrabalho; | ||
7 | + private String nomeExtensao; | ||
8 | + private Questionario questionario; | ||
9 | + | ||
10 | + public int getIdPlanoTrabalho() { | ||
11 | + return idPlanoTrabalho; | ||
12 | + } | ||
13 | + public void setIdPlanoTrabalho(int idPlanoTrabalho) { | ||
14 | + this.idPlanoTrabalho = idPlanoTrabalho; | ||
15 | + } | ||
16 | + | ||
17 | + public byte[] getArquivoPlanoTrabalho() { | ||
18 | + return arquivoPlanoTrabalho; | ||
19 | + } | ||
20 | + public void setArquivoPlanoTrabalho(byte[] arquivoPlanoTrabalho) { | ||
21 | + this.arquivoPlanoTrabalho = arquivoPlanoTrabalho; | ||
22 | + } | ||
23 | + public String getNomeExtensao() { | ||
24 | + return nomeExtensao; | ||
25 | + } | ||
26 | + public void setNomeExtensao(String nomeExtensao) { | ||
27 | + this.nomeExtensao = nomeExtensao; | ||
28 | + } | ||
29 | + public Questionario getQuestionario() { | ||
30 | + return questionario; | ||
31 | + } | ||
32 | + public void setQuestionario(Questionario questionario) { | ||
33 | + this.questionario = questionario; | ||
34 | + } | ||
35 | + | ||
36 | +} |