Commit bb65c92665671e04cdda53d5dd9fb176127330be
1 parent
fe65b51a
Exists in
master
Novas funcionalidades.
Showing
12 changed files
with
753 additions
and
263 deletions
Show diff stats
WebContent/WEB-INF/jsp/planoTrabalho/confirmacaoEnvioEmailMPF.jsp
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
2 | +<%@taglib prefix="t" tagdir="/WEB-INF/tags"%> | ||
3 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | ||
4 | +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | ||
5 | + | ||
6 | +<t:baseLayout> | ||
7 | + <jsp:body> | ||
8 | + | ||
9 | + <div class="painelSucesso"> | ||
10 | + | ||
11 | + <c:if test="${statusEnvio == true }"> | ||
12 | + <img src="imgs/afirmativo.jpg" | ||
13 | + alt="Confirmação de envio de Relatório e Plano de Trabalho ao Ministério Público Federal!"> | ||
14 | + <br> | ||
15 | + </c:if> | ||
16 | + <c:if test="${statusEnvio == false }"> | ||
17 | + <img src="imgs/negativo.gif" | ||
18 | + alt="Falha ao enviar Relatório e Plano de Trabalho ao Ministério Público Federal!"> | ||
19 | + <br> | ||
20 | + </c:if> | ||
21 | + <p> <strong>${mensagemEnvio}</strong> | ||
22 | + </p> | ||
23 | + | ||
24 | + </div> | ||
25 | + | ||
26 | + <br> | ||
27 | + <br> | ||
28 | + <a class="button" id="pPrincipal" | ||
29 | + href="${pageContext.request.contextPath}/">Página Inicial</a> | ||
30 | + <br> | ||
31 | + <br> | ||
32 | + | ||
33 | +</jsp:body> | ||
34 | +</t:baseLayout> | ||
35 | + |
WebContent/WEB-INF/jsp/planoTrabalho/planoTrabalho.jsp
@@ -31,11 +31,18 @@ | @@ -31,11 +31,18 @@ | ||
31 | <fieldset class="layoutCampos"> | 31 | <fieldset class="layoutCampos"> |
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> | ||
35 | - <label for="file">Arquivo: (tamanho máximo: 50Mb) </label> | ||
36 | - <input type="file" id="file" name="file" accept= | ||
37 | -"application/msword, application/vnd.ms-excel, application/vnd.oasis.opendocument.text , | ||
38 | -text/plain, application/pdf, image/*" required><br><br> | 34 | + <input type="password" id="valorHash" name="valorHash" size="60" maxlength="60" required><br><br> |
35 | + | ||
36 | + | ||
37 | +<label for="fileRelatorio">Arquivo de Relatório Assinado: (tamanho máximo: 50Mb) </label> | ||
38 | + <input type="file" id="fileRelatorio" name="fileRelatorio" accept= | ||
39 | +"application/msword, application/zip, application/octet-stream, application/x-rar-compressed, application/vnd.ms-excel, application/vnd.oasis.opendocument.text , | ||
40 | +text/plain, application/pdf, image/*"><br><br> | ||
41 | + | ||
42 | +<label for="filePlano">Arquivo de Plano de trabalho: (tamanho máximo: 50Mb) </label> | ||
43 | + <input type="file" id="filePlano" name="filePlano" accept= | ||
44 | +"application/msword,application/zip,application/x-rar-compressed, application/octet-stream, application/vnd.ms-excel, application/vnd.oasis.opendocument.text , | ||
45 | +text/plain, application/pdf, image/*" ><br><br> | ||
39 | <input type="submit" class="button" value="Enviar"> | 46 | <input type="submit" class="button" value="Enviar"> |
40 | </fieldset> | 47 | </fieldset> |
41 | 48 |
WebContent/WEB-INF/jsp/planoTrabalho/planoTrabalhoConfirmacao.jsp
@@ -6,25 +6,74 @@ | @@ -6,25 +6,74 @@ | ||
6 | <t:baseLayout> | 6 | <t:baseLayout> |
7 | <jsp:body> | 7 | <jsp:body> |
8 | 8 | ||
9 | + <div class="painelSucesso"> | ||
9 | 10 | ||
10 | - <div class="painelSucesso"> | ||
11 | - <c:if test="${status == true }"> | ||
12 | - <img src="imgs/afirmativo.jpg" alt="Confirmação de plano de trabalho enviado com sucesso!"><br> | 11 | + <c:if test="${statusRelatorio == true }"> |
12 | + <img src="imgs/afirmativo.jpg" | ||
13 | + alt="Confirmação de Relatório anexado com sucesso!"> | ||
14 | + <br> | ||
13 | </c:if> | 15 | </c:if> |
14 | - <c:if test="${status == false }"> | ||
15 | - <img src="imgs/negativo.gif" alt="Falha de envio de plano de trabalho!"><br> | 16 | + <c:if test="${statusRelatorio == false }"> |
17 | + <img src="imgs/negativo.gif" alt="Falha ao anexar Relatório!"> | ||
18 | + <br> | ||
16 | </c:if> | 19 | </c:if> |
17 | - <p><strong>${mensagem}</strong></p> | 20 | + <p> <strong>${mensagemRelatorio}</strong> |
21 | + </p> | ||
22 | + | ||
18 | </div> | 23 | </div> |
24 | + | ||
25 | + <div class="painelSucesso"> | ||
26 | + | ||
27 | + <c:if test="${statusPlano == true }"> | ||
28 | + <img src="imgs/afirmativo.jpg" | ||
29 | + alt="Confirmação de plano de trabalho anexado com sucesso!"> | ||
30 | + <br> | ||
31 | + </c:if> | ||
32 | + <c:if test="${statusPlano == false }"> | ||
33 | + <img src="imgs/negativo.gif" alt="Falha ao anexar plano de trabalho!"> | ||
34 | + <br> | ||
35 | + </c:if> | ||
36 | + <p> | ||
37 | + <strong>${mensagemPlano}</strong> | ||
38 | + </p> | ||
39 | + | ||
40 | + | ||
41 | + <c:if test="${statusPlano == true }"> | ||
42 | + <br> | ||
43 | + <br> | ||
44 | + <c:if test="${existeRelatorioAnexado == true }"> | ||
45 | + <label>Deseja enviar o Relatório para o Ministério Público Federal - MPF?</label> | ||
46 | + <br> | ||
47 | + <br> | ||
48 | + <strong class="atencao"> | ||
49 | + Atenção! Após o envio do Relatório ao MPF não mais será possível alterar seus dados. | ||
50 | + </strong> | ||
51 | + <br> | ||
52 | + <br> | ||
53 | + <a class="button" id="pNao" | ||
54 | + href="${pageContext.request.contextPath}/">Não</a> | ||
55 | + | ||
56 | + <a class="button" id="pSim" | ||
57 | + href="${pageContext.request.contextPath}/enviar-email-mpf">Sim</a> | ||
58 | + </c:if> | ||
59 | + </c:if> | ||
60 | + </div> | ||
61 | + | ||
62 | + | ||
63 | + | ||
19 | 64 | ||
20 | <hr class="hr_linhaDupla"> | 65 | <hr class="hr_linhaDupla"> |
21 | <h2 class="outstanding-title">Aviso:</h2> | 66 | <h2 class="outstanding-title">Aviso:</h2> |
22 | 67 | ||
23 | <ul> | 68 | <ul> |
24 | <li class="atencao">ATENÇÃO: O simples <span lang="en"><i>upload</i></span> do arquivo não faz o envio do plano de trabalho para os órgãos de controle, o plano de trabalho deverá ser enviado para a Procuradoria Federal dos Direitos do Cidadão do Ministério Público Federal até a data limite</li> | 69 | <li class="atencao">ATENÇÃO: O simples <span lang="en"><i>upload</i></span> do arquivo não faz o envio do plano de trabalho para os órgãos de controle, o plano de trabalho deverá ser enviado para a Procuradoria Federal dos Direitos do Cidadão do Ministério Público Federal até a data limite</li> |
25 | - </ul> <br><br> | 70 | + </ul> <br> |
71 | + <br> | ||
26 | 72 | ||
27 | - <a class="button" id="pPrincipal" href="${pageContext.request.contextPath}/">Página Inicial</a><br><br> | 73 | + <a class="button" id="pPrincipal" |
74 | + href="${pageContext.request.contextPath}/">Página Inicial</a> | ||
75 | + <br> | ||
76 | + <br> | ||
28 | 77 | ||
29 | </jsp:body> | 78 | </jsp:body> |
30 | </t:baseLayout> | 79 | </t:baseLayout> |
WebContent/WEB-INF/jsp/questionario/listaQuestionario.jsp
@@ -54,6 +54,8 @@ | @@ -54,6 +54,8 @@ | ||
54 | <th>Relatório Respondido</th> | 54 | <th>Relatório Respondido</th> |
55 | <th>Plano de Trabalho Enviado</th> | 55 | <th>Plano de Trabalho Enviado</th> |
56 | <th>download Plano de Trabalho</th> | 56 | <th>download Plano de Trabalho</th> |
57 | + <th>download Relatório Assinado</th> | ||
58 | + <th>Visualizar Relatório</th> | ||
57 | 59 | ||
58 | </tr> | 60 | </tr> |
59 | 61 | ||
@@ -95,8 +97,12 @@ | @@ -95,8 +97,12 @@ | ||
95 | <c:if test="${questionario.planoTrabalhoEnviado == false}"> | 97 | <c:if test="${questionario.planoTrabalhoEnviado == false}"> |
96 | <td><input type="checkbox" disabled="disabled"> </td> | 98 | <td><input type="checkbox" disabled="disabled"> </td> |
97 | </c:if> | 99 | </c:if> |
98 | - <td><a | ||
99 | - href="${pageContext.request.contextPath}/recuperar-plano-trabalho/${questionario.idQuestionario}">Recuperar</a></td> | 100 | + <td> |
101 | + <a href="${pageContext.request.contextPath}/recuperar-plano-trabalho/${questionario.idQuestionario}">Plano de Trabalho</a></td> | ||
102 | + <td> | ||
103 | + <a href="${pageContext.request.contextPath}/recuperar-relatorio/${questionario.idQuestionario}">Relatório Assinado</a></td> | ||
104 | + <td><a | ||
105 | + href="${pageContext.request.contextPath}/relatorio-imprimir/${questionario.idQuestionario}">Visualizar Relatório</a></td> | ||
100 | </tr> | 106 | </tr> |
101 | 107 | ||
102 | </c:forEach> | 108 | </c:forEach> |
WebContent/WEB-INF/mail.properties
@@ -7,4 +7,5 @@ prop.email.authpass = "" | @@ -7,4 +7,5 @@ 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 = fabricio.souza@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 | +prop.email.anexosTo = gibran.sodre@planejamento.gov.br | ||
12 | \ No newline at end of file | 13 | \ 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.IOException; | 3 | import java.io.IOException; |
4 | +import java.util.ArrayList; | ||
5 | +import java.util.List; | ||
4 | 6 | ||
5 | import javax.servlet.ServletContext; | 7 | import javax.servlet.ServletContext; |
6 | import javax.servlet.ServletOutputStream; | 8 | import javax.servlet.ServletOutputStream; |
@@ -13,6 +15,7 @@ import br.com.caelum.vraptor.Result; | @@ -13,6 +15,7 @@ import br.com.caelum.vraptor.Result; | ||
13 | import br.com.caelum.vraptor.Validator; | 15 | import br.com.caelum.vraptor.Validator; |
14 | import br.com.caelum.vraptor.interceptor.multipart.DefaultMultipartConfig; | 16 | import br.com.caelum.vraptor.interceptor.multipart.DefaultMultipartConfig; |
15 | import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; | 17 | import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; |
18 | +import br.com.caelum.vraptor.ioc.spring.VRaptorRequestHolder; | ||
16 | import br.com.caelum.vraptor.validator.ValidationMessage; | 19 | import br.com.caelum.vraptor.validator.ValidationMessage; |
17 | import br.com.dao.HashDao; | 20 | import br.com.dao.HashDao; |
18 | import br.com.dao.PlanoTrabalhoDao; | 21 | import br.com.dao.PlanoTrabalhoDao; |
@@ -21,7 +24,7 @@ import br.com.model.entity.Questionario; | @@ -21,7 +24,7 @@ import br.com.model.entity.Questionario; | ||
21 | 24 | ||
22 | 25 | ||
23 | @Resource | 26 | @Resource |
24 | -public class PlanoTrabalhoController extends DefaultMultipartConfig { | 27 | +public class PlanoTrabalhoController extends DefaultMultipartConfig { |
25 | 28 | ||
26 | private Validator validator; | 29 | private Validator validator; |
27 | private Result result; | 30 | private Result result; |
@@ -34,10 +37,10 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | @@ -34,10 +37,10 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | ||
34 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; | 37 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; |
35 | this.result = result; | 38 | this.result = result; |
36 | } | 39 | } |
37 | - | 40 | + |
38 | // alteramos o tamanho total do upload para 50MB | 41 | // alteramos o tamanho total do upload para 50MB |
39 | public long getSizeLimit() { | 42 | public long getSizeLimit() { |
40 | - return 50 * 1024 * 1024; | 43 | + return 50 * 1024 * 1024; |
41 | } | 44 | } |
42 | 45 | ||
43 | @Path("/planoTrabalho-site") | 46 | @Path("/planoTrabalho-site") |
@@ -50,72 +53,158 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | @@ -50,72 +53,158 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | ||
50 | 53 | ||
51 | } | 54 | } |
52 | 55 | ||
53 | - | ||
54 | - @Path("/salvar-plano-trabalho") | ||
55 | - public void enviarPlanoTrabalho(String valorHash, UploadedFile file) { | ||
56 | 56 | ||
57 | - String mensagem = "Não foi possível enviar o plano de trabalho!"; | ||
58 | - boolean status = false; | ||
59 | - | ||
60 | - if(file != null) | ||
61 | - { | ||
62 | - String tipoArquivo = file.getContentType(); | ||
63 | - | ||
64 | - int idPlanoTrabalho = -1; | ||
65 | - | ||
66 | - if (!tipoArquivo.equalsIgnoreCase("application/msword") | ||
67 | - && !tipoArquivo.equalsIgnoreCase("application/vnd.ms-excel") | ||
68 | - && !tipoArquivo.equalsIgnoreCase("application/vnd.oasis.opendocument.text") | ||
69 | - && !tipoArquivo.equalsIgnoreCase("text/plain") | ||
70 | - && !tipoArquivo.equalsIgnoreCase("application/pdf") | ||
71 | - && !tipoArquivo.equalsIgnoreCase("image/png") && !tipoArquivo.equalsIgnoreCase("image/gif") | ||
72 | - && !tipoArquivo.equalsIgnoreCase("image/jpeg")) { | ||
73 | - | ||
74 | - mensagem = "Formato de Arquivo inválido!"; | ||
75 | - status = false; | ||
76 | - | ||
77 | - } else { | ||
78 | - HashDao hashDao = new HashDao(); | ||
79 | - Questionario questionario = new Questionario(); | ||
80 | - questionario = hashDao.verificarHash(path, valorHash); | ||
81 | - String nomeExtensao = file.getFileName(); | ||
82 | - | 57 | + @Path("/salvar-plano-trabalho") |
58 | + public void enviarPlanoTrabalho(String valorHash, UploadedFile filePlano, | ||
59 | + UploadedFile fileRelatorio) { | ||
60 | + | ||
61 | + String mensagemPlano = null; | ||
62 | + String mensagemRelatorio = null; | ||
63 | + boolean statusPlano = false; | ||
64 | + boolean statusRelatorio = false; | ||
65 | + boolean existeRelatorioAnexado = false; | ||
66 | + Questionario questionario = new Questionario(); | ||
67 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | ||
68 | + | ||
69 | + if (filePlano != null) { | ||
70 | + String tipoArquivo = filePlano.getContentType(); | ||
71 | + | ||
72 | + | ||
73 | + if (!tipoArquivo.equalsIgnoreCase("application/msword") | ||
74 | + && !tipoArquivo.equalsIgnoreCase("application/vnd.ms-excel") | ||
75 | + && !tipoArquivo.equalsIgnoreCase("application/vnd.oasis.opendocument.text") | ||
76 | + && !tipoArquivo.equalsIgnoreCase("text/plain") | ||
77 | + && !tipoArquivo.equalsIgnoreCase("application/pdf") | ||
78 | + && !tipoArquivo.equalsIgnoreCase("image/png") | ||
79 | + && !tipoArquivo.equalsIgnoreCase("image/gif") | ||
80 | + && !tipoArquivo.equalsIgnoreCase("image/jpeg") | ||
81 | + && !tipoArquivo.equalsIgnoreCase("application/zip") | ||
82 | + && !tipoArquivo.equalsIgnoreCase("application/x-rar-compressed") | ||
83 | + && !tipoArquivo.equalsIgnoreCase("application/octet-stream")) { | ||
84 | + | ||
85 | + mensagemPlano = "Formato de Arquivo para plano de trabalho inválido!"; | ||
86 | + statusPlano = false; | ||
87 | + | ||
88 | + } else { | ||
89 | + HashDao hashDao = new HashDao(); | ||
90 | + questionario = new Questionario(); | ||
91 | + questionario = hashDao.verificarHash(path, valorHash); | ||
92 | + String nomeExtensaoPlanoTrabalho = filePlano.getFileName(); | ||
93 | + | ||
83 | if (questionario != null && questionario.getDtInicioQuestionario() != null) { | 94 | if (questionario != null && questionario.getDtInicioQuestionario() != null) { |
84 | PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | 95 | PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); |
85 | 96 | ||
86 | - idPlanoTrabalho = | ||
87 | - planoTrabalhoDao.verificaPlanoTrabalho(path, questionario.getIdQuestionario()); | 97 | + planoTrabalho = |
98 | + planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
88 | 99 | ||
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; | 100 | + if (planoTrabalho.getArquivoPlanoTrabalho() == null) { |
101 | + if (planoTrabalhoDao.salvarPlanoTrabalho(path, filePlano.getFile(), questionario, | ||
102 | + nomeExtensaoPlanoTrabalho)) { | ||
103 | + mensagemPlano = "Plano de trabalho anexado com sucesso!"; | ||
104 | + statusPlano = true; | ||
94 | } else { | 105 | } else { |
95 | - mensagem = "Não foi possível enviar o plano de trabalho!"; | 106 | + mensagemPlano = "Não foi possível anexar o plano de trabalho!"; |
96 | } | 107 | } |
97 | } else { | 108 | } else { |
98 | - if (planoTrabalhoDao.atualizarPlanoTrabalho(path, file.getFile(), questionario, | ||
99 | - idPlanoTrabalho, nomeExtensao)) { | ||
100 | - mensagem = "Plano de trabalho enviado com sucesso!"; | ||
101 | - status = true; | 109 | + if (planoTrabalhoDao.atualizarPlanoTrabalho(path, filePlano.getFile(), questionario, |
110 | + planoTrabalho.getIdPlanoTrabalho(), nomeExtensaoPlanoTrabalho)) { | ||
111 | + mensagemPlano = "Plano de trabalho anexado com sucesso!"; | ||
112 | + statusPlano = true; | ||
102 | } else { | 113 | } else { |
103 | - mensagem = "Não foi possível enviar o plano de trabalho!"; | 114 | + mensagemPlano = "Não foi possível anexar o plano de trabalho!"; |
104 | } | 115 | } |
105 | } | 116 | } |
106 | 117 | ||
107 | } else { | 118 | } else { |
108 | - mensagem = "Favor verificar o Código de Acesso!"; | 119 | + mensagemPlano = "Favor verificar o Código de Acesso!"; |
109 | } | 120 | } |
121 | + | ||
122 | + } | ||
123 | + | ||
124 | + if(planoTrabalho.getArquivoRelatorioAss() != null) | ||
125 | + { | ||
126 | + existeRelatorioAnexado = true; | ||
127 | + } | ||
110 | 128 | ||
129 | + result.include("mensagemPlano", mensagemPlano); | ||
130 | + result.include("statusPlano", statusPlano); | ||
131 | + result.include("existeRelatorioAnexado", existeRelatorioAnexado); | ||
111 | } | 132 | } |
133 | + | ||
134 | + | ||
135 | + // /Relatório Assinado | ||
136 | + | ||
137 | + if (fileRelatorio != null) { | ||
138 | + String tipoArquivo = fileRelatorio.getContentType(); | ||
139 | + | ||
140 | + if (!tipoArquivo.equalsIgnoreCase("application/msword") | ||
141 | + && !tipoArquivo.equalsIgnoreCase("application/vnd.ms-excel") | ||
142 | + && !tipoArquivo.equalsIgnoreCase("application/vnd.oasis.opendocument.text") | ||
143 | + && !tipoArquivo.equalsIgnoreCase("text/plain") | ||
144 | + && !tipoArquivo.equalsIgnoreCase("application/pdf") | ||
145 | + && !tipoArquivo.equalsIgnoreCase("image/png") | ||
146 | + && !tipoArquivo.equalsIgnoreCase("image/gif") | ||
147 | + && !tipoArquivo.equalsIgnoreCase("image/jpeg") | ||
148 | + && !tipoArquivo.equalsIgnoreCase("application/zip") | ||
149 | + && !tipoArquivo.equalsIgnoreCase("application/x-rar-compressed") | ||
150 | + && !tipoArquivo.equalsIgnoreCase("application/octet-stream")) { | ||
151 | + | ||
152 | + mensagemRelatorio = "Formato de Arquivo para Relatório é inválido!"; | ||
153 | + statusRelatorio = false; | ||
154 | + | ||
155 | + } else { | ||
156 | + HashDao hashDao = new HashDao(); | ||
157 | + questionario = new Questionario(); | ||
158 | + questionario = hashDao.verificarHash(path, valorHash); | ||
159 | + String nomeExtensaoRelatorio = fileRelatorio.getFileName(); | ||
160 | + | ||
161 | + if (questionario != null && questionario.getDtInicioQuestionario() != null) { | ||
162 | + PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
163 | + planoTrabalho = new PlanoTrabalho(); | ||
164 | + | ||
165 | + planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
166 | + | ||
167 | + if (planoTrabalho.getArquivoRelatorioAss() == null) { | ||
168 | + if (planoTrabalhoDao.salvarRelatorioAss(path, fileRelatorio.getFile(), questionario, | ||
169 | + nomeExtensaoRelatorio)) { | ||
170 | + mensagemRelatorio = "Relatório anexado com sucesso!"; | ||
171 | + statusRelatorio = true; | ||
172 | + } else { | ||
173 | + mensagemRelatorio = "Não foi possível anexar o Relatório!"; | ||
174 | + } | ||
175 | + } else { | ||
176 | + if (planoTrabalhoDao.atualizarRelatorioAss(path, fileRelatorio.getFile(), questionario, | ||
177 | + planoTrabalho.getIdPlanoTrabalho(), nomeExtensaoRelatorio)) { | ||
178 | + mensagemRelatorio = "Relatório anexado com sucesso!"; | ||
179 | + statusRelatorio = true; | ||
180 | + } else { | ||
181 | + mensagemRelatorio = "Não foi possível anexar o Relatório!"; | ||
182 | + } | ||
183 | + } | ||
184 | + | ||
185 | + } else { | ||
186 | + mensagemRelatorio = "Favor verificar o Código de Acesso!"; | ||
187 | + } | ||
188 | + | ||
189 | + } | ||
190 | + result.include("mensagemRelatorio", mensagemRelatorio); | ||
191 | + result.include("statusRelatorio", statusRelatorio); | ||
192 | + VRaptorRequestHolder.currentRequest().getServletContext() | ||
193 | + .setAttribute("questionario", questionario); | ||
194 | + VRaptorRequestHolder.currentRequest().getServletContext() | ||
195 | + .setAttribute("fileRelatorio", fileRelatorio); | ||
112 | } | 196 | } |
113 | - else | ||
114 | - { | ||
115 | - mensagem = "O arquivo não pode ser maior que 50Mb!"; | 197 | + |
198 | + | ||
199 | + if (filePlano == null && fileRelatorio == null) { | ||
200 | + mensagemPlano = "Não foi possível anexar o Plano de Trabalho!"; | ||
201 | + mensagemRelatorio = "Não foi possível anexar o Relatório!"; | ||
202 | + result.include("mensagemPlano", mensagemPlano); | ||
203 | + result.include("statusPlano", statusPlano); | ||
204 | + result.include("mensagemRelatorio", mensagemRelatorio); | ||
205 | + result.include("statusRelatorio", statusRelatorio); | ||
116 | } | 206 | } |
117 | - result.include("mensagem", mensagem); | ||
118 | - result.include("status", status); | 207 | + |
119 | this.validator.add(new ValidationMessage("", "")); | 208 | this.validator.add(new ValidationMessage("", "")); |
120 | this.validator.onErrorUsePageOf(PlanoTrabalhoController.class).planoTrabalhoConfirmacao(); | 209 | this.validator.onErrorUsePageOf(PlanoTrabalhoController.class).planoTrabalhoConfirmacao(); |
121 | } | 210 | } |
@@ -132,12 +221,11 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | @@ -132,12 +221,11 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | ||
132 | 221 | ||
133 | if (questionario != null && questionario.getIdQuestionario() > 0) { | 222 | if (questionario != null && questionario.getIdQuestionario() > 0) { |
134 | planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | 223 | planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); |
135 | - | ||
136 | - if(planoTrabalho != null) | ||
137 | - { | 224 | + |
225 | + if (planoTrabalho != null) { | ||
138 | try { | 226 | try { |
139 | - String nome = planoTrabalho.getNomeExtensao(); | ||
140 | - dados = planoTrabalho.getArquivoPlanoTrabalho(); | 227 | + String nome = planoTrabalho.getNomeExtensaoPlanoTrabalho(); |
228 | + dados = planoTrabalho.getArquivoPlanoTrabalho(); | ||
141 | response.setContentType("inline/download"); | 229 | response.setContentType("inline/download"); |
142 | String arq = "attachment;filename=" + nome; | 230 | String arq = "attachment;filename=" + nome; |
143 | response.setHeader("Content-Disposition", arq); | 231 | response.setHeader("Content-Disposition", arq); |
@@ -146,7 +234,38 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | @@ -146,7 +234,38 @@ public class PlanoTrabalhoController extends DefaultMultipartConfig { | ||
146 | os.flush(); | 234 | os.flush(); |
147 | os.close(); | 235 | os.close(); |
148 | } catch (Exception e) { | 236 | } catch (Exception e) { |
149 | - | 237 | + |
238 | + } | ||
239 | + } | ||
240 | + } | ||
241 | + } | ||
242 | + | ||
243 | + @Get("/recuperar-relatorio/{id}") | ||
244 | + public void recuperarRelatorio(int id, HttpServletResponse response) throws IOException { | ||
245 | + | ||
246 | + Questionario questionario = new Questionario(path, id); | ||
247 | + | ||
248 | + PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
249 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | ||
250 | + | ||
251 | + byte[] dados = null; | ||
252 | + | ||
253 | + if (questionario != null && questionario.getIdQuestionario() > 0) { | ||
254 | + planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
255 | + | ||
256 | + if (planoTrabalho != null) { | ||
257 | + try { | ||
258 | + String nome = planoTrabalho.getNomeExtensaoRelatorioAss(); | ||
259 | + dados = planoTrabalho.getArquivoRelatorioAss(); | ||
260 | + response.setContentType("inline/download"); | ||
261 | + String arq = "attachment;filename=" + nome; | ||
262 | + response.setHeader("Content-Disposition", arq); | ||
263 | + ServletOutputStream os = response.getOutputStream(); | ||
264 | + os.write(dados); | ||
265 | + os.flush(); | ||
266 | + os.close(); | ||
267 | + } catch (Exception e) { | ||
268 | + | ||
150 | } | 269 | } |
151 | } | 270 | } |
152 | } | 271 | } |
src/br/com/controller/QuestionarioController.java
@@ -62,7 +62,7 @@ public class QuestionarioController { | @@ -62,7 +62,7 @@ public class QuestionarioController { | ||
62 | 62 | ||
63 | @Path("/lista-questionario") | 63 | @Path("/lista-questionario") |
64 | public void listaQuestionario() { | 64 | public void listaQuestionario() { |
65 | - | 65 | + listarQuestionarioComFiltro("todos", "todos",""); |
66 | } | 66 | } |
67 | 67 | ||
68 | @Path("/listar-questionario") | 68 | @Path("/listar-questionario") |
@@ -81,8 +81,6 @@ public class QuestionarioController { | @@ -81,8 +81,6 @@ public class QuestionarioController { | ||
81 | this.validator.onErrorUsePageOf(QuestionarioController.class).listaQuestionario(); | 81 | this.validator.onErrorUsePageOf(QuestionarioController.class).listaQuestionario(); |
82 | 82 | ||
83 | 83 | ||
84 | - | ||
85 | - | ||
86 | } | 84 | } |
87 | 85 | ||
88 | @Path("/salvar-questionario") | 86 | @Path("/salvar-questionario") |
src/br/com/controller/formularioOrgaoController.java
@@ -66,7 +66,9 @@ public class formularioOrgaoController { | @@ -66,7 +66,9 @@ public class formularioOrgaoController { | ||
66 | questionario = new Questionario(); | 66 | questionario = new Questionario(); |
67 | questionario = hashDao.verificarHash(path, valorHash); | 67 | questionario = hashDao.verificarHash(path, valorHash); |
68 | 68 | ||
69 | - | 69 | + if(!questionario.isFlagEnviado()) |
70 | + { | ||
71 | + | ||
70 | if (questionario.getDtInicioQuestionario() != null && !valorHash.equalsIgnoreCase("")) { | 72 | if (questionario.getDtInicioQuestionario() != null && !valorHash.equalsIgnoreCase("")) { |
71 | 73 | ||
72 | VRaptorRequestHolder.currentRequest().getServletContext() | 74 | VRaptorRequestHolder.currentRequest().getServletContext() |
@@ -119,6 +121,20 @@ public class formularioOrgaoController { | @@ -119,6 +121,20 @@ public class formularioOrgaoController { | ||
119 | } | 121 | } |
120 | } | 122 | } |
121 | } | 123 | } |
124 | + } | ||
125 | + else | ||
126 | + { | ||
127 | + validacao = new Validacao(); | ||
128 | + validacao.setCampo("valorHash"); | ||
129 | + validacao | ||
130 | + .setMensagem("Não é mais permitido alterar seus dados!"); | ||
131 | + | ||
132 | + mensagemValidacaoCampos.add(validacao); | ||
133 | + | ||
134 | + result.include("mensagemValidacaoCampos", mensagemValidacaoCampos); | ||
135 | + this.validator.add(new ValidationMessage("", "")); | ||
136 | + this.validator.onErrorUsePageOf(loginController.class).login(); | ||
137 | + } | ||
122 | } | 138 | } |
123 | 139 | ||
124 | private void setValorCamposUrl(String nomeCampo, String valorCampo) | 140 | private void setValorCamposUrl(String nomeCampo, String valorCampo) |
src/br/com/controller/relatorioController.java
1 | package br.com.controller; | 1 | package br.com.controller; |
2 | 2 | ||
3 | +import java.io.File; | ||
4 | +import java.io.InputStream; | ||
3 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
4 | import java.util.List; | 6 | import java.util.List; |
5 | 7 | ||
8 | +import javax.activation.DataHandler; | ||
9 | +import javax.activation.FileDataSource; | ||
6 | import javax.servlet.ServletContext; | 10 | import javax.servlet.ServletContext; |
7 | 11 | ||
12 | +import org.apache.commons.fileupload.FileUpload; | ||
13 | + | ||
8 | import br.com.caelum.vraptor.Get; | 14 | import br.com.caelum.vraptor.Get; |
9 | import br.com.caelum.vraptor.Path; | 15 | import br.com.caelum.vraptor.Path; |
10 | import br.com.caelum.vraptor.Resource; | 16 | import br.com.caelum.vraptor.Resource; |
11 | import br.com.caelum.vraptor.Result; | 17 | import br.com.caelum.vraptor.Result; |
12 | import br.com.caelum.vraptor.Validator; | 18 | import br.com.caelum.vraptor.Validator; |
19 | +import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; | ||
20 | +import br.com.caelum.vraptor.ioc.spring.VRaptorRequestHolder; | ||
13 | import br.com.caelum.vraptor.validator.ValidationMessage; | 21 | import br.com.caelum.vraptor.validator.ValidationMessage; |
14 | import br.com.dao.HashDao; | 22 | import br.com.dao.HashDao; |
23 | +import br.com.dao.PlanoTrabalhoDao; | ||
24 | +import br.com.dao.QuestionarioDao; | ||
15 | import br.com.dao.RespostaQuestionarioDao; | 25 | import br.com.dao.RespostaQuestionarioDao; |
16 | import br.com.model.entity.AmostragemSiteQuestionario; | 26 | import br.com.model.entity.AmostragemSiteQuestionario; |
27 | +import br.com.model.entity.EnvioEmailSemAutenticacao; | ||
28 | +import br.com.model.entity.PlanoTrabalho; | ||
17 | import br.com.model.entity.Questionario; | 29 | import br.com.model.entity.Questionario; |
18 | import br.com.model.entity.RespostaQuestionario; | 30 | import br.com.model.entity.RespostaQuestionario; |
31 | +import br.com.model.utilities.Email; | ||
19 | import br.com.util.Validacao; | 32 | import br.com.util.Validacao; |
20 | 33 | ||
21 | @Resource | 34 | @Resource |
22 | public class relatorioController { | 35 | public class relatorioController { |
23 | - | 36 | + |
24 | private List<Validacao> mensagemValidacaoCampos = new ArrayList<Validacao>(); | 37 | private List<Validacao> mensagemValidacaoCampos = new ArrayList<Validacao>(); |
25 | private Result result; | 38 | private Result result; |
26 | private Validator validator; | 39 | private Validator validator; |
27 | private Questionario questionario; | 40 | private Questionario questionario; |
28 | private ServletContext application; | 41 | private ServletContext application; |
29 | private String path; | 42 | private String path; |
30 | - | 43 | + |
31 | public relatorioController(Result result, Validator validator, ServletContext application) { | 44 | public relatorioController(Result result, Validator validator, ServletContext application) { |
32 | this.result = result; | 45 | this.result = result; |
33 | this.validator = validator; | 46 | this.validator = validator; |
34 | this.application = application; | 47 | this.application = application; |
35 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; | 48 | this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; |
36 | } | 49 | } |
37 | - | ||
38 | - | ||
39 | - @Path("/relatorio-site") | ||
40 | - public void relatorio(){ | ||
41 | - | ||
42 | - | ||
43 | - } | ||
44 | - | ||
45 | - @Path("/relatorio-imprimir") | ||
46 | - @Get("/relatorio-imprimir/{idQuestionario}") | ||
47 | - public void relatorioImprimir(String idQuestionario, String valorHash) | ||
48 | - { | ||
49 | - if (idQuestionario != null) { | ||
50 | - gerarRelatorio(Integer.parseInt(idQuestionario)); | 50 | + |
51 | + | ||
52 | + @Path("/relatorio-site") | ||
53 | + public void relatorio() { | ||
54 | + | ||
55 | + } | ||
56 | + | ||
57 | + @Path("/relatorio-imprimir") | ||
58 | + public void relatorioImprimir(String idQuestionario, String valorHash) { | ||
59 | + if (idQuestionario != null) { | ||
60 | + gerarRelatorio(Integer.parseInt(idQuestionario)); | ||
61 | + } else if (valorHash != null) { | ||
62 | + Validacao validacao = new Validacao(); | ||
63 | + mensagemValidacaoCampos = new ArrayList<Validacao>(); | ||
64 | + mensagemValidacaoCampos = validacao.validarHashEmitirRelatorio(path, valorHash); | ||
65 | + | ||
66 | + if (mensagemValidacaoCampos.size() > 0) { | ||
67 | + result.include("mensagemValidacaoCampos", mensagemValidacaoCampos); | ||
68 | + this.validator.add(new ValidationMessage("", "")); | ||
69 | + this.validator.onErrorUsePageOf(relatorioController.class).relatorio(); | ||
51 | } | 70 | } |
52 | - else if (valorHash != null) | ||
53 | - { | ||
54 | - Validacao validacao = new Validacao(); | ||
55 | - mensagemValidacaoCampos = new ArrayList<Validacao>(); | ||
56 | - mensagemValidacaoCampos = validacao.validarHashEmitirRelatorio(path, valorHash); | ||
57 | - | ||
58 | - if (mensagemValidacaoCampos.size() > 0) { | ||
59 | - result.include("mensagemValidacaoCampos", mensagemValidacaoCampos); | ||
60 | - this.validator.add(new ValidationMessage("", "")); | ||
61 | - this.validator.onErrorUsePageOf(relatorioController.class).relatorio(); | ||
62 | - } | ||
63 | 71 | ||
64 | - HashDao hashDao = new HashDao(); | ||
65 | - questionario = new Questionario(); | ||
66 | - questionario = hashDao.verificarHash(path, valorHash); | ||
67 | - | ||
68 | - if (questionario.getDtInicioQuestionario() != null && questionario.isQuestionario_respondido()) { | ||
69 | - gerarRelatorio(questionario.getIdQuestionario()); | ||
70 | - } | ||
71 | - | 72 | + HashDao hashDao = new HashDao(); |
73 | + questionario = new Questionario(); | ||
74 | + questionario = hashDao.verificarHash(path, valorHash); | ||
75 | + | ||
76 | + if (questionario.getDtInicioQuestionario() != null | ||
77 | + && questionario.isQuestionario_respondido()) { | ||
78 | + gerarRelatorio(questionario.getIdQuestionario()); | ||
72 | } | 79 | } |
80 | + | ||
73 | } | 81 | } |
82 | + } | ||
83 | + | ||
84 | + @Path("/enviar-email-mpf") | ||
85 | + public void enviarEmailMPF() { | ||
86 | + Questionario questionario = new Questionario(); | ||
87 | + QuestionarioDao questionarioDao; | ||
74 | 88 | ||
75 | - private void gerarRelatorio(int idQuestionario) | ||
76 | - { | ||
77 | - Questionario questionario = new Questionario(path, idQuestionario); | ||
78 | - RespostaQuestionarioDao respostaQuestionarioDao = new RespostaQuestionarioDao(); | ||
79 | - | ||
80 | - List<RespostaQuestionario> lsRespostaQuestionario = new ArrayList<RespostaQuestionario>(); | ||
81 | - List<AmostragemSiteQuestionario> lsAmostragemSiteQuestionario = | ||
82 | - new ArrayList<AmostragemSiteQuestionario>(); | ||
83 | - | ||
84 | - lsRespostaQuestionario = | ||
85 | - respostaQuestionarioDao.retornarRespostaQuestionarioPorQuestionario(path, questionario | ||
86 | - .getIdQuestionario()); | ||
87 | - | ||
88 | - List<String> curso = new ArrayList<String>(); | ||
89 | - List<String> simValidacao = new ArrayList<String>(); | ||
90 | - List<String> assistiva = new ArrayList<String>(); | ||
91 | - List<String> deficiencias = new ArrayList<String>(); | ||
92 | - List<String> ferramentaValidacao = new ArrayList<String>(); | ||
93 | - | ||
94 | - for (RespostaQuestionario respostaQuestionario : lsRespostaQuestionario) { | ||
95 | - | ||
96 | - switch (respostaQuestionario.getPergunta().getIdPergunta()) { | ||
97 | - case 1: | ||
98 | - result.include("nomeOrgao", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
99 | - break; | ||
100 | - case 2: | ||
101 | - result.include("nomePessoa", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
102 | - break; | ||
103 | - case 3: | ||
104 | - result.include("cargo", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
105 | - break; | ||
106 | - case 4: | ||
107 | - result.include("telefone", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
108 | - break; | ||
109 | - case 5: | ||
110 | - result.include("email", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
111 | - break; | ||
112 | - case 7: | ||
113 | - result.include("perguntaAcessibilidade", respostaQuestionario.getOpcaoResposta() | ||
114 | - .getDescOpcaoResposta()); | ||
115 | - break; | ||
116 | - case 8: | ||
117 | - result.include("reclamacao", respostaQuestionario.getOpcaoResposta() | ||
118 | - .getDescOpcaoResposta()); | ||
119 | - break; | ||
120 | - case 9: | ||
121 | - result.include("espacoReclamacao", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
122 | - break; | ||
123 | - case 10: | ||
124 | - result.include("perguntaEstimulo", respostaQuestionario.getOpcaoResposta() | ||
125 | - .getDescOpcaoResposta()); | ||
126 | - break; | ||
127 | - case 11: | ||
128 | - curso.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
129 | - break; | ||
130 | - case 12: | ||
131 | - result.include("requisito", respostaQuestionario.getOpcaoResposta() | ||
132 | - .getDescOpcaoResposta()); | ||
133 | - break; | ||
134 | - case 13: | ||
135 | - result.include("justificativaRequisito", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
136 | - break; | ||
137 | - case 14: | ||
138 | - result.include("opcaoContrat", respostaQuestionario.getOpcaoResposta() | ||
139 | - .getDescOpcaoResposta()); | ||
140 | - break; | ||
141 | - case 15: | ||
142 | - result.include("perguntaValidacao", respostaQuestionario.getOpcaoResposta() | ||
143 | - .getDescOpcaoResposta()); | ||
144 | - break; | ||
145 | - case 16: | ||
146 | - simValidacao.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
147 | - break; | ||
148 | - case 17: | ||
149 | - ferramentaValidacao.add(respostaQuestionario.getOpcaoResposta() | ||
150 | - .getDescOpcaoResposta()); | ||
151 | - break; | ||
152 | - case 18: | ||
153 | - result.include("outroAvaliador", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
154 | - break; | ||
155 | - case 19: | ||
156 | - | ||
157 | - lsAmostragemSiteQuestionario.add(respostaQuestionario.getAmostragemSiteQuestionario()); | ||
158 | - break; | ||
159 | - /* case 20: | ||
160 | - result.include("nivelWcag", respostaQuestionario.getOpcaoResposta() | ||
161 | - .getDescOpcaoResposta()); | ||
162 | - break;*/ | ||
163 | - case 21: | ||
164 | - result.include("checklistQtnList", respostaQuestionario.getOpcaoResposta() | ||
165 | - .getDescOpcaoResposta()); | ||
166 | - break; | ||
167 | - case 22: | ||
168 | - deficiencias.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
169 | - break; | ||
170 | - case 23: | ||
171 | - result.include("funcionalidade", respostaQuestionario.getOpcaoResposta() | ||
172 | - .getDescOpcaoResposta()); | ||
173 | - break; | ||
174 | - case 24: | ||
175 | - assistiva.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
176 | - break; | ||
177 | - case 25: | ||
178 | - result.include("justificativaAssistiva", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
179 | - break; | ||
180 | - case 26: | ||
181 | - result.include("dificuldadePrazo", respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ?respostaQuestionario.getTextoResposta().replace("null", "Não Respondido"):respostaQuestionario.getTextoResposta()); | ||
182 | - break; | ||
183 | - default: | ||
184 | - break; | 89 | + UploadedFile fileRelatorio; |
90 | + | ||
91 | + String mensagemMPF = ""; | ||
92 | + String mensagemOrgao = ""; | ||
93 | + String assuntoMPF = ""; | ||
94 | + String assuntoOrgao = ""; | ||
95 | + | ||
96 | + questionario = | ||
97 | + (Questionario) VRaptorRequestHolder.currentRequest().getServletContext() | ||
98 | + .getAttribute("questionario"); | ||
99 | + | ||
100 | + fileRelatorio = | ||
101 | + (UploadedFile) VRaptorRequestHolder.currentRequest().getServletContext() | ||
102 | + .getAttribute("fileRelatorio"); | ||
103 | + | ||
104 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | ||
105 | + PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
106 | + | ||
107 | + planoTrabalho = planoTrabalhoDao.recuperarPlanoTrabalho(path, questionario); | ||
108 | + | ||
109 | + DataHandler dataHandlerRelatorio; | ||
110 | + DataHandler dataHandlerPlano; | ||
111 | + | ||
112 | + dataHandlerRelatorio = | ||
113 | + new DataHandler(planoTrabalho.getArquivoRelatorioAss(), fileRelatorio.getContentType()); | ||
114 | + dataHandlerPlano = | ||
115 | + new DataHandler(planoTrabalho.getArquivoPlanoTrabalho(), fileRelatorio.getContentType()); | ||
116 | + | ||
117 | + Email email = new Email(this.application.getRealPath("") + "/WEB-INF/mail.properties"); | ||
118 | + | ||
119 | + EnvioEmailSemAutenticacao envioEmailSemAutenticacao = | ||
120 | + new EnvioEmailSemAutenticacao(email.getHost(), Integer.toString(email.getPort())); | ||
121 | + | ||
122 | + | ||
123 | + String mensagemRetornoMPF = | ||
124 | + envioEmailSemAutenticacao.sendMailComAnexo(questionario.getEmailDestinoOrgao(), | ||
125 | + email.getAnexosTo(), assuntoMPF, mensagemMPF, email.getAuth(), email.getAuthUser(), | ||
126 | + email.getAuthPass(), dataHandlerRelatorio, planoTrabalho.getNomeExtensaoRelatorioAss(), | ||
127 | + dataHandlerPlano, planoTrabalho.getNomeExtensaoPlanoTrabalho()); | ||
128 | + | ||
129 | + if (mensagemRetornoMPF.equalsIgnoreCase("")) { | ||
130 | + String mensagemRetornoOrgao = | ||
131 | + envioEmailSemAutenticacao.sendMailComAnexo(email.getFrom(), | ||
132 | + questionario.getEmailDestinoOrgao(), assuntoOrgao, mensagemOrgao, email.getAuth(), | ||
133 | + email.getAuthUser(), email.getAuthPass(), dataHandlerRelatorio, | ||
134 | + planoTrabalho.getNomeExtensaoRelatorioAss(), dataHandlerPlano, | ||
135 | + planoTrabalho.getNomeExtensaoPlanoTrabalho()); | ||
136 | + | ||
137 | + | ||
138 | + if (mensagemRetornoOrgao.equalsIgnoreCase("")) { | ||
139 | + | ||
140 | + questionarioDao = new QuestionarioDao(); | ||
141 | + | ||
142 | + if(questionarioDao.atualizarFlagEnviado(path, questionario.getIdQuestionario())) | ||
143 | + { | ||
144 | + result.include("mensagemEnvio", "Mensagem enviada com Sucesso, você recebeu um email com os anexos!"); | ||
145 | + result.include("statusEnvio", true); | ||
185 | } | 146 | } |
147 | + } | ||
148 | + } | ||
149 | + else | ||
150 | + { | ||
151 | + result.include("mensagemEnvio", "Não foi possível enviar o email com os anexos!"); | ||
152 | + result.include("statusEnvio", false); | ||
153 | + } | ||
154 | + | ||
155 | + this.validator.add(new ValidationMessage("", "")); | ||
156 | + this.validator.onErrorUsePageOf(relatorioController.class).confirmacaoEnvioEmailMPF(); | ||
157 | + } | ||
186 | 158 | ||
159 | + public void confirmacaoEnvioEmailMPF() | ||
160 | + { | ||
161 | + | ||
162 | + } | ||
187 | 163 | ||
164 | + | ||
165 | + @Get("/relatorio-imprimir/{id}") | ||
166 | + public void relatorioImprimir(String id) { | ||
167 | + if (id != null) { | ||
168 | + gerarRelatorio(Integer.parseInt(id)); | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + private void gerarRelatorio(int idQuestionario) { | ||
173 | + Questionario questionario = new Questionario(path, idQuestionario); | ||
174 | + RespostaQuestionarioDao respostaQuestionarioDao = new RespostaQuestionarioDao(); | ||
175 | + | ||
176 | + List<RespostaQuestionario> lsRespostaQuestionario = new ArrayList<RespostaQuestionario>(); | ||
177 | + List<AmostragemSiteQuestionario> lsAmostragemSiteQuestionario = | ||
178 | + new ArrayList<AmostragemSiteQuestionario>(); | ||
179 | + | ||
180 | + lsRespostaQuestionario = | ||
181 | + respostaQuestionarioDao.retornarRespostaQuestionarioPorQuestionario(path, | ||
182 | + questionario.getIdQuestionario()); | ||
183 | + | ||
184 | + List<String> curso = new ArrayList<String>(); | ||
185 | + List<String> simValidacao = new ArrayList<String>(); | ||
186 | + List<String> assistiva = new ArrayList<String>(); | ||
187 | + List<String> deficiencias = new ArrayList<String>(); | ||
188 | + List<String> ferramentaValidacao = new ArrayList<String>(); | ||
189 | + | ||
190 | + for (RespostaQuestionario respostaQuestionario : lsRespostaQuestionario) { | ||
191 | + | ||
192 | + switch (respostaQuestionario.getPergunta().getIdPergunta()) { | ||
193 | + case 1: | ||
194 | + result | ||
195 | + .include( | ||
196 | + "nomeOrgao", | ||
197 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
198 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
199 | + .getTextoResposta()); | ||
200 | + break; | ||
201 | + case 2: | ||
202 | + result | ||
203 | + .include( | ||
204 | + "nomePessoa", | ||
205 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
206 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
207 | + .getTextoResposta()); | ||
208 | + break; | ||
209 | + case 3: | ||
210 | + result | ||
211 | + .include( | ||
212 | + "cargo", | ||
213 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
214 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
215 | + .getTextoResposta()); | ||
216 | + break; | ||
217 | + case 4: | ||
218 | + result | ||
219 | + .include( | ||
220 | + "telefone", | ||
221 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
222 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
223 | + .getTextoResposta()); | ||
224 | + break; | ||
225 | + case 5: | ||
226 | + result | ||
227 | + .include( | ||
228 | + "email", | ||
229 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
230 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
231 | + .getTextoResposta()); | ||
232 | + break; | ||
233 | + case 7: | ||
234 | + result.include("perguntaAcessibilidade", respostaQuestionario.getOpcaoResposta() | ||
235 | + .getDescOpcaoResposta()); | ||
236 | + break; | ||
237 | + case 8: | ||
238 | + result.include("reclamacao", respostaQuestionario.getOpcaoResposta() | ||
239 | + .getDescOpcaoResposta()); | ||
240 | + break; | ||
241 | + case 9: | ||
242 | + result | ||
243 | + .include( | ||
244 | + "espacoReclamacao", | ||
245 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
246 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
247 | + .getTextoResposta()); | ||
248 | + break; | ||
249 | + case 10: | ||
250 | + result.include("perguntaEstimulo", respostaQuestionario.getOpcaoResposta() | ||
251 | + .getDescOpcaoResposta()); | ||
252 | + break; | ||
253 | + case 11: | ||
254 | + curso.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
255 | + break; | ||
256 | + case 12: | ||
257 | + result.include("requisito", respostaQuestionario.getOpcaoResposta() | ||
258 | + .getDescOpcaoResposta()); | ||
259 | + break; | ||
260 | + case 13: | ||
261 | + result | ||
262 | + .include( | ||
263 | + "justificativaRequisito", | ||
264 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
265 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
266 | + .getTextoResposta()); | ||
267 | + break; | ||
268 | + case 14: | ||
269 | + result.include("opcaoContrat", respostaQuestionario.getOpcaoResposta() | ||
270 | + .getDescOpcaoResposta()); | ||
271 | + break; | ||
272 | + case 15: | ||
273 | + result.include("perguntaValidacao", respostaQuestionario.getOpcaoResposta() | ||
274 | + .getDescOpcaoResposta()); | ||
275 | + break; | ||
276 | + case 16: | ||
277 | + simValidacao.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
278 | + break; | ||
279 | + case 17: | ||
280 | + ferramentaValidacao.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
281 | + break; | ||
282 | + case 18: | ||
283 | + result | ||
284 | + .include( | ||
285 | + "outroAvaliador", | ||
286 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
287 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
288 | + .getTextoResposta()); | ||
289 | + break; | ||
290 | + case 19: | ||
291 | + | ||
292 | + lsAmostragemSiteQuestionario.add(respostaQuestionario.getAmostragemSiteQuestionario()); | ||
293 | + break; | ||
294 | + /* | ||
295 | + * case 20: result.include("nivelWcag", respostaQuestionario.getOpcaoResposta() | ||
296 | + * .getDescOpcaoResposta()); break; | ||
297 | + */ | ||
298 | + case 21: | ||
299 | + result.include("checklistQtnList", respostaQuestionario.getOpcaoResposta() | ||
300 | + .getDescOpcaoResposta()); | ||
301 | + break; | ||
302 | + case 22: | ||
303 | + deficiencias.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
304 | + break; | ||
305 | + case 23: | ||
306 | + result.include("funcionalidade", respostaQuestionario.getOpcaoResposta() | ||
307 | + .getDescOpcaoResposta()); | ||
308 | + break; | ||
309 | + case 24: | ||
310 | + assistiva.add(respostaQuestionario.getOpcaoResposta().getDescOpcaoResposta()); | ||
311 | + break; | ||
312 | + case 25: | ||
313 | + result | ||
314 | + .include( | ||
315 | + "justificativaAssistiva", | ||
316 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
317 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
318 | + .getTextoResposta()); | ||
319 | + break; | ||
320 | + case 26: | ||
321 | + result | ||
322 | + .include( | ||
323 | + "dificuldadePrazo", | ||
324 | + respostaQuestionario.getTextoResposta().equalsIgnoreCase("null") ? respostaQuestionario | ||
325 | + .getTextoResposta().replace("null", "Não Respondido") : respostaQuestionario | ||
326 | + .getTextoResposta()); | ||
327 | + break; | ||
328 | + default: | ||
329 | + break; | ||
188 | } | 330 | } |
189 | - result.include("dataRespostaQuestionario", respostaQuestionarioDao.retornarDataRespostaQuestionarioPorQuestionario(path, idQuestionario)); | ||
190 | - | ||
191 | - if(curso.size() == 0) | ||
192 | - { | ||
193 | - curso.add("Não Respondido"); | ||
194 | - } | ||
195 | - | ||
196 | - if(simValidacao.size() == 0) | ||
197 | - { | ||
198 | - simValidacao.add("Não Respondido"); | ||
199 | - } | ||
200 | - | ||
201 | - if(deficiencias.size() == 0) | ||
202 | - { | ||
203 | - deficiencias.add("Não Respondido"); | ||
204 | - } | ||
205 | - | ||
206 | - result.include("curso", curso); | ||
207 | - result.include("simValidacao", simValidacao); | ||
208 | - result.include("assistiva", assistiva); | ||
209 | - result.include("deficiencias", deficiencias); | ||
210 | - result.include("ferramentaValidacao", ferramentaValidacao); | ||
211 | - result.include("questionario", questionario); | ||
212 | - result.include("lsAmostragemSiteQuestionario", lsAmostragemSiteQuestionario); | 331 | + |
332 | + | ||
213 | } | 333 | } |
334 | + result.include("dataRespostaQuestionario", respostaQuestionarioDao | ||
335 | + .retornarDataRespostaQuestionarioPorQuestionario(path, idQuestionario)); | ||
336 | + | ||
337 | + if (curso.size() == 0) { | ||
338 | + curso.add("Não Respondido"); | ||
339 | + } | ||
340 | + | ||
341 | + if (simValidacao.size() == 0) { | ||
342 | + simValidacao.add("Não Respondido"); | ||
343 | + } | ||
344 | + | ||
345 | + if (deficiencias.size() == 0) { | ||
346 | + deficiencias.add("Não Respondido"); | ||
347 | + } | ||
348 | + | ||
349 | + result.include("curso", curso); | ||
350 | + result.include("simValidacao", simValidacao); | ||
351 | + result.include("assistiva", assistiva); | ||
352 | + result.include("deficiencias", deficiencias); | ||
353 | + result.include("ferramentaValidacao", ferramentaValidacao); | ||
354 | + result.include("questionario", questionario); | ||
355 | + result.include("lsAmostragemSiteQuestionario", lsAmostragemSiteQuestionario); | ||
356 | + } | ||
214 | } | 357 | } |
src/br/com/dao/HashDao.java
@@ -29,7 +29,7 @@ public class HashDao { | @@ -29,7 +29,7 @@ public class HashDao { | ||
29 | sql.append(" SELECT id_questionario, dt_inicio_questionario, dt_fim_questionario, "); | 29 | sql.append(" SELECT id_questionario, dt_inicio_questionario, dt_fim_questionario, "); |
30 | sql.append(" no_orgao, hash_autenticacao, questionario_respondido, email_destino_orgao, "); | 30 | sql.append(" no_orgao, hash_autenticacao, questionario_respondido, email_destino_orgao, "); |
31 | sql.append(" responsavel, cargo_responsavel, telefone, data_recebimento_email, "); | 31 | sql.append(" responsavel, cargo_responsavel, telefone, data_recebimento_email, "); |
32 | - sql.append(" idautorizacao, data_resposta_email "); | 32 | + sql.append(" idautorizacao, data_resposta_email, flag_enviado "); |
33 | sql.append(" FROM questionario where hash_autenticacao = '" + valorHash + "'"); | 33 | sql.append(" FROM questionario where hash_autenticacao = '" + valorHash + "'"); |
34 | sql.append(" and (dt_inicio_questionario <= '" + DateUtil.dataHoraAtual() + "')"); | 34 | sql.append(" and (dt_inicio_questionario <= '" + DateUtil.dataHoraAtual() + "')"); |
35 | sql.append(" and (dt_fim_questionario >= '" + DateUtil.dataHoraAtual() + "');"); | 35 | sql.append(" and (dt_fim_questionario >= '" + DateUtil.dataHoraAtual() + "');"); |
@@ -48,6 +48,7 @@ public class HashDao { | @@ -48,6 +48,7 @@ public class HashDao { | ||
48 | questionario.setResponsavel(rset.getString("responsavel")); | 48 | questionario.setResponsavel(rset.getString("responsavel")); |
49 | questionario.setCargoResponsavel(rset.getString("cargo_responsavel")); | 49 | questionario.setCargoResponsavel(rset.getString("cargo_responsavel")); |
50 | questionario.setTelefone(rset.getString("telefone")); | 50 | questionario.setTelefone(rset.getString("telefone")); |
51 | + questionario.setFlagEnviado(rset.getBoolean("flag_enviado")); | ||
51 | questionario.setEmailDestinoOrgao(rset.getString("email_destino_orgao")); | 52 | questionario.setEmailDestinoOrgao(rset.getString("email_destino_orgao")); |
52 | } | 53 | } |
53 | 54 |
src/br/com/dao/PlanoTrabalhoDao.java
1 | package br.com.dao; | 1 | package br.com.dao; |
2 | 2 | ||
3 | -import java.io.FileNotFoundException; | ||
4 | -import java.io.FileOutputStream; | ||
5 | -import java.io.IOException; | ||
6 | import java.io.InputStream; | 3 | import java.io.InputStream; |
7 | -import java.io.PrintStream; | ||
8 | import java.sql.Connection; | 4 | import java.sql.Connection; |
9 | import java.sql.PreparedStatement; | 5 | import java.sql.PreparedStatement; |
10 | import java.sql.ResultSet; | 6 | import java.sql.ResultSet; |
11 | import java.sql.SQLException; | 7 | import java.sql.SQLException; |
12 | import java.sql.Statement; | 8 | import java.sql.Statement; |
13 | -import java.util.Properties; | ||
14 | 9 | ||
15 | import br.com.model.entity.PlanoTrabalho; | 10 | import br.com.model.entity.PlanoTrabalho; |
16 | import br.com.model.entity.Questionario; | 11 | import br.com.model.entity.Questionario; |
17 | -import br.com.model.utilities.ManagerProperties; | ||
18 | 12 | ||
19 | public class PlanoTrabalhoDao { | 13 | public class PlanoTrabalhoDao { |
20 | 14 | ||
@@ -27,7 +21,7 @@ public class PlanoTrabalhoDao { | @@ -27,7 +21,7 @@ public class PlanoTrabalhoDao { | ||
27 | Connection con = Conexao.conecta(path); | 21 | Connection con = Conexao.conecta(path); |
28 | Statement estado; | 22 | Statement estado; |
29 | ResultSet rset = null; | 23 | ResultSet rset = null; |
30 | - boolean existePlanoTrabalho = false; | 24 | + //boolean existePlanoTrabalho = false; |
31 | int idPlanoTrabalho = -1; | 25 | int idPlanoTrabalho = -1; |
32 | 26 | ||
33 | try { | 27 | try { |
@@ -72,7 +66,44 @@ public class PlanoTrabalhoDao { | @@ -72,7 +66,44 @@ public class PlanoTrabalhoDao { | ||
72 | try { | 66 | try { |
73 | 67 | ||
74 | sql = new StringBuffer(); | 68 | sql = new StringBuffer(); |
75 | - sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho, nome_extensao) VALUES (?, ?, ?); "); | 69 | + sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho, extensao_plano_trabalho) VALUES (?, ?, ?); "); |
70 | + | ||
71 | + estado = con.prepareStatement(sql.toString()); | ||
72 | + | ||
73 | + estado.setInt(1, questionario.getIdQuestionario()); | ||
74 | + estado.setBinaryStream(2, file); | ||
75 | + estado.setString(3, nomeExtensao); | ||
76 | + | ||
77 | + resultado = estado.executeUpdate(); | ||
78 | + | ||
79 | + if (resultado == 0) { | ||
80 | + salvoComSucesso = false; | ||
81 | + } else { | ||
82 | + | ||
83 | + salvoComSucesso = true; | ||
84 | + } | ||
85 | + | ||
86 | + } catch (SQLException e) { | ||
87 | + | ||
88 | + e.printStackTrace(); | ||
89 | + } | ||
90 | + | ||
91 | + return salvoComSucesso; | ||
92 | + } | ||
93 | + | ||
94 | + public boolean salvarRelatorioAss(String path, InputStream file, Questionario questionario, String nomeExtensao) | ||
95 | + { | ||
96 | + | ||
97 | + StringBuffer sql = new StringBuffer(); | ||
98 | + Connection con = Conexao.conecta(path); | ||
99 | + PreparedStatement estado; | ||
100 | + int resultado = 0; | ||
101 | + boolean salvoComSucesso = false; | ||
102 | + | ||
103 | + try { | ||
104 | + | ||
105 | + sql = new StringBuffer(); | ||
106 | + sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_relatorio_ass, extensao_relatorio_ass) VALUES (?, ?, ?); "); | ||
76 | 107 | ||
77 | estado = con.prepareStatement(sql.toString()); | 108 | estado = con.prepareStatement(sql.toString()); |
78 | 109 | ||
@@ -112,7 +143,7 @@ public class PlanoTrabalhoDao { | @@ -112,7 +143,7 @@ public class PlanoTrabalhoDao { | ||
112 | //sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); | 143 | //sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); |
113 | sql.append(" UPDATE public.plano_trabalho"); | 144 | sql.append(" UPDATE public.plano_trabalho"); |
114 | sql.append(" SET arquivo_plano_trabalho=?,"); | 145 | sql.append(" SET arquivo_plano_trabalho=?,"); |
115 | - sql.append( " nome_extensao =? "); | 146 | + sql.append( " extensao_plano_trabalho =? "); |
116 | sql.append(" WHERE id_plano_trabalho=?;"); | 147 | sql.append(" WHERE id_plano_trabalho=?;"); |
117 | 148 | ||
118 | estado = con.prepareStatement(sql.toString()); | 149 | estado = con.prepareStatement(sql.toString()); |
@@ -139,6 +170,49 @@ public class PlanoTrabalhoDao { | @@ -139,6 +170,49 @@ public class PlanoTrabalhoDao { | ||
139 | return salvoComSucesso; | 170 | return salvoComSucesso; |
140 | } | 171 | } |
141 | 172 | ||
173 | + public boolean atualizarRelatorioAss(String path, InputStream file, Questionario questionario, int idPlanoTrabalho, String nomeExtensao) | ||
174 | + { | ||
175 | + | ||
176 | + StringBuffer sql = new StringBuffer(); | ||
177 | + Connection con = Conexao.conecta(path); | ||
178 | + PreparedStatement estado; | ||
179 | + int resultado = 0; | ||
180 | + boolean salvoComSucesso = false; | ||
181 | + | ||
182 | + try { | ||
183 | + | ||
184 | + sql = new StringBuffer(); | ||
185 | + //sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); | ||
186 | + sql.append(" UPDATE public.plano_trabalho"); | ||
187 | + sql.append(" SET arquivo_relatorio_ass=?,"); | ||
188 | + sql.append( " extensao_relatorio_ass =? "); | ||
189 | + sql.append(" WHERE id_plano_trabalho=?;"); | ||
190 | + | ||
191 | + estado = con.prepareStatement(sql.toString()); | ||
192 | + | ||
193 | + //estado.setInt(1, questionario.getIdQuestionario()); | ||
194 | + estado.setBinaryStream(1, file); | ||
195 | + estado.setString(2, nomeExtensao); | ||
196 | + estado.setInt(3, idPlanoTrabalho); | ||
197 | + | ||
198 | + resultado = estado.executeUpdate(); | ||
199 | + | ||
200 | + if (resultado == 0) { | ||
201 | + salvoComSucesso = false; | ||
202 | + } else { | ||
203 | + | ||
204 | + salvoComSucesso = true; | ||
205 | + } | ||
206 | + | ||
207 | + } catch (SQLException e) { | ||
208 | + | ||
209 | + e.printStackTrace(); | ||
210 | + } | ||
211 | + | ||
212 | + return salvoComSucesso; | ||
213 | + } | ||
214 | + | ||
215 | + | ||
142 | public PlanoTrabalho recuperarPlanoTrabalho(String path, Questionario questionario) | 216 | public PlanoTrabalho recuperarPlanoTrabalho(String path, Questionario questionario) |
143 | { | 217 | { |
144 | 218 | ||
@@ -147,8 +221,8 @@ public class PlanoTrabalhoDao { | @@ -147,8 +221,8 @@ public class PlanoTrabalhoDao { | ||
147 | Connection con = Conexao.conecta(path); | 221 | Connection con = Conexao.conecta(path); |
148 | Statement estado; | 222 | Statement estado; |
149 | ResultSet rset = null; | 223 | ResultSet rset = null; |
150 | - byte[] imgBytes = null; | ||
151 | - PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | 224 | + //byte[] imgBytes = null; |
225 | + PlanoTrabalho planoTrabalho = new PlanoTrabalho(); | ||
152 | 226 | ||
153 | 227 | ||
154 | try { | 228 | try { |
@@ -162,9 +236,11 @@ public class PlanoTrabalhoDao { | @@ -162,9 +236,11 @@ public class PlanoTrabalhoDao { | ||
162 | rset = estado.executeQuery(sql); | 236 | rset = estado.executeQuery(sql); |
163 | 237 | ||
164 | while (rset.next()) { | 238 | while (rset.next()) { |
165 | - planoTrabalho.setArquivoPlanoTrabalho(rset.getBytes("arquivo_plano_trabalho")); | ||
166 | planoTrabalho.setIdPlanoTrabalho(rset.getInt("id_plano_trabalho")); | 239 | planoTrabalho.setIdPlanoTrabalho(rset.getInt("id_plano_trabalho")); |
167 | - planoTrabalho.setNomeExtensao(rset.getString("nome_extensao")); | 240 | + planoTrabalho.setArquivoPlanoTrabalho(rset.getBytes("arquivo_plano_trabalho")); |
241 | + planoTrabalho.setNomeExtensaoPlanoTrabalho(rset.getString("extensao_plano_trabalho")); | ||
242 | + planoTrabalho.setArquivoRelatorioAss(rset.getBytes("arquivo_relatorio_ass")); | ||
243 | + planoTrabalho.setNomeExtensaoRelatorioAss(rset.getString("extensao_relatorio_ass")); | ||
168 | planoTrabalho.setQuestionario(questionario); | 244 | planoTrabalho.setQuestionario(questionario); |
169 | } | 245 | } |
170 | 246 |
src/br/com/dao/QuestionarioDao.java
@@ -54,8 +54,9 @@ public class QuestionarioDao { | @@ -54,8 +54,9 @@ public class QuestionarioDao { | ||
54 | questionario.setTelefone(rset.getString("telefone")); | 54 | questionario.setTelefone(rset.getString("telefone")); |
55 | questionario.setIdAutorizacaoGeracaoHash(rset.getInt("idAutorizacao")); | 55 | questionario.setIdAutorizacaoGeracaoHash(rset.getInt("idAutorizacao")); |
56 | questionario.setDtRecebimentoEmail(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("data_recebimento_email"))); | 56 | questionario.setDtRecebimentoEmail(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("data_recebimento_email"))); |
57 | - | 57 | + questionario.setFlagEnviado(rset.getBoolean("flag_enviado")); |
58 | dataRespostaQuestionario = rset.getString("data_resposta_email"); | 58 | dataRespostaQuestionario = rset.getString("data_resposta_email"); |
59 | + | ||
59 | if(dataRespostaQuestionario != null) | 60 | if(dataRespostaQuestionario != null) |
60 | { | 61 | { |
61 | questionario.setDtRespostaEmail(DateUtil.dataHoraFormatadaDiaMesAnoComParametro(dataRespostaQuestionario)); | 62 | questionario.setDtRespostaEmail(DateUtil.dataHoraFormatadaDiaMesAnoComParametro(dataRespostaQuestionario)); |
@@ -110,6 +111,7 @@ public class QuestionarioDao { | @@ -110,6 +111,7 @@ public class QuestionarioDao { | ||
110 | questionario.setTelefone(rset.getString("telefone")); | 111 | questionario.setTelefone(rset.getString("telefone")); |
111 | questionario.setIdAutorizacaoGeracaoHash(rset.getInt("idAutorizacao")); | 112 | questionario.setIdAutorizacaoGeracaoHash(rset.getInt("idAutorizacao")); |
112 | questionario.setDtRecebimentoEmail(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("data_recebimento_email"))); | 113 | questionario.setDtRecebimentoEmail(DateUtil.dataHoraFormatadaDiaMesAno(rset.getString("data_recebimento_email"))); |
114 | + questionario.setFlagEnviado(rset.getBoolean("flag_enviado")); | ||
113 | 115 | ||
114 | dataRespostaQuestionario = rset.getString("data_resposta_email"); | 116 | dataRespostaQuestionario = rset.getString("data_resposta_email"); |
115 | if(dataRespostaQuestionario != null) | 117 | if(dataRespostaQuestionario != null) |
@@ -277,6 +279,42 @@ public class QuestionarioDao { | @@ -277,6 +279,42 @@ public class QuestionarioDao { | ||
277 | return salvoComSucesso; | 279 | return salvoComSucesso; |
278 | } | 280 | } |
279 | 281 | ||
282 | + public boolean atualizarFlagEnviado(String path, int idQuestionario) | ||
283 | + { | ||
284 | + | ||
285 | + StringBuffer sql = new StringBuffer(); | ||
286 | + Connection con = Conexao.conecta(path); | ||
287 | + PreparedStatement estado; | ||
288 | + int resultado = 0; | ||
289 | + boolean salvoComSucesso = false; | ||
290 | + | ||
291 | + | ||
292 | + | ||
293 | + try { | ||
294 | + | ||
295 | + sql = new StringBuffer(); | ||
296 | + sql.append(" UPDATE public.questionario SET flag_enviado = true WHERE id_questionario = ?; "); | ||
297 | + | ||
298 | + estado = con.prepareStatement(sql.toString()); | ||
299 | + | ||
300 | + estado.setInt(1, idQuestionario); | ||
301 | + | ||
302 | + resultado = estado.executeUpdate(); | ||
303 | + | ||
304 | + if (resultado == 0) { | ||
305 | + salvoComSucesso = false; | ||
306 | + } else { | ||
307 | + | ||
308 | + salvoComSucesso = true; | ||
309 | + } | ||
310 | + | ||
311 | + } catch (SQLException e) { | ||
312 | + | ||
313 | + e.printStackTrace(); | ||
314 | + } | ||
315 | + | ||
316 | + return salvoComSucesso; | ||
317 | + } | ||
280 | 318 | ||
281 | public ResultSet retornarQuestionarioPorId(String path, int idQuestionario) { | 319 | public ResultSet retornarQuestionarioPorId(String path, int idQuestionario) { |
282 | 320 | ||
@@ -345,8 +383,8 @@ public class QuestionarioDao { | @@ -345,8 +383,8 @@ public class QuestionarioDao { | ||
345 | sql.append(" dt_inicio_questionario, dt_fim_questionario, "); | 383 | sql.append(" dt_inicio_questionario, dt_fim_questionario, "); |
346 | sql.append(" no_orgao, hash_autenticacao, questionario_respondido, email_destino_orgao, "); | 384 | sql.append(" no_orgao, hash_autenticacao, questionario_respondido, email_destino_orgao, "); |
347 | sql.append(" responsavel, cargo_responsavel, telefone, idAutorizacao, "); | 385 | sql.append(" responsavel, cargo_responsavel, telefone, idAutorizacao, "); |
348 | - sql.append(" data_recebimento_email) "); | ||
349 | - sql.append(" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); | 386 | + sql.append(" data_recebimento_email,flag_enviado) "); |
387 | + sql.append(" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);"); | ||
350 | 388 | ||
351 | 389 | ||
352 | // cria statement para executar a query | 390 | // cria statement para executar a query |
@@ -363,6 +401,7 @@ public class QuestionarioDao { | @@ -363,6 +401,7 @@ public class QuestionarioDao { | ||
363 | estado.setString(9, questionario.getTelefone()); | 401 | estado.setString(9, questionario.getTelefone()); |
364 | estado.setInt(10, questionario.getIdAutorizacaoGeracaoHash()); | 402 | estado.setInt(10, questionario.getIdAutorizacaoGeracaoHash()); |
365 | estado.setDate(11, sqlDtRecebimentoEmail); | 403 | estado.setDate(11, sqlDtRecebimentoEmail); |
404 | + estado.setBoolean(12, false); | ||
366 | //estado.setDate(12, sqlDtRespostaEmail); | 405 | //estado.setDate(12, sqlDtRespostaEmail); |
367 | 406 | ||
368 | //resultado = estado.executeUpdate(); | 407 | //resultado = estado.executeUpdate(); |