xml datasource as inputStream

RegisR
edited February 11, 2022 in Analytics #1
Hi,

I have a quick question about the BIRT 2.2.2 reportEngine.
I'm developping a batch application, which generate the XML datasource on the fly.
Of what I have seen, the report engine can only get an XML datasource from a "physical" source. I mean file or URL.
Is there a way to send the datasource as inputStream to the report engine ? Because I can have thousands of reports a day, it will be better than write the report to disk then read it from engine...

Thanks a lot!

Comments

  • RegisR
    edited December 31, 1969 #2
    Never mind...

    Sorry for the inconvenience, I finally found the response by myself by looking at the ODA xml source code...
    Here is a sample of code for those interested.

    Map appContext = runAndRenderTask.getAppContext();
    FileInputStream fileInputStream = new FileInputStream("D:/workspaces/birt/2.2.2/datasource/batch/reports/report.xml");
    appContext.put("org.eclipse.datatools.enablement.oda.xml.inputStream", fileInputStream);
    //Use closeInputStream (true) to let BIRT automatically close the inputStream.
    appContext.put("org.eclipse.datatools.enablement.oda.xml.closeInputStream", "true");
  • RegisR
    edited December 31, 1969 #3
    Hum, finally...
    It's not resolved...

    In case of the report contains 2 xml datasources... The 2 datasources will be bound on the same inputStream ! That's too bad...

    Any idea to resolve this, please ?

    Thanks !
  • vash
    edited December 31, 1969 #4
    Hi,

    Can you please tell me, from where did you get this package:
    org.eclipse.datatools.enablement.oda.xml.inputStream

    because its not available in the lib directory.

    -Vash
  • RegisR
    edited December 31, 1969 #5
    The package "org.eclipse.datatools.enablement.oda.xml.inputStream" does not exists (I think).

    It is only a string to "register" a variable. But the driver is contained in the org.eclipse.datatools.enablement.oda.xml...jar
    It's available in the plugins directory (sub folder of the lib one).
    But only since BIRT 2.2 (BIRT 2.1 uses a custom ODA drivers).
  • vash
    edited December 31, 1969 #6
    Thanks RegisR,

    Got it.
    Its in plugins.

    -Vash
  • hearttaker
    edited December 31, 1969 #7
    Hi,
    I am relatively new to BIRT .

    I'm trying to create a report design and then render the contents to an excel using BIRT 2.3

    I have used an XML datasource which will take in a physical xml file at runtime and create a design. I am actually writing an xml object into a file (say abc.xml) at run time .
    and set the xml file to the datasourcehandle as below :

    dataSourceHandle.setProperty("FILELIST", xmlFilePath);

    my question is , instead of using a physical file, is there a way to pass an xml object as a String/stream for creating the design ?

    Thanks in Advance,
    Hearttaker!!!
  • RegisR
    edited December 31, 1969 #8
    Yes, just take the code above and replace the FileInputStream by a "whatever"InputStream.
    Map appContext = runAndRenderTask.getAppContext();
    SomethingInputStream inputStream = new SomethingInputStream (...);
    appContext.put("org.eclipse.datatools.enablement.oda.xml.inputStream", inputStream);
    //Use closeInputStream (true) to let BIRT automatically close the inputStream.
    appContext.put("org.eclipse.datatools.enablement.oda.xml.closeInputStream", "true");
    The only requirement is that the inputStream streams XML...

    Please note that it is a dangerous way to do things. BIRT does not natively support InputStream. It's a property of the XML driver.

    Please also note that BIRT will make a lot of calls to the input stream. You can expect to have only one call to get data, but no ! Depending on your report and the input stream you may have huge performance issues. Because it can be called many many many many times...
  • hearttaker
    edited December 31, 1969 #9
    Thanks a ton RegisR !!!!

    it worked :))))


    Regards,
    Hearttaker !!!
  • <p>How does one consume inputStream set with "org.eclipse.datatools.enablement.oda.xml.inputStream" in java code?</p>
    <p>What datasource should be used and how to configure it to use inputStream in .rtpdesign?</p>
    <p>In XML DataSource i have to provide file.xml, there is no option to use inputStream. Do I have to somehow override this file.xml with inputStream in beforeOpen?</p>
    <p>I'd be very grateful for any advice.</p>
  • <blockquote class="ipsBlockquote" data-author="pkkoniec" data-cid="147449" data-time="1493206466">
    <div>
    <p>How does one consume inputStream set with "org.eclipse.datatools.enablement.oda.xml.inputStream" in java code?</p>
    <p>What datasource should be used and how to configure it to use inputStream in .rtpdesign?</p>
    <p>In XML DataSource i have to provide file.xml, there is no option to use inputStream. Do I have to somehow override this file.xml with inputStream in beforeOpen?</p>
    <p>I'd be very grateful for any advice.</p>
    </div>
    </blockquote>
    <p>It turns out that file.xml is overridden by inputStream without any actions required.</p>
    <p>If inputStream happens to be null, by default, file.xml is used</p>