Adding Data to BIRT Reports

The BIRT designer that is installed with Weave contains a Weave Data Source component that's available for adding data generated by Weave to a report.

Create a Data Source

Adding data to a BIRT report that is generated by Weave is done in the same manner as data from any other data source that BIRT supports, but you need to choose the "Cohga Weave Oda Data Source" driver when creating a new data source, which is done by right clicking on the Data Source item in the Outline panel in the BIRT designer and selecting New Data Source.


From the next screen you need to enter the URL of a Weave server that is currently running and will be serving the data that you wish to include in the report.

The URL entered here is only used during report design, since when the report is actually being generated it's being generated within the Weave server itself and therefore knows how to connect.

This allows us to use localhost, as in the example above which assumes the Weave server is running on the local machine, or the host name of another Weave server and still be able to copy the report to another server running Weave.

The username and password fields are not currently used

The Test Connection button will check if a connection can be established to the Weave server pointed to by the URL parameter

If the Test Connection button does not successfully connect to the server, and you know that the URL parameter is correct, it could be that the connection is being blocked by by the security.xml file, particularly if you have enabled NTLM or Kerberos security (i.e. Windows single sign-on).

If you do have NTLM or Kerberos security enabled then you can disable it just for the BIRT report designer by ensuring that the URL pattern /report/remote does not have any NTLM or Kerberos filters applied, by updating the filterChainProxy to include the following (before the last /** catch-all entry)

        /report/remote=httpSessionContextIntegrationFilter,authenticationProcessingFilter,securityContextHolderAwareRequestFilter,rememberMeProcessingFilter,anonymousProcessingFilter,jsonExceptionTranslationFilter,filterInvocationInterceptor

Also, ensure that the /report/remote URL pattern is listed in the objectDefinitionSource as being accessible anonymously (again, before the last /** catch-all entry)

        /report/remote=IS_AUTHENTICATED_ANONYMOUSLY


Once you click Finish you will have a new data source connection available for retrieving data from a Weave server

Creating a Data Set

The next step is to create a Data Set, which represents a Weave data definition that can be included in the report design.

Again to create a new Data Set you right click on the Data Sets item in the Outline panel.

When you hit next you will get a page listing the entities and data definitions available on the server, and here you choose what data you want to retrieve.

Here you can see the list of available entities in the left column and the list of all available data definition at the bottom of the middle column.

If you select one of the entities in the left column the list at the top of the middle column will populate with the list of data's that are associated with that entity.

The error at the top of the Data Set form indicates that we must choose a Data or Data Definition now that we've selected an entity

Now we need to select the Data or Data Definition that will be the actual source of the data we wish to display.

Once we've done this the Finish button is enabled again so we can complete the creation of the data definition.

The third column, Filters, is used when creating a one to many data set and will be covered later.
But it also gives an indication of the values that will be returned for the data set.

Once you click Finish you will progress to the standard BIRT data set editing wizard

this is where you can edit the properties for the data set and do things like filter the data, create new values based on data retrieved.

One useful thing you can do in the data set edit page is set the maximum number of rows the report will generate which is done in the Setting tab.
This will give you the opportunity to ensure that the user can't generate the report for 1,000,000,000 records or setup the report for a single entity.

The _id column represents the key column for the underlying data definition and is used to uniquely identify each entity.
This value will be used later when we look at filtering and embedding maps in data sets.

Once you click Ok here it'll complete the Data Set creation

Using a Data Set

The quickest way to then get the data from a data set into the report design is to simply drag and drop the data set into the report design.
This will create a new Table in the report design which represents the data set.

From here you can delete the columns you don't want to appear in the report

You probably don't want the _id column to appear, but you shouldn't delete it but just hide it.
Click on the column header for the _id column and change to the visibility tab in the properties, there you can click the Hide check box to hide it

Then if we save and generate this updated report we'll see the data for the currently selected entities

The map component in the report design was hidden in the design

Linking data sets

The filter setting in the data set property pages allows us to display additional details for each row of another data set, for example if we wanted to display registered animals at each property in our sample report we'd create a new data set, which would be linked to an animal registration data definition, but we'd filter it based on the property id and link that filter to the property id of the data set we've already created.

Here we've created a new data set from some sale data and this time setup a filter based on the _id column. It doesn't have to be the _id column but in this case the _id column is directly linked to the _id in the property details table we've already created, so we'll be joining them.

It's important that a filter column be selected when creating the data set.

You may receive a warning when you go to save the new data set, telling you that a value has not been set for the id parameter. This warning can be ignored because we'll be setting the value for the id parameter from its parents data set in the next few steps.

Now that we've created the new sub-data set we need to create some room in the existing table to add the new data.
Select the table and right click on the row handle for the detail row and select Insert|Row|Below to add a new row below the current detail row, this way the sale details for each property will be listed below the address.

Then we merge the cells together by clicking and dragging across the visible cells in the new row

and then right clicking in the selected cells and selecting Merge Cells from the menu

This way when we add the new data set to the existing table it'll fill up the width of the parent table. You don't have to do it this way, and you may find better methods of laying out your report pages, but this is to demonstrate linking data sets, not how to layout pages.

From here we can just drag and drop the new data set into the area we've just created in the existing table

Remember to hide the _id column if you don't want it to appear in the final report

The important step here is to link the new table to the parent one, this is done in the Bindings for the tables data set

By editing the bindings for this tables "_id" parameter and setting it to the value from the "_id" field in the parent table, which is done by setting the value to row["_id"], you'll link the sub-table to the parent table.

If it was a different column from the parent table that contained the value to use to filter the child table then you would use the name of that column, for example row["sale_id"].

Finally, if we generate the report we'll have sales information for each property

The report design was formatted slightly to improve readability