Home » Archived » BIRT » IRunTask run output to a database
IRunTask run output to a database [message #761538] |
Tue, 06 December 2011 11:07  |
Eclipse User |
|
|
|
Folks,
I'm trying to work out the best way to store the output of an IRunTask (the reportdocument) to a database and I'm a little confused...
IRunTask supports a String parameter which saves to a file named in that String, or it Supports an IDocArchiveWriter - the documentation for which is not clear - it states, for example, that this "Writer" is for "reading"...
Is there somewhere I can go to find information on IDocArchiveWriter (I've tried the Integrating and Extending book, this forum and the BIRT documentation to no avail) or does anyone have any other pointers that would, for example, enable me to send the output of the RunTask to a stream? (I'm considering changing the BIRT code at the moment!)
I could use a temporary file, but it seems clunky to save the file, only to read it again...
Any ideas would be gratefully received!
Pete
|
|
|
Re: IRunTask run output to a database [message #761587 is a reply to message #761538] |
Tue, 06 December 2011 12:35   |
Eclipse User |
|
|
|
Pete,
I do not have an example of this, but there are two interfaces for
writting/reading a rptdocument. IDocArchiveWriter, and
IDocArchiveReader. If you write a specialized writer most of the time
you will need to specify a specialized reader. In your case I assume
you will use the input stream to open the report document once it is
generated? BIRT supplies FileArchiveWriter(/Reader) and a
FolderArchiveWriter(Reader) classes that you could use as examples to
add your code to write to the db. I think this would be very interesting
to do. If you need some help with it let me know.
Jason
On 12/6/2011 11:07 AM, Peter Cliff wrote:
> Folks,
>
> I'm trying to work out the best way to store the output of an IRunTask
> (the reportdocument) to a database and I'm a little confused...
>
> IRunTask supports a String parameter which saves to a file named in that
> String, or it Supports an IDocArchiveWriter - the documentation for
> which is not clear - it states, for example, that this "Writer" is for
> "reading"...
>
> Is there somewhere I can go to find information on IDocArchiveWriter
> (I've tried the Integrating and Extending book, this forum and the BIRT
> documentation to no avail) or does anyone have any other pointers that
> would, for example, enable me to send the output of the RunTask to a
> stream? (I'm considering changing the BIRT code at the moment!)
>
> I could use a temporary file, but it seems clunky to save the file, only
> to read it again...
>
> Any ideas would be gratefully received!
>
> Pete
>
>
|
|
| | | | |
Re: IRunTask run output to a database [message #765785 is a reply to message #765521] |
Wed, 14 December 2011 12:19   |
Eclipse User |
|
|
|
I think I've hit a wall. I'm going to describe that wall here in the hope it either clarifies things for me or strikes a chord with someone and they say "actually, you can do it like this!"...
BIRT (using IDocArchiveWriter) seems to want (if my interpretation of the relevant interfaces/abstract classes is correct) to be able to open and non-sequencially write to multiple output streams at once. (In practice I'm not sure it does use the random access of the API, but it is there all the same). When writing blobs to Oracle you have to get the stream, write the data and then commit. I do not think it is possible to (safely) open another stream with the same connection when one is open.
I have implemented an IDocArchiveWriter, along with an associated RAOutputStream, where the Oracle connection belongs to the OutputStream and maintains the stream, etc. and the commit is called when IDocArchiveWriter is closed using a similar mechanism to that found in FileArchiveWriter. This works, but it requires a number of open connections to the database which is fairly expensive. Further, BIRT appears to always be calling write(int b), and I'm keeping it simple in this experiment I've not yet implemented buffering. As you'd expect this gets pretty slow writing a byte at a time to the database... (Though the data there now looks correct at least!)
So that leads to buffering and here I looked at the RAStreamBuffer classes which use buffer to memory and then to a RandomAccessFile and here I get confused trying work out how I might implement RandomAccessFile-like functionality to Oracle BLOBs.
Which brings us full circle. Perhaps the most straightforward way of doing this is to simply use either FileArchiveWriter or FolderArchiveWriter, "buffer" the file to disk, and when complete write the BIRT streams (as BLOBs) to Oracle sequencially. This feels wrong - I'd prefer to be able to stream direct to the database - but I'm not sure BIRT's expectations are compatible with Oracle's and being the man in the middle is proving tricky!
I could, possibly, create a IDocArchiveReader to make direct reads from the database possible rather than reverse the process on reading (extract BLOBs to disk and use FolderArchiveReader).
There you have it! Thoughts, consolation and ideas most welcome! 
[Updated on: Wed, 14 December 2011 12:26] by Moderator
|
|
|
Re: IRunTask run output to a database [message #765816 is a reply to message #765785] |
Wed, 14 December 2011 13:05   |
Eclipse User |
|
|
|
Peter,
I know creating the file and then writing to Oracle feels wrong, but it
may end up being faster. If you write the file to a tmp, then commit it
to Oracle and then delete it. Any chance you can open a bugzilla entry
for this, because this has been asked for many times. I want to have a
look at it using MySQL and see if I get the same results. Any chance
you can share what you have so far?
Jason
On 12/14/2011 12:20 PM, Peter Cliff wrote:
> I think I've hit a wall. I'm going to describe that wall here in the
> hope it either clarifies things for me or strikes a chord with someone
> and they say "actually, you can do it like this!"... :)
>
> BIRT (using IDocArchiveWriter) seems to want to be able to open and
> non-sequencially write to multiple output streams at once. (In practice
> I'm not sure it does use the random access of the API, but it is there
> all the same). When writing blobs to Oracle you have to get the stream,
> write the data and then commit. I do not think it is possible to open
> another stream with the same connection when one is open.
>
> I have implemented an IDocArchiveWriter, along with an associated
> RAOutputStream, where the Oracle connection belongs to the OutputStream
> and maintains the stream, etc. and the commit is called when
> IDocArchiveWriter is closed using a similar mechanism to that found in
> FileArchiveWriter. This works, but it requires a number of open
> connections to the database which is fairly expensive. Further, BIRT
> appears to always be calling write(int b), and I'm keeping it simple in
> this experiment I've not yet implemented buffering. As you'd expect this
> gets pretty slow as writing a byte at a time to the database... :)
>
> So that leads to buffering and here I looked at the RAStreamBuffer
> classes which use buffer to memory and then to a RandomAccessFile and
> here I get confused trying work out how I might implement
> RandomAccessFile-like functionality to Oracle BLOBs.
> Which brings us full circle. Perhaps the most straightforward way of
> doing this is to simply use either FileArchiveWriter or
> FolderArchiveWriter, "buffer" the file to disk, and when complete write
> the BIRT streams (as BLOBs) to Oracle sequencially. This feels wrong -
> I'd prefer to be able to stream direct to the database - but I'm not
> sure BIRT's expectations are compatible with Oracle's and being the man
> in the middle is proving tricky! :)
> I could, possibly, create a IDocArchiveReader to make direct reads from
> the database possible rather than reverse the process on reading
> (extract BLOBs to disk and use FolderArchiveReader).
>
> There you have it! Thoughts, consolation and ideas most welcome! :)
>
|
|
| | | | | | | | | | | | |
Re: IRunTask run output to a database [message #909195 is a reply to message #761538] |
Thu, 06 September 2012 14:05  |
Eclipse User |
|
|
|
Hi Peter, Sam,
We have a requirement to save the generated reports into the DB and it was a simple task for PDF, PPT and XLS formats. For HTML it has the complexities of the images not present in the same file as the content. Hence only for HTML, we plan to save the .rptdocument created using IRunTask and then at the time of "download" plan to run this through IRenderTask just like how you mentioned in your earlier post.
Following your experiences, I have written the output to a temporary physical file and then saving that into the DB. And in the return too, fetch the blob data from DB and write into a temporary physical file which gets passed onto IRenderTask. When I try to save the .rptdocument into the DB, the way I'm doing it, doesn't seem to be saving it right into the DB. Is it possible for you to share the code snippet on how you read the file and save into DB and fetch and write into a temporary file?
(http://www.eclipse.org/forums/index.php/t/371194/)
Thanks & Regards,
Madhav
|
|
|
Goto Forum:
Current Time: Sun May 11 21:48:14 EDT 2025
Powered by FUDForum. Page generated in 0.07038 seconds
|