Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Configure facets for a cubegrid

    I'm trying to configure a basic cube grid. i get data from data base in this form:

    origin, destination,dates, bookings,fare,revenue:
    LHR, SIN,200901,100,200,20000
    LHR, NYC,200901,300,100,30000

    so I'm using the following code to set facets:

    Code:
    public void createCubeGrid(final VLayout rLayout) {
           DataSource dS = DataSource.get("adb");
            DSRequest dSR = new DSRequest();
            dSR.setOperationId("cubeGrid");
            final CubeGrid inCube = new CubeGrid();
            dS.fetchData(new Criteria(), new DSCallback() {
                public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
    
                    if (SC.hasAnalytics()) {
                        //in order to enable charting, the Drawing module must be present
                        if (SC.hasDrawing()) {
                            inCube.setEnableCharting(true);
                        }
                        inCube.setData(dsResponse.getData());
    
                        inCube.setWidth100();
                        inCube.setHeight100();
                        inCube.setHideEmptyFacetValues(true);
                        inCube.setShowCellContextMenus(true);
    
                        final NumberFormat numberFormat = NumberFormat.getFormat("0,000");
    
                        inCube.setCellFormatter(new CellFormatter() {
                            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                                if (value == null) return null;
                                try {
                                    return numberFormat.format(((Number) value).longValue());
                                } catch (Exception e) {
                                    return value.toString();
                                }
                            }
                        });
    //                    inCube.setValueProperty("bookings");
                        inCube.setRowFacets("ORIG", "DEST");
                        inCube.setColumnFacets("dates","bookings");
                        rLayout.addMember(inCube);
                    } else {
                        HTMLFlow htmlFlow = new HTMLFlow("<div class='explorerCheckErrorMessage'><p>This example is disabled in this SDK because it requires the optional " +
                                "<a href=\"http://www.smartclient.com/product/index.jsp\" target=\"_blank\">Analytics module</a>.</p>" +
                                "<p>Click <a href=\"http://www.smartclient.com/smartgwtee/showcase/#cube-analytics\" target=\"\">here</a> to see this example on smartclient.com</p></div>");
                        htmlFlow.setWidth100();
                    }
                }
            }, dSR);
        }
    Cube grid is not drawn.

    but if i change the lines which set the facets to this:

    Code:
                     inCube.setValueProperty("bookings");
                        inCube.setRowFacets("ORIG", "DEST");
                        inCube.setColumnFacets("dates");
    Cube grid is drawn with column headers as dates field and data filled with bookings.

    i'm trying to replicate the sample in showcase and want to show bookings, revenue, fare as column facets and values instead of only bookings.

    #2
    Look in the Developer Console for errors or warnings (always do this).

    If you need help, show the actual data returned as seen in the RPC tab of the Developer Console (always do this).

    Comment


      #3
      RPC response:

      Code:
      [
          {
              queueStatus:0, 
              invalidateCache:false, 
              endRow:18, 
              data:[
                  {
                      DEST:"MAA", 
                      ORIG:"BOM", 
                      bookings:41057, 
                      dates:200903
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"BOM", 
                      bookings:26463, 
                      dates:200903
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"CCU", 
                      bookings:16852, 
                      dates:200903
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"DEL", 
                      bookings:17719, 
                      dates:200903
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"DEL", 
                      bookings:41821, 
                      dates:200903
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"CCU", 
                      bookings:4000, 
                      dates:200903
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"CCU", 
                      bookings:18682, 
                      dates:200901
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"BOM", 
                      bookings:46324, 
                      dates:200901
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"DEL", 
                      bookings:17684, 
                      dates:200901
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"CCU", 
                      bookings:3870, 
                      dates:200901
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"BOM", 
                      bookings:27732, 
                      dates:200901
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"DEL", 
                      bookings:41369, 
                      dates:200901
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"CCU", 
                      bookings:17501, 
                      dates:200902
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"BOM", 
                      bookings:39547, 
                      dates:200902
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"BOM", 
                      bookings:29161, 
                      dates:200902
                  }, 
                  {
                      DEST:"MAA", 
                      ORIG:"DEL", 
                      bookings:43969, 
                      dates:200902
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"CCU", 
                      bookings:3813, 
                      dates:200902
                  }, 
                  {
                      DEST:"AMD", 
                      ORIG:"DEL", 
                      bookings:18479, 
                      dates:200902
                  }
              ], 
              status:0, 
              startRow:0, 
              totalRows:18, 
              isDSResponse:true
          }
      ]
      Also i see the following warning:

      Code:
      22:50:18.942:TMR7:WARN:Log:TypeError: this.rowFields[i][0] is undefined
          CubeGrid.createRowHeaderBars() @ builtinds/sc/modules/ISC_Analytics.js:446
          CubeGrid.createChildren() @ builtinds/sc/modules/ISC_Analytics.js:407
          ListGrid.prepareForDraw() @ builtinds/sc/modules/ISC_Grids.js:1404
          Class.invokeSuper(_1=>null,  _2=>"prepareForDraw") @ builtinds/sc/modules/ISC_Core.js:305
          Class.Super(_1=>"prepareForDraw",  _2=>[object Arguments]) @ builtinds/sc/modules/ISC_Core.js:297
          CubeGrid.prepareForDraw() @ builtinds/sc/modules/ISC_Analytics.js:456
          ListGrid.draw() @ builtinds/sc/modules/ISC_Grids.js:1397
          Class.invokeSuper(_1=>null,  _2=>"draw") @ builtinds/sc/modules/ISC_Core.js:305
          Class.Super(_1=>"draw",  _2=>[object Arguments]) @ builtinds/sc/modules/ISC_Core.js:297
          CubeGrid.draw() @ builtinds/sc/modules/ISC_Analytics.js:457
          Layout.layoutChildren("resized", -10, -13) @ builtinds/sc/modules/ISC_Foundation.js:461
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.resizeBy(-10, -13, undef, undef) @ builtinds/sc/modules/ISC_Core.js:2660
          Canvas.resizeTo(1030, 464) @ builtinds/sc/modules/ISC_Core.js:2689
          Layout.resizeMembers([object Array], [object Array], true) @ builtinds/sc/modules/ISC_Foundation.js:416
          Layout.layoutChildren("resized", -10, -13) @ builtinds/sc/modules/ISC_Foundation.js:461
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.moveBy(0, 0, undef, true) @ builtinds/sc/modules/ISC_Core.js:2602
          Canvas.moveTo(0, 24, undef, true) @ builtinds/sc/modules/ISC_Core.js:2638
          Canvas.setRect(0, 24, 1042, 476) @ builtinds/sc/modules/ISC_Core.js:2326
          TabSet.fixLayout() @ builtinds/sc/modules/ISC_Containers.js:416
          TabSet.layoutChildren("resized", -10, -13) @ builtinds/sc/modules/ISC_Containers.js:450
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.resizeBy(-10, -13, undef, undef) @ builtinds/sc/modules/ISC_Core.js:2660
          Canvas.resizeTo(1042, 500) @ builtinds/sc/modules/ISC_Core.js:2689
          Layout.resizeMembers([object Array], [object Array], false) @ builtinds/sc/modules/ISC_Foundation.js:416
          Layout.layoutChildren("resized", -10, -13) @ builtinds/sc/modules/ISC_Foundation.js:464
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.resizeBy(-10, -13, undef, undef) @ builtinds/sc/modules/ISC_Core.js:2660
          Canvas.resizeTo(1052, 510) @ builtinds/sc/modules/ISC_Core.js:2689
          Layout.resizeMembers([object Array], [object Array], false) @ builtinds/sc/modules/ISC_Foundation.js:416
          Layout.layoutChildren("resized", -10, -21) @ builtinds/sc/modules/ISC_Foundation.js:464
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.resizeBy(-10, -21, undef, undef) @ builtinds/sc/modules/ISC_Core.js:2660
          Canvas.resizeTo(1052, 855) @ builtinds/sc/modules/ISC_Core.js:2689
          Layout.resizeMembers([object Array], [object Array], true) @ builtinds/sc/modules/ISC_Foundation.js:416
          Layout.layoutChildren("resized", -13, -21) @ builtinds/sc/modules/ISC_Foundation.js:461
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.resizeBy(-13, -21, undef, undef) @ builtinds/sc/modules/ISC_Core.js:2660
          Canvas.resizeTo(1319, 855) @ builtinds/sc/modules/ISC_Core.js:2689
          Layout.resizeMembers([object Array], [object Array], true) @ builtinds/sc/modules/ISC_Foundation.js:416
          Layout.layoutChildren("resized", -13, -23) @ builtinds/sc/modules/ISC_Foundation.js:461
          Canvas._completeResizeBy() @ builtinds/sc/modules/ISC_Core.js:2663
          Canvas.moveBy(0, 0, undef, true) @ builtinds/sc/modules/ISC_Core.js:2602
          Canvas.moveTo(null, null, undef, true) @ builtinds/sc/modules/ISC_Core.js:2638
          Canvas.setRect(null, null, "80%", "100%") @ builtinds/sc/modules/ISC_Core.js:2326
          Canvas._resolvePercentageSize() @ builtinds/sc/modules/ISC_Core.js:2706
          Canvas.pageResize(null, undef) @ builtinds/sc/modules/ISC_Core.js:2636
          Class.invokeSuper(_1=>null,  _2=>"pageResize") @ builtinds/sc/modules/ISC_Core.js:305
          Class.Super(_1=>"pageResize",  _2=>[object Arguments]) @ builtinds/sc/modules/ISC_Core.js:297
          Layout.pageResize(null, undef) @ builtinds/sc/modules/ISC_Foundation.js:494
          [c]Page.handleEvent(_1=>null,  _2=>"resize") @ builtinds/sc/modules/ISC_Core.js:1280
          EventHandler._fireResizeEvent("landscape") @ builtinds/sc/modules/ISC_Core.js:1607
          EventHandler._pageResize() @ builtinds/sc/modules/ISC_Core.js:1606
          anonymous() @ builtinds/sc/modules/ISC_Core.js:63
          [c]Class.fireCallback(_1=>"isc.EH.$hr()",  _2=>undef,  _3=>[object Array],  _4=>[object Proxy],  _5=>true) @ builtinds/sc/modules/ISC_Core.js:322
          Timer._fireTimeout("$ir490") @ builtinds/sc/modules/ISC_Core.js:1262
          unnamed() @ builtinds/sc/modules/ISC_Core.js:1257
          unnamed() @

      Comment


        #4
        OK, so the data is not as you originally described, and this result is expected since you've absorbed all of the properties in the CellRecords as facets, and there's no valueProperty to show in the cells.

        Comment


          #5
          so for the following data:
          Origin,destination,dates,bookings,fare,revenue

          LHR, SIN,200901,100,200,20000
          LHR, NYC,200901,300,100,30000

          I need to come up with rows as :

          LHR, SIN, 200901, 'bookings',100
          LHR, SIN, 200901, 'fare',200
          LHR, SIN, 200901, 'revenue',20000

          LHR, NYC, 200901, 'bookings',300
          LHR, NYC, 200901, 'fare',100
          LHR, NYC, 200901, 'revenue',30000

          and set column facets as dates and the (bookings/fare/revenue) variable.

          If this is the case, then I find it difficult to understand why cubes always need data in this way while databases store data in linear form (minimizing number of rows) instead.

          Comment


            #6
            It's called star schema, common in OLAP. It's represented this way because it's the most convenient format when all facets are independent, eg, the cube allows users to rearrange where the facets are placed on the fly.

            If you have a good book on OLAP, or just Google around, you should be able to find sample SQL queries for returning this kind of result from a table that isn't set up like a star schema.

            Comment


              #7
              Originally posted by curiousgally
              so for the following data:
              Origin,destination,dates,bookings,fare,revenue

              LHR, SIN,200901,100,200,20000
              LHR, NYC,200901,300,100,30000

              I need to come up with rows as :

              LHR, SIN, 200901, 'bookings',100
              LHR, SIN, 200901, 'fare',200
              LHR, SIN, 200901, 'revenue',20000

              LHR, NYC, 200901, 'bookings',300
              LHR, NYC, 200901, 'fare',100
              LHR, NYC, 200901, 'revenue',30000

              and set column facets as dates and the (bookings/fare/revenue) variable.

              If this is the case, then I find it difficult to understand why cubes always need data in this way while databases store data in linear form (minimizing number of rows) instead.

              I have a similar issue. Did u find a solution for your kind of data???????. I have a similar set of data. Please tell me how did you solve this?


              So for the following data,
              category, subCategory, count

              c1,sc1,1
              c1,sc2,2
              c2,sc3,1
              c3,sc4,5
              c3,sc5,4
              c3,sc6,9
              c3,sc7,0


              So for c1 - there is fixed sub category sc1 and sc2
              for c2 - sc3
              for c3 - sc4,sc5,sc6,sc7
              and the value property is the count.


              cubeGrid.setFacets(new Facet("category"), new Facet("subCategory"), new Facet("count"));
              cubeGrid.setRowFacets("category", "subCategory");
              cubeGrid.setValueProperty("count");

              now this one does not work, please suggest the right way.
              Last edited by Koripella; 9 Sep 2011, 14:08.

              Comment


                #8
                I have done the above sample as a spike.

                My findings:

                If you don't have a database which is not as per OLAP standards (refer previous post by Isomorphic), its definitely going to be a pain to get the Cube Grid to work as you want.
                Basic Cube Grid would be easier though because you know before hand what query would be required to populate the cube grid. Hence like Isomorphic mentioned you can write queries which fetch data in OLAP standards. I have done some sample on this (long back) and you do have some powerful functions in Oracle which do this for you. If your database doesn't support such functions and you desperately need a Basic Cube Grid, you could even construct your data with multiple queries using DMI (not sure if this would be a good approach).

                Advanced Cube Grid will be very difficult to achieve with this kind of data source. I have tried it out. The simple reason being you have to understand what all facets will be queried dynamically and the complication increases when you re-arrange the facets etc. I feel achieving Advanced Cube Grid would be a pain (not impossible though).
                If you are planning to create a implementation for Advanced CubeGrid, my first suggestion would be to check a smartgwt Advanced CubeGrid sample and closely observe the query that gets fired each time you expand few columns or rows, also when you try change some column facet to row etc. When you look at the queries being fired, you will get a fair idea as to how to come up with your custom queries and how to cover all the possible scenarios that could happen.

                Another shortcoming I have come across when I tried to implement Advanced Cube Grid is:
                It would be easier to construct such Olap dataset using UNIONS etc in the query, but I don't think such things are allowed in the datasource xml file. Hence I left it there.


                Hope this helps. Feel free to share your findings (could help me too :) )!!!!

                Comment


                  #9
                  It's not the CubeGrid creating the problem, it's just an inherently challenging problem to get a cube-like view of relational tables - an entirely category of software tools exists to solve this problem (ETL - Extract Transform & Load) with multiple approaches (Google "ROLAP, MOLAP, HOLAP").

                  Once you can get an OLAP-style view of your data, the CubeGrid is a perfect fit. That's why it's so easy to integrate with Mondrian MDX or other OLAP systems.

                  So, look into possible use of standard ETL tools to solve the complexity problem - there's really nothing to simplify or enhance in how the cube fetches data (and you've offered no suggestions).

                  Note: UNIONS are allowed in .ds.xml files, as with all customized SQL, the only requirement is that the final SQL result matches the declared fields.

                  Comment


                    #10
                    Isomorphic,

                    thanks for the info. Somehow, I never got this reply from you regarding Mondrion or Jasper server integration for my previous questions on cube grid. Hence I just mentioned what I had come cross when I tried to implement it. I never mentioned Cube Grid is creating the problem. I have mentioned that with this kind of data source getting Advanced Cube Grid to work is difficult. Not everything can be achieved with a single technology This can never be a limitation to SmartGWT. I understand that.

                    P.S. we came across flexmoster which works fine for pivoting. But I try to stay as far as possible from Flex. :)

                    Comment


                      #11
                      The Mondrian / Jasper article is brand new (~2 weeks), that's why we didn't mention it before.

                      It's good to hear that you don't blame the CubeGrid for the complexity of extracting cube-like data from SQL - it was just your use of the word "shortcoming" that made us want to clarify this.

                      Comment


                        #12
                        Iso,

                        Any details on the versions of lib to be used in this sample to connect to a jasper olap server. I get lot of exceptions.

                        Will provide more info..!

                        Comment


                          #13
                          Isomorphic,

                          I'm trying to connect to JasperServer by a XMLA connection. Had to use jars from mondrian, olap4j to get this. This seems to be tricky. But I could get it run. The UI now fetches the cubes but then doesn't fetch the Dimensions on click of a cube. Throws an error:

                          Code:
                          java.lang.NullPointerException
                          	at com.smartgwt.sample.server.OLAPDataSourceDimensions.fetchRecordsDimensions(OLAPDataSourceDimensions.java:35)
                          	at com.smartgwt.sample.server.OLAPDataSourceDimensions.executeFetch(OLAPDataSourceDimensions.java:22)
                          	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1154)
                          	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:721)
                          	at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
                          	at com.isomorphic.application.AppBase.execute(AppBase.java:491)
                          	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1714)
                          	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
                          	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
                          	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
                          	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
                          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
                          	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
                          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                          	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                          	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                          	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                          	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                          	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
                          	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
                          	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
                          	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
                          	at java.lang.Thread.run(Thread.java:662)

                          Thanks.

                          Comment


                            #14
                            We just added versions to the wiki page describing how to set this up - check that you have the same.

                            Name as is obvious from the source, whatever cube you selected, OLAP4J was not able to retrieve it by it's name.

                            Comment


                              #15
                              Just checked the updated link. I think people will still face difficulty. In Mondrian and Olap4j there are jars which have same classes with difference.
                              You have total of 3 instances of class XmlOlapCube both mondrian and olap4j combined. So it took me quite some time to figure out the correct match. It could be of help to somebody.

                              Modrian:

                              mondrian.jar
                              mondrian-jdk14.jar


                              Olap4j:

                              retroweaver-rt.jar
                              olap4j-jdk14.jar
                              xercesImpl.jar


                              Thanks.

                              Comment

                              Working...
                              X