Commit 3776d11c58d5560e443b757f9de02a987e9e2279
1 parent
d6893e44
Exists in
master
Implementação da funcionalidade para envio de plano de trabalho.
Showing
6 changed files
with
207 additions
and
5 deletions
Show diff stats
WebContent/WEB-INF/jsp/index/formulario.jsp
@@ -579,6 +579,7 @@ | @@ -579,6 +579,7 @@ | ||
579 | <input type="checkbox" name="assistiva" id="assistiva6" value="61" | 579 | <input type="checkbox" name="assistiva" id="assistiva6" value="61" |
580 | ${marcar == 'true'?'checked=\"checked\"':''}><label | 580 | ${marcar == 'true'?'checked=\"checked\"':''}><label |
581 | for="assistiva6">Prodeaf</label><br> | 581 | for="assistiva6">Prodeaf</label><br> |
582 | + | ||
582 | 583 | ||
583 | <c:set var="marcar" scope="session" value="false" /> | 584 | <c:set var="marcar" scope="session" value="false" /> |
584 | <c:forEach items="${assistiva}" var="item"> | 585 | <c:forEach items="${assistiva}" var="item"> |
@@ -589,6 +590,18 @@ | @@ -589,6 +590,18 @@ | ||
589 | <input type="checkbox" name="assistiva" id="assistiva7" value="62" | 590 | <input type="checkbox" name="assistiva" id="assistiva7" value="62" |
590 | ${marcar == 'true'?'checked=\"checked\"':''}><label | 591 | ${marcar == 'true'?'checked=\"checked\"':''}><label |
591 | for="assistiva7">VLibras</label><br> | 592 | for="assistiva7">VLibras</label><br> |
593 | + | ||
594 | + | ||
595 | + <c:set var="marcar" scope="session" value="false" /> | ||
596 | + <c:forEach items="${assistiva}" var="item"> | ||
597 | + <c:if test="${item == '69'}"> | ||
598 | + <c:set var="marcar" scope="session" value="true" /> | ||
599 | + </c:if> | ||
600 | + </c:forEach> | ||
601 | + <input type="checkbox" name="assistiva" id="assistiva5" value="69" | ||
602 | + ${marcar == 'true'?'checked=\"checked\"':''}><label | ||
603 | + for="assistiva5"><span lang="en">NVDA</span></label><br> | ||
604 | + | ||
592 | 605 | ||
593 | <c:set var="marcar" scope="session" value="false" /> | 606 | <c:set var="marcar" scope="session" value="false" /> |
594 | <c:forEach items="${assistiva}" var="item"> | 607 | <c:forEach items="${assistiva}" var="item"> |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
2 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | ||
3 | +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | ||
4 | +<!DOCTYPE html> | ||
5 | +<html lang=pt-br> | ||
6 | + | ||
7 | +<head> | ||
8 | +<title>Relatório Circunstanciado de Acessibilidade Digital</title> | ||
9 | +</head> | ||
10 | +<body> | ||
11 | + | ||
12 | + | ||
13 | +<form action="${pageContext.request.contextPath}/salvar-plano-trabalho" method="post" enctype="multipart/form-data"> | ||
14 | + | ||
15 | +<fieldset> | ||
16 | +<legend>Plano de Trabalho</legend> | ||
17 | + | ||
18 | +<label for="valorHash">Código Hash: </label> | ||
19 | +<input type="text" id="valorHash" name="valorHash"><br><br> | ||
20 | +<label for="file">Arquivo: </label> | ||
21 | +<input type="file" id="file" name="file"><br><br> | ||
22 | +<input type="submit" value="Salvar"> | ||
23 | +</fieldset> | ||
24 | +</form> | ||
25 | +</body> | ||
26 | +</html> | ||
0 | \ No newline at end of file | 27 | \ No newline at end of file |
WebContent/WEB-INF/jsp/planoTrabalho/planoTrabalhoConfirmacao.jsp
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
2 | +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> | ||
3 | +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> | ||
4 | +<!DOCTYPE html> | ||
5 | +<html lang=pt-br> | ||
6 | + | ||
7 | +<head> | ||
8 | +<title>Relatório Circunstanciado de Acessibilidade Digital</title> | ||
9 | +</head> | ||
10 | +<body> | ||
11 | +${mensagem} | ||
12 | +</body> | ||
13 | +</html> | ||
0 | \ No newline at end of file | 14 | \ No newline at end of file |
@@ -0,0 +1,69 @@ | @@ -0,0 +1,69 @@ | ||
1 | +package br.com.controller; | ||
2 | + | ||
3 | +import javax.servlet.ServletContext; | ||
4 | + | ||
5 | +import br.com.caelum.vraptor.Path; | ||
6 | +import br.com.caelum.vraptor.Resource; | ||
7 | +import br.com.caelum.vraptor.Result; | ||
8 | +import br.com.caelum.vraptor.Validator; | ||
9 | +import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; | ||
10 | +import br.com.caelum.vraptor.validator.ValidationMessage; | ||
11 | +import br.com.dao.HashDao; | ||
12 | +import br.com.dao.PlanoTrabalhoDao; | ||
13 | +import br.com.model.entity.Questionario; | ||
14 | + | ||
15 | +@Resource | ||
16 | +public class PlanoTrabalhoController { | ||
17 | + | ||
18 | + private Validator validator; | ||
19 | + private Result result; | ||
20 | + private ServletContext application; | ||
21 | + private String path; | ||
22 | + | ||
23 | + public PlanoTrabalhoController(Result result, Validator validator, ServletContext application) | ||
24 | + { | ||
25 | + this.validator = validator; | ||
26 | + this.application = application; | ||
27 | + this.path = this.application.getRealPath("") + "/WEB-INF/conexao.properties"; | ||
28 | + this.result = result; | ||
29 | + } | ||
30 | + | ||
31 | + @Path("/planoTrabalho-site") | ||
32 | + public void planoTrabalho() | ||
33 | + { | ||
34 | + | ||
35 | + } | ||
36 | + | ||
37 | + @Path("/plano-trabalho-confirmacao") | ||
38 | + public void planoTrabalhoConfirmacao() | ||
39 | + { | ||
40 | + | ||
41 | + } | ||
42 | + | ||
43 | + @Path("/salvar-plano-trabalho") | ||
44 | + public void enviarPlanoTrabalho(String valorHash, UploadedFile file) | ||
45 | + { | ||
46 | + HashDao hashDao = new HashDao(); | ||
47 | + Questionario questionario = new Questionario(); | ||
48 | + questionario = hashDao.verificarHash(path, valorHash); | ||
49 | + String mensagem = "Não foi possível enviar o plano de trabalho!"; | ||
50 | + | ||
51 | + if(questionario != null && questionario.getDtInicioQuestionario() != null) | ||
52 | + { | ||
53 | + PlanoTrabalhoDao planoTrabalhoDao = new PlanoTrabalhoDao(); | ||
54 | + | ||
55 | + if(planoTrabalhoDao.salvarPlanoTrabalho(valorHash, file.getFile(), questionario)) | ||
56 | + { | ||
57 | + mensagem = "Plano de trabalho enviado com sucesso!"; | ||
58 | + } | ||
59 | + } | ||
60 | + else | ||
61 | + { | ||
62 | + mensagem = "Favor verificar o Código Hash!"; | ||
63 | + } | ||
64 | + result.include("mensagem", mensagem); | ||
65 | + this.validator.add(new ValidationMessage("", "")); | ||
66 | + this.validator.onErrorUsePageOf(PlanoTrabalhoController.class).planoTrabalhoConfirmacao(); | ||
67 | + } | ||
68 | + | ||
69 | +} |
src/br/com/controller/QuestionarioController.java
@@ -52,7 +52,7 @@ public class QuestionarioController { | @@ -52,7 +52,7 @@ public class QuestionarioController { | ||
52 | 52 | ||
53 | 53 | ||
54 | @Path("/salvar-questionario") | 54 | @Path("/salvar-questionario") |
55 | - public void questionarioSalvar(String autorizacao, String emailDestinoOrgao, UploadedFile file, String noOrgao) { | 55 | + public void questionarioSalvar(String autorizacao, String emailDestinoOrgao, UploadedFile file,String nomeDestinatario, String cargoDestinatario, String noOrgao) { |
56 | 56 | ||
57 | 57 | ||
58 | AutorizacaoGeracaoHashDao autorizacaoGeracaoHashDao = new AutorizacaoGeracaoHashDao(); | 58 | AutorizacaoGeracaoHashDao autorizacaoGeracaoHashDao = new AutorizacaoGeracaoHashDao(); |
@@ -72,9 +72,10 @@ public class QuestionarioController { | @@ -72,9 +72,10 @@ public class QuestionarioController { | ||
72 | String dtInicioQuestionario = ""; | 72 | String dtInicioQuestionario = ""; |
73 | String dtFimQuestionario = ""; | 73 | String dtFimQuestionario = ""; |
74 | String hashAutenticacao = null; | 74 | String hashAutenticacao = null; |
75 | + Properties prop = null; | ||
75 | 76 | ||
76 | try { | 77 | try { |
77 | - Properties prop = managerProperties.getProp(this.application.getRealPath("") + "/WEB-INF/intervaloRespostaFormulario.properties"); | 78 | + prop = managerProperties.getProp(this.application.getRealPath("") + "/WEB-INF/respostaFormulario.properties"); |
78 | 79 | ||
79 | dtInicioQuestionario = prop.getProperty("dataInicio"); | 80 | dtInicioQuestionario = prop.getProperty("dataInicio"); |
80 | dtFimQuestionario = prop.getProperty("dataFim"); | 81 | dtFimQuestionario = prop.getProperty("dataFim"); |
@@ -96,11 +97,41 @@ public class QuestionarioController { | @@ -96,11 +97,41 @@ public class QuestionarioController { | ||
96 | QuestionarioDao questionarioDao = new QuestionarioDao(); | 97 | QuestionarioDao questionarioDao = new QuestionarioDao(); |
97 | 98 | ||
98 | if (questionarioDao.salvarQuestionario(path, file.getFile(), questionario)) { | 99 | if (questionarioDao.salvarQuestionario(path, file.getFile(), questionario)) { |
100 | + | ||
101 | + StringBuffer mensagem = new StringBuffer(); | ||
102 | + | ||
103 | + mensagem.append("Prezado(a),\n"); | ||
104 | + mensagem.append("senhor(a) "+ nomeDestinatario +", " + cargoDestinatario + ", do "+ noOrgao +", conforme solicitado, o acesso \n"); | ||
105 | + mensagem.append("ao FAD para o preenchimento de informações sobre a atual situação da \n"); | ||
106 | + mensagem.append("acessibilidade dos ambientes digitais do seu órgão ou entidade deverá ser \n"); | ||
107 | + mensagem.append("realizado pelo endereço "+ prop.getProperty("enderecoFad") + " utilizando o código de \n"); | ||
108 | + mensagem.append("acesso: "+ hashAutenticacao +" .\n\n"); | ||
109 | + mensagem.append("A guarda do código de acesso, bem como as informações prestadas são de sua \n"); | ||
110 | + mensagem.append("inteira responsabilidade.\n\n"); | ||
111 | + mensagem.append("O FAD poderá ser preenchido no período "+ prop.getProperty("dataInicio") + " a "+ prop.getProperty("dataFim") +", data limite \n"); | ||
112 | + mensagem.append("para o envio do relatório circunstanciado (formulário de acessibilidade digital e plano de \n"); | ||
113 | + mensagem.append("trabalho) à Procuradoria Federal dos Direitos do Cidadão do Ministério Público Federal e \n"); | ||
114 | + mensagem.append("publicado no sítio ou portal eletrônico do órgão ou entidade.\n\n"); | ||
115 | + mensagem.append("Maiores informações, dúvidas e sugestões devem ser encaminhadas pelo canal \n"); | ||
116 | + mensagem.append(prop.getProperty("enderecoFad") + "\n\n"); | ||
117 | + mensagem.append("PRespeitosamente,\n\n"); | ||
118 | + mensagem.append("Ministério do Planejamento, Desenvolvimento e Gestão\n"); | ||
119 | + mensagem.append("Secretaria de Tecnologia da Informação\n"); | ||
120 | + mensagem.append("Departamento de Governo Digital \n"); | ||
121 | + mensagem.append("Coordenação-Geral de Padrões de Governo Digital\n"); | ||
122 | + mensagem.append(prop.getProperty("emailContato") + "\n"); | ||
123 | + | ||
124 | + String[] telefoneContato = prop.getProperty("telefoneContato").split(","); | ||
125 | + | ||
126 | + for (String telefone : telefoneContato) { | ||
127 | + mensagem.append(telefone + "\n"); | ||
128 | + } | ||
129 | + | ||
99 | Contato contato = new Contato(); | 130 | Contato contato = new Contato(); |
100 | contato.setEmail(emailDestinoOrgao); | 131 | contato.setEmail(emailDestinoOrgao); |
101 | - contato.setAssunto("assunto"); | ||
102 | - contato.setMensagem("Código Hash:" + hashAutenticacao); | ||
103 | - contato.setNome("nome"); | 132 | + contato.setAssunto("Formulário Eletrônico de Acessibilidade Digital (FAD) – Concessão de Acesso"); |
133 | + contato.setMensagem(mensagem.toString()); | ||
134 | + contato.setNome(nomeDestinatario); | ||
104 | 135 | ||
105 | if(enviarHashPorEmail(contato)) | 136 | if(enviarHashPorEmail(contato)) |
106 | { | 137 | { |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +package br.com.dao; | ||
2 | + | ||
3 | +import java.io.InputStream; | ||
4 | +import java.sql.Connection; | ||
5 | +import java.sql.PreparedStatement; | ||
6 | +import java.sql.ResultSet; | ||
7 | +import java.sql.SQLException; | ||
8 | +import java.sql.Statement; | ||
9 | + | ||
10 | +import br.com.model.entity.Questionario; | ||
11 | + | ||
12 | +public class PlanoTrabalhoDao { | ||
13 | + | ||
14 | + public boolean salvarPlanoTrabalho(String path, InputStream file, Questionario questionario) | ||
15 | + { | ||
16 | + | ||
17 | + StringBuffer sql = new StringBuffer(); | ||
18 | + Connection con = Conexao.conecta(path); | ||
19 | + PreparedStatement estado; | ||
20 | + int resultado = 0; | ||
21 | + boolean salvoComSucesso = false; | ||
22 | + | ||
23 | + try { | ||
24 | + | ||
25 | + sql = new StringBuffer(); | ||
26 | + sql.append(" INSERT INTO public.plano_trabalho(id_questionario, arquivo_plano_trabalho) VALUES (?, ?); "); | ||
27 | + | ||
28 | + estado = con.prepareStatement(sql.toString()); | ||
29 | + | ||
30 | + estado.setInt(1, questionario.getIdQuestionario()); | ||
31 | + estado.setBinaryStream(2, file); | ||
32 | + | ||
33 | + resultado = estado.executeUpdate(); | ||
34 | + | ||
35 | + if (resultado == 0) { | ||
36 | + salvoComSucesso = false; | ||
37 | + } else { | ||
38 | + | ||
39 | + salvoComSucesso = true; | ||
40 | + } | ||
41 | + | ||
42 | + } catch (SQLException e) { | ||
43 | + | ||
44 | + e.printStackTrace(); | ||
45 | + } | ||
46 | + | ||
47 | + return salvoComSucesso; | ||
48 | + } | ||
49 | + | ||
50 | +} |