Skip to main content



      Home
Home » Archived » BIRT » How to use/access existing Java Objects as the Data Source for BIRT
How to use/access existing Java Objects as the Data Source for BIRT [message #79771] Fri, 07 October 2005 05:14 Go to next message
Eclipse UserFriend
Hi all,

I have an Eclipse plugin that has its own data within the client side model.
I want to use BIRT to be able to create reports directly from this client
side model. I would like to be able to expose this model as a data source
for BIRT.

Are there any examples of doing this?

Thanks in advance.

Regards,

Tim.
Re: How to use/access existing Java Objects as the Data Source for BIRT [message #79801 is a reply to message #79771] Fri, 07 October 2005 09:51 Go to previous messageGo to next message
Eclipse UserFriend
Tim,
If you are using the engine API to run your report, you can pass in a
prepopulated Java object like:
EngineConfig config = new EngineConfig();
config.addScriptableJavaObject("objectName", objectInstance);

Then in script you can access the object like
var test = objectName.myMethod();

So if your data has some sort of iterator, you could implement this in a
Scripted Datasource and pass your object in with the above code and then in
your fetch method iterate over your results.

Jason Weathersby
BIRT PMC

"Tim Shelley" <tim_j_shelley@hotmail.com> wrote in message
news:di5eah$26h$1@news.eclipse.org...
> Hi all,
>
> I have an Eclipse plugin that has its own data within the client side
> model. I want to use BIRT to be able to create reports directly from this
> client side model. I would like to be able to expose this model as a data
> source for BIRT.
>
> Are there any examples of doing this?
>
> Thanks in advance.
>
> Regards,
>
> Tim.
>
Re: How to use/access existing Java Objects as the Data Source for BIRT [message #79815 is a reply to message #79801] Fri, 07 October 2005 10:43 Go to previous message
Eclipse UserFriend
Personnally, I pass a HashMap to the Birt Engine, using
config.addScriptableJavaObject("map", map); in the Servlet calling the
reportEngine.
The Map contains one entry per Dataset i identified for my report, the
key being the dataset name.
Each Dataset entry is Vector of Maps ('fieldName, value') used to fill
the dataset row. I might change this a little, though, since each
field key is duplicated for each row... But it's not my priority yet.

In the report, I use
-------------
it = map.get("datasetName").iterator();
-------------

in the 'open' method of my dataset,
and I use
-------------
if (! it.hasNext()) {
return false;
}
line = it.next(); // gives me a Map (containing key - value pairs)
keys = line.keySet().iterator();;
while (keys.hasNext()) {
key = keys.next();
row[key] = line.get(key);
}
return true;
-------------
in the 'fetch' method to populate the dataset rows.

OK, this isn't perfect, but it is quite flexible...
I think I'll change the 'open' method to also read the field keys...


On Fri, 7 Oct 2005 09:51:25 -0400, "Jason Weathersby"
<jweathersby@actuate.com> wrote:

>Tim,
>If you are using the engine API to run your report, you can pass in a
>prepopulated Java object like:
> EngineConfig config = new EngineConfig();
> config.addScriptableJavaObject("objectName", objectInstance);
>
>Then in script you can access the object like
>var test = objectName.myMethod();
>
>So if your data has some sort of iterator, you could implement this in a
>Scripted Datasource and pass your object in with the above code and then in
>your fetch method iterate over your results.
>
>Jason Weathersby
>BIRT PMC
>
>"Tim Shelley" <tim_j_shelley@hotmail.com> wrote in message
>news:di5eah$26h$1@news.eclipse.org...
>> Hi all,
>>
>> I have an Eclipse plugin that has its own data within the client side
>> model. I want to use BIRT to be able to create reports directly from this
>> client side model. I would like to be able to expose this model as a data
>> source for BIRT.
>>
>> Are there any examples of doing this?
>>
>> Thanks in advance.
>>
>> Regards,
>>
>> Tim.
>>
>
Previous Topic:Getting the image-name
Next Topic:Is it possible to do data aggregation ?
Goto Forum:
  


Current Time: Thu Jul 17 21:51:02 EDT 2025

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

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

Back to the top