Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Custom ODA driver: how to provide column info programmatically?
lexthang
I have a custom ODA driver. I could create data source/data set with this driver in the BIRT report designer with no problem.
Problem occurs when I do that programmatically using the Designer API. When I create a table using a dataset I programmatically created, there's an exception about "Cannot get the result set metadata".
I compare the .rptdesign file my code creates and the one produces by the designer, and it seems in my file, the column information are missing (see attached image). So I go about adding those column information.
My first stop is cachedMetaData. I created a CachedMetaData object and then add it to the dataset like so:
ArrayList<ResultSetColumn> colArray = ...; // Populate the array
CachedMetaData metaData = StructureFactory.createCachedMetaData();
metaData.setProperty("resultSet", colArray);
datasetHandle.setCachedMetaData(metaData);
I did check that all the data in the array are correct, they do get saved to .rptdesign file, but in the designer the columns are still empty.
Next I tried to create a list of OdaResultSetColumn and set it on the dataset, like so: (I do this because I see it in the "good" .rptdesign file. Basically I'm just trying to duplicate what works)
ArrayList<OdaResultSetColumn> odaColArray = ...; //Populate the array
datasetHandle.setProperty("resultSet", odaColArray);
This throws an exception below. This is really odd, because in the "good" .rptdesign, I do check and see that the datasetHandle has a property "resultSet" that points to an ArrayList of OdaResultSetColumn.
My question: did someone do this before? I mean programmatically create a .rptdesign file using a custom ODA driver? Was there an exception about metadata? Did you have to populate column information? How did you do that?
This is the exception when adding "resultSet" property to the datasetHandle:
org.eclipse.birt.report.model.api.metadata.PropertyValueException: The value "[org.eclipse.birt.report.model.api.elements.structures.OdaResultSetColumn@477f92da, org.eclipse.birt.report.model.api.elements.structures.OdaResultSetColumn@8824ae2, org.eclipse.birt.report.model.api.elements.structures.OdaResultSetColumn@22023fcb, org.eclipse.birt.report.model.api.elements.structures.OdaResultSetColumn@41aa39de]" is invalid with the type "structure".
at org.eclipse.birt.report.model.metadata.StructPropertyType.validateValue(StructPropertyType.java:103)
at org.eclipse.birt.report.model.metadata.PropertyDefn.doValidateValueWithExpression(PropertyDefn.java:904)
at org.eclipse.birt.report.model.metadata.PropertyDefn.validateValue(PropertyDefn.java:872)
at org.eclipse.birt.report.model.command.PropertyCommand.validateValue(PropertyCommand.java:833)
at org.eclipse.birt.report.model.command.PropertyCommand.setProperty(PropertyCommand.java:251)
at org.eclipse.birt.report.model.command.PropertyCommand.setProperty(PropertyCommand.java:131)
at org.eclipse.birt.report.model.api.DesignElementHandle.setProperty(DesignElementHandle.java:520)
Find more posts tagged with
Comments
lexthang
I found the cause for this. I've been doing it the wrong way. You cannot just call DataSetHandle.setProperty("resultSet", ...). You need to do it this way:
ArrayList<OdaResultSetColumn> arrayOfColumns = ...;
PropertyHandle resultSet = datasetHandle.getPropertyHandle(ScriptDataSetHandle.RESULT_SET_PROP);
//then:
for (OdaResultSetColumn col : arrayOfColumns) {
resultSet.addItem(col)
}
The same thing with columnHints, but this type to get the property handle you call:
PropertyHandle resultSet = datasetHandle.getPropertyHandle(ScriptDataSetHandle.COLUMN_HINTS_PROP);