Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Cannot getExtends for a ScalarParameterHandle
JimTalbut
Hi,<br />
<br />
I have an app that is trying to provide information on a report.<br />
The report makes use of a library, and parameters in the report extend parameters from the library (I don't have control of the report).<br />
In the report one parameter is defined as:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<scalar-parameter name="rp_Sort" id="14" extends="mylib.rp_Sort"/>
</pre>
and in the library:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<scalar-parameter name="rp_Sort" id="14">
<property name="hidden">true</property>
<property name="valueType">static</property>
<property name="isRequired">false</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</pre>
<br />
My problem is that I need to report the isRequired property correctly for the parameter.<br />
The code is (roughly):<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
IReportEngine reportEngine = gtiReportEngine.getReportEngine();
IGetParameterDefinitionTask paramTask = reportEngine.createGetParameterDefinitionTask( reportRunnable );
Collection parameters = paramTask.getParameterDefns( true );
for( Object object : parameters )
{
if( object instanceof IScalarParameterDefn )
{
IScalarParameterDefn scalarParam = ( IScalarParameterDefn ) object;
ParameterDefn paramInfo = new ParameterDefn();
paramInfo.setName( scalarParam.getName() );
while( scalarParam != null )
{
paramInfo.setNullable( ! scalarParam.isRequired() );
if( null != scalarParam.getHandle() ) {
ScalarParameterHandle reportElementHandle = (ScalarParameterHandle)scalarParam.getHandle();
scalarParam = null;
if( null != reportElementHandle ) {
DesignElementHandle extendsHandle = reportElementHandle.getExtends();
if( null != extendsHandle ) {
if( extendsHandle instanceof IScalarParameterDefn ) {
scalarParam = ( IScalarParameterDefn ) object;
}
}
}
} else {
scalarParam = null;
}
}
results.add( paramInfo );
}
}
</pre>
<br />
isRequired returns null, which is expected (because isRequired is not set on the parameter in the report) but getExtends also returns null - which means I have no way to access to the isRequired from the library.<br />
<br />
Any ideas?<br />
<br />
Thanks
Find more posts tagged with
Comments
Rainer
Jim,
you got everything you need, so you get the required flag by calling
reportElementHandle.isRequired();
Because isRequired is a boolean variable you should always get true or false.
That should be everything you have to do you don?t need an extendHandle.
Regards Rainer
JimTalbut
That's not what I'm seeing.<br />
Adding logging to the code above and looking at that sp_Sort param gives:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
ParameterInformer.java(69) ? scalarParam.getName() = rp_Sort, class = org.eclipse.birt.report.engine.api.impl.ScalarParameterDefn
ParameterInformer.java(91) ? list is null || empty
ParameterInformer.java(120) ? reportElementHandle = org.eclipse.birt.report.model.api.ScalarParameterHandle
ParameterInformer.java(121) ? scalarParam.isRequired() = true
ParameterInformer.java(122) ? reportElementHandle.isRequired() = true
ParameterInformer.java(126) ? extendsHandle = null
</pre>
isRequired comes out true, despite being false in the library.
JimTalbut
Oh no!
My bad, I was pulling out the wrong library.
Sorry for the bother and thanks for the help.