Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Is it possible to read Query from a Report by API

  1. #1

    Default Is it possible to read Query from a Report by API

    Hi,

    is it possible to read the SQL-Query from a *.prpt-File by Pentaho-API?

  2. #2
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    You can extract the data...

    prpt can be opened as a ZIP file, and your queries are in a directory called "Datasources" as XML files. The SQL Query is in there.
    **THIS IS A SIGNATURE - IT GETS POSTED ON (ALMOST) EVERY POST**
    I'm no expert.
    Take my comments at your own risk.

    PDI user since PDI 3.1
    PDI on Windows 7 & Linux

    Please keep in mind (and this may not apply to this thread):
    No forum member is going to do your work for you. We will help you sort out how to do a specific part of the work, as best we can, in the timelines that our work will allow us.
    Signature Updated: 2014-06-30

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

    Default

    why work with a xml-structure if you can access the datasources directly?

    MasterReport#getDataFactory()
    SubReport#getDataFactory()

    you most likely get a ComboundDataFactory from there (check with instanceof), which is a container containing more datafactories. Seek for the SQLReportDataFactory in there.


    To get to the subreports, you most likely have to iterate over the report into the bands to get the subreports that are attached there. Will Gorman's book explains the API - otherwise have a look at the sources, our API is fairly simple.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  4. #4

    Default

    Quote Originally Posted by Taqua View Post
    why work with a xml-structure if you can access the datasources directly?

    MasterReport#getDataFactory()
    SubReport#getDataFactory()
    I think, that's exactly what I would like to do, but I didn't find out yet, how I can build a MasterReport from an existing prpt-File. Is there any example for that?

    I found this one: http://forums.pentaho.org/showpost.p...59&postcount=1

    And tried to "copy" it.

    reportPath = "file:/<pathToPrpt>";
    ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    Resource res = manager.createDirectly(new URL(reportPath),MasterReport.class);
    MasterReport report = (MasterReport) res.getResource();
    DataFactory df = report.getDataFactory();
    ....
    But on Line "Resource res = manager.createDirectly(new URL(reportPath),MasterReport.class);" I get an ContentNotRecognizedException.

    What does this mean?

    Ok, sorry, I solved it by myself now ;-)

    Just missed some JAR-Files and forgot to boot the ReportEngine
    Last edited by michael.mest; 06-30-2010 at 01:30 AM.

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

    Default

    There are samples in the demo and the sdk (while the SDK definitely has the better documented ones). And as said: Will Gormans book goes into all the dirty details of the API - there is no better resource out there to get started.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

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.