Esempio n. 1
0
  @Override
  public void load(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UsuarioDTO usuario = WebUtil.getUsuario(request);
    if (usuario == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }
    HTMLForm form = document.getForm("form");
    form.clear();
    SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean();
    SolicitacaoServicoService solicitacaoServicoService =
        (SolicitacaoServicoService)
            ServiceLocator.getInstance()
                .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request));
    CalendarioService calendarioService =
        (CalendarioService) ServiceLocator.getInstance().getService(CalendarioService.class, null);
    JustificativaSolicitacaoService justificativaService =
        (JustificativaSolicitacaoService)
            ServiceLocator.getInstance().getService(JustificativaSolicitacaoService.class, null);
    solicitacaoServicoDto =
        solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico());
    request.setAttribute("dataHoraSolicitacao", solicitacaoServicoDto.getDataHoraSolicitacaoStr());

    HTMLSelect slaACombinar = (HTMLSelect) document.getSelectById("slaACombinar");
    slaACombinar.addOption(
        "S", "-- " + UtilI18N.internacionaliza(request, "citcorpore.comum.acombinar") + " --");
    slaACombinar.addOption(
        "N", UtilI18N.internacionaliza(request, "citcorpore.comum.definirtempo"));

    Collection colJustificativas = justificativaService.listAtivasParaSuspensao();
    document.getSelectById("idJustificativa").removeAllOptions();
    document
        .getSelectById("idJustificativa")
        .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione"));
    if (colJustificativas != null) {
      document
          .getSelectById("idJustificativa")
          .addOptions(colJustificativas, "idJustificativa", "descricaoJustificativa", null);
    }

    Collection colCalendarios = calendarioService.list();
    document.getSelectById("idCalendario").removeAllOptions();
    document
        .getSelectById("idCalendario")
        .addOption("", UtilI18N.internacionaliza(request, "citcorpore.comum.selecione"));
    if (colCalendarios != null) {
      document
          .getSelectById("idCalendario")
          .addOptions(colCalendarios, "idCalendario", "descricao", null);
    }
    form.setValues(solicitacaoServicoDto);
    document.executeScript("verificaMudarTipoSLA()");
  }
Esempio n. 2
0
  /**
   * Inclui Novo Pesfil Acesso e AcessoMenu.
   *
   * @param document
   * @param request
   * @param response
   * @throws Exception
   * @author thays.araujo
   */
  public void save(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    this.setPerfilAcessoBean((PerfilAcessoDTO) document.getBean());

    String[] acessoMenuSerializados =
        this.getPerfilAcessoBean().getAcessoMenuSerializados().split(";");
    Collection<PerfilAcessoMenuDTO> colPerfilAcessoMenuDTO = new ArrayList<PerfilAcessoMenuDTO>();
    for (String menus : acessoMenuSerializados) {
      String[] aux = menus.split("@");
      PerfilAcessoMenuDTO perfilAcessoMenu = new PerfilAcessoMenuDTO();
      perfilAcessoMenu.setIdMenu(new Integer(aux[0].trim()));
      String[] tiposAcesso = aux[1].split("-");
      perfilAcessoMenu.setGrava(tiposAcesso[1]);
      perfilAcessoMenu.setPesquisa(tiposAcesso[0]);
      perfilAcessoMenu.setDeleta(tiposAcesso[2]);
      colPerfilAcessoMenuDTO.add(perfilAcessoMenu);
      this.getPerfilAcessoBean().setAcessoMenus(colPerfilAcessoMenuDTO);
    }

    if (this.getPerfilAcessoBean().getIdPerfilAcesso() == null) {
      if (this.getPerfilAcessoService().verificarSePerfilAcessoExiste(this.getPerfilAcessoBean())) {
        document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.registroJaCadastrado"));
      } else {
        this.getPerfilAcessoService().create(this.getPerfilAcessoBean());
        document.alert(UtilI18N.internacionaliza(request, "MSG05"));
      }
    } else {
      if (this.getPerfilAcessoService().verificarSePerfilAcessoExiste(this.getPerfilAcessoBean())) {
        document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.registroJaCadastrado"));
      } else {
        this.getPerfilAcessoService().update(this.getPerfilAcessoBean());
        document.alert(UtilI18N.internacionaliza(request, "MSG06"));
      }
    }
    HTMLForm form = document.getForm("form");
    form.clear();

    document.executeScript("limpar_LOOKUP_PERFILACESSO()");
  }
Esempio n. 3
0
 @Override
 public void load(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   UsuarioDTO usuarioDto = WebUtil.getUsuario(request);
   if (usuarioDto == null) {
     document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
     document.executeScript(
         "window.location = '"
             + Constantes.getValue("SERVER_ADDRESS")
             + request.getContextPath()
             + "'");
     return;
   }
 }
Esempio n. 4
0
  /**
   * Exclui Perfil Acesso atribuindo sua data fim em Grupo.
   *
   * @param document
   * @param request
   * @param response
   * @throws Exception
   */
  public void delete(
      DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    this.setPerfilAcessoBean((PerfilAcessoDTO) document.getBean());

    PerfilAcessoService perfilAcessoService =
        (PerfilAcessoService)
            ServiceLocator.getInstance().getService(PerfilAcessoService.class, null);

    if (this.getPerfilAcessoBean().getIdPerfilAcesso() != null) {

      if (perfilAcessoService.excluirPerfilDeAcesso(this.getPerfilAcessoBean())) {
        document.alert(UtilI18N.internacionaliza(request, "MSG07"));
      } else {
        document.alert(
            UtilI18N.internacionaliza(request, "citcorpore.comum.registroNaoPodeSerExcluido"));
      }
    }

    HTMLForm form = document.getForm("form");
    form.clear();

    document.executeScript("limpar_LOOKUP_PERFILACESSO()");
  }
Esempio n. 5
0
  /**
   * Salva a Mudança de SLA da Solicitação.
   *
   * @param document
   * @param request
   * @param response
   * @throws Exception
   * @author valdoilo.damasceno Data: 25/10/2013 - Horário: 16:03. Chamada
   *     parent.pesquisarItensFiltro()
   */
  public void save(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UsuarioDTO usuario = WebUtil.getUsuario(request);
    if (usuario == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }

    SolicitacaoServicoDTO solicitacaoServicoDto = (SolicitacaoServicoDTO) document.getBean();
    SolicitacaoServicoService solicitacaoServicoService =
        (SolicitacaoServicoService)
            ServiceLocator.getInstance()
                .getService(SolicitacaoServicoService.class, WebUtil.getUsuarioSistema(request));
    SolicitacaoServicoDTO solicitacaoServicoAux =
        solicitacaoServicoService.restoreAll(solicitacaoServicoDto.getIdSolicitacaoServico());
    solicitacaoServicoDto.setIdSolicitante(solicitacaoServicoAux.getIdSolicitante());
    solicitacaoServicoDto.setDataInicio(solicitacaoServicoAux.getDataInicio());
    solicitacaoServicoDto.setDataHoraSolicitacao(solicitacaoServicoAux.getDataHoraSolicitacao());
    solicitacaoServicoDto.setUsuarioDto(usuario);
    solicitacaoServicoDto.setRegistradoPor(usuario.getNomeUsuario());
    solicitacaoServicoDto.setHouveMudanca("S");
    solicitacaoServicoDto.setSituacao(solicitacaoServicoAux.getSituacao());
    solicitacaoServicoDto.setPrazohhAnterior(solicitacaoServicoAux.getPrazoHH());
    solicitacaoServicoDto.setPrazommAnterior(solicitacaoServicoAux.getPrazoMM());
    solicitacaoServicoDto.setTempoDecorridoHH(solicitacaoServicoAux.getTempoDecorridoHH());
    solicitacaoServicoDto.setTempoDecorridoMM(solicitacaoServicoAux.getTempoDecorridoMM());

    if (solicitacaoServicoDto.getSlaACombinar().equalsIgnoreCase("S")) {
      solicitacaoServicoDto.setPrazoCapturaHH(0);
      solicitacaoServicoDto.setPrazoCapturaMM(0);
      solicitacaoServicoDto.setPrazoHH(0);
      solicitacaoServicoDto.setPrazoMM(0);
    }
    solicitacaoServicoService.updateSLA(solicitacaoServicoDto);

    document.executeScript("parent.refreshTelaGerenciamento();");
  }
Esempio n. 6
0
  public void avalia(
      DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    UsuarioDTO usuarioDto = WebUtil.getUsuario(request);
    if (usuarioDto == null) {
      document.alert(UtilI18N.internacionaliza(request, "citcorpore.comum.sessaoExpirada"));
      document.executeScript(
          "window.location = '"
              + Constantes.getValue("SERVER_ADDRESS")
              + request.getContextPath()
              + "'");
      return;
    }
    AcordoNivelServicoService acordoNivelServicoService =
        (AcordoNivelServicoService)
            ServiceLocator.getInstance().getService(AcordoNivelServicoService.class, null);
    RequisitoSLAService requisitoSLAService =
        (RequisitoSLAService)
            ServiceLocator.getInstance().getService(RequisitoSLAService.class, null);
    Collection colAcordos = acordoNivelServicoService.findAcordosSemVinculacaoDireta();
    Collection colReqs = requisitoSLAService.list();

    ControleGenerateSLAPorRequisitoSLA controleGenerateSLAPorRequisitoSLA =
        new ControleGenerateSLAPorRequisitoSLA();
    ControleGenerateSLAPorRequisitoSLAEmAndamento controleGenerateSLAPorRequisitoSLAEmAndamento =
        new ControleGenerateSLAPorRequisitoSLAEmAndamento();
    String table = "<table border='1'>";
    if (colAcordos != null && colAcordos.size() > 0) {
      table += "<tr>";
      table += "<td>";
      table += "<b>" + UtilI18N.internacionaliza(request, "sla.avaliacao.acordo") + "</b>";
      table += "</td>";
      table += "</tr>";
      table += "<tr>";
      table += "<td>";
      table += "&nbsp;";
      table += "</td>";
      table += "</tr>";
      for (Iterator it = colAcordos.iterator(); it.hasNext(); ) {
        AcordoNivelServicoDTO acordoNivelServicoDTO = (AcordoNivelServicoDTO) it.next();
        table += "<tr>";
        table += "<td colspan='5' style='background-color:gray'>";
        table +=
            UtilI18N.internacionaliza(request, "citcorpore.comum.acordo")
                + ": <b>"
                + acordoNivelServicoDTO.getTituloSLA()
                + "</b>";
        table += "</td>";
        table += "</tr>";
        if (acordoNivelServicoDTO.getTipo().equalsIgnoreCase("T")) {
          table +=
              generateSLATime(
                  document,
                  request,
                  acordoNivelServicoDTO,
                  acordoNivelServicoDTO.getIdAcordoNivelServico(),
                  usuarioDto);
          table +=
              generateAvailSLATime(
                  document,
                  request,
                  acordoNivelServicoDTO,
                  acordoNivelServicoDTO.getIdAcordoNivelServico(),
                  usuarioDto);
        } else if (acordoNivelServicoDTO.getTipo().equalsIgnoreCase("D")) {
          table +=
              generateAvailSLAAvailability(
                  document,
                  request,
                  response,
                  acordoNivelServicoDTO,
                  acordoNivelServicoDTO.getIdAcordoNivelServico(),
                  usuarioDto);
        }
      }
    }
    if (colReqs != null && colReqs.size() > 0) {
      table += "<tr>";
      table += "<td>";
      table += "&nbsp;";
      table += "</td>";
      table += "</tr>";
      table += "<tr>";
      table += "<td>";
      table += "<b>" + UtilI18N.internacionaliza(request, "sla.avaliacao.requisito") + "</b>";
      table += "</td>";
      table += "</tr>";
      for (Iterator it = colReqs.iterator(); it.hasNext(); ) {
        RequisitoSLADTO requisitoSLADTO = (RequisitoSLADTO) it.next();
        List lst = controleGenerateSLAPorRequisitoSLA.execute(requisitoSLADTO.getIdRequisitoSLA());
        double qtdeDentroPrazo = 0;
        double qtdeForaPrazo = 0;
        if (lst != null && lst.size() > 0) {
          for (Iterator itSLA = lst.iterator(); itSLA.hasNext(); ) {
            Object[] objs = (Object[]) itSLA.next();
            if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
              qtdeForaPrazo = (Double) objs[2];
            } else {
              qtdeDentroPrazo = (Double) objs[2];
            }
          }
        }
        double qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
        double qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;

        final DefaultValueDataset dataset =
            new DefaultValueDataset(new Double(qtdeDentroPrazoPerc));

        // create the chart...
        final ThermometerPlot plot = new ThermometerPlot(dataset);
        final JFreeChart chart =
            new JFreeChart(
                UtilI18N.internacionaliza(request, "sla.avaliacao.avaliacaogeral"), // chart title
                JFreeChart.DEFAULT_TITLE_FONT,
                plot, // plot
                false); // include legend

        plot.setSubrangeInfo(ThermometerPlot.NORMAL, 90.000001, 100);
        plot.setSubrangeInfo(ThermometerPlot.WARNING, 80.000001, 90);
        plot.setSubrangeInfo(ThermometerPlot.CRITICAL, 0, 80);

        plot.setThermometerStroke(new BasicStroke(2.0f));
        plot.setThermometerPaint(Color.lightGray);

        String nomeImgAval =
            CITCorporeUtil.caminho_real_app
                + "/tempFiles/"
                + usuarioDto.getIdUsuario()
                + "/avalREQSLA_"
                + requisitoSLADTO.getIdRequisitoSLA()
                + ".png";
        String nomeImgAvalRel =
            br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                + "/tempFiles/"
                + usuarioDto.getIdUsuario()
                + "/avalREQSLA_"
                + requisitoSLADTO.getIdRequisitoSLA()
                + ".png";
        File arquivo = new File(nomeImgAval);

        if (arquivo.exists()) {
          arquivo.delete();
        } else {
          String nomeDir =
              CITCorporeUtil.caminho_real_app + "/tempFiles/" + usuarioDto.getIdUsuario() + "/";
          File dirTemp = new File(nomeDir);
          dirTemp.mkdirs();
          arquivo.createNewFile();
        }

        ChartUtilities.saveChartAsPNG(arquivo, chart, 500, 200);

        List lst2 =
            controleGenerateSLAPorRequisitoSLAEmAndamento.execute(
                requisitoSLADTO.getIdRequisitoSLA());
        qtdeDentroPrazo = 0;
        qtdeForaPrazo = 0;
        if (lst2 != null && lst2.size() > 0) {
          for (Iterator itSLA = lst2.iterator(); itSLA.hasNext(); ) {
            Object[] objs = (Object[]) itSLA.next();
            if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
              qtdeForaPrazo = (Double) objs[2];
            } else {
              qtdeDentroPrazo = (Double) objs[2];
            }
          }
        }
        qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
        qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;

        DefaultPieDataset datasetPie = new DefaultPieDataset();
        datasetPie.setValue(
            UtilI18N.internacionaliza(request, "sla.avaliacao.noprazo")
                + " ("
                + UtilFormatacao.formatDouble(qtdeDentroPrazo, 0)
                + ")",
            new Double(qtdeDentroPrazoPerc));
        datasetPie.setValue(
            UtilI18N.internacionaliza(request, "sla.avaliacao.foraprazo")
                + " ("
                + UtilFormatacao.formatDouble(qtdeForaPrazo, 0)
                + ")",
            new Double(qtdeForaPrazoPerc));

        JFreeChart chartX =
            ChartFactory.createPieChart(
                UtilI18N.internacionaliza(request, "sla.avaliacao.emandamento"), // chart title
                datasetPie, // data
                true, // include legend
                false,
                false);

        PiePlot plotPie = (PiePlot) chartX.getPlot();
        plotPie.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        plotPie.setNoDataMessage(UtilI18N.internacionaliza(request, "sla.avaliacao.naohadados"));
        plotPie.setCircular(false);
        plotPie.setLabelGap(0.02);

        String nomeImgAval2 =
            CITCorporeUtil.caminho_real_app
                + "/tempFiles/"
                + usuarioDto.getIdUsuario()
                + "/avalREQSLA2_"
                + requisitoSLADTO.getIdRequisitoSLA()
                + ".png";
        String nomeImgAvalRel2 =
            br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                + "/tempFiles/"
                + usuarioDto.getIdUsuario()
                + "/avalREQSLA2_"
                + requisitoSLADTO.getIdRequisitoSLA()
                + ".png";
        File arquivo2 = new File(nomeImgAval2);
        if (arquivo2.exists()) {
          arquivo2.delete();
        }
        ChartUtilities.saveChartAsPNG(arquivo2, chartX, 200, 200);

        table += "<tr>";
        table += "<td style='border:1px solid black; vertical-align:middle;'>";
        table += UtilHTML.encodeHTML(UtilStrings.retiraApostrofe(requisitoSLADTO.getAssunto()));
        table += "</td>";
        table += "<td style='border:1px solid black; vertical-align:middle;'>";
        if (requisitoSLADTO.getSituacao() != null
            && requisitoSLADTO.getSituacao().equalsIgnoreCase("A")) {
          table +=
              "<img src='"
                  + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                  + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                  + "/imagens/bolaverde.png' border='0'  title='"
                  + UtilI18N.internacionaliza(request, "requisitosla.ativo")
                  + "'/>";
          table += UtilI18N.internacionaliza(request, "requisitosla.ativo");
        } else if (requisitoSLADTO.getSituacao() != null
            && requisitoSLADTO.getSituacao().equalsIgnoreCase("P")) {
          table +=
              "<img src='"
                  + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                  + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                  + "/imagens/bolavermelha.png' border='0'  title='"
                  + UtilI18N.internacionaliza(request, "requisitosla.planejamento")
                  + "'/>";
          table += UtilI18N.internacionaliza(request, "requisitosla.planejamento");
        } else if (requisitoSLADTO.getSituacao() != null
            && requisitoSLADTO.getSituacao().equalsIgnoreCase("R")) {
          table +=
              "<img src='"
                  + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                  + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                  + "/imagens/bolavermelha.png' border='0'  title='"
                  + UtilI18N.internacionaliza(request, "requisitosla.emrevisao")
                  + "'/>";
          table += UtilI18N.internacionaliza(request, "requisitosla.emrevisao");
        } else {
          table +=
              "<img src='"
                  + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
                  + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
                  + "/imagens/bolavermelha.png' border='0'  title='"
                  + UtilI18N.internacionaliza(request, "requisitosla.inativo")
                  + "'/>";
          table += UtilI18N.internacionaliza(request, "requisitosla.inativo");
        }
        table += "</td>";
        table += "<td style='border:1px solid black'>";
        table += "<img src='" + nomeImgAvalRel + "' border='0'/>";
        table += "</td>";
        table += "<td style='border:1px solid black'>";
        table += "<img src='" + nomeImgAvalRel2 + "' border='0'/>";
        table += "</td>";
        table += "</tr>";
      }
    }
    table += "</table>";
    document.getElementById("divInfo").setInnerHTML(table);
  }
Esempio n. 7
0
  private String geraTabelaMeses(
      String tituloSLA,
      Integer idAcordoNivelServico,
      HttpServletRequest request,
      UsuarioDTO usuarioDto)
      throws ParseException, IOException {
    ControleGenerateSLAPorAcordoNivelServicoByMesAno
        controleGenerateSLAPorAcordoNivelServicoByMesAno =
            new ControleGenerateSLAPorAcordoNivelServicoByMesAno();
    int m = UtilDatas.getMonth(UtilDatas.getDataAtual());
    int y = UtilDatas.getYear(UtilDatas.getDataAtual());
    int mPesq = (m + 1); // Faz este incremento de 1, pois logo que entrar no laço, faz um -1
    String strTable = "<table width='100%' border='1'>";
    String strHeader = "";
    String strDados = "";
    strHeader += "<tr>";
    strDados += "<tr>";

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < 6; i++) {
      mPesq = (mPesq - 1);
      if (mPesq <= 0) {
        mPesq = 12;
        y = y - 1;
      }
      strHeader = strHeader + "<td colspan='2' style='border:1px solid black; text-align:center'>";
      strHeader = strHeader + (mPesq + "/" + y);
      strHeader = strHeader + "</td>";

      List lst =
          controleGenerateSLAPorAcordoNivelServicoByMesAno.execute(idAcordoNivelServico, y, mPesq);
      double qtdeDentroPrazo = 0;
      double qtdeForaPrazo = 0;
      if (lst != null && lst.size() > 0) {
        for (Iterator itSLA = lst.iterator(); itSLA.hasNext(); ) {
          Object[] objs = (Object[]) itSLA.next();
          if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
            qtdeForaPrazo = (Double) objs[2];
          } else {
            qtdeDentroPrazo = (Double) objs[2];
          }
        }
      }
      double qtdeDentroPrazoPerc = 0;
      if ((qtdeDentroPrazo + qtdeForaPrazo) > 0) {
        qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
      }
      double qtdeForaPrazoPerc = 0;
      if ((qtdeDentroPrazo + qtdeForaPrazo) > 0) {
        qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
      }
      strDados = strDados + "<td style='border:1px solid black'>";
      strDados = strDados + UtilFormatacao.formatDouble(qtdeDentroPrazoPerc, 2) + "%";
      strDados = strDados + "</td>";
      strDados = strDados + "<td style='border:1px solid black'>";
      strDados = strDados + UtilFormatacao.formatDouble(qtdeForaPrazoPerc, 2) + "%";
      strDados = strDados + "</td>";

      dataset.setValue(
          new Double(qtdeDentroPrazoPerc),
          UtilI18N.internacionaliza(request, "sla.avaliacao.noprazo"),
          "" + (mPesq + "/" + y));
      dataset.setValue(
          new Double(qtdeForaPrazoPerc),
          UtilI18N.internacionaliza(request, "sla.avaliacao.foraprazo"),
          "" + (mPesq + "/" + y));
    }
    strHeader += "</tr>";
    strDados += "</tr>";

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            tituloSLA, // chart title
            UtilI18N.internacionaliza(request, "sla.avaliacao.indicadores"), // domain axis label
            UtilI18N.internacionaliza(request, "sla.avaliacao.resultado"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0, 64, 0));

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    String nomeImgAval =
        CITCorporeUtil.caminho_real_app
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLAXX_"
            + idAcordoNivelServico
            + ".png";
    String nomeImgAvalRel =
        br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
            + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLAXX_"
            + idAcordoNivelServico
            + ".png";
    File arquivo2 = new File(nomeImgAval);
    if (arquivo2.exists()) {
      arquivo2.delete();
    }
    ChartUtilities.saveChartAsPNG(arquivo2, chart, 500, 200);
    strTable += "<tr>";
    strTable += "<td colspan='12'>";
    strTable += "<img src='" + nomeImgAvalRel + "' border='0'/>";
    strTable += "</td>";
    strTable += "</tr>";

    strTable += strHeader;
    strTable += strDados;

    strTable += "</table>";
    return strTable;
  }
Esempio n. 8
0
  private String generateAvailSLATime(
      DocumentHTML document,
      HttpServletRequest request,
      AcordoNivelServicoDTO acordoNivelServicoDTO,
      Integer idAcordoNivelServico,
      UsuarioDTO usuarioDto)
      throws IOException, ParseException {
    SlaAvaliacaoDTO slaAvaliacaoDto = (SlaAvaliacaoDTO) document.getBean();
    ControleGenerateSLAPorAcordoNivelServico controleGenerateSLAPorAcordoNivelServico =
        new ControleGenerateSLAPorAcordoNivelServico();
    ControleGenerateSLAPorAcordoNivelServicoEmAndamento
        controleGenerateSLAPorAcordoNivelServicoEmAndamento =
            new ControleGenerateSLAPorAcordoNivelServicoEmAndamento();
    List lst =
        controleGenerateSLAPorAcordoNivelServico.execute(
            idAcordoNivelServico, slaAvaliacaoDto.getDataInicio(), slaAvaliacaoDto.getDataFim());
    double qtdeDentroPrazo = 0;
    double qtdeForaPrazo = 0;
    if (lst != null && lst.size() > 0) {
      for (Iterator itSLA = lst.iterator(); itSLA.hasNext(); ) {
        Object[] objs = (Object[]) itSLA.next();
        if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
          qtdeForaPrazo = (Double) objs[2];
        } else {
          qtdeDentroPrazo = (Double) objs[2];
        }
      }
    }
    double qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
    double qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;

    final DefaultValueDataset dataset = new DefaultValueDataset(new Double(qtdeDentroPrazoPerc));

    // create the chart...
    final ThermometerPlot plot = new ThermometerPlot(dataset);
    final JFreeChart chart =
        new JFreeChart(
            UtilI18N.internacionaliza(request, "sla.avaliacao.avaliacaogeral"), // chart title
            JFreeChart.DEFAULT_TITLE_FONT,
            plot, // plot
            false); // include legend

    plot.setSubrangeInfo(ThermometerPlot.NORMAL, 90.000001, 100);
    plot.setSubrangeInfo(ThermometerPlot.WARNING, 80.000001, 90);
    plot.setSubrangeInfo(ThermometerPlot.CRITICAL, 0, 80);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);

    String nomeImgAval =
        CITCorporeUtil.caminho_real_app
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLA_"
            + acordoNivelServicoDTO.getIdAcordoNivelServico()
            + ".png";
    String nomeImgAvalRel =
        br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
            + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLA_"
            + acordoNivelServicoDTO.getIdAcordoNivelServico()
            + ".png";
    File arquivo = new File(nomeImgAval);

    if (arquivo.exists()) {
      arquivo.delete();
    } else {
      String nomeDir =
          CITCorporeUtil.caminho_real_app + "/tempFiles/" + usuarioDto.getIdUsuario() + "/";
      File dirTemp = new File(nomeDir);
      dirTemp.mkdirs();
      arquivo.createNewFile();
    }

    ChartUtilities.saveChartAsPNG(arquivo, chart, 500, 200);

    List lst2 = controleGenerateSLAPorAcordoNivelServicoEmAndamento.execute(idAcordoNivelServico);
    qtdeDentroPrazo = 0;
    qtdeForaPrazo = 0;
    if (lst2 != null && lst2.size() > 0) {
      for (Iterator itSLA = lst2.iterator(); itSLA.hasNext(); ) {
        Object[] objs = (Object[]) itSLA.next();
        if (((String) objs[0]).indexOf("Fora") > -1 || ((String) objs[0]).indexOf("Out") > -1) {
          qtdeForaPrazo = (Double) objs[2];
        } else {
          qtdeDentroPrazo = (Double) objs[2];
        }
      }
    }
    qtdeDentroPrazoPerc = (qtdeDentroPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;
    qtdeForaPrazoPerc = (qtdeForaPrazo / (qtdeDentroPrazo + qtdeForaPrazo)) * 100;

    DefaultPieDataset datasetPie = new DefaultPieDataset();
    datasetPie.setValue(
        UtilI18N.internacionaliza(request, "sla.avaliacao.noprazo")
            + " ("
            + UtilFormatacao.formatDouble(qtdeDentroPrazo, 0)
            + ")",
        new Double(qtdeDentroPrazoPerc));
    datasetPie.setValue(
        UtilI18N.internacionaliza(request, "sla.avaliacao.foraprazo")
            + " ("
            + UtilFormatacao.formatDouble(qtdeForaPrazo, 0)
            + ")",
        new Double(qtdeForaPrazoPerc));

    JFreeChart chartX =
        ChartFactory.createPieChart(
            UtilI18N.internacionaliza(request, "sla.avaliacao.emandamento"), // chart title
            datasetPie, // data
            true, // include legend
            true,
            false);

    PiePlot plotPie = (PiePlot) chartX.getPlot();
    plotPie.setLabelFont(new Font("SansSerif", Font.PLAIN, 6));
    plotPie.setNoDataMessage(UtilI18N.internacionaliza(request, "sla.avaliacao.naohadados"));
    plotPie.setCircular(true);
    plotPie.setLabelGap(0);

    String nomeImgAval2 =
        CITCorporeUtil.caminho_real_app
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLA2_"
            + idAcordoNivelServico
            + ".png";
    String nomeImgAvalRel2 =
        br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
            + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
            + "/tempFiles/"
            + usuarioDto.getIdUsuario()
            + "/avalSLA2_"
            + idAcordoNivelServico
            + ".png";
    File arquivo2 = new File(nomeImgAval2);
    if (arquivo2.exists()) {
      arquivo2.delete();
    }
    ChartUtilities.saveChartAsPNG(arquivo2, chartX, 200, 200);

    String table = "";
    table += "<tr>";
    table += "<td style='border:1px solid black; vertical-align:middle;'>";
    // table +=
    // UtilHTML.encodeHTML(UtilStrings.retiraApostrofe(acordoNivelServicoDTO.getTituloSLA()));
    table +=
        "<br>"
            + geraTabelaMeses(
                acordoNivelServicoDTO.getTituloSLA(), idAcordoNivelServico, request, usuarioDto);
    table += "</td>";
    table += "<td style='border:1px solid black; vertical-align:middle;'>";
    if (acordoNivelServicoDTO.getTipo() != null
        && acordoNivelServicoDTO.getTipo().equalsIgnoreCase("T")) {
      table +=
          "<img src='"
              + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
              + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
              + "/imagens/relogio.png' border='0'  title='"
              + UtilI18N.internacionaliza(request, "sla.avaliacao.tempo")
              + "'/>";
      table += UtilI18N.internacionaliza(request, "sla.avaliacao.tempo");
    } else if (acordoNivelServicoDTO.getTipo() != null
        && acordoNivelServicoDTO.getTipo().equalsIgnoreCase("D")) {
      table +=
          "<img src='"
              + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
              + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
              + "/imagens/disponibilidade.png' border='0'  title='"
              + UtilI18N.internacionaliza(request, "sla.avaliacao.disponibilidade")
              + "'/>";
      table += UtilI18N.internacionaliza(request, "sla.avaliacao.disponibilidade");
    } else if (acordoNivelServicoDTO.getTipo() != null
        && acordoNivelServicoDTO.getTipo().equalsIgnoreCase("V")) {
      table +=
          "<img src='"
              + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
              + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
              + "/imagens/outrasfontes.png' border='0'  title='"
              + UtilI18N.internacionaliza(request, "sla.avaliacao.outrasfontes")
              + "'/>";
      table += UtilI18N.internacionaliza(request, "sla.avaliacao.outrasfontes");
    }
    table += "</td>";
    table += "<td style='border:1px solid black; vertical-align:middle;'>";
    if (acordoNivelServicoDTO.getDataFim() != null
        && acordoNivelServicoDTO.getDataFim().before(UtilDatas.getDataAtual())) {
      table +=
          "<img src='"
              + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
              + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
              + "/imagens/bolavermelha.png' border='0'  title='"
              + UtilI18N.internacionaliza(request, "sla.avaliacao.inativo")
              + "'/>";
      table += UtilI18N.internacionaliza(request, "sla.avaliacao.inativo");
    } else {
      table +=
          "<img src='"
              + br.com.citframework.util.Constantes.getValue("SERVER_ADDRESS")
              + br.com.citframework.util.Constantes.getValue("CONTEXTO_APLICACAO")
              + "/imagens/bolaverde.png' border='0'  title='"
              + UtilI18N.internacionaliza(request, "sla.avaliacao.ativo")
              + "'/>";
      table += UtilI18N.internacionaliza(request, "sla.avaliacao.ativo");
    }
    table += "</td>";
    table += "<td style='border:1px solid black'>";
    table += "<img src='" + nomeImgAvalRel + "' border='0'/>";
    table += "</td>";
    table += "<td style='border:1px solid black'>";
    table += "<img src='" + nomeImgAvalRel2 + "' border='0'/>";
    table += "</td>";
    table += "</tr>";

    return table;
  }
Esempio n. 9
0
 private String generateSLATime(
     DocumentHTML document,
     HttpServletRequest request,
     AcordoNivelServicoDTO acordoNivelServicoDTO,
     Integer idAcordoNivelServico,
     UsuarioDTO usuarioDto)
     throws Exception {
   TempoAcordoNivelServicoDao tempoAcordoNivelServicoDao = new TempoAcordoNivelServicoDao();
   String table = "<tr><td><table border='1' width='90%'>";
   table += "<tr>";
   table += "<td colspan='6'>";
   table += "<b>" + UtilI18N.internacionaliza(request, "sla.alvostempo") + "</b>";
   table += "</td>";
   table += "</tr>";
   table += "<tr>";
   table += "<td>";
   table += "&nbsp;";
   table += "</td>";
   table += "</tr>";
   table += "<tr>";
   table += "<td>";
   table += "    &nbsp;";
   table += "</td>";
   table += "<td style='text-align: center; background-color: gray; border:1px solid black;'>";
   table += "    <b>--- 1 ---</b>";
   table += "</td>";
   table += "<td style='text-align: center; background-color: gray; border:1px solid black;'>";
   table += "    <b>--- 2 ---</b>";
   table += "</td>";
   table += "<td style='text-align: center; background-color: gray; border:1px solid black;'>";
   table += "    <b>--- 3 ---</b>";
   table += "</td>";
   table += " <td style='text-align: center; background-color: gray; border:1px solid black;'>";
   table += "    <b>--- 4 ---</b>";
   table += "</td>";
   table += "<td style='text-align: center; background-color: gray; border:1px solid black;'>";
   table += "    <b>--- 5 ---</b>";
   table += "</td> ";
   table += "</tr>";
   table += "<tr>";
   table += "<td>";
   table += "<b>" + UtilI18N.internacionaliza(request, "sla.captura") + "</b>";
   table += "</td>";
   for (int i = 1; i <= 5; i++) {
     Collection colAux1 =
         tempoAcordoNivelServicoDao.findByIdAcordoAndFaseAndIdPrioridade(
             idAcordoNivelServico, 1, i);
     if (colAux1 != null && colAux1.size() > 0) {
       TempoAcordoNivelServicoDTO tempoAcordoNivelServicoDTO =
           (TempoAcordoNivelServicoDTO) ((List) colAux1).get(0);
       table +=
           "<td style='text-align:right;border:1px solid black;'>"
               + tempoAcordoNivelServicoDTO.getTempoHH()
               + ":"
               + tempoAcordoNivelServicoDTO.getTempoMM()
               + "</td>";
     }
   }
   table += "<tr>";
   table += "<td>";
   table += "<b>" + UtilI18N.internacionaliza(request, "sla.resolucao") + "</b>";
   table += "</td>";
   for (int i = 1; i <= 5; i++) {
     Collection colAux1 =
         tempoAcordoNivelServicoDao.findByIdAcordoAndFaseAndIdPrioridade(
             idAcordoNivelServico, 2, i);
     if (colAux1 != null && colAux1.size() > 0) {
       TempoAcordoNivelServicoDTO tempoAcordoNivelServicoDTO =
           (TempoAcordoNivelServicoDTO) ((List) colAux1).get(0);
       table +=
           "<td style='text-align:right;border:1px solid black;'>"
               + tempoAcordoNivelServicoDTO.getTempoHH()
               + ":"
               + tempoAcordoNivelServicoDTO.getTempoMM()
               + "</td>";
     }
   }
   table += "</tr>";
   table += "</table></td></tr>";
   return table;
 }
  @Override
  public void load(DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    HashMap hashValores = getFormFields(request);
    String idStr = (String) hashValores.get("ID");
    int id = -1;
    try {
      if (idStr != null && !idStr.equalsIgnoreCase("-1")) {
        idStr = UtilStrings.apenasNumeros(idStr);
      }
      id = Integer.parseInt(idStr);
    } catch (Exception e) {
      // e.printStackTrace();
    }
    BICategoriasService biCategoriasService =
        (BICategoriasService)
            ServiceLocator.getInstance().getService(BICategoriasService.class, null);
    BIConsultaService biConsultaService =
        (BIConsultaService) ServiceLocator.getInstance().getService(BIConsultaService.class, null);
    String strCab = "";
    if (id == -1) {
      strCab += "[{";
      strCab += "\"id\":-1,";
      strCab +=
          "\"text\":\"" + UtilI18N.internacionaliza(request, "listagemConsultas.consultas") + "\",";
      strCab += "\"children\":[";
      Collection colObjsNeg = biCategoriasService.findSemPai();
      if (colObjsNeg != null) {
        boolean bPrim = true;
        for (Iterator it = colObjsNeg.iterator(); it.hasNext(); ) {
          BICategoriasDTO biCategoriasDTO = (BICategoriasDTO) it.next();
          if (!bPrim) {
            strCab += ",";
          }
          strCab += "{";
          strCab += "\"id\":\"G" + biCategoriasDTO.getIdCategoria() + "\",";
          strCab += "\"text\":\"" + biCategoriasDTO.getNomeCategoria() + "\",";
          strCab += "\"state\":\"closed\"";
          strCab += "}";
          bPrim = false;
        }
      }
      strCab += "]";
      strCab += "}]";
    } else {
      Collection col = biCategoriasService.findByIdCategoriaPai(id);
      Collection col2 = biConsultaService.findByIdCategoria(id);
      if (col != null || col2 != null) {
        if (col == null) col = new ArrayList();
        if (col2 == null) col2 = new ArrayList();
        strCab += "[";
        boolean bPrim = true;
        for (Iterator it = col.iterator(); it.hasNext(); ) {
          if (!bPrim) {
            strCab += ",";
          }
          BICategoriasDTO biCategoriasDTO = (BICategoriasDTO) it.next();
          // String strTam = "";
          strCab += "{";
          strCab += "\"id\":\"G" + biCategoriasDTO.getIdCategoria() + "\",";
          strCab += "\"text\":\"" + biCategoriasDTO.getNomeCategoria() + "\"";
          strCab += "}";
          bPrim = false;
        }
        bPrim = true;
        for (Iterator it = col2.iterator(); it.hasNext(); ) {
          if (!bPrim) {
            strCab += ",";
          }
          BIConsultaDTO biConsultaDTO = (BIConsultaDTO) it.next();
          // String strTam = "";
          strCab += "{";
          strCab +=
              "\"id\":\"" + biConsultaDTO.getTipoConsulta() + biConsultaDTO.getIdConsulta() + "\",";
          strCab += "\"text\":\"" + biConsultaDTO.getNomeConsulta() + "\"";
          strCab += "}";
          bPrim = false;
        }
        strCab += "]";
      }
    }

    request.setAttribute("json_retorno", strCab);
  }
Esempio n. 11
0
  private void gerarMenus(
      StringBuffer sb,
      Collection<MenuDTO> listaDeSubMenus,
      String nivel,
      Integer idPerfilAcesso,
      HttpServletRequest request)
      throws ServiceException, Exception {
    int i = 0;
    PerfilAcessoMenuService perfilAcessoMenuService =
        (PerfilAcessoMenuService)
            ServiceLocator.getInstance().getService(PerfilAcessoMenuService.class, null);
    for (MenuDTO submenu : listaDeSubMenus) {
      Collection<MenuDTO> novaListaSubMenus = this.getMenuService().listarSubMenus(submenu);
      String nomeSubmenus = submenu.getNome();
      sb.append("<li class=\"closed\">");
      sb.append("<div class=\"hitarea closed-hitarea collapsable-hitarea\"></div>");
      if (novaListaSubMenus != null && !novaListaSubMenus.isEmpty()) {
        pesq += "checkPesq" + submenu.getIdMenu().toString() + " ";
        gravar += "checkPesq" + submenu.getIdMenu().toString() + " ";
        del += "checkDel" + submenu.getIdMenu().toString() + " ";
        aux = "0";
        sb.append("<span class=\"folder\">");
        sb.append("<div>" + UtilI18N.internacionaliza(request, nomeSubmenus) + "</div>");

      } else {

        sb.append("<span class=\"file\">");
        sb.append("<div>" + UtilI18N.internacionaliza(request, nomeSubmenus) + "</div>");
      }
      PerfilAcessoMenuDTO perfilAcessoMenuDTO = new PerfilAcessoMenuDTO();
      perfilAcessoMenuDTO.setIdMenu(submenu.getIdMenu());
      if (idPerfilAcesso != null) {
        perfilAcessoMenuDTO.setIdPerfilAcesso(idPerfilAcesso);
        Collection<PerfilAcessoMenuDTO> dadosAcessoMenu =
            perfilAcessoMenuService.restoreMenusAcesso(perfilAcessoMenuDTO);
        // sb.append("" + nomeSubmenus + "");
        if (dadosAcessoMenu != null && dadosAcessoMenu.size() > 0) {
          for (PerfilAcessoMenuDTO dto : dadosAcessoMenu) {
            sb.append(
                "<label class='pull-left mr10'><input  type=\"checkbox\" "
                    + trataRetorno(dto.getPesquisa())
                    + " class=\""
                    + pesq
                    + "\" name=\"menu\" id=\"pesq_"
                    + submenu.getIdMenu()
                    + "\" value=\""
                    + submenu.getIdMenu()
                    + " "
                    + "\" \"  onclick=\"checkboxPesquisar("
                    + submenu.getIdMenuPai()
                    + ");\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                    + "</label>");
            sb.append(
                "<label class='pull-left mr10'><input type=\"checkbox\" "
                    + trataRetorno(dto.getGrava())
                    + " class=\""
                    + gravar
                    + "\" name=\"menu\" id=\"gravar_"
                    + submenu.getIdMenu()
                    + "\" \" value=\""
                    + submenu.getIdMenu()
                    + " "
                    + "\" onclick=\"checkboxGravar("
                    + submenu.getIdMenuPai()
                    + ");\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                    + "</label>");
            sb.append(
                "<label><input type=\"checkbox\" "
                    + trataRetorno(dto.getDeleta())
                    + " class=\""
                    + del
                    + "\" name=\"menu\" id=\"del_"
                    + submenu.getIdMenu()
                    + "\" \" value=\""
                    + submenu.getIdMenu()
                    + " "
                    + "\" onclick=\"checkboxDeletar("
                    + submenu.getIdMenuPai()
                    + ");\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                    + "</label>");
          }
        } else {
          sb.append(
              "<label class='pull-left mr10'><input type=\"checkbox\"  class=\""
                  + pesq
                  + "\" name=\"menu\" id=\"pesq_"
                  + submenu.getIdMenu()
                  + "\" \" value=\""
                  + submenu.getIdMenu()
                  + " "
                  + "\" onclick=\"checkboxPesquisar("
                  + submenu.getIdMenuPai()
                  + ");\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                  + "</label>");
          sb.append(
              "<label class='pull-left mr10'><input type=\"checkbox\"  class=\""
                  + gravar
                  + "\" name=\"menu\" id=\"gravar_"
                  + submenu.getIdMenu()
                  + "\" \" value=\""
                  + submenu.getIdMenu()
                  + " "
                  + "\" onclick=\"checkboxGravar("
                  + submenu.getIdMenuPai()
                  + ");\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                  + "</label>");
          sb.append(
              "<label><input type=\"checkbox\"  class=\""
                  + del
                  + "\" name=\"menu\" id=\"del_"
                  + submenu.getIdMenu()
                  + "\" \" value=\""
                  + submenu.getIdMenu()
                  + " "
                  + "\" onclick=\"checkboxDeletar("
                  + submenu.getIdMenuPai()
                  + ");\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                  + "</label>");
        }
      } else {
        sb.append(
            "<label class='pull-left mr10'><input type=\"checkbox\"  class=\""
                + pesq
                + "\" name=\"menu\" id=\"pesq_"
                + submenu.getIdMenu()
                + "\" \" value=\""
                + submenu.getIdMenu()
                + " "
                + "\" onclick=\"checkboxPesquisar("
                + submenu.getIdMenuPai()
                + ");\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                + "</label>");
        sb.append(
            "<label class='pull-left mr10'><input type=\"checkbox\"  class=\""
                + gravar
                + "\" name=\"menu\" id=\"gravar_"
                + submenu.getIdMenu()
                + "\" \" value=\""
                + submenu.getIdMenu()
                + " "
                + "\" onclick=\"checkboxGravar("
                + submenu.getIdMenuPai()
                + ");\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                + "</label>");
        sb.append(
            "<label><input type=\"checkbox\"  class=\""
                + del
                + "\" name=\"menu\" id=\"del_"
                + submenu.getIdMenu()
                + "\" \" value=\""
                + submenu.getIdMenu()
                + " "
                + "\" onclick=\"checkboxDeletar("
                + submenu.getIdMenuPai()
                + ");\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                + "</label>");
      }
      sb.append("</span>");
      i++;
      if (novaListaSubMenus != null && !novaListaSubMenus.isEmpty()) {
        sb.append("<ul id=\"subBios\"> ");
        this.gerarMenus(sb, novaListaSubMenus, aux, idPerfilAcesso, request);
        sb.append("</ul> ");
        sb.append("</li>");
      }
    }
  }
Esempio n. 12
0
  private void montarArvoreDeMenus(
      DocumentHTML document, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    this.setPerfilAcessoBean((PerfilAcessoDTO) document.getBean());
    Collection<MenuDTO> listaDeMenus = getMenuService().listarMenus();
    PerfilAcessoMenuService perfilAcessoMenuService =
        (PerfilAcessoMenuService)
            ServiceLocator.getInstance().getService(PerfilAcessoMenuService.class, null);
    StringBuffer sb = new StringBuffer();
    int i = 0;
    sb.append("<div id=\"corpoInf\">");
    sb.append("<br>");
    sb.append("<ul id=\"browser\" class=\"filetree treeview\">");
    Integer idPerfilAcesso = null;

    for (MenuDTO menu : listaDeMenus) {

      if (menu.getNome().trim().equalsIgnoreCase("$menu.nome.recursosHumanos")) {
        String mostrarGerenciaRecursosHumanos =
            ParametroUtil.getValorParametroCitSmartHashMap(
                ParametroSistema.MOSTRAR_GERENCIA_RECURSOS_HUMANOS, "N");
        if (!mostrarGerenciaRecursosHumanos.trim().equalsIgnoreCase("S")
            || menu.getMostrar() == null
            || !Boolean.parseBoolean(menu.getMostrar())) {
          continue;
        }
      } else if (menu.getNome().trim().equalsIgnoreCase("$menu.nome.compras")) {
        String mostrarCompras =
            ParametroUtil.getValorParametroCitSmartHashMap(ParametroSistema.MOSTRAR_COMPRAS, "N");
        if (!mostrarCompras.trim().equalsIgnoreCase("S")
            || menu.getMostrar() == null
            || !Boolean.parseBoolean(menu.getMostrar())) {
          continue;
        }
      }

      pesq = "";
      del = "";
      gravar = "";
      pesq += "checkPesq" + menu.getIdMenu().toString() + " ";
      gravar += "checkGravar" + menu.getIdMenu().toString() + " ";
      del += "checkDel" + menu.getIdMenu().toString() + " ";

      String nome = menu.getNome();
      sb.append("<li class=\"closed\">");
      sb.append("<div class=\"hitarea closed-hitarea collapsable-hitarea\">");
      sb.append("</div>");
      sb.append("<span class=\"folder\">");
      sb.append("<div>" + UtilI18N.internacionaliza(request, nome) + "</div>");
      PerfilAcessoMenuDTO perfilAcessoMenuDTO = new PerfilAcessoMenuDTO();
      perfilAcessoMenuDTO.setIdMenu(menu.getIdMenu());

      if (this.getPerfilAcessoBean() != null) {
        idPerfilAcesso = this.getPerfilAcessoBean().getIdPerfilAcesso();
        perfilAcessoMenuDTO.setIdPerfilAcesso(idPerfilAcesso);
        Collection<PerfilAcessoMenuDTO> dadosAcessoMenu =
            perfilAcessoMenuService.restoreMenusAcesso(perfilAcessoMenuDTO);
        if (dadosAcessoMenu != null && dadosAcessoMenu.size() > 0) {
          for (PerfilAcessoMenuDTO dto : dadosAcessoMenu) {
            sb.append(
                "<label class=\"labelCheck pull-left mr10\"><input "
                    + trataRetorno(dto.getPesquisa())
                    + " class=\"checkPesq"
                    + menu.getIdMenu()
                    + "\" type=\"checkbox\" name=\"menu\" id=\"pesq_"
                    + menu.getIdMenu()
                    + "\" value=\""
                    + menu.getIdMenu()
                    + " "
                    + "\"  onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                    + "</label>");
            sb.append(
                "<label class=\"labelCheck pull-left mr10\"><input "
                    + trataRetorno(dto.getGrava())
                    + " class=\"checkGravar"
                    + menu.getIdMenu()
                    + "\" type=\"checkbox\" name=\"menu\" id=\"gravar_"
                    + menu.getIdMenu()
                    + "\" value=\""
                    + menu.getIdMenu()
                    + " "
                    + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                    + "</label>");
            sb.append(
                "<label class=\"labelCheck\"><input "
                    + trataRetorno(dto.getDeleta())
                    + " class=\"checkDel"
                    + menu.getIdMenu()
                    + "\" type=\"checkbox\" name=\"menu\" id=\"del_"
                    + menu.getIdMenu()
                    + "\" value=\""
                    + menu.getIdMenu()
                    + " "
                    + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                    + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                    + "</label>");
          }
        } else {
          sb.append(
              "<label class=\"labelCheck pull-left mr10\"><input class=\"checkPesq"
                  + menu.getIdMenu()
                  + "\" type=\"checkbox\" name=\"menu\" id=\"pesq_"
                  + menu.getIdMenu()
                  + "\" value=\""
                  + menu.getIdMenu()
                  + " "
                  + "\"  onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                  + "</label>");
          sb.append(
              "<label class=\"labelCheck pull-left mr10\"><input class=\"checkGravar"
                  + menu.getIdMenu()
                  + "\" type=\"checkbox\" name=\"menu\" id=\"gravar_"
                  + menu.getIdMenu()
                  + "\" value=\""
                  + menu.getIdMenu()
                  + " "
                  + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                  + "</label>");
          sb.append(
              "<label class=\"labelCheck\"><input class=\"checkDel"
                  + menu.getIdMenu()
                  + "\" type=\"checkbox\" name=\"menu\" id=\"del_"
                  + menu.getIdMenu()
                  + "\" value=\""
                  + menu.getIdMenu()
                  + " "
                  + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                  + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                  + "</label>");
        }
      } else {
        sb.append(
            "<label class=\"labelCheck pull-left mr10\"><input class=\"checkPesq"
                + menu.getIdMenu()
                + "\" type=\"checkbox\" name=\"menu\" id=\"pesq_"
                + menu.getIdMenu()
                + "\" value=\""
                + menu.getIdMenu()
                + " "
                + "\"  onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.pesquisar")
                + "</label>");
        sb.append(
            "<label class=\"labelCheck pull-left mr10\"><input class=\"checkGravar"
                + menu.getIdMenu()
                + "\" type=\"checkbox\" name=\"menu\" id=\"gravar_"
                + menu.getIdMenu()
                + "\" value=\""
                + menu.getIdMenu()
                + " "
                + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.gravar")
                + "</label>");
        sb.append(
            "<label class=\"labelCheck\"><input class=\"checkDel"
                + menu.getIdMenu()
                + "\" type=\"checkbox\" name=\"menu\" id=\"del_"
                + menu.getIdMenu()
                + "\" value=\""
                + menu.getIdMenu()
                + " "
                + "\" onclick=\"marcarTodosCheckbox(this);\" />&nbsp;"
                + UtilI18N.internacionaliza(request, "citcorpore.comum.deletar")
                + "</label>");
      }

      sb.append("</span>");
      sb.append("<ul> ");
      Collection<MenuDTO> listaDeSubMenus = getMenuService().listarSubMenus(menu);
      i++;
      this.gerarMenus(sb, listaDeSubMenus, "0", idPerfilAcesso, request);
      sb.append("</ul>");
      sb.append("</li>");
    }
    sb.append("</ul>");
    sb.append("</div>");

    HTMLElement divPrincipal = document.getElementById("principalInf");
    divPrincipal.setInnerHTML(sb.toString());

    document.executeScript("tree(\"#browser\");JANELA_AGUARDE_MENU.hide();");
  }