Exemplo n.º 1
0
  public void reporteToXls() {
    try {
      validarDatos();
      cargarParametros();
      reportFactory.exportReportToXlsFile(pathReporte, nombreArchivo, parameters);

    } catch (ExcepcionGeneralSistema ex) {
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
    } catch (NamingException ex) {
      Logger.getLogger(InformeBase.class.getName()).log(Level.SEVERE, null, ex);
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
    } catch (SQLException ex) {
      Logger.getLogger(InformeBase.class.getName()).log(Level.SEVERE, null, ex);
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
    } catch (JRException ex) {
      Logger.getLogger(InformeBase.class.getName()).log(Level.SEVERE, null, ex);
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
    } catch (IOException ex) {
      Logger.getLogger(InformeBase.class.getName()).log(Level.SEVERE, null, ex);
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
    } catch (Exception ex) {
      JsfUtil.addErrorMessage("No se puede ejecutar reporte xls " + ex);
      Logger.getLogger(InformeBase.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Exemplo n.º 2
0
  public void reporteToPdf() {
    try {
      validarDatos();
      cargarParametros();
      reportFactory.exportReportToPdfFile(pathReporte, nombreArchivo, parameters);
      muestraReporte = true;
      todoOk = true;

    } catch (ExcepcionGeneralSistema e) {
      //            e.printStackTrace();
      JsfUtil.addErrorMessage("No se puede ejecutar reporte pdf " + e);
      todoOk = false;
      muestraReporte = false;
    } catch (JRException e) {
      //            e.printStackTrace();
      JsfUtil.addErrorMessage("No se puede ejecutar reporte pdf " + e);
      todoOk = false;
      muestraReporte = false;
    } catch (Exception e) {
      //            e.printStackTrace();
      JsfUtil.addErrorMessage("No se puede ejecutar reporte pdf " + e);
      todoOk = false;
      muestraReporte = false;
    }
  }
Exemplo n.º 3
0
  public void reporteToEmail(CorreoElectronico ce) throws Exception {

    if (aplicacionBean.getParametro().getEnviaNotificaciones() == 'S') {

      String pathPDF = reportFactory.getPathTemporales() + nombreArchivo + ".pdf";

      if (pathPDF == null || pathPDF.isEmpty())
        throw new ExcepcionGeneralSistema("No existe reporte o archivo a enviar");

      ce.setPathArchivo(pathPDF);

      List<CorreoElectronico> correos = new ArrayList<CorreoElectronico>();
      correos.add(ce);

      SenderEmail se = new SenderEmail(mailFactoryBean, correos);
      se.start();

      JsfUtil.addInfoMessage("El envío fue exitoso. Destino: " + emailEnvioComprobante);

    } else {
      JsfUtil.addWarningMessage("No tiene permiso para enviar notificaciones");
    }

    solicitaEmail = false;
  }
Exemplo n.º 4
0
  @Override
  public JasperPrint fillReport() throws Exception {

    final JasperReport[] jra = reportCard.getRichReportJRA();
    final JasperReport masterReport = jra[0];

    // init jasper "rendering map"
    final Map<String, Object> jasperFillManagerParameters = new LinkedHashMap<String, Object>();

    // add parameters to "rendering map"
    if (reportParameters != null) {
      for (final ReportParameter rp : reportParameters) {
        jasperFillManagerParameters.put(rp.getFullName(), rp.getValue());
      }
    }

    // add subreports to "rendering map"
    for (int k = 1; k < jra.length; k++) {
      if (jra[k] != null) {
        jasperFillManagerParameters.put(ReportFactory.PARAM_SUBREPORT + k, jra[k]);
      }
    }

    // add images to "rendering map"
    final InputStream[] isa = reportCard.getImagesISA();
    for (int i = 0; i < isa.length; i++) {
      jasperFillManagerParameters.put(ReportFactory.PARAM_IMAGE + i, isa[i]);
    }

    // launch report rendering
    super.fillReport(masterReport, jasperFillManagerParameters);

    return jasperPrint;
  }
 @Override
 public Report generateReport(String fileInput) throws CalculateIncomeTaxException {
   Reader in = null;
   List<InputRawData> inputRawData = new ArrayList<InputRawData>();
   try {
     in = new FileReader(fileInput);
     Iterable<CSVRecord> records = CSVFormat.EXCEL.withHeader().withIgnoreEmptyLines().parse(in);
     for (CSVRecord record : records) {
       String firstName = record.get("FirstName");
       String lastName = record.get("LastName");
       String annualSalary = record.get("AnnualSalary");
       String superRate = record.get("SuperRate");
       String paymentMonth = record.get("PaymentMonth");
       inputRawData.add(
           new InputRawData(firstName, lastName, annualSalary, superRate, paymentMonth));
     }
   } catch (FileNotFoundException fileNotFound) {
     fileNotFound.printStackTrace();
   } catch (IOException ioException) {
     ioException.printStackTrace();
   } finally {
     try {
       in.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   return reportFactory.create(inputRawData);
 }
Exemplo n.º 6
0
 @Override
 public void sendReportToStream(final OutputStream outStream) throws Exception {
   if (getReportExtension() == ReportExtension.ZIP) {
     writeZip(outStream);
   } else {
     super.sendReportToStream(outStream);
   }
 }