Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » BIRT DE with POJO and ODA (not a Scripted Source)(BIRT DE with POJO and ODA (not a Scripted Source))
BIRT DE with POJO and ODA (not a Scripted Source) [message #1059384] Fri, 17 May 2013 19:30 Go to next message
Donavan Anderson is currently offline Donavan AndersonFriend
Messages: 2
Registered: May 2013
Junior Member
I have scoured the web and applied some good trial-and-error coding for the last four days in search of an answer to the following, which I hope someone may be able to assist with (and I thank you in advance).

I have successfully created a BIRT Design Engine columnar report with a source database (all internal DE, no Eclipse IDE required). Now I would like to use a POJO as the data source with an ODA and not a scripted source. I have created a POJO based report using an ODA with the Eclipse IDE but I am pursuing performing this creation using just the BIRT Design Engine so that I can create dynamic reports.

I am starting with just a simple data object (customerlist.Customer) and a simple service object (customerlist.CustomerDataset) that returns some static sample data as a list.

I wanted to start with a known working POJO ODA so I am currently using Actuate's version "com.actuate.data.oda.pojo_22.0.0.v20130129.jar", which is what I used to create a POJO report using the Eclipse IDE.

I am stuck on the following:
• How to set the query text for a POJO (I know how to set this for a database source and an XML source, but I have not found an example for a POJO).
• How to map the table columns to the POJO.
• Other missing properties for the data source?

Here is the XML source for the "queryText" as generated by the IDE. I can see that the name, type, and method need to be mapped, but how??...

<xml-property name="queryText"><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PojoQuery appContextKey="APP_CONTEXT_KEY_DATA SET" dataSetClass="customerlist.CustomerDataset" version="1.0">
<ColumnMapping index="1" name="City" odaDataType="String">
<Method name="getCity"/>
</ColumnMapping>
<ColumnMapping index="2" name="Country" odaDataType="String">
<Method name="getCountry"/>
</ColumnMapping>
<ColumnMapping index="3" name="CustomerName" odaDataType="String">
<Method name="getCustomerName"/>
</ColumnMapping>
<ColumnMapping index="4" name="CustomerNumber" odaDataType="Integer">
<Method name="getCustomerNumber"/>
</ColumnMapping>
<ColumnMapping index="5" name="State" odaDataType="String">
<Method name="getState"/>
</ColumnMapping>
</PojoQuery>


Here are the methods for creating the data source and data set...

private void createDataSource() throws SemanticException {
OdaDataSourceHandle dataSourceHandle = elementFactory.newOdaDataSource("Data Source", "com.actuate.data.oda.pojo");

dataSourceHandle.setProperty("pojoDataSetClassPath", " customerlist.CustomerDataset" );

// TODO: Any missing properties??

reportDesignHandle.getDataSources().add(dataSourceHandle);
}

private void createDataSet() throws SemanticException {
OdaDataSetHandle dataSetHandle = elementFactory.newOdaDataSet("ds", "com.actuate.data.oda.pojo.dataSet");

dataSetHandle.setDataSource("Data Source");

dataSetHandle.setQueryText(); // TODO: What to put here??

reportDesignHandle.getDataSets().add(dataSetHandle);
}

And to create the table...

private TableHandle createTable() {
TableHandle table = elementFactory.newTableItem("reportTable", columnReport.getTotalColumns());
table.setDataSet(reportDesignHandle.findDataSet("ds"));

PropertyHandle computedSet = table.getColumnBindings();
ComputedColumn tableColumn = null;

for (int i = 0; i < tableColumnNames.size(); i++) {
tableColumn = StructureFactory.createComputedColumn();
tableColumn.setName((String) tableColumnNames.get(i));
tableColumn.setExpression("dataSetRow[\"" + (String) tableColumnNames.get(i) + "\"]");
computedSet.addItem(tableColumn);
}
...
DataItemHandle dataItem = elementFactory.newDataItem(tableColumnNames.get(i));
dataItem.setResultSetColumn((String) tableColumnNames.get(i));
cell.getContent().add(dataItem);
...
}

It just occurred to me to try using the getter method in "setResultSetColumn" instead of the column name, but I am still stuck without the appropriate setQueryText string.

Please let me know if you need any additional information.
Thank you for any assistance you can provide.


Donavan
Re: BIRT DE with POJO and ODA (not a Scripted Source) [message #1060072 is a reply to message #1059384] Wed, 22 May 2013 22:10 Go to previous messageGo to next message
Donavan Anderson is currently offline Donavan AndersonFriend
Messages: 2
Registered: May 2013
Junior Member
I solved it.
You need to create an XML document in the format outlined at the top of my post (for "queryText") and set the query to it. Also note that the name assigned in the XML must match the column name, including case.
Re: BIRT DE with POJO and ODA (not a Scripted Source) [message #1060087 is a reply to message #1060072] Thu, 23 May 2013 03:35 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Great! Glad you got it! Sorry your post apparently fell through the cracks. Thanks for posting the update!

Michael

Developer Evangelist, Silanis
Re: BIRT DE with POJO and ODA (not a Scripted Source) [message #1703413 is a reply to message #1060087] Fri, 31 July 2015 11:56 Go to previous message
Simone D\'Amario is currently offline Simone D\'AmarioFriend
Messages: 1
Registered: July 2015
Junior Member
How can you say you are creating a DYNAMIC report if you have to add at hand, each column name in the .xml file ?
Previous Topic:Report is running without asking for parameters
Next Topic:To fix bars width in the bar chart
Goto Forum:
  


Current Time: Fri Apr 26 17:06:41 GMT 2024

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

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

Back to the top