Ejemplo n.º 1
0
  /** @see org.pivot4j.analytics.datasource.DataSourceManager#getCubes(java.lang.String) */
  @Override
  public List<CubeInfo> getCubes(String catalogName) {
    if (catalogName == null) {
      throw new NullArgumentException("catalogName");
    }

    SimpleDataSourceInfo definition = getDefinition(catalogName);

    if (definition == null) {
      throw new IllegalArgumentException(
          "Data source with the given name does not exist : " + catalogName);
    }

    OlapDataSource dataSource = createDataSource(definition);

    List<CubeInfo> cubes = new LinkedList<CubeInfo>();

    OlapConnection connection = null;

    try {
      connection = dataSource.getConnection();

      for (Cube cube : connection.getOlapSchema().getCubes()) {
        if (cube.isVisible()) {
          cubes.add(new CubeInfo(cube.getName(), cube.getCaption(), cube.getDescription()));
        }
      }
    } catch (SQLException e) {
      throw new PivotException(e);
    } finally {
      if (connection != null) {
        try {
          connection.close();
        } catch (SQLException e) {
          throw new PivotException(e);
        }
      }
    }

    return cubes;
  }