return mdxConnection;
}
protected IPentahoConnection getConnectionOrig() {
IPentahoConnection localConnection = null;
MdxConnectionAction connAction = (MdxConnectionAction) getActionDefinition();
try {
String mdxConnectionStr = connAction.getMdxConnectionString().getStringValue();
Properties mdxConnectionProps = (Properties) connAction.getConnectionProps().getValue();
String jdbcStr = connAction.getConnection().getStringValue();
String jndiStr = connAction.getJndi().getStringValue();
String location = connAction.getLocation().getStringValue();
String role = connAction.getRole().getStringValue();
String catalog = connAction.getCatalog().getStringValue();
if ( ( catalog == null ) && ( connAction.getCatalogResource() != null ) ) {
IActionSequenceResource resource = getResource( connAction.getCatalogResource().getName() );
catalog = resource.getAddress();
if ( ( resource.getSourceType() == IActionSequenceResource.URL_RESOURCE )
&& ( catalog.indexOf( "solution:" ) != 0 ) ) { //$NON-NLS-1$
// Extra step to make sure that remote mondrian models
// fully qualified aren't munged
// MB
if ( !catalog.startsWith( "http:" ) ) { //$NON-NLS-1$
catalog = "solution:" + catalog; //$NON-NLS-1$
}
} else if ( ( resource.getSourceType() == IActionSequenceResource.SOLUTION_FILE_RESOURCE )
|| ( resource.getSourceType() == IActionSequenceResource.FILE_RESOURCE ) ) {
if ( !catalog.startsWith( "solution:" ) ) {
catalog = "solution:" + catalog; //$NON-NLS-1$
}
}
}
if ( catalog == null ) {
warn( Messages.getInstance().getString( "MDXBaseComponent.ERROR_0007_CATALOG_NOT_DEFINED", getActionName() ) ); //$NON-NLS-1$
} else {
if ( mdxConnectionProps != null ) {
mdxConnectionProps.put( MdxConnectionAction.CATALOG_ELEMENT, catalog );
}
}
String userId = connAction.getUserId().getStringValue();
String password = connAction.getPassword().getStringValue();
if ( mdxConnectionProps != null ) {
localConnection =
PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, mdxConnectionProps,
getSession(), this );
} else {
if ( mdxConnectionStr != null ) {
localConnection =
PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, mdxConnectionStr,
getSession(), this );
} else {
String connectStr = null;
if ( jdbcStr != null ) {
connectStr = jdbcStr + "; Catalog=" + catalog; //$NON-NLS-1$
} else if ( jndiStr != null ) {
IDBDatasourceService datasourceService =
PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, null );
if ( datasourceService.getDataSource( jndiStr ) == null ) {
error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0005_INVALID_CONNECTION" ) ); //$NON-NLS-1$
return null;
}
connectStr = "dataSource=" + jndiStr + "; Catalog=" + catalog; //$NON-NLS-1$ //$NON-NLS-2$
// Add extra definitions from platform mondrian metadata
MondrianCatalog mc =
org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper.getInstance().getCatalog(
catalog, getSession() );
try {
connectStr += ";" + mc.getDataSourceInfo();
} catch ( Exception e ) {
// Just swallow the exception
}
}
if ( role != null ) {
connectStr += "; Role=" + role; //$NON-NLS-1$
}
Properties props = new Properties();
props.setProperty( IPentahoConnection.CONNECTION, connectStr );
props.setProperty( IPentahoConnection.PROVIDER, location );
if ( userId != null ) {
props.setProperty( IPentahoConnection.USERNAME_KEY, userId );
}
if ( password != null ) {
props.setProperty( IPentahoConnection.PASSWORD_KEY, password );
}
localConnection =
PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, props, getSession(), this );
}
if ( localConnection == null ) {
error( Messages.getInstance().getErrorString( "MDXBaseComponent.ERROR_0005_INVALID_CONNECTION" ) ); //$NON-NLS-1$
return null;
}
}
if ( localConnection instanceof MDXConnection ) {
MDXConnection mdxConn = (MDXConnection) localConnection;
if ( connAction != null ) {
if ( ( connAction.getExtendedColumnNames() != ActionInputConstant.NULL_INPUT ) ) {
mdxConn.setUseExtendedColumnNames( connAction.getExtendedColumnNames().getBooleanValue() );
}
}
}
return localConnection;
} catch ( Exception e ) {