Community
Participate
Working Groups
Build Identifier: Eclipse 20110301-1815. Birt DE API 2.6.2 At the moment IRunTask does not offer an easy way to obtain an rptdocument on a Stream, at least not direct as IRenderTaks implementation using HTMLRenderOption class. I hope that in future version Birt developers can provide via API a similar mechanism to stream the rptdocument file. I understand that the structure of the rptdocument is somewhat complex (it's a binary format, it's compressed and the abstraction to interact with it's to manage an archive with contenents and dirs). But my need it's easy than interact with the file. I need the stream just to store it on a BLOB column on db to avoid a file storage (I need to control the cache using a db instead of a storage). Storing the output format in HTML, PDF and XLS is less convenient than storing the intermediate format itself. Reproducible: Always
A workaround is saving the report document into a local file then uploading it to the database. The document should be downloaded as a local file before rendering. Your application may implement a document caching layer to manager the document downloading.
(In reply to comment #1) > A workaround is saving the report document into a local file then uploading it > to the database. The document should be downloaded as a local file before > rendering. Your application may implement a document caching layer to manager > the document downloading. This is a good solution but I need to implement a mechanism to limit disk storage. I also need to "bind" file presence to db transaction: file can't be destroyed by cache mechanism if it has not been yet stored on the BLOB. Using a stream it's easy because of its liveness inside memory: destruction is done bye garbage collector. Also I can use the stream directly to push the output to the browser client.
You can implement a in memory IArchiveFile and use that in memory archive to create/rendering document. You can see the org.eclipse.birt.core.archive.compound.IArchiveFile. For example, class MemoryArchive implements IArchiveFile { MemoryArchive(int sizeLimit); //throws out exception if exceed the size limitation MemoryArchive(byte[] source); byte[] getBytes(); } //Running MemoryArchive archive = new MemoryArchive(sizeLimit); IRunTask task = engine.createRunTask(); task.run(new ArchiveWriter(archive)); task.close9); byte[] bytes = archive.getBytes(); //upload the bytes to the database.. //Rendering byte[] bytes; //download from the database MemoryArchive archive = new MemoryArchive(bytes); IReportDocument document = engine.openReportDocument(archive); RenderTask task = engine.createRenderTask(document); task.render() ...
(In reply to comment #3) > You can implement a in memory IArchiveFile and use that in memory archive to > create/rendering document. > You can see the org.eclipse.birt.core.archive.compound.IArchiveFile. For > example, > class MemoryArchive implements IArchiveFile { > MemoryArchive(int sizeLimit); //throws out exception if exceed the size > limitation > MemoryArchive(byte[] source); > byte[] getBytes(); > } > //Running > MemoryArchive archive = new MemoryArchive(sizeLimit); > IRunTask task = engine.createRunTask(); > task.run(new ArchiveWriter(archive)); > task.close9); > byte[] bytes = archive.getBytes(); > //upload the bytes to the database.. > //Rendering > byte[] bytes; //download from the database > MemoryArchive archive = new MemoryArchive(bytes); > IReportDocument document = engine.openReportDocument(archive); > RenderTask task = engine.createRenderTask(document); > task.render() > ... Sounds great! I'm coding :-) Should I risk something providing empty implementations for other method signatures in IArchiveFile interface? Btw thanks a lot for this workaround. It's my fault I do not understand the javadoc in details.
This is the signature of openReportDocument public IReportDocument openReportDocument(java.lang.String systemId, org.eclipse.birt.core.archive.IDocArchiveReader reader,java.util.Map options) throws EngineException Call to this method in your code snippet is a bit different. I've got the second parameter, the first maybe null.... but I've got no idea about the options Map). Can it be null in my case?