当前位置: 首页>>代码示例>>Java>>正文


Java OlapWrapper类代码示例

本文整理汇总了Java中org.olap4j.OlapWrapper的典型用法代码示例。如果您正苦于以下问题:Java OlapWrapper类的具体用法?Java OlapWrapper怎么用?Java OlapWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OlapWrapper类属于org.olap4j包,在下文中一共展示了OlapWrapper类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCannedProcedure

import org.olap4j.OlapWrapper; //导入依赖的package包/类
@Test public void testCannedProcedure() throws Exception {
	String ddl = "create foreign procedure proc(arg integer, arg1 date) returns table (x string) options (\"teiid_rel:native-query\" '$2 $1 something')";
	String query = "exec proc(2, {d'1970-01-01'})";
	
	TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "phy");
	
	CommandBuilder commandBuilder = new CommandBuilder(tm);
       Command obj = commandBuilder.getCommand(query);
        
	OlapExecutionFactory oef = new OlapExecutionFactory();
	Connection mock = Mockito.mock(java.sql.Connection.class);
	OlapWrapper mock2 = Mockito.mock(OlapWrapper.class);
	OlapConnection mock3 = Mockito.mock(OlapConnection.class);
	OlapStatement mock4 = Mockito.mock(OlapStatement.class);
	Mockito.stub(mock4.executeOlapQuery(Mockito.anyString())).toThrow(new TeiidRuntimeException());
	Mockito.stub(mock3.createStatement()).toReturn(mock4);
	Mockito.stub(mock2.unwrap(OlapConnection.class)).toReturn(mock3);
	Mockito.stub(mock.unwrap(OlapWrapper.class)).toReturn(mock2);
	ProcedureExecution pe = oef.createProcedureExecution((Call)obj, Mockito.mock(ExecutionContext.class), new RuntimeMetadataImpl(tm), mock);
	try {
		pe.execute();
		fail();
	} catch (TeiidRuntimeException e) {
		Mockito.verify(mock4).executeOlapQuery("'1970-01-01' 2 something");
	}
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:TestOlapTranslator.java

示例2: unwrap

import org.olap4j.OlapWrapper; //导入依赖的package包/类
private OlapConnection unwrap(Connection conn) throws TranslatorException {
   	try {
   		OlapWrapper wrapper = conn.unwrap(OlapWrapper.class);
   		OlapConnection olapConn = wrapper.unwrap(OlapConnection.class);
   		return olapConn;
   	} catch(SQLException e) {
   		throw new TranslatorException(e);
   	}		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:10,代码来源:OlapExecutionFactory.java

示例3: getOlapConnection

import org.olap4j.OlapWrapper; //导入依赖的package包/类
/**
 * Gets an olap4j connection, creating a new one if fresh is true.
 *
 * @return mondrian Connection.
 */
public synchronized OlapConnection getOlapConnection() throws SQLException {
    if (this.connectString == null) {
        makeConnectString();
    }
    final String olapConnectString = "jdbc:mondrian:" + connectString;
    final java.sql.Connection jdbcConnection =
        java.sql.DriverManager.getConnection(olapConnectString);
    // Cast to OlapWrapper lets code work on JDK1.5, before java.sql.Wrapper
    //noinspection RedundantCast
    return ((OlapWrapper) jdbcConnection).unwrap(OlapConnection.class);
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:17,代码来源:CmdRunner.java

示例4: getConnection

import org.olap4j.OlapWrapper; //导入依赖的package包/类
OlapConnection getConnection(
    CatalogInfo catalogInfo,
    MondrianServer server,
    String roleName,
    Properties props)
    throws SQLException
{
  String connectString = catalogInfo.olap4jConnectString;

  // Save the server for the duration of the call to 'getConnection'.
  final LockBox.Entry entry =
      MondrianServerRegistry.INSTANCE.lockBox.register(server);

  final Properties properties = new Properties();
  properties.setProperty(
      RolapConnectionProperties.Instance.name(),
      entry.getMoniker());
  if (roleName != null) {
      properties.setProperty(
          RolapConnectionProperties.Role.name(),
          roleName);
  }
  properties.putAll(props);
  // Make sure we load the Mondrian driver into
  // the ClassLoader.
  try {
    ClassResolver.INSTANCE.forName(
        MondrianOlap4jDriver.class.getName(), true);
  } catch (ClassNotFoundException e) {
      throw new OlapException("Cannot find mondrian olap4j driver.");
  }

  final java.sql.Connection connection =
      java.sql.DriverManager.getConnection(connectString, properties);
  return ((OlapWrapper) connection).unwrap(OlapConnection.class);
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:37,代码来源:FileRepository.java


注:本文中的org.olap4j.OlapWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。