Thursday, September 05, 2013

First Tutorial Video Release: BIRT Report Examples View

We started releasing a series of tutorial videos on YouTube. The first one, starring yours truly, is up right now. It covers a little known and under utilized area of the BIRT Designer containing a whole set of example reports. Check it out.

Thursday, August 08, 2013

BIRT: Using JSON

This topic has come up quite a bit. Using JSON in BIRT Reports. This comes up for just about everything, from using as a Data Source to serializing large amounts of parameters for use in a report design. Seriously, lots of stuff.

Since the Rhino engine has not been updated to a version passed 1.7R4, there is no access to the nice Rhino JSON methods. So, we have have a few options. Since Rhino can use anything in the Java JVM, we can use any 3rd party JSON parser out there. My preference is Google GSON library. The caveat is that you must build the object structure beforehand in Java, and then use the GSON to parse a string into the object representation.

 There are other options as well, such as these: 
http://www.birt-exchange.org/devshare/_/designing-birt-reports/1053-scripted-data-source-using-json

 I ran across the old school method of using an eval() statement to do the same thing. While not as safe, this is a much simpler, quicker method, and will suffice in most cases. And example can be found here: http://www.birt-exchange.org/devshare/_/designing-birt-reports/birt-json-scripted-data-set-and-parameter-parsing-r1484

 Update: Kristopher Clark, whom is a very talented member of the BIRT community, posted something similar. In his example, he is using Apache Commons to stream in a JSON file and use as a scripted data source. This showcases BIRT's ability to leverage anything within the Java Classpath in a report execution.

BIRT: BIRT DaVinci Plugin

Recently, I had the opportunity to catch up with the author of BIRT Chart DaVinci, Keith Howard, at a BIRT get together in the Bay Area. I had previously blogged about Chart DaVinci, so it's no secret that I like it. But there was always one little issue for me, and that was the manual application of the scripts. So, after chatting with Keith, we came up with a solution. Why not build a plugin for BIRT that displays all the styles in Chart DaVinci in a gallery that the user can select and apply to a report, and the plug-in does all the work. And that is exactly what I built. So, without further ado, the BIRT Chart DaVinci Plugin is available over at the BIRT Exchange. Follow the instructions and start applying some slick, pre-done styles to your BIRT charts.

Wednesday, July 17, 2013

BIRT: Report to get available Emitter ID's

Below is an example report that demonstrates how to get a list of available Emitters and their ID's and Formats from the Report Engine within a BIRT Report. Good thing the entire Report Engine API and Design Engine API are available within a report.


<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
    <property name="createdBy">Eclipse BIRT Designer Version 4.2.1.v201209101448 Build &lt;4.2.1.v20120912-1721></property>
    <property name="units">in</property>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="bidiLayoutOrientation">ltr</property>
    <property name="imageDPI">96</property>
    <styles>
        <style name="report" id="4">
            <property name="fontFamily">sans-serif</property>
            <property name="fontSize">10pt</property>
        </style>
        <style name="crosstab-cell" id="5">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
        <style name="crosstab" id="6">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
    </styles>
    <page-setup>
        <simple-master-page name="Simple MasterPage" id="2">
            <page-footer>
                <text id="3">
                    <property name="contentType">html</property>
                    <text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
                </text>
            </page-footer>
        </simple-master-page>
    </page-setup>
    <body>
        <text-data id="7">
            <expression name="valueExpr">var x = 0;&#13;
var emitterInfo = reportContext.getReportRunnable().getReportEngine().getEmitterInfo();&#13;
&#13;
var sb = new Packages.java.lang.StringBuilder();&#13;
&#13;
for (x = 0; x &lt; emitterInfo.length; x++)&#13;
        {&#13;
            var info = emitterInfo[x];&#13;
            &#13;
            var id = info.getID();&#13;
            var format = info.getFormat();&#13;
            &#13;
            sb.append(id + " - " + format + "&lt;br>\n");&#13;
        }&#13;
        &#13;
sb.toString();</expression>
            <property name="contentType">html</property>
        </text-data>
    </body>
</report>