0

I am beginner with the BI concepts and mondrian .I am using olap4j API with mondrian server and my requirement is to get the mysql column names mapped in the schema file or metadata about the database . Basically i am able to connect and can execute a sample query with the foodmart sample data. Please provide me the sample code to get the columns names (i am using mysql) or db metadata

Sample code i am trying is

        Class.forName("mondrian.olap4j.MondrianOlap4jDriver");
        Connection connection = DriverManager
                .getConnection("jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/foodmart;Provider=Mondrian;"
                        + "Catalog=D:/Softwares/mondrian-3.2.0.13661/demo/FoodMart.xml;PoolNeeded=false;JdbcUser=root;JdbcPassword=admin123;JdbcDrivers=com.mysql.jdbc.Driver;");

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

        NamedList<Cube> cubes = olapConnection.getOlapSchema().getCubes();
        for (Cube eachCube : cubes) {

            System.out.println(" Cube name..." + eachCube.getName());

            for (Measure measure : eachCube.getMeasures()) {

                System.out.println(" Measures " + measure.getName());
                System.out.println("Measure Levels...."
                        + measure.getLevel().getCaption());

            }

            for (Hierarchy hierarchy : eachCube.getHierarchies()) {

                System.out.println("hierarchy " + hierarchy.getName());
                NamedList<Level> levels = hierarchy.getLevels();

                for (Level l : levels) {

                    System.out.println(" Hierarchy levels " + l.getName());
                    List<Member> members = l.getMembers();

                    for(Member member:members){
                        System.out.println(" Member name " +member.getName());


                    }

                }
            }

        }
Naresh G
  • 11
  • 4
  • please provide any attempts you made, so that people could help you based on that. – xlembouras Feb 20 '14 at 07:52
  • Sample code , i am trying ..bit i am not this is approach for (Measure measure : eachCube.getMeasures()) { System.out.println(" Measures " + measure.getName()); System.out.println("Measure Levels...." + measure.getLevel().getCaption()); } for (Hierarchy hierarchy : eachCube.getHierarchies()) { System.out.println("hierarchy " + hierarchy.getName()); NamedList levels = hierarchy.getLevels(); for (Level l : levels) { System.out.println(" Hierarchy levels " + l.getName()); } } } – Naresh G Feb 20 '14 at 08:02
  • add this code to your question and format it properly – xlembouras Feb 20 '14 at 08:25

1 Answers1

0

You are assuming that there is a column in a schema backing the olap4j connection. This is not an assumption that olap4j can make. It is designed to abstract these concerns.

The correct way to pass special hints like these is through annotations. You can add annotations to schemas, cubes, dimensions, hierarchies and levels.

Luc
  • 672
  • 3
  • 8