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)
ODA Driver and Data Set Parameters Default Values
Paul A
Hi,<br />
<br />
I having problems trying to add default values for my data set parameters only once.<br />
<br />
I am developing an ODA Driver. I have created the ODA Driver and ODA Designer through the wizards as described in the Integrating and Extending BIRT Second Edition book (Developing an ODA Extension pages 477 onwards). I am writing this in Eclipse Indigo SDK.<br />
<br />
The ODA Designer wizard creates a CustomDataSetWizardPage class. This class has a updateParameterDesign method in which there appears to be some manipulation for properties.<br />
<br />
I am wanting to use 2 parameters in my Query. I have modified the ParameterMetaData in my ODA Driver project. This now has 2 hard coded parameters named:<br />
* DateFromX<br />
* DateToX<br />
<br />
Both parameters are of java.sql.Types.TIMESTAMP type. <br />
<br />
When I run/debug the project, the new instance of Eclipse SDK starts. I create my new connection and new data set. I click on Finish button when adding the data set, the code execution halts on my breakpoint in CustomDataSetWizardPage#updateParameterDesign. This method is called from:<br />
<br />
CustomDataSetWizardPage#collectDataSetDesign<br />
CustomDataSetWizardPage#savePage<br />
CustomDataSetWizardPage#updateDesign<br />
<br />
In this method I have the following code:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
private void updateParameterDesign( IParameterMetaData paramMd, DataSetDesign dataSetDesign )
throws OdaException
{
DataSetParameters paramDesign =
DesignSessionUtil.toDataSetParametersDesign( paramMd,
DesignSessionUtil.toParameterModeDesign( IParameterMetaData.parameterModeIn ) );
// no exception in conversion; go ahead and assign to specified dataSetDesign
dataSetDesign.setParameters( paramDesign );
if( paramDesign == null )
return; // no parameter definitions; done with update
paramDesign.setDerivedMetaData( false );
// TODO replace below with data source specific implementation;
// hard-coded parameter's default value for demo purpose
if( paramDesign.getParameterDefinitions().size() > 0 )
{
for( ParameterDefinition paramDef : paramDesign.getParameterDefinitions() ) {
System.out.println("Parameter summary");
System.out.println("getDefaultScalarValue = " + paramDef.getDefaultScalarValue() );
System.out.println("getDefaultValueCount = " + paramDef.getDefaultValueCount() );
System.out.println("toString = " + paramDef.toString() );
if( paramDef.getDefaultScalarValue() == null ) {
Timestamp ts = new Timestamp( GregorianCalendar.getInstance().getTimeInMillis() );
paramDef.setDefaultScalarValue( ts.toGMTString() );
System.out.println("Set default scalar value");
}
}
}
</pre>
<br />
I click on continue in my debugging session. <br />
<br />
Now the Edit Data Set dialog is displayed with the Output Columns shown. I then click on the Parameters in the left hand panel. <br />
<br />
It shows my DateFromX and DateToX with the correct data type. The Default Value for each parameter is shown as 28 Jul 2011 10:06:59 GMT. This is understandable as I set this as shown in the code snippet above.<br />
<br />
At this point I click on OK and the dialog is closed.<br />
<br />
I then double click on my data set in the Outline view in Eclipse. The Edit Data Set dialog is again shown with the output columns being displayed.<br />
<br />
I then click on the Parameters in the left hand panel. The code execution again halts on my breakpoint in CustomDataSetWizardPage#updateParameterDesign. This time I step through the code. At this point the line of code paramDef.getDefaultScalarValue() returns null (for both parameters). <br />
<br />
I was hoping to check to see if the parameter was already set and if it was it would not bother setting the value - i.e. I want it to remember the initial value.<br />
<br />
I am probably doing something wrong in the code snippet above but I cannot spot anything obvious.<br />
<br />
Any help greatly appreciated.<br />
<br />
Cheers,<br />
<br />
Andez
Find more posts tagged with
Comments
Paul A
Think I have figured this out for myself and was quite easy.<br />
<br />
The wizard created the CreateDataSetWizardPage#updateParameterDesign which only ever set the parameters everytime it was called. I new check is to be added to see if the parameters have been set, and if they have not then create the new parameter set based on the IParameterMetaData which is in the snippet in the original post. If they have already been set then just get them.<br />
<br />
The updated updateParameterDesign method is as follows:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
private void updateParameterDesign( IParameterMetaData paramMd, DataSetDesign dataSetDesign )
throws OdaException
{
DataSetParameters paramDesign;
// check to see if the parameters already exist in the design
if( dataSetDesign.getParameters() == null ) {
// parameters do not exist so create a new instance
paramDesign = DesignSessionUtil.toDataSetParametersDesign( paramMd,
DesignSessionUtil.toParameterModeDesign( IParameterMetaData.parameterModeIn ) );
// no exception in conversion; go ahead and assign to specified dataSetDesign
dataSetDesign.setParameters( paramDesign );
if( paramDesign == null )
return; // no parameter definitions; done with update
paramDesign.setDerivedMetaData( false );
} else {
// parameters have already been set so just get them
paramDesign = dataSetDesign.getParameters();
}
if( paramDesign.getParameterDefinitions().size() > 0 )
{
for( ParameterDefinition paramDef : paramDesign.getParameterDefinitions() ) {
//paramDef.addDefaultValue( new Timestamp( GregorianCalendar.getInstance().getTimeInMillis() ) );
System.out.println("Parameter summary");
System.out.println("getDefaultScalarValue = " + paramDef.getDefaultScalarValue() );
System.out.println("getDefaultValueCount = " + paramDef.getDefaultValueCount() );
System.out.println("toString = " + paramDef.toString() );
if( paramDef.getDefaultScalarValue() == null ) {
Timestamp ts = new Timestamp( GregorianCalendar.getInstance().getTimeInMillis() );
paramDef.setDefaultScalarValue( ts.toGMTString() );
System.out.println("Set default scalar value");
}
}
}
}
</pre>
<br />
Hope this may help someone<br />
<br />
Andez