Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  public static void main(String[] args) {
    try {
      URL url =
          JasperAB.class
              .getClassLoader()
              .getResource("br/com/analiseFornecedores/relatorio/relatorio_controle_1.jasper");
      File reportFile = new File(url.getFile());
      JasperReport relatorio = (JasperReport) JRLoader.loadObject(reportFile.getPath());
      Collection<RelatorioControleVO> lista = new ArrayList<RelatorioControleVO>();

      AnaliseRN rn = new AnaliseRN();
      Collection<AnaliseVO> analises = new ArrayList<AnaliseVO>();
      try {
        AnaliseVO filtro = new AnaliseVO();
        analises = rn.obterPorFiltro(filtro);
        lista = rn.obterRelatorioControle(analises);
      } catch (ExecaoRegraNegocio e) {
        e.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }

      JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(lista);
      Map<?, ?> param = new HashMap();
      JasperPrint jasperPrint = JRFiller.fillReport(relatorio, param, ds);
      JasperViewer.viewReport(jasperPrint, true);
    } catch (JRException e) {
      e.printStackTrace();
    }
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {
      UsuarioVO usuarioSessao =
          (UsuarioVO) request.getSession().getAttribute(ConstantesIF.SESSAO_USUARIO);
      AnaliseVO analiseVO = new AnaliseVO();
      analiseVO.setCodigo(new Integer(request.getParameter("codigo")));

      if (request.getParameter("situacaoReceitaFederal") != null
          && !"".equals(request.getParameter("situacaoReceitaFederal")))
        analiseVO.setSituacaoReceitaFederal(request.getParameter("situacaoReceitaFederal"));
      if (request.getParameter("situacaoSefaz") != null
          && !"".equals(request.getParameter("situacaoSefaz")))
        analiseVO.setSituacaoSefaz(request.getParameter("situacaoSefaz"));
      if (request.getParameter("situacaoSefazSalvador") != null
          && !"".equals(request.getParameter("situacaoSefazSalvador")))
        analiseVO.setSituacaoSefazSalvador(request.getParameter("situacaoSefazSalvador"));
      if (request.getParameter("observacao") != null
          && !"".equals(request.getParameter("observacao")))
        analiseVO.setObservacao(request.getParameter("observacao"));

      AnaliseRN analiseRN = new AnaliseRN();

      request.setAttribute("analise", analiseRN.obterPorChave(analiseVO));

      analiseRN.alterar(analiseVO);

      request.setAttribute("analise", analiseRN.obterPorChave(analiseVO));

      request.setAttribute("msg", "Analise alterada com sucesso.");

    } catch (Exception e) {
      tratarException(e, request);
    } finally {
      request.getRequestDispatcher("/jsp/analise/analiseForm.jsp").forward(request, response);
    }
  }