Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Calling ReportDesigner report from Java

  1. #1
    Join Date
    Jul 2008
    Posts
    10

    Default Calling ReportDesigner report from Java

    I have created a report file using ReportDesigner and am trying to load and preview this from Java. It looks like I need to do more to get my report's XML parsed. I have found two ways of doing this on the Wiki and both fail with the same warnings:

    WARN: Unknown tag <http://jfreereport.sourceforge.net/namespaces/reports/legacy/simpleroperty>: Start to ignore this element and all of its childs. [bbcode turned some of the message into a smiley. Sigh]

    There are lots of messages along those lines. What am I missing? I'm using ReportDesigner 1.7.0 build 0536. I'm compiling my Java with the jars in ReportDesigner's lib directory which includes reporting engine classic 0.8.9.5.

    What am I missing?

    Here is my Java. The commented out bit at the bottom fails to work in the same way:

    HTML Code:
    package com.babblemind.reports;
    
    import java.net.MalformedURLException;
    import java.net.URL;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    
    import org.jfree.resourceloader.Resource;
    import org.jfree.resourceloader.ResourceException;
    import org.jfree.resourceloader.ResourceManager;
    
    import org.jfree.report.JFreeReport;
    import org.jfree.report.JFreeReportBoot;
    import org.jfree.report.modules.gui.base.PreviewDialog;
    import org.jfree.report.modules.parser.base.ReportGenerator;
    
    public class Simple02 {
        public static void main(String args[]) {
        new Simple02();
        }
    
        private Simple02() {
        JFreeReportBoot.getInstance().start();
    
        try {
            JFreeReport report = parseReport(getClass().getResource(
            "/staff-sales.report"));
    
            PreviewDialog frame = new PreviewDialog(report);
            frame.pack();
            frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
        }
    
        private JFreeReport parseReport(URL in) throws Exception {
        ReportGenerator generator = ReportGenerator.getInstance();
        JFreeReport report = generator.parseReport(in);
    
    
    
        //ResourceManager manager = new ResourceManager();
        //manager.registerDefaults();
        //Resource res = manager.createDirectly(in, JFreeReport.class);
        //JFreeReport report = (JFreeReport) res.getResource();
    
        return report;
        }
    }

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    The engine itself does not understand the *.report fileformat. This format is a proprietary thing of the report-designer and is not well-defined enough to allow the engine prior to the current SVN version to make sane use of it. You have to export the report into a *.xml file so that the engine can understand the report.

    In the current SVN, I added a parser for that fileformat so that the engine can use the report-designer files directly. Naturally, it has the same limitations as the 1.7-report-designer and requires a large set of extension modules from the current SVN version to run.

    So to run reports, either export the XML (but sadly you will lose the datasource definitions in the process) or use the latest SVN version along with the report-designer-parser module.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3
    Join Date
    Jul 2008
    Posts
    10

    Default

    Thanks for the quick reply.

    Ahh.... I would never have guessed that! Now I have created an XML file using File->Publish. In my Java, how do I give it back the data source? (I'm using an XML [XQuery] data source).
    Last edited by mikewilsonuk; 07-10-2008 at 11:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.