Examples of OlapConnection


Examples of org.olap4j.OlapConnection

  }

  @NotNull
  public Cube getNativeCube(@NotNull SaikuCube cube) throws SaikuOlapException {
    try {
      OlapConnection con = connections.getOlapConnection(cube.getConnection());
      if (con != null) {
        for (Database db : con.getOlapDatabases()) {
          Catalog cat = db.getCatalogs().get(cube.getCatalog());
          if (cat != null) {
            for (Schema schema : cat.getSchemas()) {
              if (StringUtils.isBlank(cube.getSchema())
                  && StringUtils.isBlank(schema.getName()) || schema.getName().equals(cube.getSchema())) {
View Full Code Here

Examples of org.olap4j.OlapConnection

  }

  @Nullable
  public OlapConnection getNativeConnection(String name) throws SaikuOlapException {
    try {
      OlapConnection con = connections.getOlapConnection(name);
      if (con != null) {
        return con;
      }
    } catch (Exception e) {
      throw new SaikuOlapException("Cannot get native connection for ( " + name + " )", e);
View Full Code Here

Examples of org.olap4j.OlapConnection

  public List<SimpleCubeElement> getAllMembers(@NotNull SaikuCube cube, String hierarchy, String level,
                                               @NotNull String searchString,
                                               int searchLimit) throws SaikuOlapException {
    try {
      Cube nativeCube = getNativeCube(cube);
      OlapConnection con = nativeCube.getSchema().getCatalog().getDatabase().getOlapConnection();
      Hierarchy h = findHierarchy(hierarchy, nativeCube);

      boolean search = StringUtils.isNotBlank(searchString);
      int found = 0;
      List<SimpleCubeElement> simpleMembers;
View Full Code Here

Examples of org.olap4j.OlapConnection

      throw new SaikuOlapException("Cannot find member: " + uniqueMemberName + " in cube:" + cube.getName(), e);
    }
  }

  private boolean isMondrian(@NotNull Cube cube) {
    OlapConnection con = cube.getSchema().getCatalog().getDatabase().getOlapConnection();
    try {
      return con.isWrapperFor(RolapConnection.class);
    } catch (SQLException e) {
      LOG.error("SQLException", e.getNextException());
    }
    return false;
  }
View Full Code Here

Examples of org.olap4j.OlapConnection

    }

    if (PentahoSystem.getObjectFactory().objectDefined(MDXConnection.MDX_CONNECTION_MAPPER_KEY)) {
      IConnectionUserRoleMapper mondrianUserRoleMapper = PentahoSystem.get(IConnectionUserRoleMapper.class, MDXConnection.MDX_CONNECTION_MAPPER_KEY, null);
      if (mondrianUserRoleMapper != null) {
        OlapConnection c = (OlapConnection) con.getConnection();
        String[] validMondrianRolesForUser = mondrianUserRoleMapper.mapConnectionRoles(PentahoSessionHolder.getSession(), c.getCatalog());
        if (setRole(con, validMondrianRolesForUser, datasource)) {
          return con;
        }
      }
    }
View Full Code Here

Examples of org.olap4j.OlapConnection

  private boolean setRole(ISaikuConnection con, String[] validMondrianRolesForUser, SaikuDatasource datasource) {
    if (con.getConnection() instanceof OlapConnection)
    {
      try {
        OlapConnection c = (OlapConnection) con.getConnection();
        String roles = "";
        if (validMondrianRolesForUser != null && validMondrianRolesForUser.length > 0) {
          for (String r : validMondrianRolesForUser) {
            // lets make sure the role is actually available, just to be safe
            if (c.getAvailableRoleNames().contains(r)) {
              roles += r +",";
            }
          }

          System.out.println("Setting role to datasource:" + datasource.getName() + " role: " + roles);

          if (validMondrianRolesForUser != null && validMondrianRolesForUser.length == 0) {
            return true;
          }
          else if (validMondrianRolesForUser != null && validMondrianRolesForUser.length == 1) {
            c.setRoleName(validMondrianRolesForUser[0]);
          } else {
            SaikuMondrianHelper.setRoles(c, validMondrianRolesForUser);
          }
        } else {
          c.setRoleName(null);
        }


        return true;
      } catch (Exception e) {
View Full Code Here

Examples of org.olap4j.OlapConnection

    stubHostedServer();
    final Properties properties = new Properties();
    properties.put(
      RolapConnectionProperties.Locale.name(),
      getLocale().toString() );
    OlapConnection conn = mock( OlapConnection.class );
    when( server.getConnection( "Pentaho", "myHostedServer", null, properties ) ).thenReturn( conn );
    olapService.flushAll( session );
    verify( mockXmlaExtra ).flushSchemaCache( conn );
  }
View Full Code Here

Examples of org.olap4j.OlapConnection

    stubHostedServer();
    final Properties properties = new Properties();
    properties.put(
      RolapConnectionProperties.Locale.name(),
      getLocale().toString() );
    OlapConnection conn = mock( OlapConnection.class );
    when( server.getConnection( "Pentaho", "myHostedServer", null, properties ) ).thenReturn( conn );
    when( conn.isWrapperFor( any( Class.class ) ) ).thenReturn( true );
    final RolapConnection rolapConn = mock( RolapConnection.class );
    when( conn.unwrap( any( Class.class ) ) ).thenReturn( rolapConn );
    when( rolapConn.getCacheControl( any( PrintWriter.class ) ) ).thenThrow(
      new RuntimeException( "something happend" ) );
    try {
      olapService.flushAll( session );
    } catch ( IOlapServiceException e ) {
View Full Code Here

Examples of org.olap4j.OlapConnection

     *
     * @param queryString MDX query text
     */
    public <T> T runQuery(String queryString, Util.Functor1<T, CellSet> f) {
        long start = System.currentTimeMillis();
        OlapConnection connection = null;
        OlapStatement statement = null;
        CellSet cellSet = null;
        try {
            connection = getOlapConnection();
            statement = connection.createStatement();
            debug("CmdRunner.runQuery: AFTER createStatement");
            start = System.currentTimeMillis();
            cellSet = statement.executeOlapQuery(queryString);
            return f.apply(cellSet);
        } catch (SQLException e) {
View Full Code Here

Examples of org.olap4j.OlapConnection

                addRow(row, rows);
            }
        }

        private void populateMember(List<Row> rows) throws SQLException {
            OlapConnection connection =
                handler.getConnection(
                    request,
                    Collections.<String, String>emptyMap());
            for (Catalog catalog
                : catIter(connection, catNameCond(), catalogCond))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.