Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: how to call setDataFactory of a subReport

  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Default how to call setDataFactory of a subReport

    Hi,

    I have a report with master report and one subReport designed from Pentaho Report Designer.

    I change the DataFactory of the MasterReport as follows :

    Code:
     ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    Resource res = manager.createDirectly(new URL("file:chapter5/data/sub_sample.prpt"), MasterReport.class);
    MasterReport report = (MasterReport) res.getResource();
    
    MyStaticFactory factory = new MyStaticFactory();
    report.setDataFactory(factory);
    
    PdfReportUtil.createPDF(report,"chapter5/output/sample.pdf");
    This works very nicely for the queries defined in Master Report but it does not for the Sub Report. My question is how can i also call setDataFactory of the SubReport .

    Basically i want to call setDataFactory for master & sub , can do for master ,but couldn't find a way to it for sub report.
    I want both of the factories to be changed while report is being generated.

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

    Default

    You have to traverse the report model to locate your subreport and then you can call "setDataFactory(..)" on it.

    But then again: Datafactories are inherited anyway, so when you set the datafactory on your masterreport, your subreport will be able to see them as well. Just make sure that your datafactories know what queries they can answer (#isQueryValid(..)") and also ensure that your subreport and masterreport have different queries.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3
    Join Date
    Jun 2010
    Posts
    2

    Default

    Thanks for the information,

    When i use the master-datasource in sub-report (inherited ) then queryDaya of the master factory is called.

    But when i use a seperate datasource in sub-report , queryData of the master factory is not called.

    One last question i have is about where to start processing should i go with :

    Code:
    MasterReport report = (MasterReport) res.getResource();
    report.get... and then traverse ?
    or should i go with other utility in the pentaho api , can you tell me where to start .

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.