Announcement

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

    How to fetch data from local repository when using drawing tool?

    I use Analytics module in CubeGrid aplication. My application calls stored procedure which returns table for my CubeGrid.
    Also I store Facet values in java code.
    Code:
    Facet period = new Facet();
    period.setValues( 
            new FacetValue("January", "January"),
            ...
    )

    Now I want to use drawing module in CubeGrid by setting
    Code:
    advancedCube.setEnableCharting(true)
    But SmartGWT tries to make select from my stored procedure.
    Code:
    <DataSource ID="UserCubesBudget"...
    Code:
    INFO  SQLDriver - [builtinApplication.UserCubesBudget_fetch] Executing SQL query on 'SQLServer': SELECT UserCubesBudget.item2, UserCubesBudget.periodname...
    But of course SQLServerException occurs because UserCubesBudget is not a table.

    As far as I know SmartGWT framework stores data fetched from stored procedure in local repository like DataSet. How to override standard method and select data from local repository?

    #2
    In general, due to load on demand, creating a chart may involve fetching new data. Currently the cube doesn't try to determine if it already has all the needed data for a chart.

    You can prevent this request from going to the server by either using cacheAllData:true on your DataSource, or, if you are sending criteria to the server (so cacheAllData won't work automatically), you can create a clientOnly DataSource from the dataset given to the cube, and bind the cube to that clientOnly DataSource.

    Comment


      #3
      I got it. But there are still some problems.

      I did:
      1)
      Code:
      DataSource dataSourceCube = new DataSource();
      dataSourceCube.setID("UserCubesEvaluation");
      dataSourceCube.setCacheAllData(true);
      
      advancedCube.setDataSource(dataSourceCube);
      advancedCube.setFetchOperation("fetchUserCubesEvaluation");
      advancedCube.fetchData();
      2)
      Code:
      <DataSource ID="UserCubesEvaluation" serverType="sql" dbName="SQLServer">
      	<fields>
      		<field name="item1" type="text" />		
      		<field name="item2" type="text" />
      		<field name="value1" type="float" />		
      	</fields>	
      	<operationBindings>		
      		<operationBinding operationType="fetch" operationId="fetchUserCubesEvaluation">
      			<customSQL>				
      				EXEC sp_MnGetUserCubesEvaluation					
      			</customSQL>
      		</operationBinding>										
      	</operationBindings>
      </DataSource>
      And the framework tries to do:
      Code:
      INFO  SQLDriver - [builtinApplication.UserCubesEvaluation_fetch] Executing SQL query on 'SQLServer': SELECT UserCubesEvaluation.item1, UserCubesEvaluation.item2
      It does not call stored procedure but try to do select. How can I resolve this issue?

      Comment


        #4
        Please show the request and the portion of the server log for it from the dev console

        Comment


          #5
          Here it is:

          The request from Dev Console:

          Code:
          {
              dataSource:"UserCubesEvaluation", 
              operationType:"fetch", 
              componentId:"(cacheAllData fetch)", 
              resultSet:[ResultSet ID:isc_ResultSet_0 (created by: (cacheAllData fetch))], 
              callback:{
                  caller:[ResultSet ID:isc_ResultSet_0 (created by: (cacheAllData fetch))], 
                  methodName:"fetchRemoteDataReply"
              }, 
              willHandleError:true, 
              showPrompt:true, 
              requestId:"UserCubesEvaluation$6271", 
              clientContext:{
                  requestIndex:{
                      Class:"Number", 
                      formatter:"toString", 
                      localeStringFormatter:"toString", 
                      localeProperties:Obj
                  }
              }, 
              fallbackToEval:false, 
              componentContext:"(from: undefined)", 
              cachingAllData:true, 
              bypassCache:true
          }
          Attached Files

          Comment


            #6
            The automatic cacheAllData request is not using the fetchOperation you're using because it's purpose is to retrieve *all* of the data for the dataSource. We may look further into that.

            In the meantime, just forget about the operationId - don't set it on the grid or the operationBinding in your DS - that makes it the default fetch op and the cacheAllData request should use it.

            Comment


              #7
              Thank you so much! Now it works.

              But there is a warning:
              Code:
              15:19:22.414 [ERROR] [cubegrid] 15:19:21.706:WARN:Log:Specified ID:UserCubesEvaluation collides with the ID of an existing object '[DataSource ID:UserCubesEvaluation]'.
              I did:
              Code:
              DataSource dataSourceCube = new DataSource();
              dataSourceCube.setID("UserCubesEvaluation");
              dataSourceCube.setCacheAllData(true);
              Code:
              <DataSource ID="UserCubesEvaluation">
              ...
              </DataSource>
              How to resolve this issue?
              Last edited by b.kazybaev; 14 Mar 2013, 01:29.

              Comment


                #8
                Use DataSource.get() instead of new DataSource() and don't set the ID

                Comment


                  #9
                  And one more case is that framework loads, when it starts firstly, not all data of a table. You may see below picture.

                  But when I open a chart then close it. CubeGrid automatically loads the rest data.

                  And there are window vibrations when application loads. I can not determine the reason for it.
                  Attached Files
                  Last edited by b.kazybaev; 14 Mar 2013, 01:45.

                  Comment


                    #10
                    Originally posted by Isomorphic View Post
                    Use DataSource.get() instead of new DataSource() and don't set the ID
                    If I do not create new DataSource(), then how can I set setCacheAllData(true)?

                    Comment


                      #11
                      Code:
                      DataSource ds = DataSource.get("yourID");
                      ds.setCacheAllData(true);
                      or just set cacheAllData="true" in your datasource

                      Comment


                        #12
                        Originally posted by b.kazybaev View Post
                        And one more case is that framework loads, when it starts firstly, not all data of a table. You may see below picture.

                        But when I open a chart then close it. CubeGrid automatically loads the rest data.

                        And there are window vibrations when application loads. I can not determine the reason for it.
                        Hey, Isomorphic

                        Why only half data loads when I first open application? Could you explain such behavior and help to resolve the issue? I provided you screenshot of table.

                        Comment


                          #13
                          It's impossible to say from a screenshot.

                          What do you see in the dev console? Is the fetch returning all the data you expect? Are there any JS errors? Does just redrawing the grid fix it?

                          Comment


                            #14
                            I am seeing in Dev Console the following:

                            1) in RPC tab
                            There are two requests. The first one's URL is:
                            http://127.0.0.1:8888/cubegrid/sc/IDACall

                            The second one's URL is:
                            [client only]

                            I have seen DSRequest and Response tabs and found that for the first request the Responce contains "All Data". But for the second request it does not contain all data.

                            Here is the first and second DSRequest:
                            1)
                            Code:
                            {
                                dataSource:"UserCubesEvaluation", 
                                operationType:"fetch", 
                                componentId:"(cacheAllData fetch)", 
                                resultSet:[ResultSet ID:isc_ResultSet_0 (created by: (cacheAllData fetch))], 
                                callback:{
                                    caller:[ResultSet ID:isc_ResultSet_0 (created by: (cacheAllData fetch))], 
                                    methodName:"fetchRemoteDataReply"
                                }, 
                                willHandleError:true, 
                                showPrompt:true, 
                                requestId:"UserCubesEvaluation$6271", 
                                clientContext:{
                                    requestIndex:{
                                        Class:"Number", 
                                        formatter:"toString", 
                                        localeStringFormatter:"toString", 
                                        localeProperties:Obj
                                    }
                                }, 
                                fallbackToEval:false, 
                                componentContext:"(from: undefined)", 
                                cachingAllData:true, 
                                bypassCache:true
                            }
                            2)
                            Code:
                            {
                                dataSource:"UserCubesEvaluation", 
                                operationType:"fetch", 
                                data:{
                                    item1:[
                                        "Талдыкорган Г.А.", 
                                        "Капчагай Г.А.", 
                                        "Текели Г.А.", 
                                        "Алакольский район", 
                                        "Балхашский район", 
                                        "Енбекшиказахский район", 
                                        "Коксуский район", 
                                        "Райымбекский район"
                                    ], 
                                    item2:[
                                        "Общая оценка эффективности по информационным технологиям", 
                                        "Общий балл оценки эффективности достижения и реализации стратегических целей и задач", 
                                        "Общая оценка эффективности по оказанию государственных услуг", 
                                        "Общий балл оценки эффективности исполнения актов и поручений", 
                                        "Общая оценка эффективности по управлению персоналом"
                                    ]
                                }, 
                                textMatchStyle:"exact", 
                                callback:{
                                    target:[CubeGrid ID:isc_CubeGrid_0], 
                                    methodName:"$54c"
                                }, 
                                showPrompt:true, 
                                requestId:"UserCubesEvaluation$6270", 
                                fallbackToEval:false, 
                                bypassCache:true
                            }
                            I did not see any js errors.

                            Comment


                              #15
                              I dunno why but in the second request item1 does not have all regions.
                              Code:
                              data:{
                                      item1:[
                                      ...

                              Comment

                              Working...
                              X