Package org.olap4j

Examples of org.olap4j.OlapConnection


  }   

  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);
      }   
  }
View Full Code Here


        }
    }

    private MdxParser createParser() {
        try {
            OlapConnection olapConnection = getOlapConnection();
            return olapConnection.getParserFactory()
                .createMdxParser(olapConnection);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            + "WHERE [Marital Status].[S]");
    }

    private void checkUnparse(String queryString, final String expected) {
        try {
            OlapConnection olapConnection = getOlapConnection();
            MdxParser mdxParser =
                olapConnection.getParserFactory()
                    .createMdxParser(olapConnection);
            final SelectNode query = mdxParser.parseSelect(queryString);
            String unparsedQueryString = TestContext.toString(query);
            TestContext.assertEqualsVerbose(expected, unparsedQueryString);
        } catch (SQLException e) {
View Full Code Here

            "[Foo].&[_Key2].[Bar]");
    }

    // todo: enable this
    public void _testCloneQuery() throws SQLException {
        OlapConnection olapConnection = getOlapConnection();
        MdxParser mdxParser =
            olapConnection.getParserFactory()
                .createMdxParser(olapConnection);
        final SelectNode query = mdxParser.parseSelect(
            "select {[Measures].Members} on columns,\n"
            + " {[Store].Members} on rows\n"
            + "from [Sales]\n"
View Full Code Here

                + "Catalog=FoodMart2005Palo;"
                + "Cube=Budget");

        OlapWrapper wrapper = (OlapWrapper) connection;

        OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);

        OlapStatement statement = olapConnection.createStatement();

        CellSet cellSet =
            statement.executeOlapQuery(
                "SELECT {[store].[USA]} ON COLUMNS , {[Account].[1000]} ON ROWS\n"
                + "FROM [Budget]");
View Full Code Here

    public void assertTransformTo(
        String initialMdx,
        String expectedMdx,
        MdxQueryTransform trans) throws SQLException
    {
        OlapConnection olapConnection = getConnection();

        MdxParser mdxParser =
            olapConnection.getParserFactory().createMdxParser(olapConnection);

        SelectNode before = mdxParser.parseSelect(initialMdx);
        SelectNode after = trans.apply(before);

        // we also parse the expected MDX in order to normalize it
View Full Code Here

      return (OlapConnection) connection;
    }
    if (connection instanceof OlapWrapper)
    {
      final OlapWrapper wrapper = (OlapWrapper) connection;
      final OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);
      if (olapConnection == null)
      {
        throw new SQLException("Unable to unwrap the connection: " + driver); //$NON-NLS-1$
      }
      return olapConnection;
View Full Code Here

  private void addCatalogToCache( IPentahoSession session, String catalogName ) {

    final IOlapService.Catalog catalog =
      new Catalog( catalogName, new ArrayList<IOlapService.Schema>() );

    OlapConnection connection = null;

    try {

      connection =
        getConnection( catalogName, session );

      for ( org.olap4j.metadata.Schema schema4j : connection.getOlapSchemas() ) {

        connection.setSchema( schema4j.getName() );

        final IOlapService.Schema schema =
          new Schema(
            schema4j.getName(),
            catalog,
            new ArrayList<IOlapService.Cube>(),
            new ArrayList<String>( connection.getAvailableRoleNames() ) );

        for ( org.olap4j.metadata.Cube cube4j : schema4j.getCubes() ) {
          schema.cubes.add(
            new IOlapService.Cube( cube4j.getName(), cube4j.getCaption(), schema ) );
        }

        catalog.schemas.add( schema );
      }

      // We're done.
      getCache( session ).add( catalog );

    } catch ( OlapException e ) {

      LOG.warn(
        "Failed to initialize the olap connection cache for catalog "
        + catalogName,
        e );

    } finally {
      try {
        if ( connection != null ) {
          connection.close();
        }
      } catch ( SQLException e ) {
        LOG.warn(
          "Failed to gracefully close an olap connection to catalog "
          + catalogName,
View Full Code Here

  }

  private void flushHostedAndRemote( final IPentahoSession session )
    throws SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    for ( String name : getCatalogNames( session ) ) {
      OlapConnection connection = null;
      try {
        connection = getConnection( name, session );
        XmlaHandler.XmlaExtra xmlaExtra = getXmlaExtra( connection );
        if ( xmlaExtra != null ) {
          xmlaExtra.flushSchemaCache( connection );
        }
      } catch ( Exception e ) {
        LOG.warn(
          Messages.getInstance().getErrorString("MondrianCatalogHelper.ERROR_0019_FAILED_TO_FLUSH", name ), e );
      } finally {
        if ( connection != null ) {
          connection.close();
        }
      }
    }
  }
View Full Code Here

        if ( props.get( RolapConnectionProperties.Catalog.name(), "" ).equals( context ) ) {
          serverName = name;
        }
      }
      if ( serverName != null ) {
        OlapConnection conn = null;
        try {
          // Use a null session for root access.
          conn = olapService.getConnection( serverName, null );
          List<String> roleList = conn.getAvailableRoleNames();
          String[] roleArray = roleList.toArray( new String[roleList.size()] );
          Arrays.sort( roleArray );
          return roleArray;
        } catch ( OlapException e ) {
          log.error(
              "Failed to get a list of roles from olap connection " + context,
              e );
          throw new RuntimeException( e );
        } finally {
          if ( conn != null ) {
            try {
              conn.close();
            } catch ( SQLException e ) {
              // OK to squash this one.
              log.error(
                  "Failed to get a list of roles from olap connection " + context,
                  e );
View Full Code Here

TOP

Related Classes of org.olap4j.OlapConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.