Package org.efs.openreports.objects

Examples of org.efs.openreports.objects.Report


    PreparedStatement pStmt = null;
    ResultSet rs = null;

    try
    {
      Report report = input.getReport();
      Map<String,Object> parameters = input.getParameters();
     
      ReportDataSource dataSource = report.getDataSource();
      conn = dataSourceProvider.getConnection(dataSource.getId());

      if (parameters == null || parameters.isEmpty())
      {
        pStmt = conn.prepareStatement(report.getQuery());
      }
      else
      {
        // Use JasperReports Query logic to parse parameters in chart
        // queries

        JRDesignQuery query = new JRDesignQuery();
        query.setText(report.getQuery());

        // convert parameters to JRDesignParameters so they can be
        // parsed
        Map<String,JRDesignParameter> jrParameters = ORUtil.buildJRDesignParameters(parameters);
View Full Code Here


  {
    Connection conn = null;

    try
    {
      Report report = input.getReport();
           
      // create new HashMap to send to JXLS in order to maintain original map of parameters
      Map<String,Object> jxlsReportMap = new HashMap<String,Object>(input.getParameters());
     
      if (report.getQuery() != null && report.getQuery().trim().length() > 0)
      {
        QueryReportEngine queryEngine = new QueryReportEngine(dataSourceProvider, directoryProvider, propertiesProvider);       
       
        // set ExportType to null so QueryReportEngine just returns a list of results
        input.setExportType(null);
       
        QueryEngineOutput output = (QueryEngineOutput) queryEngine
            .generateReport(input);   
       
        jxlsReportMap.put(ORStatics.JXLS_REPORT_RESULTS, output.getResults());
      }
      else
      {
        conn = dataSourceProvider.getConnection(report.getDataSource().getId());
        JXLSReportManagerImpl rm = new JXLSReportManagerImpl(conn, jxlsReportMap, dataSourceProvider);
        jxlsReportMap.put("rm", rm);
      }

      FileInputStream template = new FileInputStream(directoryProvider
          .getReportDirectory()
          + report.getFile());

      XLSTransformer transformer = new XLSTransformer();
      HSSFWorkbook workbook = transformer.transformXLS(template, jxlsReportMap);     

      ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

      List<Report> selectedReports = new ArrayList<Report>();
     
      for (int i = 0; i < reportIds.length; i++)
      {
        Report report = reportProvider.getReport(new Integer(reportIds[i]));
        selectedReports.add(report);       
      }
     
      HttpServletResponse response = ServletActionContext.getResponse();
      response.setHeader("Content-disposition", "inline; filename=or-report-export.xml");
View Full Code Here

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    CloseableTableModel model = null;
   
    try
    {
      Report report = input.getReport();
      Map parameters = input.getParameters();
     
      ReportDataSource dataSource = report.getDataSource();
      conn = dataSourceProvider.getConnection(dataSource.getId());

      if (parameters == null || parameters.isEmpty())
      {
        pStmt = conn.prepareStatement(report.getQuery());
      }
      else
      {
        // Use JasperReports Query logic to parse parameters in chart
        // queries

        JRDesignQuery query = new JRDesignQuery();
        query.setText(report.getQuery());

        // convert parameters to JRDesignParameters so they can be
        // parsed
        Map jrParameters = ORUtil.buildJRDesignParameters(parameters);

        pStmt = JRQueryExecuter.getStatement(query, jrParameters, parameters, conn);
      }
     
      ORProperty maxRows = propertiesProvider.getProperty(ORProperty.QUERYREPORT_MAXROWS);
      if (maxRows != null && maxRows.getValue() != null)
      { 
        pStmt.setMaxRows(Integer.parseInt(maxRows.getValue()));
      }
     
      rs = pStmt.executeQuery();   
     
      model = ResultSetTableModelFactory.getInstance().createTableModel(rs);

      ReportGenerator generator = ReportGenerator.getInstance();
     
      JFreeReport jfreeReport = generator.parseReport(directoryProvider
          .getReportDirectory()
          + report.getFile());
      jfreeReport.setData(model);

      ReportEngineOutput output = new ReportEngineOutput();
     
      if (input.getExportType() == ExportType.PDF)
View Full Code Here

    try
    {
      for (int i = 0; i < ids.length; i++)
      {
        Report report = reportProvider.getReport(new Integer(ids[i]));
        reports.add(report);
      }
    }
    catch (Exception e)
    {
View Full Code Here

                  report.getReportChart().setDataSource(dataSource);
                }
               
                if (report.getReportChart().getDrillDownReport() != null)
                {
                  Report drillDownReport = reportProvider.getReport(report.getReportChart().getDrillDownReport().getName());
                  if (drillDownReport == null)
                  {           
                    drillDownReport = reportProvider.insertReport(report.getReportChart().getDrillDownReport());
                    log.info("Adding Report: " + drillDownReport.getName());
                  }
                  report.getReportChart().setDrillDownReport(drillDownReport);
                }
               
                if (report.getReportChart().getOverlayChart() != null)
View Full Code Here

    {
        Object object = getCurrentRowObject();

        if (object instanceof Report)
        {
            Report report = (Report)object;
            return "<a href=\"editReport.action?command=edit&amp;id=" + report.getId() + "\">Edit Report</a>";
        }
        else if (object instanceof ReportGroup)
        {
            ReportGroup reportGroup = (ReportGroup)object;
            return "<a href=\"editGroup.action?command=edit&amp;id=" + reportGroup.getId() + "\">Edit Group</a>";
View Full Code Here

    ReportSchedule reportSchedule =
      (ReportSchedule) jobDataMap.get(ORStatics.REPORT_SCHEDULE);
    reportSchedule.setScheduleDescription(context.getJobDetail().getDescription());

    Report report = reportSchedule.getReport();
    ReportUser user = reportSchedule.getUser();
    Map<String,Object> reportParameters = reportSchedule.getReportParameters();

    log.debug("Report: " + report.getName());
    log.debug("User: " + user.getName());   

    JRVirtualizer virtualizer = null;
          
    ReportLog reportLog = new ReportLog(user, report, new Date());
        reportLog.setExportType(reportSchedule.getExportType());
        reportLog.setRequestId(reportSchedule.getRequestId());
       
    try
    {
      //
      ReportUserAlert alert = reportSchedule.getAlert();     
     
      if (alert != null)
      {
        log.debug("Executing Alert Condition");
       
        alert.setReport(report);
        alert = alertProvider.executeAlert(alert, true);
       
        if (!alert.isTriggered())
        {
          log.debug("Alert Not Triggered. Report not run.");
          return;
        }
       
        log.debug("Alert Triggered. Running report.");
      }
      //     

      // add standard report parameters
      reportParameters.put(ORStatics.USER_ID, user.getId());
      reportParameters.put(ORStatics.EXTERNAL_ID, user.getExternalId());
      reportParameters.put(ORStatics.USER_NAME, user.getName());
      reportParameters.put(ORStatics.IMAGE_DIR, new File(directoryProvider.getReportImageDirectory()));
      reportParameters.put(ORStatics.REPORT_DIR, new File(directoryProvider.getReportDirectory()));
      //
     
      reportLogProvider.insertReportLog(reportLog);     
     
      ReportEngineInput reportInput = new ReportEngineInput(report, reportParameters);
      reportInput.setExportType(ExportType.findByCode(reportSchedule.getExportType()));
            reportInput.setXmlInput(reportSchedule.getXmlInput());
            reportInput.setLocale(reportSchedule.getLocale());
     
      if (report.isJasperReport())
      {
        // add any charts
        if (report.getReportChart() != null)
        {
          log.debug("Adding chart: " + report.getReportChart().getName());
       
          ChartReportEngine chartEngine = new ChartReportEngine(
              dataSourceProvider, directoryProvider, propertiesProvider);
         
          ChartEngineOutput chartOutput = (ChartEngineOutput) chartEngine.generateReport(reportInput);
       
          reportParameters.put("ChartImage", chartOutput.getContent());       
        }

        if (report.isVirtualizationEnabled())
        {
          log.debug("Virtualization Enabled");
          virtualizer = new JRFileVirtualizer(2, directoryProvider.getTempDirectory());
          reportParameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
        }
View Full Code Here

    @Override
    public void doExecute(String location, ActionInvocation invocation) throws IOException, TemplateException
    {       
        QueryReportResultAction queryReportAction = (QueryReportResultAction) invocation.getAction();
        Report report = queryReportAction.getReport();           
       
        super.doExecute(report.getFile(), invocation);
    }
View Full Code Here

    private MailProvider mailProvider;
    private DirectoryProvider directoryProvider;
   
    public void deliverReport(ReportSchedule reportSchedule, ReportEngineOutput reportOutput) throws DeliveryException
    {
        Report report = reportSchedule.getReport();
        ReportUser user = reportSchedule.getUser();
       
        Date runDate = new Date();
       
        String fileName = runDate.getTime() + "-"
                + StringUtils.deleteWhitespace(user.getName()) + "-"
                + StringUtils.deleteWhitespace(report.getName());                      
       
        try
        {
            FileOutputStream file = new FileOutputStream(directoryProvider
                .getReportGenerationDirectory()
                + fileName + reportOutput.getContentExtension());
           
            file.write(reportOutput.getContent())
            file.flush();
            file.close();
        }
        catch(IOException ioe)
        {
            throw new DeliveryException(ioe);
        }       
       
        DeliveredReport info = new DeliveredReport();            
        info.setParameters(reportSchedule.getReportParameters());
        info.setReportDescription(reportSchedule.getScheduleDescription());
        info.setReportName(report.getName());
        info.setReportFileName(fileName + reportOutput.getContentExtension());
        info.setRunDate(runDate);
        info.setUserName(user.getName());
        info.setDeliveryMethod("fileSystemDeliveryMethod");
       
        try
        {
            FileOutputStream file = new FileOutputStream(directoryProvider.getReportGenerationDirectory() + fileName + ".xml");

            XStream xStream = new XStream();
            xStream.alias("reportGenerationInfo", DeliveredReport.class);
            xStream.toXML(info, file);
       
            file.flush();
            file.close();
        }
        catch(IOException ioe)
        {
            throw new DeliveryException(ioe);
        }  
       
        MailMessage mail = new MailMessage();              
        mail.setSender(user.getEmail());
        mail.parseRecipients(reportSchedule.getRecipients());
        mail.setText(report.getName() + ": Generated on " + new Date());
        mail.setBounceAddress(reportSchedule.getDeliveryReturnAddress());
       
        if (reportSchedule.getScheduleDescription() != null && reportSchedule.getScheduleDescription().trim().length() > 0)
        {
            mail.setSubject(reportSchedule.getScheduleDescription());
        }
        else
        {
            mail.setSubject(reportSchedule.getReport().getName());
        }     
       
        try
        {
            mailProvider.sendMail(mail);   
        }
        catch(ProviderException pe)
        {
            throw new DeliveryException(pe);
        }  
       
        log.debug(report.getName() + " written to: " + fileName);
    }
View Full Code Here

TOP

Related Classes of org.efs.openreports.objects.Report

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.