Package org.efs.openreports.util

Examples of org.efs.openreports.util.ByteArrayDataSource


   
    public void deliverReport(ReportSchedule reportSchedule, ReportEngineOutput reportOutput) throws DeliveryException
    {
        ArrayList<ByteArrayDataSource> htmlImageDataSources = new ArrayList<ByteArrayDataSource>();
       
        ByteArrayDataSource byteArrayDataSource = exportReport(reportOutput, reportSchedule, htmlImageDataSources);

        MailMessage mail = new MailMessage();              
        mail.setByteArrayDataSource(byteArrayDataSource);
        mail.addHtmlImageDataSources(htmlImageDataSources);         
        mail.setSender(reportSchedule.getUser().getEmail());
        mail.parseRecipients(reportSchedule.getRecipients());
        mail.setBounceAddress(reportSchedule.getDeliveryReturnAddress());
       
        if (reportSchedule.getScheduleDescription() != null && reportSchedule.getScheduleDescription().trim().length() > 0)
        {
            mail.setSubject(reportSchedule.getScheduleDescription());
        }
        else
        {
            mail.setSubject(reportSchedule.getReport().getName());
        }
       
        if (reportSchedule.getExportType() != ExportType.HTML.getCode())
        {
            mail.setText(reportSchedule.getReport().getName() + ": Generated on " + new Date());
        }

        try
        {
            mailProvider.sendMail(mail);
        }
        catch(ProviderException pe)
        {
            throw new DeliveryException(pe);
        }
       
        log.debug(byteArrayDataSource.getName() + " sent to: " + mail.formatRecipients(";"));       
    }
View Full Code Here


    protected ByteArrayDataSource exportReport(ReportEngineOutput reportOutput, ReportSchedule reportSchedule,
            ArrayList<ByteArrayDataSource> htmlImageDataSources)
    {      
        String reportName = StringUtils.deleteWhitespace(reportSchedule.getReport().getName());

        ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(reportOutput.getContent(), reportOutput.getContentType());
        byteArrayDataSource.setName(reportName + reportOutput.getContentExtension());
       
        if (reportSchedule.getExportType() == ExportType.HTML.getCode()
                && reportSchedule.getReport().isJasperReport())
        {
            Map imagesMap = ((JasperReportEngineOutput) reportOutput).getImagesMap();

            for (Iterator entryIter = imagesMap.entrySet().iterator(); entryIter
                    .hasNext();)
            {
                Map.Entry entry = (Map.Entry) entryIter.next();

                ByteArrayDataSource imageDataSource = new ByteArrayDataSource(
                        (byte[]) entry.getValue(), getImageContentType((byte[]) entry
                                .getValue()));

                imageDataSource.setName((String) entry.getKey());

                htmlImageDataSources.add(imageDataSource);
            }
        }
View Full Code Here

TOP

Related Classes of org.efs.openreports.util.ByteArrayDataSource

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.