Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Scripted Data Source and custom ODA data source: advantages and disadvantages
Scripted Data Source and custom ODA data source: advantages and disadvantages [message #813380] Mon, 05 March 2012 07:37 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
I need to include BIRT reports in my RCP application. Since the data has to be retrieved by calling Java code, my options seem to be:

1) using Scripted Data Source written in Javascript

2) using Scripted Data Source written in Java

3) using an ODA extension

In option 1) there is no type checking, so I'd prefer to avoid it.

For option 2): are there good examples available (my googling only found Javascript examples)? Can I provide a Scripted Data Source in a separate OSGi bundle or does it have to be a part of .rptdesign/.rptlibrary?

Option 3) looks more complicated, but doable.

What other implications do these choices have?
Re: Scripted Data Source and custom ODA data source: advantages and disadvantages [message #813950 is a reply to message #813380] Mon, 05 March 2012 21:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Here is a very simple example of a Java Scripted Data Set:

package my.event.handlers;

import org.eclipse.birt.report.engine.api.script.IReportContext;
import org.eclipse.birt.report.engine.api.script.IUpdatableDataSetRow;
import org.eclipse.birt.report.engine.api.script.ScriptException;
import
org.eclipse.birt.report.engine.api.script.eventadapter.ScriptedDataSetEventAdapter;
import org.eclipse.birt.report.engine.api.script.instance.IDataSetInstance;

public class MyScriptedDataSetExample extends ScriptedDataSetEventAdapter {

@Override
public void beforeOpen(IDataSetInstance dataSet,
IReportContext reportContext) throws ScriptException {


}

@Override
public void open(IDataSetInstance dataSet) throws ScriptException {
}

private Integer cnt=0;
private Integer cntT=3;

@Override
public boolean fetch(IDataSetInstance dataSet, IUpdatableDataSetRow row) {

//dataSet.getInputParameterValue(arg0);
if( cnt < cntT){
try{
row.setColumnValue("col1", new Integer(cnt));
row.setColumnValue("col2", "hello");

cnt++;
return true;
}catch (Exception e){

}
}
return false;
}

}

Currently you implement these in a Java Project, jar it and put the jar
in the web-inf/lib. The only report specific thing is that in the data
set you have to specify the fully qualified class name to use. This is
done in the properties view under event handler for the data set.

On ODAs: These are generally preferable when you need to expose a gui
to another user or group of users.

Jason


On 3/5/2012 2:37 AM, Alexey Romanov wrote:
> I need to include BIRT reports in my RCP application. Since the data has
> to be retrieved by calling Java code, my options seem to be:
>
> 1) using Scripted Data Source written in Javascript
>
> 2) using Scripted Data Source written in Java
>
> 3) using an ODA extension
>
> In option 1) there is no type checking, so I'd prefer to avoid it.
> For option 2): are there good examples available (my googling only found
> Javascript examples)? Can I provide a Scripted Data Source in a separate
> OSGi bundle or does it have to be a part of .rptdesign/.rptlibrary?
>
> Option 3) looks more complicated, but doable.
>
> What other implications do these choices have?
Re: Scripted Data Source and custom ODA data source: advantages and disadvantages [message #814200 is a reply to message #813950] Tue, 06 March 2012 06:42 Go to previous messageGo to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
Thanks!
Re: Scripted Data Source and custom ODA data source: advantages and disadvantages [message #831093 is a reply to message #814200] Wed, 28 March 2012 13:10 Go to previous message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
After considering it a bit more, I see that Scripted Data Sources don't fit my usecase at all, precisely because I need to let other people develop reports for this application and I don't know in advance what parameters, etc. they will need. However, my boss just came up with another idea: simply write data access in Script Function extensions. Since they are written as OSGi bundles, I can access the application without problems. Posting this in case someone else finds it useful Smile
Previous Topic:Adding elements to HTML head in report item presentation
Next Topic:Script Functions not in Category
Goto Forum:
  


Current Time: Fri Mar 29 12:47:48 GMT 2024

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

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

Back to the top