Commit dfd0ecd55c948152275c50d61a6e83aa42bcc302

Authored by 96409975520
1 parent d7195f24
Exists in master

Criação do painel de acessibilidade.

Desenvolvimento/Codificacao/e-Selo/WebContent/WEB-INF/jsp/gerarPainelErrosMaisComuns/index.jsp 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2 + pageEncoding="ISO-8859-1"%>
  3 +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4 +<html>
  5 +<head>
  6 +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7 +<title>Insert title here</title>
  8 +</head>
  9 +<body>
  10 +
  11 +</body>
  12 +</html>
0 13 \ No newline at end of file
... ...
Desenvolvimento/Codificacao/e-Selo/WebContent/WEB-INF/jsp/painelAcessibilidade/mediaAvaliacao.jsp 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
  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 +<%@page contentType="text/html" pageEncoding="UTF-8"%>
  5 +<t:baseLayout>
  6 + <jsp:body>
  7 + <br>
  8 + <c:forEach items="${lsCaminhoAvaliacao}" var="caminhoAvaliacao">
  9 + <a href="${caminhoAvaliacao.link }" class="${caminhoAvaliacao.classe }">${caminhoAvaliacao.nome }</a><br>
  10 + </c:forEach>
  11 + <br>
  12 +
  13 + <c:if test="${not empty lsMediaAvaliacao}">
  14 + <label id="ultimaAvaliacao">Última avaliação em: ${ultimaAvaliacao }</label>
  15 + <table>
  16 + <thead>
  17 + <tr>
  18 + <th id="nome">${tipo}</th>
  19 + <th id="total">Total de ${nomeTotal}</th>
  20 + <th id="media">Média</th>
  21 + </tr>
  22 + </thead>
  23 + <tbody>
  24 + <c:forEach items="${lsMediaAvaliacao}" var="mediaAvaliacao">
  25 + <tr>
  26 + <td headers="nome" class="celula">
  27 + <c:if test="${tipo == 'URLs'}">
  28 +
  29 + <c:set var = "stringLowerCase" value = "${fn:toLowerCase(mediaAvaliacao.nome)}" />
  30 + <c:set var = "string1" value = "${fn:replace(stringLowerCase, 'http://', '')}"/>
  31 + <c:set var = "string2" value ="${fn:replace(string1, '/', '')}"/>
  32 + <c:set var = "string3" value ="${fn:replace(string2, '.', '')}"/>
  33 + <c:set var = "string4" value ="${fn:replace(string3, ' ', '')}"/>
  34 + <a href="http://eselo-prd.brazilsouth.cloudapp.azure.com:8080/arquivosHtml/${string4}.html">${mediaAvaliacao.nome }</a>
  35 +
  36 + </c:if>
  37 + <c:if test="${tipo != 'URLs'}">
  38 + <a href="/eselo/media-avaliacao/${novoTipo }/${mediaAvaliacao.id}/${mediaAvaliacao.nome }">${mediaAvaliacao.nome }</a>
  39 + </c:if>
  40 + </td>
  41 + <td headers="total" class="celula centralizado">
  42 + ${mediaAvaliacao.total }
  43 + </td>
  44 +
  45 + <td headers="media" class="celula centralizado">
  46 + ${mediaAvaliacao.media }
  47 + </td>
  48 + </tr>
  49 +
  50 + </c:forEach>
  51 +
  52 + </tbody>
  53 + </table>
  54 + <br>
  55 + </c:if>
  56 + </jsp:body>
  57 +</t:baseLayout>
0 58 \ No newline at end of file
... ...
Desenvolvimento/Codificacao/e-Selo/WebContent/WEB-INF/jsp/painelAcessibilidade/outrosErrosMaisComuns.jsp 0 → 100644
... ... @@ -0,0 +1 @@
  1 +${html}
0 2 \ No newline at end of file
... ...
Desenvolvimento/Codificacao/e-Selo/WebContent/WEB-INF/tags/baseLayout.tag 0 → 100644
... ... @@ -0,0 +1,95 @@
  1 +<%@ tag language="java" pageEncoding="UTF-8"%>
  2 +<%@attribute name="body" fragment="true"%>
  3 +
  4 +
  5 +<!DOCTYPE html>
  6 +<html lang="pt-br">
  7 +<head>
  8 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9 +<meta name="viewport" content="width=device-width, initial-scale=1.0">
  10 +<link rel="shortcut icon"
  11 + href="${pageContext.request.contextPath}/static/ico/favicon.png">
  12 +<link
  13 + href="${pageContext.request.contextPath}/static/css/painelAcessibilidade.css"
  14 + rel="stylesheet">
  15 +<link
  16 + href="${pageContext.request.contextPath}/static/css/barra_brasil.css"
  17 + rel="stylesheet">
  18 +
  19 +
  20 +<title>Painel de Acessibilidade Digital do Governo</title>
  21 +
  22 +</head>
  23 +<body>
  24 + <header id="topoPagina">
  25 +
  26 + <div id="topo">
  27 + <ul id="accessibility">
  28 + <li><a accesskey="1" href="#inicioConteudo" id="link-conteudo">Ir
  29 + para o conteúdo <span>1</span>
  30 + </a></li>
  31 + <li><a accesskey="4" href="#footer-brasil" id="link-rodape">Ir
  32 + para o rodapé <span>4</span>
  33 + </a></li>
  34 + </ul>
  35 + <br> <br>
  36 + <div id="logo">
  37 + <h1 id="portal-title-1">Painel de Acessibilidade Digital do
  38 + Governo</h1>
  39 + </div>
  40 + <div id="barra-brasil" class="barra_brasil">
  41 + <ul id="menu-barra-temp">
  42 + <li><a class="primeiro-link" href="http://brasil.gov.br">Portal
  43 + do Governo Brasileiro</a></li>
  44 + <li><a class="segundo-link"
  45 + href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualizesua
  46 + Barra de Governo</a></li>
  47 + </ul>
  48 + </div>
  49 + </div>
  50 + </header>
  51 + <div class="contanner">
  52 + <div class="logoAvaliacao">
  53 + <div id="emag">
  54 + <label>eMAG v 3.1</label>
  55 + </div>
  56 + <div id="grafico">
  57 + <h2 class="oculto_visao">Gráfico com as notas das últimas
  58 + avaliações ordenada da mais antiga para a mais atual, limitado até
  59 + quatro avaliações.</h2>
  60 + <ul class="oculto_visao">
  61 + <li>Nota 1: <span id="nota1">100.0</span><span>Data da avaliação:2017-08-10 12:42:22.0</span></li>
  62 + <li>Nota 2: <span id="nota2">100.0</span><span>Data da avaliação:2017-08-10 13:57:09.0</span></li>
  63 + <li>Nota 3: <span id="nota3">100.0</span><span>Data da avaliação:2017-08-11 16:49:07.0</span></li>
  64 + <li>Nota 4: <span id="nota4">100.0</span><span>Data da avaliação:Tue Aug 15 12:49:25 GMT 2017</span></li>
  65 + </ul>
  66 + <label id="qntAvaliacoes" class="oculto">4</label>
  67 + <div class="myChart">
  68 + <iframe class="chartjs-hidden-iframe"
  69 + style="width: 100%; display: block; border: 0px; height: 0px; margin: 0px; position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px;"></iframe>
  70 + <canvas id="myChart" style="width: 420px; height: 210px;"
  71 + width="420" height="210"></canvas>
  72 + </div>
  73 + </div>
  74 + </div>
  75 + <a id="inicioConteudo" class="oculto">Início do Conteúdo</a>
  76 + <div class="avaliacao">
  77 + <!-- Início Conteudo -->
  78 +
  79 + <jsp:doBody />
  80 +
  81 + <!--Término Conteudo-->
  82 + </div>
  83 + <a id="fimConteudo" class="oculto">Fim do Conteúdo</a>
  84 + <div id="voltar-topo">
  85 + <a href="#topoPagina">Voltar para o topo</a>
  86 + </div>
  87 + </div>
  88 + <footer id="footer-brasil"></footer>
  89 + <script defer="defer" src="//barra.brasil.gov.br/barra.js" type="text/javascript"></script>
  90 + <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.10.2.min.js"></script>
  91 + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js"></script>
  92 + <script src="${pageContext.request.contextPath}/static/js/chartMediaAvaliacao.js"></script>
  93 + <noscript>Seu navegador não possui suporte para JavaScript!</noscript>
  94 +</body>
  95 +</html>
... ...
Desenvolvimento/Codificacao/e-Selo/WebContent/static/css/painelAcessibilidade.css
... ... @@ -122,7 +122,7 @@ Table {
122 122 }
123 123  
124 124 #emag {
125   - width: 200px;
  125 + width: 180px;
126 126 height: 280px;
127 127 background: #92d68f;
128 128 text-align: center;
... ... @@ -130,7 +130,7 @@ Table {
130 130 }
131 131  
132 132 #testesAutomaticos {
133   - width: 200px;
  133 + width: 220px;
134 134 height: 280px;
135 135 border-left: 1px solid #000000;
136 136 border-right: 1px solid #000000;
... ... @@ -144,6 +144,14 @@ Table {
144 144 height: 200px;
145 145 text-align: center;
146 146 float: left;
  147 + margin-left: 150px;
  148 +}
  149 +
  150 +#grafico2 {
  151 + width: 532px;
  152 + height: 200px;
  153 + text-align: center;
  154 + float: left;
147 155 }
148 156  
149 157 .myChart {
... ... @@ -192,6 +200,7 @@ table {
192 200 table th {
193 201 background: #585450;
194 202 color: #ffffff;
  203 + text-align: left !important;
195 204 }
196 205  
197 206 .avaliacao label {
... ... @@ -317,6 +326,36 @@ a.oculto {
317 326 list-style: none;
318 327 margin-top: 2px;
319 328 }
  329 +
  330 + #tituloTabela
  331 + {
  332 + margin-left: 10px !important;
  333 + }
  334 +
  335 + .mBrasil{
  336 + margin-left: 20px;
  337 + }
  338 + .orgao{
  339 + margin-left: 40px;
  340 + }
  341 + .dominio{
  342 + margin-left: 60px;
  343 + }
  344 + .sitio{
  345 + margin-left: 80px;
  346 + }
  347 + #ultimaAvaliacao{
  348 + font-size:12px;
  349 + float: right;
  350 + margin-right: 20px;
  351 + }
  352 + .centralizado{
  353 + text-align: center;
  354 + width: 15%;
  355 + }
  356 +
  357 +
  358 +
320 359 } /*-----Fim max-width: 1024px */
321 360  
322 361 /*------Inicio max-width: 768px----*/
... ... @@ -461,7 +500,14 @@ h1 {
461 500 width: 35em;
462 501 height: 20em;
463 502 text-align: center;
464   -
  503 + float: left;
  504 + margin-left: 150px;
  505 +}
  506 +#grafico2 {
  507 + width: 532px;
  508 + height: 200px;
  509 + text-align: center;
  510 + float: left;
465 511 }
466 512  
467 513 .myChart {
... ... @@ -507,11 +553,13 @@ table {
507 553  
508 554 .table, th, td {
509 555 border: 2px solid #000000;
  556 +
510 557 }
511 558  
512 559 table th {
513 560 background: #585450;
514 561 color: #ffffff;
  562 + text-align: left !important;
515 563 }
516 564  
517 565 .avaliacao label {
... ... @@ -636,4 +684,8 @@ a.oculto {
636 684 list-style: none;
637 685 margin-top: 2px;
638 686 }
  687 + #tituloTabela
  688 + {
  689 + margin-left: 10px !important;
  690 + }
639 691 }
640 692 \ No newline at end of file
... ...
Desenvolvimento/Codificacao/e-Selo/WebContent/static/js/chartPainelAgregado.js 0 → 100644
... ... @@ -0,0 +1,49 @@
  1 +$(document).ready(function() {
  2 + var qntAvaliacoes = $("#qntAvaliacoes").text();
  3 +
  4 + var canvas = document.getElementById('myChart');
  5 +
  6 +
  7 + var data = {
  8 +
  9 + labels: ["0",$("#erro1").text(), $("#erro2").text(), $("#erro3").text(), $("#erro4").text() ,$("#erro5").text(),
  10 + $("#erro6").text(), $("#erro7").text(),$("#erro8").text(),$("#erro9").text(),$("#erro10").text()],
  11 + datasets: [
  12 + {
  13 + label: "Avaliações",
  14 + fill: false,
  15 + lineTension: 0.1,
  16 + backgroundColor: "rgba(75,192,192,0.4)",
  17 + borderColor: "rgba(75,192,192,1)",
  18 + borderCapStyle: 'butt',
  19 + borderDash: [],
  20 + borderDashOffset: 0.0,
  21 + borderJoinStyle: 'miter',
  22 + pointBorderColor: "rgba(75,192,192,1)",
  23 + pointBackgroundColor: "#fff",
  24 + pointBorderWidth: 1,
  25 + pointHoverRadius: 5,
  26 + pointHoverBackgroundColor: "rgba(75,192,192,1)",
  27 + pointHoverBorderColor: "rgba(220,220,220,1)",
  28 + pointHoverBorderWidth: 2,
  29 + pointRadius: 5,
  30 + pointHitRadius: 10,
  31 + data: [0,$("#p_erro1").text(), $("#p_erro2").text(),$("#p_erro3").text(),$("#p_erro4").text(),
  32 + $("#p_erro5").text(), $("#p_erro6").text(),$("#p_erro7").text(),$("#p_erro8").text(), $("#p_erro9").text(),$("#p_erro10").text()],
  33 +
  34 + }
  35 + ]
  36 + };
  37 +
  38 + var option = {
  39 + showLines: true
  40 + };
  41 + var myLineChart = Chart.Line(canvas,{
  42 + data:data,
  43 + options:option
  44 + });
  45 +
  46 +
  47 +
  48 + //fim 1 avaliações
  49 +});
0 50 \ No newline at end of file
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/component/Util.java
... ... @@ -15,6 +15,7 @@ import java.util.Date;
15 15 import java.util.Locale;
16 16 import java.util.regex.Pattern;
17 17  
  18 +import javax.persistence.Temporal;
18 19 import javax.swing.text.MaskFormatter;
19 20  
20 21 public class Util {
... ... @@ -49,4 +50,10 @@ public class Util {
49 50 .format( DateTimeFormatter.ISO_DATE_TIME );
50 51  
51 52 }
  53 +
  54 + public static String convertDataBrasil(java.sql.Timestamp data) {
  55 + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
  56 + return sdf.format(data);
  57 +
  58 + }
52 59 }
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/AvaliacaoController.java
... ... @@ -61,6 +61,7 @@ import br.com.eselo.component.Util;
61 61 import br.com.eselo.component.WebChecker;
62 62 import br.com.eselo.dao.AvaliacaoDAO;
63 63 import br.com.eselo.dao.CriterioDAO;
  64 +import br.com.eselo.dao.ErrosMaisComunsDAO;
64 65 import br.com.eselo.dao.ParametroCalculoDAO;
65 66 import br.com.eselo.dao.RecomendacaoDAO;
66 67 import br.com.eselo.dao.ResultadoCriterioDao;
... ... @@ -73,6 +74,7 @@ import br.com.eselo.integracao.RelatorioAvaliacao;
73 74 import br.com.eselo.integracao.ResultadoAvaliacao;
74 75 import br.com.eselo.model.Avaliacao;
75 76 import br.com.eselo.model.Criterio;
  77 +import br.com.eselo.model.ErrosMaisComuns;
76 78 import br.com.eselo.model.ParametroCalculo;
77 79 import br.com.eselo.model.Recomendacao;
78 80 import br.com.eselo.model.ResultadoCriterio;
... ... @@ -125,7 +127,7 @@ public class AvaliacaoController {
125 127 daoUrl = _daoUrl;
126 128 dao = _dao;
127 129 daoSitio = _daoSitio;
128   - daoResultadoRecomendacao = _daoResultadoRecomendacao;
  130 + daoResultadoRecomendacao = _daoResultadoRecomendacao;
129 131 result = _result;
130 132 paramDao = _paramDao;
131 133 request = _request;
... ... @@ -217,7 +219,6 @@ public class AvaliacaoController {
217 219  
218 220 ParametroCalculo parametroCalculo = paramDao
219 221 .getLastParametrosCalculoAtivo();
220   -
221 222 if (parametroCalculo != null) {
222 223  
223 224 // foi colocada abaixo (Gibran)
... ... @@ -291,6 +292,7 @@ public class AvaliacaoController {
291 292  
292 293 }
293 294  
  295 +
294 296 criterioAvaliado.setNu_nota(notaCriterio);
295 297 criterioAvaliado.setIdCriterio(criterioSalvar
296 298 .getId());
... ... @@ -354,19 +356,16 @@ public class AvaliacaoController {
354 356 */
355 357  
356 358  
357   -
358 359 conformidadeAcessibilidade = 100 * (somatorioNotaRecomendacoes / somaPesosRecomendacoes);
359 360  
360 361  
361 362 conformidadeAcessibilidade = (double) new Double(
362 363 conformidadeAcessibilidade * 100).intValue() / 100;
363   - System.out.println("erro_01");
364 364 // System.out.println("conformidadeAcessibilidade = " +
365 365 // conformidadeAcessibilidade);
366 366 recomendacoesCriteriosParaImprimir
367 367 .add("conformidadeAcessibilidade = "
368 368 + conformidadeAcessibilidade);
369   - System.out.println("erro_02");
370 369 //for (String string : recomendacoesCriteriosParaImprimir) {
371 370 // System.out.println(string);
372 371 //}
... ... @@ -408,7 +407,7 @@ public class AvaliacaoController {
408 407 */
409 408 @Post("/calcular-nota")
410 409 public void calcularNota(RelatorioAvaliacao relatorioAvaliacao, boolean salvarAvaliacao) {
411   - System.out.println(relatorioAvaliacao);
  410 + // System.out.println(relatorioAvaliacao);
412 411 ResultadoAvaliacao resultadoAvaliacao = new ResultadoAvaliacao();
413 412 String observacao = "Foi impossivel realizar a avaliação.";
414 413 String urlComProtocolo = relatorioAvaliacao.getUrl();
... ... @@ -423,7 +422,7 @@ public class AvaliacaoController {
423 422 // + request.getContextPath();
424 423 String fullContextPath = "/";
425 424  
426   -
  425 +
427 426 if (relatorioAvaliacao.getRecomendacoes() != null
428 427 && relatorioAvaliacao.getRecomendacoes().size() > 0
429 428 && relatorioAvaliacao.getDate() != null
... ... @@ -434,7 +433,6 @@ public class AvaliacaoController {
434 433 } catch (MalformedURLException e) {
435 434 e.printStackTrace();
436 435 }
437   -
438 436 Url url = daoUrl.getStringUrl(relatorioAvaliacao.getUrl());
439 437  
440 438 if (url == null) {
... ... @@ -503,6 +501,7 @@ public class AvaliacaoController {
503 501 avaliacao.setQtdeLinhas(relatorioAvaliacao.getQtdeLinhas());
504 502 avaliacao.setNota(nota);
505 503  
  504 +
506 505 Url url = daoUrl.getStringUrl(relatorioAvaliacao.getUrl());
507 506  
508 507 if (url == null) {
... ... @@ -511,12 +510,14 @@ public class AvaliacaoController {
511 510 daoUrl.save(url);
512 511 }
513 512 url.setUrl(relatorioAvaliacao.getUrl());
514   -
  513 +
  514 +
515 515 avaliacao.setUrl(url);
  516 +
516 517 avaliacao = new LeitorXML().lerResultadosXML(relatorioAvaliacao,
517 518 avaliacao);
  519 +
518 520 dao.save(avaliacao);
519   -
520 521 return avaliacao;
521 522 }
522 523  
... ... @@ -573,9 +574,10 @@ public class AvaliacaoController {
573 574 @Post("/avaliar-url")
574 575 public void avaliarUrl(@QueryParam("url") String url) {
575 576  
576   - //boolean paginaAvaliada = false;
  577 +
  578 + boolean paginaAvaliada = false;
577 579 boolean urlAvaliada = false;
578   - //String paginaAlterada = "";
  580 + String paginaAlterada = "";
579 581  
580 582 String urlServico = properties.getProperty(URL_SERVICO);
581 583  
... ... @@ -589,14 +591,13 @@ public class AvaliacaoController {
589 591  
590 592 result.use(Results.xml()).from(urlAvaliada).recursive().serialize();
591 593  
592   - /*
  594 +
593 595  
594   - int codResponse = 0;
  596 + /*int codResponse = 0;
595 597 HttpMethod metodoRequisicaoGET = null;
596 598 HttpClient clienteHTTPJakartaCommons;
597 599 url = url.replace("https", "http");
598   -
599   - System.out.println("iniciou a verificarConexao");
  600 +
600 601 codResponse = verificarConexao(url, "http.agent", "Jakarta Commons-HttpClient/3.1");
601 602 if (codResponse != 200) {
602 603 codResponse = verificarConexao(url, "user-agent", "NewUseAgent/1.0");
... ... @@ -606,22 +607,23 @@ public class AvaliacaoController {
606 607  
607 608 if(codResponse == 200)
608 609 {
609   - System.out.println("iniciou a verificarAlteracaoPagina");
  610 +
610 611 if(verificarAlteracaoPagina(url))
611 612 {
612 613 String urlServico = properties.getProperty(URL_SERVICO);
613   -
614   - WebChecker.PostParams postParams = WebChecker.from(urlServico)
  614 +
  615 + WebChecker.PostParams postParams = null;
  616 +
  617 + postParams = WebChecker.from(urlServico)
615 618 .withPostRequest();
616 619  
617 620 postParams.addParam("url", url);
618 621 Gson g = new GsonBuilder().create();
619   - System.out.println("chamou servico ases");
620 622 urlAvaliada = g.fromJson(postParams.execute().getContent(),
621 623 Boolean.class);
  624 +
622 625 //result.use(Results.xml()).from(urlAvaliada).recursive().serialize();
623 626 paginaAvaliada = true;
624   - System.out.println("retornou servico ases");
625 627 }
626 628 else
627 629 {
... ... @@ -685,11 +687,11 @@ public class AvaliacaoController {
685 687  
686 688 public void salvarAvaliacao(ResumoAvaliacao resumoAvaliacao) {
687 689  
688   - //File diretorioJson = new File(this.application.getRealPath("")
689   - // + "/WEB-INF/arquivosJson");
690   - //diretorioJson.mkdir();
691 690  
692   - File diretorioJson = new File( properties.getProperty(SALVAR_ARQUIVOS_JSON));
  691 + //para teste local
  692 + File diretorioJson = new File(this.application.getRealPath("") + "/WEB-INF/arquivosJson"); diretorioJson.mkdir();
  693 +
  694 + //File diretorioJson = new File( properties.getProperty(SALVAR_ARQUIVOS_JSON));
693 695  
694 696  
695 697  
... ... @@ -707,7 +709,7 @@ public class AvaliacaoController {
707 709 }
708 710  
709 711 resumoAvaliacao
710   - .setUrlResultado(urlArquivosHtml + nomeArquivo + ".html");
  712 + .setUrlResultado(urlArquivosHtml + "/" + nomeArquivo + ".html");
711 713  
712 714 String json;
713 715 Gson gson = new Gson();
... ... @@ -737,11 +739,10 @@ public class AvaliacaoController {
737 739 Criterio criterio;
738 740 Recomendacao recomendacao;
739 741  
740   - //File diretorioHtml = new File(this.application.getRealPath("")
741   - // + "/WEB-INF/arquivosHtml");
742   - //diretorioHtml.mkdir();
  742 + //para teste local
  743 + File diretorioHtml = new File(this.application.getRealPath("") + "/WEB-INF/arquivosHtml"); diretorioHtml.mkdir();
743 744  
744   - File diretorioHtml = new File(properties.getProperty(SALVAR_ARQUIVOS_HTML));
  745 + //File diretorioHtml = new File(properties.getProperty(SALVAR_ARQUIVOS_HTML));
745 746  
746 747 String nomeArquivo;
747 748 StringBuffer html = new StringBuffer();
... ... @@ -771,101 +772,101 @@ public class AvaliacaoController {
771 772  
772 773  
773 774  
774   - bufferOut.write("<!DOCTYPE html>");
775   - bufferOut.write("<html lang=\"pt-br\">");
776   - bufferOut.write("<head>");
  775 + bufferOut.write("<!DOCTYPE html>\n");
  776 + bufferOut.write("<html lang=\"pt-br\">\n");
  777 + bufferOut.write("<head>\n");
777 778 bufferOut
778   - .write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
  779 + .write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
779 780 bufferOut
780   - .write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
  781 + .write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n");
781 782  
782 783 bufferOut
783   - .write("<link rel=\"shortcut icon\" href=\"static/ico/favicon.png\">");
  784 + .write("<link rel=\"shortcut icon\" href=\"static/ico/favicon.png\">\n");
784 785  
785 786 bufferOut
786   - .write("<title>Painel de Acessibilidade Digital do Governo</title>");
787   - bufferOut.write("<link href=\"/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">");
  787 + .write("<title>Painel de Acessibilidade Digital do Governo</title>\n");
  788 + bufferOut.write("<link href=\"/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">\n");
788 789 //bufferOut.write("<link href=\"" + this.application.getRealPath("") + "/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">");
789 790  
790 791 bufferOut
791   - .write("<link href=\"/static/css/barra_brasil.css\" rel=\"stylesheet\">");
792   -
793   - bufferOut.write("</head>");
794   - bufferOut.write("<body>");
795   - bufferOut.write("<header id=\"topoPagina\">");
796   - bufferOut.write("<div>");
797   - bufferOut.write(" <div id=\"topo\">");
798   - bufferOut.write(" <ul id=\"accessibility\">");
  792 + .write("<link href=\"/static/css/barra_brasil.css\" rel=\"stylesheet\">\n");
  793 +
  794 + bufferOut.write("</head>\n");
  795 + bufferOut.write("<body>\n");
  796 + bufferOut.write("<header id=\"topoPagina\">\n");
  797 + bufferOut.write("<div>\n");
  798 + bufferOut.write(" <div id=\"topo\">\n");
  799 + bufferOut.write(" <ul id=\"accessibility\">\n");
799 800 bufferOut
800 801 .write(" <li> <a accesskey=\"1\" href=\"#inicioConteudo\" id=\"link-conteudo\">Ir");
801 802 bufferOut.write(" para o conteúdo <span>1</span>");
802   - bufferOut.write(" </a></li>");
  803 + bufferOut.write(" </a></li>\n");
803 804 bufferOut
804 805 .write(" <li><a accesskey=\"4\" href=\"#footer-brasil\" id=\"link-rodape\">Ir");
805 806 bufferOut.write(" para o rodapé <span>4</span>");
806   - bufferOut.write(" </a></li>");
  807 + bufferOut.write(" </a></li>\n");
807 808 bufferOut.write(" </ul><br><br>");
808 809  
809   - bufferOut.write("<div id=\"logo\">");
  810 + bufferOut.write("<div id=\"logo\">\n");
810 811 bufferOut.write("<h1 id=\"portal-title-1\">");
811 812 bufferOut.write(" Painel de Acessibilidade Digital do Governo ");
812   - bufferOut.write("</h1>");
813   - bufferOut.write("</div>");
  813 + bufferOut.write("</h1>\n");
  814 + bufferOut.write("</div>\n");
814 815  
815   - bufferOut.write("<div id=\"barra-brasil\" class=\"barra_brasil\">");
  816 + bufferOut.write("<div id=\"barra-brasil\" class=\"barra_brasil\">\n");
816 817  
817   - bufferOut.write("<ul id=\"menu-barra-temp\">");
  818 + bufferOut.write("<ul id=\"menu-barra-temp\">\n");
818 819 bufferOut
819 820 .write("<li><a class=\"primeiro-link\" href=\"http://brasil.gov.br\">Portal");
820   - bufferOut.write("do Governo Brasileiro</a></li>");
  821 + bufferOut.write("do Governo Brasileiro</a></li>\n");
821 822 bufferOut.write("<li><a class=\"segundo-link\"");
822 823 bufferOut
823 824 .write("href=\"http://epwg.governoeletronico.gov.br/barra/atualize.html\">Atualize");
824   - bufferOut.write("sua Barra de Governo</a></li>");
825   - bufferOut.write("</ul>");
826   - bufferOut.write("</div>");
827   - bufferOut.write("</header>");
828   - bufferOut.write("<div class=\"contanner\"> ");
  825 + bufferOut.write("sua Barra de Governo</a></li>\n");
  826 + bufferOut.write("</ul>\n");
  827 + bufferOut.write("</div>\n");
  828 + bufferOut.write("</header>\n");
  829 + bufferOut.write("<div class=\"contanner\"> \n");
829 830  
830   - bufferOut.write("<div id=\"contato\">");
  831 + bufferOut.write("<div id=\"contato\">\n");
831 832 bufferOut
832   - .write(" <a href=\"http://www.planejamento.gov.br/\">Ministério do Planejamento - http://www.planejamento.gov.br (link para um novo sítio)</a>");
833   - bufferOut.write("</div>");
  833 + .write(" <a href=\"http://www.planejamento.gov.br/\">Ministério do Planejamento - http://www.planejamento.gov.br (link para um novo sítio)</a>\n");
  834 + bufferOut.write("</div>\n");
834 835  
835   - bufferOut.write("<div class=\"contanner\">");
  836 + bufferOut.write("<div class=\"contanner\">\n");
836 837 bufferOut
837   - .write("<a id=\"inicioConteudo\" class=\"oculto\">Início do conteúdo</a>");
  838 + .write("<a id=\"inicioConteudo\" class=\"oculto\">Início do conteúdo</a>\n");
838 839  
839 840  
840   - bufferOut.write(" <div class=\"logoAvaliacao\">");
  841 + bufferOut.write(" <div class=\"logoAvaliacao\">\n");
841 842 bufferOut.write(" <div id=\"emag\">");
842   - bufferOut.write(" <label>eMAG v. 3.1</label> ");
843   - bufferOut.write(" </div>");
  843 + bufferOut.write(" <label>eMAG v. 3.1</label> \n");
  844 + bufferOut.write(" </div>\n");
844 845  
845 846  
846   - bufferOut.write(" <div id=\"testesAutomaticos\"> ");
  847 + bufferOut.write(" <div id=\"testesAutomaticos\"> \n");
847 848 //bufferOut.write(" <label>Testes Automáticos<br> Nota: " + resumoAvaliacao.getValor() + "/100</label> </div> ");
848 849  
849   - bufferOut.write(" <div class=\"cell width-5 position-2 >");
  850 + bufferOut.write(" <div class=\"cell width-5 position-2 >\n");
850 851  
851 852  
852   - bufferOut.write(" <div id=\"block\">");
  853 + bufferOut.write(" <div id=\"block\">\n");
853 854 bufferOut.write(" <div id=\"webaxscore\" class=\"scoreB_" + webaxscore + "\">Porcentagem");
854 855 bufferOut.write(" <strong>ASES</strong>");
855   - bufferOut.write(" <span>" + notaAvaliacao +"%</span>");
856   - bufferOut.write(" </div>");
857   - bufferOut.write(" </div>");
  856 + bufferOut.write(" <span>" + notaAvaliacao +"%</span>\n");
  857 + bufferOut.write(" </div>\n");
  858 + bufferOut.write(" </div>\n");
858 859  
859 860 //bufferOut.write(" <br>");
860 861  
861 862  
862   - bufferOut.write("<div id=\"legenda\" >");
  863 + bufferOut.write("<div id=\"legenda\" >\n");
863 864 bufferOut.write("<label>Legenda</label><br>");
864 865 bufferOut.write("<ul>");
865   - bufferOut.write(" <li class=\"legenda\"><img id=\"bom\" alt=\"farol verde, nota maior ou igual a 95%\" src=\"http://189.9.137.162:8080/eselo/static/img/verde.png\"></li>");
866   - bufferOut.write(" <li class=\"legenda\"><img id=\"razoavel\" alt=\"farol amarela, nota maior ou igual a 85% e menor que 95%\" src=\"http://189.9.137.162:8080/eselo/static/img/amarelo.png\"></li>");
867   - bufferOut.write(" <li class=\"legenda\"><img id=\"ruim\" alt=\"farol laranja, nota maior ou igual a 70% e menor que 85%\" src=\"http://189.9.137.162:8080/eselo/static/img/laranja.png\"></li>");
868   - bufferOut.write(" <li class=\"legenda\"><img id=\"pessimo\" alt=\"farol vermelho, nota menor que 70%\" src=\"http://189.9.137.162:8080/eselo/static/img/vermelho.png\"></li>");
  866 + bufferOut.write(" <li class=\"legenda\"><img id=\"bom\" alt=\"farol verde, nota maior ou igual a 95%\" src=\"/static/img/verde.png\"></li>");
  867 + bufferOut.write(" <li class=\"legenda\"><img id=\"razoavel\" alt=\"farol amarela, nota maior ou igual a 85% e menor que 95%\" src=\"/static/img/amarelo.png\"></li>");
  868 + bufferOut.write(" <li class=\"legenda\"><img id=\"ruim\" alt=\"farol laranja, nota maior ou igual a 70% e menor que 85%\" src=\"/static/img/laranja.png\"></li>");
  869 + bufferOut.write(" <li class=\"legenda\"><img id=\"pessimo\" alt=\"farol vermelho, nota menor que 70%\" src=\"/static/img/vermelho.png\"></li>");
869 870 bufferOut.write("</ul>");
870 871 bufferOut.write("</div>");
871 872  
... ... @@ -890,7 +891,7 @@ public class AvaliacaoController {
890 891 bufferOut.write(" </div> ");*/
891 892  
892 893  
893   - bufferOut.write(" <div id=\"grafico\" > ");
  894 + bufferOut.write(" <div id=\"grafico2\" > ");
894 895  
895 896 bufferOut
896 897 .write(" <h2 class=\"oculto_visao\" >Gráfico com as notas das últimas avaliações ordenada da mais antiga para a mais atual, limitado até quatro avaliações.</h2> ");
... ... @@ -914,8 +915,7 @@ public class AvaliacaoController {
914 915 i = 0;
915 916 for (Avaliacao avaliacaoOrdenada : avaliacoesOrdenada) {
916 917 i++;
917   - bufferOut
918   - .write("<li >Nota " + i + ": <span id=\"nota" + i
  918 + bufferOut.write("<li >Nota " + i + ": <span id=\"nota" + i
919 919 + "\">" + avaliacaoOrdenada.getNota()
920 920 + "</span><span>Data da avaliação:"
921 921 + avaliacaoOrdenada.getDataAvaliacao()
... ... @@ -1083,48 +1083,50 @@ public class AvaliacaoController {
1083 1083 private boolean verificarAlteracaoPagina(String url) {
1084 1084  
1085 1085 boolean paginaAlterada = false;
1086   - System.out.println("iniciou a verificacao");
1087   - //WebChecker pagina = WebChecker.from(url).withGetRequest().execute();
1088   - String html = "1234";//pagina.getContent().toLowerCase();
  1086 + WebChecker pagina = WebChecker.from(url).withGetRequest().execute();
  1087 + String html = pagina.getContent().toString().toLowerCase().replace("\n", "");
  1088 +
1089 1089 MessageDigest digest;
1090 1090 byte[] secured = null;
1091 1091  
1092   - System.out.println("iniciou a criacao hash");
  1092 +
  1093 +
1093 1094 try {
1094   - digest = MessageDigest.getInstance("MD5");
  1095 + digest = MessageDigest.getInstance("SHA-1");
1095 1096 digest.reset();
1096 1097 secured = digest.digest(html.getBytes());
1097 1098  
1098 1099 } catch (NoSuchAlgorithmException e) {
1099 1100 e.printStackTrace();
1100 1101 }
1101   - System.out.println("terminou criacao hash");
1102 1102  
1103 1103 Url urlCompleta = null;
1104 1104 try {
1105   - urlCompleta = daoUrl.getStringUrl(URLNormalizer.normalize(url));
1106   -
1107   - System.out.println("buscou urlCompleta");
  1105 + urlCompleta = daoUrl.getStringUrl(URLNormalizer.normalize(url));
1108 1106 } catch (MalformedURLException e) {
1109 1107 e.printStackTrace();
1110 1108 }
1111 1109  
  1110 + pagina = null;
  1111 + html = null;
  1112 +
1112 1113 if(urlCompleta != null)
1113 1114 {
  1115 +
1114 1116 if (urlCompleta.getCodHash() == null || !MessageDigest.isEqual(urlCompleta.getCodHash(), secured))
1115 1117 {
  1118 +
1116 1119  
1117 1120 try {
1118 1121 urlCompleta.setCodHash(secured);
1119 1122 daoUrl.update(urlCompleta);
1120 1123 paginaAlterada = true;
  1124 +
  1125 +
1121 1126 } catch (Exception e) {
1122 1127 e.getCause();
1123 1128 }
1124 1129  
1125   -
1126   -
1127   -
1128 1130 }
1129 1131 }
1130 1132 else
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/ErrosMaisComunsController.java 0 → 100644
... ... @@ -0,0 +1,579 @@
  1 +package br.com.eselo.controller;
  2 +
  3 +import java.io.File;
  4 +import java.io.FileNotFoundException;
  5 +import java.io.FileOutputStream;
  6 +import java.io.IOException;
  7 +import java.io.InputStream;
  8 +import java.io.OutputStreamWriter;
  9 +import java.io.UnsupportedEncodingException;
  10 +import java.text.DecimalFormat;
  11 +import java.util.List;
  12 +import java.util.Properties;
  13 +
  14 +import javax.servlet.ServletContext;
  15 +
  16 +import org.slf4j.Logger;
  17 +import org.slf4j.LoggerFactory;
  18 +
  19 +import br.com.caelum.vraptor.Get;
  20 +import br.com.caelum.vraptor.Resource;
  21 +import br.com.caelum.vraptor.Result;
  22 +import br.com.caelum.vraptor.view.Results;
  23 +import br.com.eselo.component.Mailer;
  24 +import br.com.eselo.dao.ErrosMaisComunsDAO;
  25 +import br.com.eselo.model.Avaliacao;
  26 +import br.com.eselo.model.ErrosMaisComuns;
  27 +
  28 +@Resource
  29 +public class ErrosMaisComunsController {
  30 +
  31 + private static final Logger LOGGER = LoggerFactory.getLogger(AvaliacaoController.class);
  32 + private final ErrosMaisComunsDAO errosMaisComunsDAO;
  33 + private ServletContext application;
  34 + private Result result;
  35 + private static final String PAINEL_AGREGADO = "eselo.config.avaliacao.painelAgregado";
  36 + private final Properties properties = new Properties();
  37 +
  38 + public ErrosMaisComunsController(ErrosMaisComunsDAO _errosMaisComunsDAO, ServletContext application, Result result) throws IOException {
  39 + super();
  40 + errosMaisComunsDAO = _errosMaisComunsDAO;
  41 + this.application = application;
  42 + this.result = result;
  43 + String fileName = "config.properties";
  44 + InputStream stream = Mailer.class.getResourceAsStream("/" + fileName);
  45 + Properties propertiesFile = new Properties();
  46 +
  47 + if (stream != null) {
  48 + propertiesFile.load(stream);
  49 + this.properties.putAll(propertiesFile);
  50 + } else {
  51 + LOGGER.warn("Could not find the file '{}' to load.", fileName);
  52 + }
  53 + }
  54 +
  55 +
  56 + @Get("/gerar-painel-erros-mais-comuns")
  57 + public void gerarPainelErrosMaisComuns() {
  58 +
  59 + List<ErrosMaisComuns> lsErrosMaisComuns = errosMaisComunsDAO.errosMaisComuns();
  60 + File painelAgregado = new File(properties.getProperty(PAINEL_AGREGADO));
  61 +
  62 + boolean paginaGerada = false;
  63 +
  64 + try {
  65 + //List<ErrosMaisComuns> lsErrosMaisComuns = errosMaisComunsDAO.errosMaisComuns();
  66 +
  67 + OutputStreamWriter bufferOut = new OutputStreamWriter(new FileOutputStream(painelAgregado + "/painelAgregado.txt"),"UTF-8");
  68 +
  69 + System.out.println(painelAgregado);
  70 + //Inicia criação da página
  71 +
  72 +
  73 + //bufferOut.write(" <%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%> ");
  74 + //bufferOut.write(" <%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%> ");
  75 + //bufferOut.write(" <%@ taglib prefix=\"tiles\" uri=\"http://tiles.apache.org/tags-tiles\"%> ");
  76 +
  77 + bufferOut.write("<!DOCTYPE html>\n");
  78 + bufferOut.write("<html lang=\"pt-br\">\n");
  79 + bufferOut.write("<head>\n");
  80 + bufferOut
  81 + .write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  82 + bufferOut
  83 + .write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n");
  84 +
  85 + bufferOut
  86 + .write("<link rel=\"shortcut icon\" href=\"static/ico/favicon.png\">\n");
  87 +
  88 + bufferOut
  89 + .write("<title>Painel de Acessibilidade Digital do Governo</title>\n");
  90 + bufferOut.write("<link href=\"/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">\n");
  91 + //bufferOut.write("<link href=\"" + this.application.getRealPath("") + "/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">");
  92 +
  93 + bufferOut
  94 + .write("<link href=\"/static/css/barra_brasil.css\" rel=\"stylesheet\">\n");
  95 +
  96 + bufferOut.write("</head>\n");
  97 + bufferOut.write("<body>\n");
  98 + bufferOut.write("<header id=\"topoPagina\">\n");
  99 + bufferOut.write("<div>\n");
  100 + bufferOut.write(" <div id=\"topo\">\n");
  101 + bufferOut.write(" <ul id=\"accessibility\">\n");
  102 + bufferOut
  103 + .write(" <li> <a accesskey=\"1\" href=\"#inicioConteudo\" id=\"link-conteudo\">Ir");
  104 + bufferOut.write(" para o conteúdo <span>1</span>");
  105 + bufferOut.write(" </a></li>\n");
  106 + bufferOut
  107 + .write(" <li><a accesskey=\"4\" href=\"#footer-brasil\" id=\"link-rodape\">Ir");
  108 + bufferOut.write(" para o rodapé <span>4</span>");
  109 + bufferOut.write(" </a></li>\n");
  110 + bufferOut.write(" </ul><br><br>");
  111 +
  112 + bufferOut.write("<div id=\"logo\">\n");
  113 + bufferOut.write("<h1 id=\"portal-title-1\">");
  114 + bufferOut.write(" Painel de Acessibilidade Digital do Governo ");
  115 + bufferOut.write("</h1>\n");
  116 + bufferOut.write("</div>\n");
  117 +
  118 + bufferOut.write("<div id=\"barra-brasil\" class=\"barra_brasil\">\n");
  119 +
  120 + bufferOut.write("<ul id=\"menu-barra-temp\">\n");
  121 + bufferOut
  122 + .write("<li><a class=\"primeiro-link\" href=\"http://brasil.gov.br\">Portal");
  123 + bufferOut.write("do Governo Brasileiro</a></li>\n");
  124 + bufferOut.write("<li><a class=\"segundo-link\"");
  125 + bufferOut
  126 + .write("href=\"http://epwg.governoeletronico.gov.br/barra/atualize.html\">Atualize");
  127 + bufferOut.write("sua Barra de Governo</a></li>\n");
  128 + bufferOut.write("</ul>\n");
  129 + bufferOut.write("</div>\n");
  130 + bufferOut.write("</header>\n");
  131 + bufferOut.write("<div class=\"contanner\"> \n");
  132 +
  133 + //bufferOut.write("<div id=\"contato\">\n");
  134 + //bufferOut
  135 + // .write(" <a href=\"http://www.planejamento.gov.br/\">Ministério do Planejamento - http://www.planejamento.gov.br (link para um novo sítio)</a>\n");
  136 + //bufferOut.write("</div>\n");
  137 +
  138 + bufferOut.write(" <div class=\"contanner\"> ");
  139 +
  140 +
  141 + bufferOut.write(" <div class=\"logoAvaliacao\"> ");
  142 + bufferOut.write(" <div id=\"emag\"> ");
  143 + bufferOut.write(" <label>eMAG v 3.1</label> ");
  144 + bufferOut.write(" </div> ");
  145 +
  146 +
  147 + //bufferOut.write(" <div id=\"testesAutomaticos\"> ");
  148 + //bufferOut.write(" <label>Testes Automáticos<br>7.3/10</label> </div> ");
  149 +
  150 + //início Gráfico
  151 + bufferOut.write(" <div id=\"grafico\"> ");
  152 +
  153 +
  154 + bufferOut
  155 + .write(" <h2 class=\"oculto_visao\" >Gráfico com os 10 erros mais comuns.</h2> ");
  156 +
  157 + bufferOut.write("<ul class=\"oculto_visao\" > ");
  158 +
  159 + long total = 0;
  160 + double percentual = 0;
  161 + long totalDezErrosMaisComuns = 0;
  162 + double qntErro;
  163 +
  164 + int i = 0;
  165 + for (ErrosMaisComuns errosMaisComuns : lsErrosMaisComuns) {
  166 +
  167 + if(errosMaisComuns.getDescricao().equalsIgnoreCase("Total"))
  168 + {
  169 + total = errosMaisComuns.getQtd_erros();
  170 + }
  171 + else
  172 + {
  173 + qntErro = errosMaisComuns.getQtd_erros() * 100;
  174 + percentual = qntErro/total;
  175 + totalDezErrosMaisComuns = totalDezErrosMaisComuns + errosMaisComuns.getQtd_erros();
  176 +
  177 + DecimalFormat df = new DecimalFormat("0.##");
  178 +
  179 + i++;
  180 + bufferOut.write("<li >erro: <span id=\"erro" + i +"\">" + "Erro: " + i + "</span><span>" + errosMaisComuns.getDescricao() + "</span> <span id=\"p_erro" + i + "\">" + df.format(percentual) + "</span></li>");
  181 + }
  182 + }
  183 +
  184 + qntErro = (total - totalDezErrosMaisComuns) * 100;
  185 + percentual = qntErro/total;
  186 +
  187 + DecimalFormat df = new DecimalFormat("0.##");
  188 +
  189 + i++;
  190 + bufferOut.write("<li >erro: <span id=\"erro" + i + "\">" + "Erro: " + i + "</span><span>Outros</span> <span id=\"p_erro" + i + "\">" + df.format(percentual) + "</span></li>");
  191 +
  192 + bufferOut.write("</ul>");
  193 + bufferOut.write("<label id=\"qntAvaliacoes\" class=\"oculto\">" + i
  194 + + "</label>");
  195 + bufferOut.write(" <div class=\"myChart\" > ");
  196 + bufferOut.write(" <canvas id=\"myChart\" ></canvas> ");
  197 + bufferOut.write(" </div>");
  198 + bufferOut.write(" </div>");
  199 + bufferOut.write(" </div>");
  200 + bufferOut.write(" </div>");
  201 +
  202 + //inicio Avaliação
  203 + bufferOut.write(" <div class=\"avaliacao\"> ");
  204 +
  205 +
  206 + bufferOut.write(" <h2 id=\"tituloTabela\">Os 10 erros mais comuns</h2>");
  207 + //inicio tabela
  208 + bufferOut.write(" <table> ");
  209 + bufferOut.write(" <thead> ");
  210 + bufferOut.write(" <tr><th colspan=\"3\"> Testes Automáticos</th></tr>");
  211 + bufferOut.write(" <tr> ");
  212 + bufferOut.write(" <th id=\"erro_numero\">Erro n°</th> ");
  213 + bufferOut.write(" <th id=\"erro\">Erro</th> ");
  214 + bufferOut.write(" <th id=\"incidencia\">Incidência</th> ");
  215 +
  216 +
  217 +
  218 +
  219 +
  220 + total = 0;
  221 + percentual = 0;
  222 + totalDezErrosMaisComuns = 0;
  223 + qntErro = 0;
  224 + Integer erro_numero = 0;
  225 +
  226 + for (ErrosMaisComuns errosMaisComuns : lsErrosMaisComuns) {
  227 +
  228 + if(errosMaisComuns.getDescricao().equalsIgnoreCase("Total"))
  229 + {
  230 + total = errosMaisComuns.getQtd_erros();
  231 + }
  232 + else
  233 + {
  234 + qntErro = errosMaisComuns.getQtd_erros() * 100.00;
  235 + percentual = qntErro/total;
  236 + totalDezErrosMaisComuns = totalDezErrosMaisComuns + errosMaisComuns.getQtd_erros();
  237 +
  238 + erro_numero++;
  239 +
  240 + DecimalFormat df2 = new DecimalFormat("0.##");
  241 + bufferOut.write(" <tr> ");
  242 + bufferOut.write(" <td headers=\"erro_numero\" class=\"celula\"> " + erro_numero + " </td> ");
  243 + bufferOut.write(" <td headers=\"erro\" class=\"celula\"> " + errosMaisComuns.getDescricao() + " </td> ");
  244 + bufferOut.write(" <td headers=\"incidencia\" class=\"celula\"> " + df2.format(percentual) + "% </td> ");
  245 + bufferOut.write(" </tr> ");
  246 + System.out.println(df2.format(percentual));
  247 + }
  248 + }
  249 +
  250 + qntErro = (total - totalDezErrosMaisComuns) * 100.00;
  251 + percentual = qntErro/total;
  252 +
  253 + DecimalFormat df2 = new DecimalFormat("0.##");
  254 +
  255 + erro_numero++;
  256 +
  257 + bufferOut.write(" <tr> ");
  258 + bufferOut.write(" <td headers=\"erro_numero\" class=\"celula\"> " + erro_numero + " </td> ");
  259 + bufferOut.write(" <td headers=\"erroMaisComum\" class=\"celula\"> <a href=\"/outros-erros-mais-comuns\"> Outros </a></td> ");
  260 + bufferOut.write(" <td headers=\"percentual\" class=\"celula\">" + df2.format(percentual) + "%</td> ");
  261 + bufferOut.write(" <tr> ");
  262 +
  263 + bufferOut.write(" </tbody> ");
  264 + bufferOut.write(" </table> <br>");
  265 +
  266 +
  267 + //fim Avaliação
  268 + bufferOut.write(" </div> ");
  269 + //bufferOut.write(" </div> ");
  270 +
  271 + bufferOut.write("<div id=\"voltar-topo\">");
  272 + bufferOut.write("<a href=\"#topoPagina\">Voltar para o topo</a>");
  273 + bufferOut.write("</div>");
  274 +
  275 + //fim contanner
  276 + bufferOut.write(" </div> ");
  277 + bufferOut.write(" </div> ");
  278 + bufferOut.write("<footer id=\"footer-brasil\"></footer>");
  279 + bufferOut
  280 + .write("<script defer=\"defer\" src=\"//barra.brasil.gov.br/barra.js\"");
  281 + bufferOut.write("type=\"text/javascript\"></script>");
  282 +
  283 + bufferOut.write("<script type=\"text/javascript\" src=\"/static/js/jquery-1.10.2.min.js\"></script>");
  284 + //bufferOut.write("<script type=\"text/javascript\" src=\"" + this.application.getRealPath("") + "/static/js/jquery-1.10.2.min.js\"></script>");
  285 +
  286 + bufferOut
  287 + .write("<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js\"></script>");
  288 +
  289 +
  290 + bufferOut.write("<script src=\"/static/js/chartPainelAgregado.js\"></script>");
  291 + //bufferOut.write("<script src=\"" + this.application.getRealPath("") + "/static/js/chart.js\"></script>");
  292 +
  293 +
  294 + bufferOut.write("<noscript>Seu navegador não possui suporte para JavaScript!</noscript>");
  295 + bufferOut.write("</body>");
  296 + bufferOut.write(" </html> ");
  297 +
  298 +
  299 + bufferOut.close();
  300 + paginaGerada = true;
  301 + //Termina criação da página
  302 + if(paginaGerada)
  303 + {
  304 + paginaGerada = gerarPainelOutrosErrosMaisComuns();
  305 + }
  306 +
  307 +
  308 + } catch (UnsupportedEncodingException e) {
  309 + paginaGerada = false;
  310 + e.printStackTrace();
  311 + } catch (FileNotFoundException e) {
  312 + paginaGerada = false;
  313 + e.printStackTrace();
  314 + } catch (IOException e) {
  315 + paginaGerada = false;
  316 + e.printStackTrace();
  317 + }finally
  318 + {
  319 + result.use(Results.xml()).from(paginaGerada).recursive().serialize();
  320 + }
  321 +
  322 +
  323 + }
  324 +
  325 + @SuppressWarnings("finally")
  326 + private boolean gerarPainelOutrosErrosMaisComuns()
  327 + {
  328 + boolean paginaGerada = false;
  329 +
  330 + File painelAgregado = new File(properties.getProperty(PAINEL_AGREGADO));
  331 +
  332 + try {
  333 + List<ErrosMaisComuns> lsOutrosErrosMaisComuns = errosMaisComunsDAO.OutrosErrosMaisComuns();
  334 +
  335 + OutputStreamWriter bufferOut = new OutputStreamWriter(new FileOutputStream(painelAgregado + "/painelOutrosErrosMaisComuns.txt"),"UTF-8");
  336 +
  337 + System.out.println(painelAgregado);
  338 + //Inicia criação da página
  339 +
  340 +
  341 + //bufferOut.write(" <%@ page language=\"java\" contentType=\"text/html; charset=UTF-8\" pageEncoding=\"UTF-8\"%> ");
  342 + //bufferOut.write(" <%@ taglib prefix=\"c\" uri=\"http://java.sun.com/jsp/jstl/core\"%> ");
  343 + //bufferOut.write(" <%@ taglib prefix=\"tiles\" uri=\"http://tiles.apache.org/tags-tiles\"%> ");
  344 +
  345 + bufferOut.write("<!DOCTYPE html>\n");
  346 + bufferOut.write("<html lang=\"pt-br\">\n");
  347 + bufferOut.write("<head>\n");
  348 + bufferOut
  349 + .write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n");
  350 + bufferOut
  351 + .write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n");
  352 +
  353 + bufferOut
  354 + .write("<link rel=\"shortcut icon\" href=\"static/ico/favicon.png\">\n");
  355 +
  356 + bufferOut
  357 + .write("<title>Painel de Acessibilidade Digital do Governo</title>\n");
  358 + bufferOut.write("<link href=\"/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">\n");
  359 + //bufferOut.write("<link href=\"" + this.application.getRealPath("") + "/static/css/painelAcessibilidade.css\" rel=\"stylesheet\">");
  360 +
  361 + bufferOut
  362 + .write("<link href=\"/static/css/barra_brasil.css\" rel=\"stylesheet\">\n");
  363 +
  364 + bufferOut.write("</head>\n");
  365 + bufferOut.write("<body>\n");
  366 + bufferOut.write("<header id=\"topoPagina\">\n");
  367 + bufferOut.write("<div>\n");
  368 + bufferOut.write(" <div id=\"topo\">\n");
  369 + bufferOut.write(" <ul id=\"accessibility\">\n");
  370 + bufferOut
  371 + .write(" <li> <a accesskey=\"1\" href=\"#inicioConteudo\" id=\"link-conteudo\">Ir");
  372 + bufferOut.write(" para o conteúdo <span>1</span>");
  373 + bufferOut.write(" </a></li>\n");
  374 + bufferOut
  375 + .write(" <li><a accesskey=\"4\" href=\"#footer-brasil\" id=\"link-rodape\">Ir");
  376 + bufferOut.write(" para o rodapé <span>4</span>");
  377 + bufferOut.write(" </a></li>\n");
  378 + bufferOut.write(" </ul><br><br>");
  379 +
  380 + bufferOut.write("<div id=\"logo\">\n");
  381 + bufferOut.write("<h1 id=\"portal-title-1\">");
  382 + bufferOut.write(" Painel de Acessibilidade Digital do Governo ");
  383 + bufferOut.write("</h1>\n");
  384 + bufferOut.write("</div>\n");
  385 +
  386 + bufferOut.write("<div id=\"barra-brasil\" class=\"barra_brasil\">\n");
  387 +
  388 + bufferOut.write("<ul id=\"menu-barra-temp\">\n");
  389 + bufferOut
  390 + .write("<li><a class=\"primeiro-link\" href=\"http://brasil.gov.br\">Portal");
  391 + bufferOut.write("do Governo Brasileiro</a></li>\n");
  392 + bufferOut.write("<li><a class=\"segundo-link\"");
  393 + bufferOut
  394 + .write("href=\"http://epwg.governoeletronico.gov.br/barra/atualize.html\">Atualize");
  395 + bufferOut.write("sua Barra de Governo</a></li>\n");
  396 + bufferOut.write("</ul>\n");
  397 + bufferOut.write("</div>\n");
  398 + bufferOut.write("</header>\n");
  399 + bufferOut.write("<div class=\"contanner\"> \n");
  400 +
  401 + //bufferOut.write("<div id=\"contato\">\n");
  402 + //bufferOut.write(" <a href=\"http://www.planejamento.gov.br/\">Ministério do Planejamento - http://www.planejamento.gov.br (link para um novo sítio)</a>\n");
  403 + //bufferOut.write("</div>\n");
  404 +
  405 + bufferOut.write(" <div class=\"contanner\"> ");
  406 +
  407 +
  408 + //bufferOut.write(" <div class=\"logoAvaliacao\"> ");
  409 + //bufferOut.write(" <div id=\"emag\"> ");
  410 + //bufferOut.write(" <label>eMAG</label> ");
  411 + //bufferOut.write(" </div> ");
  412 +
  413 +
  414 + //bufferOut.write(" <div id=\"testesAutomaticos\"> ");
  415 + //bufferOut.write(" <label>Testes Automáticos<br>7.3/10</label> </div> ");
  416 +
  417 + //início Gráfico
  418 + //bufferOut.write(" <div id=\"grafico\"> ");
  419 +
  420 +
  421 + /*bufferOut
  422 + .write(" <h2 class=\"oculto_visao\" >Gráfico com os 10 erros mais comuns.</h2> ");
  423 +
  424 + bufferOut.write("<ul class=\"oculto_visao\" > ");
  425 +
  426 + long total = 0;
  427 + double percentual = 0;
  428 + long totalDezErrosMaisComuns = 0;
  429 + double qntErro;
  430 +
  431 + int i = 0;
  432 + for (ErrosMaisComuns errosMaisComuns : lsOutrosErrosMaisComuns) {
  433 + i++;
  434 + if(errosMaisComuns.getDsDescricao().equalsIgnoreCase("Total"))
  435 + {
  436 + total = errosMaisComuns.getQtdErros();
  437 + }
  438 + else if( i > 10)
  439 + {
  440 + qntErro = errosMaisComuns.getQtdErros() * 100.00;
  441 + percentual = qntErro/total;
  442 + totalDezErrosMaisComuns = totalDezErrosMaisComuns + errosMaisComuns.getQtdErros();
  443 +
  444 + DecimalFormat df = new DecimalFormat("0.##");
  445 +
  446 +
  447 + bufferOut.write("<li >erro: <span id=\"erro" + i +"\">" + "Erro: " + i + "</span><span>" + errosMaisComuns.getDsDescricao() + "</span> <span id=\"p_erro" + i + "\">" + df.format(percentual) + "</span></li>");
  448 + }
  449 + }
  450 +
  451 + qntErro = (total - totalDezErrosMaisComuns) * 100.00;
  452 + percentual = qntErro/total;
  453 +
  454 + DecimalFormat df = new DecimalFormat("0.##");
  455 +
  456 + i++;
  457 + bufferOut.write("<li >erro: <span id=\"erro" + i + "\">" + "Erro: " + i + "</span><span>Outros</span> <span id=\"p_erro" + i + "\">" + df.format(percentual) + "</span></li>");
  458 +
  459 + bufferOut.write("</ul>");
  460 + bufferOut.write("<label id=\"qntAvaliacoes\" class=\"oculto\">" + i
  461 + + "</label>");
  462 + bufferOut.write(" <div class=\"myChart\" > ");
  463 + bufferOut.write(" <canvas id=\"myChart\" ></canvas> ");
  464 + bufferOut.write(" </div>");
  465 + bufferOut.write(" </div>");*/
  466 + //bufferOut.write(" </div>");
  467 + //bufferOut.write(" </div>");
  468 +
  469 + //inicio Avaliação
  470 +
  471 + bufferOut
  472 + .write(" <a href=\"/painelAcessibilidade\">Voltar ao painel de acessibilidade</a>\n");
  473 + bufferOut.write(" <div class=\"avaliacao\"> ");
  474 +
  475 + bufferOut.write(" <h2 id=\"tituloTabela\">Outros erros mais comuns</h2>");
  476 + //inicio tabela
  477 + bufferOut.write(" <table> ");
  478 + bufferOut.write(" <thead> ");
  479 + bufferOut.write(" <tr><th colspan=\"3\"> Testes Automáticos</th></tr>");
  480 + bufferOut.write(" <tr> ");
  481 + bufferOut.write(" <th id=\"erro_numero\">Erro nº</th> ");
  482 + bufferOut.write(" <th id=\"erro\">Erro</th> ");
  483 + bufferOut.write(" <th id=\"incidencia\">Incidência</th> ");
  484 +
  485 +
  486 +
  487 +
  488 +
  489 + long total = 0;
  490 + double percentual = 0;
  491 + long totalDezErrosMaisComuns = 0;
  492 + double qntErro = 0;
  493 + int i = 0;
  494 + int erro_numero = 0;
  495 +
  496 + for (ErrosMaisComuns errosMaisComuns : lsOutrosErrosMaisComuns) {
  497 + i++;
  498 + if(errosMaisComuns.getDescricao().equalsIgnoreCase("Total"))
  499 + {
  500 + total = errosMaisComuns.getQtd_erros();
  501 + }
  502 + else if(i > 10)
  503 + {
  504 +
  505 + qntErro = errosMaisComuns.getQtd_erros() * 100.00;
  506 + percentual = qntErro/total;
  507 + totalDezErrosMaisComuns = totalDezErrosMaisComuns + errosMaisComuns.getQtd_erros();
  508 +
  509 + DecimalFormat df2 = new DecimalFormat("0.##");
  510 +
  511 + erro_numero++;
  512 +
  513 + bufferOut.write(" <tr> ");
  514 + bufferOut.write(" <td headers=\"erro_numero\" class=\"celula\"> " + erro_numero + " </td> ");
  515 + bufferOut.write(" <td headers=\"erro\" class=\"celula\"> " + errosMaisComuns.getDescricao() + " </td> ");
  516 + bufferOut.write(" <td headers=\"incidencia\" class=\"celula\"> " + df2.format(percentual) + "% </td> ");
  517 + bufferOut.write(" </tr> ");
  518 + }
  519 + }
  520 +
  521 +
  522 +
  523 + bufferOut.write(" </tbody> ");
  524 + bufferOut.write(" </table> <br>");
  525 +
  526 +
  527 + //fim Avaliação
  528 + bufferOut.write(" </div> ");
  529 + //bufferOut.write(" </div> ");
  530 +
  531 + bufferOut.write("<div id=\"voltar-topo\">");
  532 + bufferOut.write("<a href=\"#topoPagina\">Voltar para o topo</a>");
  533 + bufferOut.write("</div>");
  534 +
  535 + //fim contanner
  536 + bufferOut.write(" </div> ");
  537 + bufferOut.write(" </div> ");
  538 + bufferOut.write("<footer id=\"footer-brasil\"></footer>");
  539 + bufferOut
  540 + .write("<script defer=\"defer\" src=\"//barra.brasil.gov.br/barra.js\"");
  541 + bufferOut.write("type=\"text/javascript\"></script>");
  542 +
  543 + bufferOut.write("<script type=\"text/javascript\" src=\"/static/js/jquery-1.10.2.min.js\"></script>");
  544 + //bufferOut.write("<script type=\"text/javascript\" src=\"" + this.application.getRealPath("") + "/static/js/jquery-1.10.2.min.js\"></script>");
  545 +
  546 + bufferOut
  547 + .write("<script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.3/Chart.min.js\"></script>");
  548 +
  549 +
  550 + bufferOut.write("<script src=\"/static/js/chartPainelAgregado.js\"></script>");
  551 + //bufferOut.write("<script src=\"" + this.application.getRealPath("") + "/static/js/chart.js\"></script>");
  552 +
  553 +
  554 + bufferOut.write("<noscript>Seu navegador não possui suporte para JavaScript!</noscript>");
  555 + bufferOut.write("</body>");
  556 + bufferOut.write(" </html> ");
  557 +
  558 +
  559 + bufferOut.close();
  560 + paginaGerada = true;
  561 + //Termina criação da página
  562 +
  563 + } catch (UnsupportedEncodingException e) {
  564 + paginaGerada = false;
  565 + e.printStackTrace();
  566 + } catch (FileNotFoundException e) {
  567 + paginaGerada = false;
  568 + e.printStackTrace();
  569 + } catch (IOException e) {
  570 + paginaGerada = false;
  571 + e.printStackTrace();
  572 + }finally
  573 + {
  574 + return paginaGerada;
  575 + }
  576 + }
  577 +
  578 +
  579 +}
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/PainelAcessibilidadeController.java
1 1 package br.com.eselo.controller;
2 2  
3 3  
  4 +import java.io.BufferedReader;
  5 +import java.io.File;
  6 +import java.io.FileInputStream;
  7 +import java.io.FileNotFoundException;
  8 +import java.io.IOException;
  9 +import java.io.InputStream;
  10 +import java.io.InputStreamReader;
4 11 import java.net.MalformedURLException;
  12 +import java.sql.Date;
5 13 import java.util.ArrayList;
6 14 import java.util.List;
  15 +import java.util.Properties;
7 16  
8 17 import javax.ws.rs.QueryParam;
9 18  
  19 +import org.slf4j.Logger;
  20 +import org.slf4j.LoggerFactory;
  21 +
10 22 import br.com.caelum.vraptor.Get;
  23 +import br.com.caelum.vraptor.Path;
11 24 import br.com.caelum.vraptor.Post;
12 25 import br.com.caelum.vraptor.Resource;
13 26 import br.com.caelum.vraptor.Result;
14 27 import br.com.caelum.vraptor.Validator;
  28 +import br.com.caelum.vraptor.ioc.spring.VRaptorRequestHolder;
  29 +import br.com.eselo.component.Mailer;
15 30 import br.com.eselo.component.URLNormalizer;
  31 +import br.com.eselo.component.Util;
  32 +import br.com.eselo.conversor.ESeloDateConverter;
  33 +import br.com.eselo.dao.ErrosMaisComunsDAO;
  34 +import br.com.eselo.dao.MediaAvaliacaoDAO;
16 35 import br.com.eselo.dao.UrlDAO;
  36 +import br.com.eselo.model.MediaAvaliacao;
  37 +import br.com.eselo.model.UltimaAvaliacao;
17 38 import br.com.eselo.model.Url;
18 39  
19 40 @Resource
20 41 public class PainelAcessibilidadeController {
21 42  
  43 + private static final Logger LOGGER = LoggerFactory
  44 + .getLogger(AvaliacaoController.class);
22 45 private Result result;
23 46 private Validator validator;
24 47 private final UrlDAO daoUrl;
  48 + private final MediaAvaliacaoDAO mediaAvaliacaoDAO;
  49 + private static final String PAINEL_AGREGADO = "eselo.config.avaliacao.painelAgregado";
  50 + private final Properties properties = new Properties();
25 51  
26   - public PainelAcessibilidadeController(Result result, Validator validator, UrlDAO _dao){
  52 + public PainelAcessibilidadeController(Result result, Validator validator, UrlDAO _dao, MediaAvaliacaoDAO _mediaAvaliacaoDAO) throws IOException{
27 53 this.result = result;
28 54 this.validator = validator;
29 55 this.daoUrl = _dao;
  56 + this.mediaAvaliacaoDAO = _mediaAvaliacaoDAO;
  57 +
  58 + String fileName = "config.properties";
  59 + InputStream stream = Mailer.class.getResourceAsStream("/" + fileName);
  60 + Properties propertiesFile = new Properties();
  61 +
  62 + if (stream != null) {
  63 + propertiesFile.load(stream);
  64 + this.properties.putAll(propertiesFile);
  65 + } else {
  66 + LOGGER.warn("Could not find the file '{}' to load.", fileName);
  67 + }
30 68 }
31 69  
32 70 @Get("/painelAcessibilidade")
33   - public void painelAcessibilidade(@QueryParam("url") String url,@QueryParam("sitio") String sitio,@QueryParam("id") String id) {
34   - String teste = "";
35   - String te = "Objeto montado";
36   - Url url1 = new Url();
37   - Url url2 = null;
38   - //try {
39   - // url = new Url();//daoUrl. getStringUrl(URLNormalizer.normalize("http://asesweb.governoeletronico.gov.br/ases/"));
40   - //} catch (MalformedURLException e) {
41   - // TODO Auto-generated catch block
42   - // e.printStackTrace();
43   - //}
  71 + public void painelAcessibilidade() {
44 72  
  73 + File diretorioHtml = new File(properties.getProperty(PAINEL_AGREGADO) + "/painelAgregado.txt");
  74 +
  75 + StringBuilder html = new StringBuilder();
45 76 try {
  77 + BufferedReader myBuffer = new BufferedReader(new InputStreamReader(new FileInputStream(diretorioHtml), "UTF-8"));
  78 + String linha;
  79 +
  80 +
  81 + while ( ( linha = myBuffer.readLine() ) != null) {
  82 + html.append(linha);
  83 + }
  84 + myBuffer.close();
46 85  
47   - System.out.println("montagem do objeto");
48   - url1.setId(Long.parseLong(id));
49   - url1.setUrl(URLNormalizer.normalize(url));
50   - url1.setIdSitio(Long.parseLong(sitio));
51   - url1.setCodHash(te.getBytes());
52   - System.out.println("Objeto montado");
53   - System.out.println("Update do objeto");
54   - daoUrl.update(url1);
55   - System.out.println("Objeto atualizado no banco");
56   - } catch (Exception e) {
  86 + result.include("html", html);
  87 +
  88 + } catch (FileNotFoundException e1) {
  89 + e1.printStackTrace();
  90 + } catch (IOException e) {
57 91 e.printStackTrace();
58   - e.getCause();
59 92 }
60 93  
61 94  
  95 + }
  96 +
  97 + @Get("/outros-erros-mais-comuns")
  98 + public void outrosErrosMaisComuns() {
62 99  
  100 + File diretorioHtml = new File(properties.getProperty(PAINEL_AGREGADO) + "/painelOutrosErrosMaisComuns.txt");
63 101  
  102 + StringBuilder html = new StringBuilder();
64 103 try {
65   - url2 = daoUrl. getStringUrl(URLNormalizer.normalize(url));
  104 + BufferedReader myBuffer = new BufferedReader(new InputStreamReader(new FileInputStream(diretorioHtml), "UTF-8"));
  105 + String linha;
  106 +
66 107  
67   - result.include("url", url2);
68   - } catch (MalformedURLException e) {
  108 + while ( ( linha = myBuffer.readLine() ) != null) {
  109 + html.append(linha);
  110 + }
  111 + myBuffer.close();
  112 +
  113 + result.include("html", html);
  114 +
  115 + } catch (FileNotFoundException e1) {
  116 + e1.printStackTrace();
  117 + } catch (IOException e) {
69 118 e.printStackTrace();
70 119 }
71 120  
... ... @@ -73,5 +122,213 @@ public class PainelAcessibilidadeController {
73 122 }
74 123  
75 124  
  125 + @Get
  126 + @Path("/media-avaliacao/{tipo}/{id}/{nome}")
  127 + public void mediaAvaliacao(String tipo, String id,String nome) {
  128 +
  129 + String novoTipo = "";
  130 + String nomeTotal = "";
  131 +
  132 + List<MediaAvaliacao> lsMediaAvaliacao = mediaAvaliacaoDAO.mediaAvaliacao(tipo, id);
  133 +
  134 + //List<String> caminhoAvaliacao = new ArrayList<String>();
  135 +
  136 + List<CaminhoLink> lsCaminhoAvaliacao = (List<CaminhoLink>) VRaptorRequestHolder.currentRequest().getServletContext().getAttribute("lsCaminhoAvaliacao");
  137 + CaminhoLink caminhoLink = new CaminhoLink();
  138 +
  139 + if(lsCaminhoAvaliacao == null)
  140 + {
  141 + lsCaminhoAvaliacao = new ArrayList<CaminhoLink>();
  142 + //caminhoLink.setNome("Órgão: " + nome);
  143 + //caminhoLink.setLink("/eselo/orgao");
  144 + //lsCaminhoAvaliacao.add(caminhoLink);
  145 + }
  146 +
  147 + boolean existe = false;
  148 +
  149 + switch (tipo) {
  150 +
  151 + case "orgao": novoTipo="dominio";
  152 + tipo = "Órgãos";
  153 + caminhoLink = new CaminhoLink();
  154 + caminhoLink.setNome("Órgão: " + nome);
  155 + caminhoLink.setLink("/eselo/media-avaliacao/dominio/"+ id + "/" + nome);
  156 +
  157 +
  158 +
  159 + for (CaminhoLink i : lsCaminhoAvaliacao) {
  160 + if(i.getNome().equalsIgnoreCase(caminhoLink.getNome()))
  161 + {
  162 + existe = true;
  163 + }
  164 + }
  165 +
  166 + if(!existe)
  167 + {
  168 + lsCaminhoAvaliacao.add(caminhoLink);
  169 + }
  170 +
  171 +
  172 +
  173 + break;
  174 +
  175 + case "dominio": novoTipo="sitio";
  176 + tipo = "Domínios";
  177 + nomeTotal = "sítios";
  178 + caminhoLink = new CaminhoLink();
  179 + caminhoLink.setNome("Órgão: " + nome);
  180 + caminhoLink.setLink("/eselo/media-avaliacao/dominio/"+ id + "/" + nome);
  181 + caminhoLink.setClasse("orgao");
  182 +
  183 + existe = false;
  184 +
  185 + for (CaminhoLink i : lsCaminhoAvaliacao) {
  186 + if(i.getNome().equalsIgnoreCase(caminhoLink.getNome()))
  187 + {
  188 + existe = true;
  189 + }
  190 + }
  191 +
  192 + if(!existe)
  193 + {
  194 + lsCaminhoAvaliacao.add(caminhoLink);
  195 + }
  196 +
  197 + for (int i = 0; i < lsCaminhoAvaliacao.size(); i++) {
  198 +
  199 + if (lsCaminhoAvaliacao.get(i).getClasse().equalsIgnoreCase("dominio") || lsCaminhoAvaliacao.get(i).getClasse().equalsIgnoreCase("sitio")) {
  200 + lsCaminhoAvaliacao.remove(i);
  201 + i--;
  202 + }
  203 + }
  204 +
  205 + break;
  206 + case "sitio": novoTipo="url";
  207 + tipo = "Sítios";
  208 + nomeTotal = "URLs";
  209 + caminhoLink = new CaminhoLink();
  210 + caminhoLink.setNome("Domínio: " + nome);
  211 + caminhoLink.setLink("/eselo/media-avaliacao/sitio/"+ id + "/" + nome);
  212 + caminhoLink.setClasse("dominio");
  213 +
  214 + existe = false;
  215 +
  216 + for (CaminhoLink i : lsCaminhoAvaliacao) {
  217 + if(i.getNome().equalsIgnoreCase(caminhoLink.getNome()))
  218 + {
  219 + existe = true;
  220 + }
  221 + }
  222 +
  223 + if(!existe)
  224 + {
  225 + lsCaminhoAvaliacao.add(caminhoLink);
  226 + }
  227 +
  228 +
  229 + for (int i = 0; i < lsCaminhoAvaliacao.size(); i++) {
  230 +
  231 + if (lsCaminhoAvaliacao.get(i).getClasse().equalsIgnoreCase("sitio")) {
  232 + lsCaminhoAvaliacao.remove(i);
  233 + i--;
  234 + }
  235 + }
  236 +
  237 + break;
  238 + case "url": novoTipo="url";
  239 + tipo = "URLs";
  240 + nomeTotal = "URLs";
  241 + caminhoLink = new CaminhoLink();
  242 + caminhoLink.setNome("Sítio: " + nome);
  243 + caminhoLink.setLink("/eselo/media-avaliacao/url/"+ id + "/" + nome);
  244 + caminhoLink.setClasse("sitio");
  245 +
  246 + existe = false;
  247 +
  248 + for (CaminhoLink i : lsCaminhoAvaliacao) {
  249 + if(i.getNome().equalsIgnoreCase(caminhoLink.getNome()))
  250 + {
  251 + existe = true;
  252 + }
  253 + }
  254 +
  255 + if(!existe)
  256 + {
  257 + lsCaminhoAvaliacao.add(caminhoLink);
  258 + }
  259 +
  260 + break;
  261 +
  262 + default:
  263 + break;
  264 + }
  265 +
  266 +
  267 + //tipo = tipo.substring(0,1).toUpperCase().concat(tipo.substring(1));
  268 + result.include("lsMediaAvaliacao", lsMediaAvaliacao);
  269 + result.include("tipo", tipo);
  270 + result.include("novoTipo", novoTipo);
  271 + result.include("nomeTotal", nomeTotal);
  272 +
  273 +
  274 + VRaptorRequestHolder.currentRequest().getServletContext().setAttribute("lsCaminhoAvaliacao", lsCaminhoAvaliacao);
  275 +
  276 + }
  277 +
  278 + @Get
  279 + @Path("/media-avaliacao/{tipo}")
  280 + public void mediaAvaliacao(String tipo) {
  281 +
  282 + String novoTipo = "";
  283 +
  284 + UltimaAvaliacao dataUltimaAvaliacao = mediaAvaliacaoDAO.ultimaAvaliacao();
  285 + List<MediaAvaliacao> lsMediaAvaliacao = mediaAvaliacaoDAO.mediaAvaliacao(tipo, null);
  286 +
  287 +
  288 + result.include("lsMediaAvaliacao", lsMediaAvaliacao);
  289 + result.include("tipo", "Órgãos");
  290 + result.include("novoTipo", "dominio");
  291 + result.include("nomeTotal", "domínios");
  292 +
  293 + List<CaminhoLink> lsCaminhoAvaliacao = new ArrayList<CaminhoLink>();
  294 + CaminhoLink caminhoLink = new CaminhoLink();
  295 +
  296 + caminhoLink.setNome("Média Brasil");
  297 + caminhoLink.setLink("/eselo/media-avaliacao/orgao");
  298 + caminhoLink.setClasse("mBrasil");
  299 + lsCaminhoAvaliacao.add(caminhoLink);
  300 + VRaptorRequestHolder.currentRequest().getServletContext().setAttribute("lsCaminhoAvaliacao", lsCaminhoAvaliacao);
  301 + VRaptorRequestHolder.currentRequest().getServletContext().setAttribute("ultimaAvaliacao", Util.convertDataBrasil(dataUltimaAvaliacao.getData_ultima_avaliacao()));
  302 + }
76 303  
  304 + public class CaminhoLink
  305 + {
  306 + private String nome;
  307 + private String link;
  308 + private String classe;
  309 +
  310 + public String getNome() {
  311 + return nome;
  312 + }
  313 + public void setNome(String nome) {
  314 + this.nome = nome;
  315 + }
  316 + public String getLink() {
  317 + return link;
  318 + }
  319 + public void setLink(String link) {
  320 + this.link = link;
  321 + }
  322 + public String getClasse() {
  323 + return classe;
  324 + }
  325 + public void setClasse(String classe) {
  326 + this.classe = classe;
  327 + }
  328 +
  329 +
  330 +
  331 + }
77 332 }
  333 +
  334 +
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/conversor/ESeloDateConverter.java
... ... @@ -2,12 +2,15 @@ package br.com.eselo.conversor;
2 2  
3 3 import static com.google.common.base.Strings.isNullOrEmpty;
4 4  
  5 +import java.sql.Timestamp;
5 6 import java.text.ParseException;
6 7 import java.text.SimpleDateFormat;
7 8 import java.util.Date;
8 9 import java.util.Locale;
9 10 import java.util.ResourceBundle;
10 11  
  12 +import javax.persistence.Temporal;
  13 +
11 14 import br.com.caelum.iogi.exceptions.ConversionException;
12 15 import br.com.caelum.vraptor.Convert;
13 16 import br.com.caelum.vraptor.Converter;
... ... @@ -30,4 +33,7 @@ public class ESeloDateConverter implements Converter&lt;Date&gt; {
30 33  
31 34 }
32 35  
  36 +
  37 +
  38 +
33 39 }
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/model/ErrosMaisComuns.java 0 → 100644
... ... @@ -0,0 +1,61 @@
  1 +package br.com.eselo.model;
  2 +
  3 +import javax.persistence.Column;
  4 +import javax.persistence.Entity;
  5 +import javax.persistence.Id;
  6 +import javax.persistence.Table;
  7 +
  8 +@Entity
  9 +@Table(name = "erros_mais_comuns")
  10 +public class ErrosMaisComuns {
  11 +
  12 +
  13 + @Column(name = "qtd_erros", nullable = false)
  14 + private Long qtd_erros;
  15 +
  16 + @Id
  17 + @Column(name = "criterio", nullable = false)
  18 + private Long criterio;
  19 +
  20 + @Column(name = "peso", nullable = false)
  21 + private Long peso;
  22 +
  23 + @Column(name = "descricao", nullable = false)
  24 + private String descricao;
  25 +
  26 + public Long getQtd_erros() {
  27 + return qtd_erros;
  28 + }
  29 +
  30 + public void setQtd_erros(Long qtd_erros) {
  31 + this.qtd_erros = qtd_erros;
  32 + }
  33 +
  34 + public Long getCriterio() {
  35 + return criterio;
  36 + }
  37 +
  38 + public void setCriterio(Long criterio) {
  39 + this.criterio = criterio;
  40 + }
  41 +
  42 + public Long getPeso() {
  43 + return peso;
  44 + }
  45 +
  46 + public void setPeso(Long peso) {
  47 + this.peso = peso;
  48 + }
  49 +
  50 + public String getDescricao() {
  51 + return descricao;
  52 + }
  53 +
  54 + public void setDescricao(String descricao) {
  55 + this.descricao = descricao;
  56 + }
  57 +
  58 +
  59 +
  60 +
  61 +}
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/model/MediaAvaliacao.java 0 → 100644
... ... @@ -0,0 +1,60 @@
  1 +package br.com.eselo.model;
  2 +
  3 +import javax.persistence.Column;
  4 +import javax.persistence.Entity;
  5 +import javax.persistence.Id;
  6 +import javax.persistence.Table;
  7 +
  8 +@Entity
  9 +@Table(name = "sel_media_avaliacao_temp")
  10 +public class MediaAvaliacao {
  11 +
  12 +
  13 + @Id
  14 + @Column(name = "id", nullable = false)
  15 + private Long id;
  16 +
  17 + @Column(name = "nome", nullable = true)
  18 + private String nome;
  19 +
  20 + @Column(name = "total", nullable = true)
  21 + private Long total;
  22 +
  23 + @Column(name = "media", nullable = true)
  24 + private double media;
  25 +
  26 + public Long getId() {
  27 + return id;
  28 + }
  29 +
  30 + public void setId(Long id) {
  31 + this.id = id;
  32 + }
  33 +
  34 + public String getNome() {
  35 + return nome;
  36 + }
  37 +
  38 + public void setNome(String nome) {
  39 + this.nome = nome;
  40 + }
  41 +
  42 + public Long getTotal() {
  43 + return total;
  44 + }
  45 +
  46 + public void setTotal(Long total) {
  47 + this.total = total;
  48 + }
  49 +
  50 + public double getMedia() {
  51 + return media;
  52 + }
  53 +
  54 + public void setMedia(double media) {
  55 + this.media = media;
  56 + }
  57 +
  58 +
  59 +
  60 +}
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/model/UltimaAvaliacao.java 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +package br.com.eselo.model;
  2 +
  3 +import java.sql.Date;
  4 +import java.sql.Timestamp;
  5 +
  6 +import javax.persistence.Column;
  7 +import javax.persistence.Entity;
  8 +import javax.persistence.Id;
  9 +import javax.persistence.Table;
  10 +import javax.persistence.Temporal;
  11 +import javax.persistence.TemporalType;
  12 +
  13 +@Entity
  14 +@Table(name = "sel_ultima_avaliacao")
  15 +public class UltimaAvaliacao {
  16 +
  17 +
  18 + @Id
  19 + @Column(name = "data_ultima_avaliacao", nullable = false)
  20 + @Temporal(TemporalType.DATE)
  21 + private Timestamp data_ultima_avaliacao;
  22 +
  23 + public Timestamp getData_ultima_avaliacao() {
  24 + return data_ultima_avaliacao;
  25 + }
  26 +
  27 + public void setData_ultima_avaliacao(Timestamp data_ultima_avaliacao) {
  28 + this.data_ultima_avaliacao = data_ultima_avaliacao;
  29 + }
  30 +
  31 +
  32 +
  33 +}
... ...
Desenvolvimento/Codificacao/e-Selo/src/main/resources/config.properties
1 1 eselo.config.avaliacao.caminhoSelos = imgSelo
2   -eselo.config.avaliacao.urlServico =http://asesweb-prd.brazilsouth.cloudapp.azure.com/servico-avaliacao-acessibilidade-salvando
  2 +#eselo.config.avaliacao.urlServico =http://asesweb-prd.brazilsouth.cloudapp.azure.com/servico-avaliacao-acessibilidade-salvando
3 3 #eselo.config.avaliacao.urlServico = http://189.9.137.162:8080/ases/servico-avaliacao-acessibilidade-salvando
4   -#eselo.config.avaliacao.urlServico = http://localhost:18080/ases/servico-avaliacao-acessibilidade-salvando
  4 +eselo.config.avaliacao.urlServico = http://localhost:18080/ases/servico-avaliacao-acessibilidade-salvando
  5 +
5 6  
6 7  
7 8 eselo.config.avaliacao.arquivosHtml=/var/www/arquivo/painel/html
8 9 eselo.config.avaliacao.arquivosJson=/var/www/arquivo/painel/json
  10 +eselo.config.avaliacao.painelAgregado=/var/www/arquivo/painel/painelAgregado
9 11  
10 12  
11   -#eselo.config.avaliacao.enderecoHtml=http://localhost:18080/eselo/arquivosHtml/
  13 +eselo.config.avaliacao.enderecoHtml=http://localhost:18080/eselo/arquivosHtml/
12 14 #eselo.config.avaliacao.enderecoHtml=http://189.9.137.162:8080/eselo/arquivosHtml/
13   -eselo.config.avaliacao.enderecoHtml=http://eselo-prd.brazilsouth.cloudapp.azure.com/arquivosHtml
14 15 \ No newline at end of file
  16 +#eselo.config.avaliacao.enderecoHtml=http://eselo-prd.brazilsouth.cloudapp.azure.com:8080/arquivosHtml
15 17 \ No newline at end of file
... ...