BIRT DE with POJO and ODA (not a Scripted Source) [message #1059384] |
Fri, 17 May 2013 19:30 |
Donavan Anderson 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03832 seconds