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)
Checking datatype dynamically?
Happy
Hi there,<br />
I have a situation where datasets are being generated dynamically and populated into a table (also dynamically generated using javascript).<br />
<br />
The issue I am facing is that I wish to know what datatype a particular column is, and set a drill-through action depending on the result.<br />
<br />
In particular, if the datatype assigned to a column is a 'blob', I wish to set a hyperlink to another report to process the blob data. Or, if easier, if the datatype != 'blob', I wish to remove the existing hyperlink action.<br />
<br />
Cheers<br />
<br />
<br />
for reference, here is the script as it stands, located in the onPrepare for a table. <br />
<br />
importPackage( Packages.org.eclipse.birt.report.model.api );<br />
importPackage( Packages.org.eclipse.birt.report.engine.api.script);<br />
<br />
//get a reference to the ElementFactory<br />
myTable = reportContext.getReportRunnable().getDesignHandle().findElement("dynamicTable");<br />
elementFactory = reportContext.getReportRunnable().getDesignHandle().getElementFactory();<br />
//structureFactory = reportContext.getReportRunnable().designHandle.getStructureFactory();<br />
myDS = reportContext.getReportRunnable().designHandle.findDataSet("DynamicDataSet");<br />
<br />
//header = table.getHeader( ).get( 0 );<br />
HeaderRow = myTable.getHeader().get(0);<br />
DetailRow = myTable.getDetail().get(0);<br />
<br />
computedSet = myTable.getColumnBindings( );<br />
//reportContext.getReportRunnable().designHandle.<br />
<br />
//FirstRow.setProperty("style", "table-detail");<br />
DetailRow.getCells().get(0).setProperty("style", "table-detail");<br />
<br />
columnNameArray = params["ColumnNameList"].value.split(",");<br />
var i=0;<br />
for (i=1;i<params["COLUMNCOUNT"].value;i++)<br />
{<br />
myTable.insertColumn(i, 1);<br />
DetailRow.getCells().get(i).setProperty("style", "table-detail");<br />
<br />
}<br />
for (i=0;i<params["COLUMNCOUNT"].value;i++)<br />
{<br />
myHeaderCell = HeaderRow.getCells().get(i);<br />
Headerlabel = elementFactory.newLabel( null );<br />
Headerlabel.setText( """ + columnNameArray
+ """);//$NON-NLS-1$<br />
myHeaderCell.getContent( ).add( Headerlabel );<br />
<br />
//myTable.insertColumn(i, 1);<br />
myCell = DetailRow.getCells().get(i);<br />
cs1 = StructureFactory.createComputedColumn( );<br />
cs1.setName(""" + columnNameArray
+ """);<br />
cs1.setExpression( "dataSetRow["" + columnNameArray[i] + ""]");<br />
computedSet.addItem(cs1);<br />
data = elementFactory.newDataItem( null );<br />
data.setResultSetColumn(""" + columnNameArray
+ """);<br />
<br />
//elementFactory.<br />
//if (dataSetRow[columnNameArray
].getParams("dataType") == 'BLOB')<br />
// This does not work, should action everything<br />
<br />
drillAction = StructureFactory.createAction();<br />
datahandle = data.setAction(drillAction);<br />
datahandle.setLinkType("drill-through");<br />
datahandle.setReportName("BlobConverter.rptdesign");<br />
datahandle.setTargetFileType("report-design");<br />
datahandle.setTargetWindow("_blank"); //CHANGE ME<br />
<br />
myCell.getContent().add(data);<br />
}
Find more posts tagged with
Comments
mwilliams
Hi Happy,
In the onCreate method of the data element, you can do something like the following to figure out the class of the data:
this.getValue().getClass().getName();
When I did this on an integer data element and printed this value out to the report, I got, "java.lang.Integer". Let me know if this helps at all.
Happy
Thanks, I discovered this method after I changed my approach. Currently I have 1 dataset per DB table, one table per dataset, a report parameter to select the dataset and an initialisation script to delete all tables but the selected.
I'll probably combine both my templates into a mega template of doom soon enough.
(so far the feasability study into using BIRT as a database Retrieve/Filter web viewer is going well, just need to see how difficult it is to add in some kind of form to filter by a list of database tables with an input text box, feeding into the same report as a report parameter)
Fun times
Oh, and that Birt-Viewer application is pretty much the sole reason I have been looking at BIRT rather then Jasper Reports at the moment, it is very well made.
mwilliams
Happy,
Well, let us know whenever you have questions. We'll try to help.