javamysqlpivotolap-cubeolap4j

Olap4j/mysql, how I can generate or create Cube?


I do not know how I can generate or create Cube with Olap4j/Olap connection, when I have Cube I can load it and work with it, but I have database and I want from code generate Cube and save it as xml. So how many ways we have for it?

 Connection connection = DriverManager.getConnection(
            String.format(
                    "jdbc:mondrian:Jdbc=%s; Catalog=file:%s",
                    "jdbc:mysql://localhost:3306/network?user=root&password=root",
                    "C:\\Users\\John\\Documents\\pivot4j-web\\src\\java\\org\\pivot4j\\analytics\\test\\FoodMartX.xml"
            )
    );

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

    Schema s = olapConnection.getOlapSchema();


    System.out.println("Schema: " + s.getName());


    for (Cube cube : s.getCubes()) {

        System.out.println("Cube: " + cube.getName());

        for (Dimension dimension : cube.getDimensions()) {
            System.out.println("Dimension: " + dimension.getName());
        }

        for (Measure measure : cube.getMeasures()) {
            System.out.println("Measure: " + measure.getName());
        }
    }

Solution

  • Pivot4J or Olap4J is used to browse an existing OLAP schema, so you'll need to rely on using another tool to create cubes which is usually provided by the vendor of the respective OLAP backend you're using.

    As to Mondrian, there's a GUI application called Schema Workbench which allows you to manipulate Mondrian schema files.

    Hope this helps!

    Xavier