Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Get an IReportDocument from IRunAndRenderTask(Is it possible get an instance of IReportDocument from an IRunAndRenderTask)
Get an IReportDocument from IRunAndRenderTask [message #769684] Thu, 22 December 2011 14:30 Go to next message
Alessio Pollero is currently offline Alessio PolleroFriend
Messages: 74
Registered: August 2011
Member
I have an application that generates report in a given output format(e.g. : HTML, PDF, ...) using report engine API, to generate the report in the desired format i create an IRunAndRenderTask instance and then call the run() method, this generate the report in the desired format, and everything works fine .

Now i want to retrieve also the IReportDocument of the generation and save it in a collection for later use , is it possible ? How can i get an IReportDocument from an IRunAndRenderTask ?

I assume that should be possible since RunAndRenderTask should before generate an IReportDocument and then render it ...
Re: Get an IReportDocument from IRunAndRenderTask [message #769706 is a reply to message #769684] Thu, 22 December 2011 15:07 Go to previous messageGo to next message
Peter Cliff is currently offline Peter CliffFriend
Messages: 14
Registered: December 2011
Location: South West England
Junior Member
Hi Alessio,

I'm doing something very similar to this and have implemented it using a combination IRunTask - to create the IReportDocument - and then (at a later date or immediately) use IRenderTask to produce the output. So the short anwser is "Yes, it is possible, but use IRunTask and IRenderTask instead of IRunAndRenderTask".

Examples are given here: http://eclipse.org/birt/phoenix/deploy/reportEngineAPI.php

In summary:

String path = "/tmp/BIRTrrdemo/";
		
// Init engine...
EngineConfig config = new EngineConfig();
Platform.startup( config );

ReportEngineFactory ref = new ReportEngineFactory();
IReportEngine engine = ref.createReportEngine( config );

// Open design
IReportRunnable design = engine.openReportDesign( path + "test.rptdesign" );
		
HashMap values = getDefaultParams( design, engine );

// Run task to create document...
IRunTask task = engine.createRunTask( design );
task.setParameterValues( values );

FileArchiveWriter faw = null;
faw = new FileArchiveWriter( path + "myDocumentFile.rptdocument" );

// Creates the file representation of the IReportDocument
task.run( faw );

// Could stop here and store the IReportDocument for rendering later...
	
// Now render...
System.out.println( "Read & render..." );
Map< ?, ? > nowt = new HashMap< Object, Object >();
FileArchiveReader far = null;
far = new FileArchiveReader( path + "myDocumentFile.rptdocument" );

// We got the IReportDocument now...
IReportDocument doc = engine.openReportDocument( null, far, nowt );

//... render it		
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName( path + "myDocumentFile.html" );
	
IRenderTask render = engine.createRenderTask( doc );
render.setRenderOption( options );
render.render();


You'll notice that this all uses files. I'm trying to work out how the IReportDocument might end up being streamed direct to a database and you can read all about that here:

http://www.eclipse.org/forums/index.php/t/263628/

If you are so inclined... Smile
Re: Get an IReportDocument from IRunAndRenderTask [message #769758 is a reply to message #769706] Thu, 22 December 2011 16:34 Go to previous messageGo to next message
Alessio Pollero is currently offline Alessio PolleroFriend
Messages: 74
Registered: August 2011
Member
So, i have to split the process in two distinct phase :

First step : IRunTask
Second step : IRenderTask

The only thing unclear is that you save the report document into a file and then you load it again from that file, is not possible retrieving an object of IReportDocument directly without saving and loading a from file ?

Re: Get an IReportDocument from IRunAndRenderTask [message #769767 is a reply to message #769758] Thu, 22 December 2011 16:43 Go to previous messageGo to next message
Peter Cliff is currently offline Peter CliffFriend
Messages: 14
Registered: December 2011
Location: South West England
Junior Member
I'm not sure why you'd want to do that? You'd either want to cache it somewhere for later or do the Run/Render using IRunAndRender?

Are you trying to alter the IReportDocument just after Run, and before Render - manipulating the data for example?

I guess you could implement your own IDocArchiveWriter that pipes to an IDocArchiveReader and do what you need in the middle. I've looked at those classes and that way lies madness so be warned! Smile
Re: Get an IReportDocument from IRunAndRenderTask [message #769774 is a reply to message #769767] Thu, 22 December 2011 16:51 Go to previous messageGo to next message
Alessio Pollero is currently offline Alessio PolleroFriend
Messages: 74
Registered: August 2011
Member
No, i want an object of an IReportDocument to store into a collection in memory, for example :

LinkedList<IReportDocument> listDocument = new LinkedList<>();
listDocument.add(aGeneratedDocument);


Is there a simple way to retrieve the IReportDocument instance ?

Re: Get an IReportDocument from IRunAndRenderTask [message #769792 is a reply to message #769774] Thu, 22 December 2011 17:10 Go to previous message
Peter Cliff is currently offline Peter CliffFriend
Messages: 14
Registered: December 2011
Location: South West England
Junior Member
I don't know the answer I'm afraid but I would guess the answer to be "no, there is no simple way"... (I'm still confused as to why you'd want to hold on to the IReportDoc like that... Smile)

Looking at the source of the implementation of IRunAndRender (org.eclipse.birt.report.engine.api.impl.RunAndRenderTask I think) it makes no mention of IReportDocument... Could be hidden elsewhere of course!

Good luck!
Previous Topic:get report title and force a specific Locale
Next Topic:Where do I find BIRT Charting Programmer Reference or BIRT Programmer Reference?
Goto Forum:
  


Current Time: Fri Mar 29 11:54:37 GMT 2024

Powered by FUDForum. Page generated in 0.02104 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top