View Javadoc

1   package com.eyeq.pivot4j.pentaho.datasource;
2   
3   import java.sql.SQLException;
4   import java.util.Properties;
5   
6   import org.olap4j.OlapConnection;
7   import org.pentaho.commons.connection.IPentahoConnection;
8   import org.pentaho.platform.api.engine.IPentahoSession;
9   import org.pentaho.platform.engine.services.connection.PentahoConnectionFactory;
10  import org.pentaho.platform.plugin.services.connections.mondrian.MDXOlap4jConnection;
11  
12  import com.eyeq.pivot4j.datasource.AbstractOlapDataSource;
13  
14  public class MdxOlap4JDataSource extends AbstractOlapDataSource {
15  
16  	private IPentahoSession session;
17  
18  	private Properties properties;
19  
20  	/**
21  	 * @param session
22  	 * @param properties
23  	 */
24  	public MdxOlap4JDataSource(IPentahoSession session, Properties properties) {
25  		if (session == null) {
26  			throw new IllegalAccessError("Required argument 'session' is null.");
27  		}
28  
29  		if (properties == null) {
30  			throw new IllegalAccessError(
31  					"Required argument 'properties' is null.");
32  		}
33  
34  		this.session = session;
35  		this.properties = properties;
36  	}
37  
38  	/**
39  	 * @return the session
40  	 */
41  	public IPentahoSession getSession() {
42  		return session;
43  	}
44  
45  	/**
46  	 * @return the properties
47  	 */
48  	public Properties getProperties() {
49  		return properties;
50  	}
51  
52  	/**
53  	 * @see com.eyeq.pivot4j.datasource.AbstractOlapDataSource#createConnection(java
54  	 *      .lang.String, java.lang.String)
55  	 */
56  	@Override
57  	protected OlapConnection createConnection(String userName, String password)
58  			throws SQLException {
59  		MDXOlap4jConnection connection = (MDXOlap4jConnection) PentahoConnectionFactory
60  				.getConnection(IPentahoConnection.MDX_OLAP4J_DATASOURCE,
61  						properties, session, null);
62  		return connection.getConnection();
63  	}
64  }