String connectionName = parameterProvider.getStringParameter( "connection", null ); //$NON-NLS-1$
String query = parameterProvider.getStringParameter( "query", null ); //$NON-NLS-1$
String dataAction = parameterProvider.getStringParameter( "data-process", null ); //$NON-NLS-1$
IPentahoConnection connection = null;
try {
chartComponent.setParamName( innerParam );
chartComponent.setParameterProvider( IParameterProvider.SCOPE_REQUEST, parameterProvider );
if ( ( connectionName != null ) && ( query != null ) ) {
// connection = new SQLConnection(connectionName, logger)
// TODO support non-SQL data sources. Much easier now using the factory
connection =
PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, connectionName,
userSession, logger );
try {
query =
TemplateUtil.applyTemplate( query, TemplateUtil.parametersToProperties( parameterProvider ), null );
IPentahoResultSet results = connection.executeQuery( query );
chartComponent.setValues( results );
} finally {
boolean ignored = true;
}
chartComponent.setUrlTemplate( urlDrillTemplate );
if ( outerParams != null ) {
StringTokenizer tokenizer = new StringTokenizer( outerParams, ";" ); //$NON-NLS-1$
while ( tokenizer.hasMoreTokens() ) {
chartComponent.addOuterParamName( tokenizer.nextToken() );
}
}
} else if ( dataAction != null ) {
chartComponent.setDataAction( dataAction );
}
// ***************** END QUESTIONABLE CODE ********************************************************
content = chartComponent.getContent( "text/html" ); //$NON-NLS-1$
} finally {
if ( connection != null ) {
connection.close();
}
}
} catch ( Throwable e ) {
logger.error( Messages.getInstance().getErrorString( "Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET" ), e ); //$NON-NLS-1$