| Summary: | Save rptdocument to an OutputStream: IRunTask interface | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Simone Pulcini <spulci> |
| Component: | BIRT | Assignee: | Birt-ReportEngine-inbox <Birt-ReportEngine-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | spulci, wyan |
| Version: | 2.6.2 | Keywords: | api |
| Target Milestone: | Future | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Simone Pulcini
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?
|