Friday, January 28, 2011

BIRT: Chart DaVinci

I don't know how I missed this post over at the BIRT Exchange. This is a really great drop in script that you can use in your charts that will instantly spruce them up. Takes a lot of manual picking at charts to get that professional look out of the design process. Definitively well worth a look if your doing any kind of chart work.

Thursday, January 27, 2011

BIRT: Dynamically Adding a Data Set to a Report

So a co-worker asked me today to help him by dynamically adding a data set to a report. He ended up going a slightly different route using the StructureElementFactory class, but this is what I came up with using the reports existing ElementFactory, and dynamically adding in the parameters and query text. This example can be expanded upon of course to set this up in whatever way you need, in coordination with using the DEAPI to dynamically add a table for a more dynamic report. It will even save off the report design at the end for future reference. I used the beforeFactory event, but this will work just as well in the Initialize event as well.

public class ReportEventHandler extends ReportEventAdapter {

public void beforeFactory(IReportDesign report, IReportContext reportContext) {
super.beforeFactory(report, reportContext);

try {
ReportDesignHandle reportDesign = reportContext.getDesignHandle();
OdaDataSetHandle dataSet = reportDesign.getElementFactory().newOdaDataSet("Data Set", "");

dataSet.setDataSource("Data Source");
dataSet.setQueryText("select employeenumber from employees where employeenumber = ?");

OdaDataSetParameter param = new OdaDataSetParameter();



OdaResultSetColumn result = new OdaResultSetColumn();

ColumnHint resultHint = new ColumnHint();
resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, "EMPLOYEENUMBER");
resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, "integer");


//this works

//and so does this

//just saving for debug purposes, you can ignore this
} catch (ContentException e) {
} catch (NameException e) {
} catch (SemanticException e) {
} catch (IOException e) {

Tuesday, January 25, 2011

BIRT: Connecting Data Elements to Existing Table Bindings

Not sure how I never knew this existed before, but I discovered a really cool little feature in BIRT. Lets say you have an existing table binding in a report. For me, I ran across this when I went into the XML source and copied a binding multiple times to duplicate it and make minor changes. Or, lets say you just added an Aggregation via the Property Editors binding tab instead of dragging and dropping. Now you want to add in a data element to display it. If you try to drop in a new Data Element, it will create a new binding, even if you are just referencing an existing table binding. Thats no good, you dont want duplicates, you just want to reference an existing binding. There is always the option of using a Dynamic Text element, but what if you want to change the underlying expression in the future, and you find the Property Editor tedious. Well, there is a quick way.

Add a Data element in the report designer. Do not change the name or add an expression, just his Escape. It will create a blank placeholder. Then, right-mouse click on this blank data element, and choose Change Data Column. The Select Data Binding dialog will pop up, and you can select which Data Binding to use. Once you hit OK, it will act just like an original Data Report Item. Again, not sure how I never came across that before...

Monday, January 24, 2011

BIRT: BIRT Helper Functions

The BIRT Functions provide a wealth of useful functionality that typically gets overlooked by developers. Simple operations such as compares, divides, string functions are handled by these functions with special handling for those really annoying gotchas that are typical.

Consider the following example. Lets say you have a real simple divide expression, such as:

numA / numB

That’s simple enough, right? But that’s assuming that numb is never 0, otherwise you have to worry about the dreaded divide by 0 error. Or better yet, what if one of the values is null because it is not present in the dataset? Normally you would need to change the expression to look like:

if ((numA != null) && (numB > 0))


numA / numB






But that gets tedious, especially if you have a lot of divide expressions. That’s where the BIRT Functions come into play. In the above scenario, the BirtMath.safeDivide() method can help alleviate the need to do that. So, in the above example, I would basically just use the following:

BirtMath.safeDivide(numA, numB, 0);

BIRT is full of helpful functions such as this, such as Round, RoundUp, RoundDown, different comparison functions, and Date Time functions to work with anything from Years, Quarters, down to seconds. Plus, this functionality is expandable via the BIRT Script Library extension point. I typically recommend that most report writers use these functions in favor of the native Javascript functions.

Sunday, January 09, 2011

EclipseCon 2011: Getting Started with BIRT

I have been approved and scheduled for another year at EclipseCon. This year I only have 1 talk, despite having some really good proposals about writing plugins for BIRT. But the Getting Started with BIRT talk is always a good one for new users to BIRT, I always enjoy presenting it and getting to know the folks in the crowd, and I always welcome interaction during and after the talk from attendees.

With only 1 talk scheduled for me this year, this provides me with a great chance to attend a lot of talks. Last year the talks I attended steered me towards EMF, which was helpful in helping some of my paying clients. I am really looking forward to a lot of the talks scheduled for this year. I will probably continue my EMF studying by attending this talk by Kenn Hussey, who was helping with a BIRT ODA, and Ed Merks. since GWT is familiar territory for me already, I look forward to the marriage of these two to drive some EMF points home for me. There are some good Window Builder talks on the program, which is exciting for me since I have been a user of Window Builder for years, and this is the first year that they are doing talks after being bought by Google. My friend Benny has a great talk planned about GIT. Benny has had a lot of experience with GIT, and his involvement as a contributor stemmed from his frustration with shortcomings in the Eclipse implementation, so it will be interesting to hear what he has to say on progress with the plugins. Lots of good talks =)

If your planing on attending, feel free to mozy on by my talk or the BIRT booth and say hi!!