Announcement

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

    #16
    Hi Isomorphic, here is the code in the onmoduleload method for fetching the facets and the cubegrid:

    Code:
    DSRequest requestSeries = new DSRequest();
    
    requestSeries.setOperationId("serieIngresosFetch") ;
    
    DataSource.get("ingresos").fetchData(null, new DSCallback() {
    
    @Override
    
    public void execute(DSResponse response, Object rawData, DSRequest request) {
    
    // TODO Auto-generated method stub
    
    
    final RecordList seriesIngresos = response.getDataAsRecordList();
    
    final Facet serie = new Facet();
    serie.setId("serie");
    serie.setTitle("SERIE");
    
    FacetValue[] facetsSerie = new FacetValue[seriesIngresos.getLength()];
    
    for (int i=0;i< seriesIngresos.getLength();i++)
    {
    
    
    
    facetsSerie[i] = new FacetValue(seriesIngresos.get(i).getAttribute("nom breSerieIngreso"), seriesIngresos.get(i).getAttribute("nombreSerieIng reso"));
    
    }
    
    serie.setValues(facetsSerie);
    
    DSRequest requestOfertas = new DSRequest();
    
    requestOfertas.setOperationId("ofertaIngresosFetch ");
    
    DataSource.get("ingresos").fetchData(null, new DSCallback() {
    
    @Override
    
    public void execute(DSResponse response, Object rawData, DSRequest request) {
    
    // TODO Auto-generated method stub
    
    
    final RecordList ofertasIngresos = response.getDataAsRecordList();
    
    final Facet oferta = new Facet();
    oferta.setId("oferta");
    oferta.setTitle("OFERTA");
    
    FacetValue[] facetsOferta = new FacetValue[ofertasIngresos.getLength()];
    
    for (int i=0;i< ofertasIngresos.getLength();i++)
    {
    
    
    
    facetsOferta[i] = new FacetValue(ofertasIngresos.get(i).getAttribute("ti tuloOferta"), ofertasIngresos.get(i).getAttribute("tituloOferta" ));
    
    }
    
    oferta.setValues(facetsOferta);
    
    
    DSRequest requestMeses = new DSRequest();
    
    requestMeses.setOperationId("mesIngresosFetch");
    
    DataSource.get("ingresos").fetchData(null, new DSCallback() {
    
    @Override
    
    public void execute(DSResponse response, Object rawData, DSRequest request) {
    
    // TODO Auto-generated method stub
    
    
    final RecordList mesIngresos = response.getDataAsRecordList();
    
    final Facet mes = new Facet();
    mes.setId("mes");
    mes.setTitle("MES");
    
    FacetValue[] facetsMes = new FacetValue[mesIngresos.getLength()];
    
    for (int i=0;i< mesIngresos.getLength();i++)
    {
    
    
    
    facetsMes[i] = new FacetValue(mesIngresos.get(i).getAttribute("mes"), mesIngresos.get(i).getAttribute("mes"));
    
    }
    
    mes.setValues(facetsMes);
    
    if(SC.hasAnalytics())
    
    {
    
    
    
    final CubeGrid advancedCube = new CubeGrid();
    
    advancedCube.setFetchOperation("ingresosFetch");
    
    if(SC.hasDrawing()) {
    advancedCube.setEnableCharting(true);
    }
    
    advancedCube.setWidth100();
    
    advancedCube.setHeight100();
    
    advancedCube.setFacets(serie,oferta,mes);
    
    
    
    
    
    
    advancedCube.setHideEmptyFacetValues(true);
    
    advancedCube.setShowCellContextMenus(true);
    
    
    
    
    
    
    advancedCube.setRowFacets("serie","oferta");
    advancedCube.setColumnFacets("mes");
    advancedCube.setValueProperty("_value");
    
    advancedCube.setDataSource(DataSource.get("ingreso s"));
    advancedCube.setAutoFetchData(true);
    
    VLOInformes.addMember(advancedCube);
    }
    
    
    
    }
    
    },requestMeses);
    
    }
    
    },requestOfertas);
    
    }
    
    },requestSeries);
    Hope this could help.

    Thanks in advance

    Comment


      #17
      Oh, the problem is this line:

      Code:
      advancedCube.setHideEmptyFacetValues(true);
      For obvious reasons this feature cannot be used with load on demand - you have to provide the data up front via setData().

      Comment


        #18
        Hi isomorphic,

        I was using this code (fetching the facets and fetching the cubrid) because the other way was getting me crazy.

        Here is the code which I firstly use to populate the cubegrid:

        Code:
        			final CubeGrid advancedCube = new CubeGrid();
                    	
                   	 if(SC.hasDrawing()) {  
        	    	    	   advancedCube.setEnableCharting(true);  
        	                } 
           	       
           	       		advancedCube.setWidth100();
        
           	             advancedCube.setHeight100();
        
           	            // advancedCube.setFacets(serie,oferta,mes);
           	             
           	             advancedCube.setHideEmptyFacetValues(true);
        					
           	             advancedCube.setShowCellContextMenus(true);
           	             
           	             advancedCube.setRowFacets("serie","oferta");
           	             advancedCube.setColumnFacets("mes");
           	             advancedCube.setValueProperty("_value"); 
                   	
               	    DSRequest requestIngresos = new DSRequest();
        
               	    requestIngresos.setOperationId("ingresosFetch");
        
         	            DataSource.get("ingresos").fetchData(null, new DSCallback() {
        
         	                     @Override
        
         	                     public void execute(DSResponse response, Object rawData, DSRequest request) {
        
         	                    	 advancedCube.setData(response.getData());
                   	
         	                    	VLOInformes.addMember(advancedCube);
        
         	                     }
         	            },requestIngresos);
        With this code, I get the correct facet values but nothing appear with the value property.

        The fetch operation which I use to populate the cubegrid, response with this info (taken from the RPC tab of the developer console):

        DSRequest data of the operation:

        {
        "dataSource":"ingresos",
        "operationType":"fetch",
        "operationId":"ingresosFetch",
        "data":null,
        "showPrompt":true,
        "oldValues":null,
        "requestId":"ingresos$62722"
        }

        DSResponse data of the operation:

        [
        {
        data:[
        {
        serie:"DESARROLLO",
        _value:21900,
        mes:"February",
        oferta:"1"
        },
        {
        serie:"DESARROLLO",
        _value:100000,
        mes:"May",
        oferta:"1"
        },
        {
        serie:"DESARROLLO",
        _value:20000,
        mes:"March",
        oferta:"2"
        },
        {
        serie:"SISTEMAS",
        _value:480,
        mes:"February",
        oferta:"1"
        },
        {
        serie:"SISTEMAS",
        _value:3950,
        mes:"March",
        oferta:"1"
        },
        {
        serie:"SISTEMAS",
        _value:52000,
        mes:"May",
        oferta:"1"
        },
        {
        serie:"SISTEMAS",
        _value:100,
        mes:"February",
        oferta:"2"
        }
        ],
        endRow:7,
        invalidateCache:false,
        isDSResponse:true,
        operationType:"fetch",
        queueStatus:0,
        startRow:0,
        status:0,
        totalRows:7
        }
        ]

        As you can see, I get all the data correctly and the cubegrid populates the facets correctly but the _value (I mean the value property) is not set in the cubegrid.

        I attach you the image of the cubegrid to help you see the problem.

        I hope you could help me because it's getting me crazy ;)

        Thanks in advance,

        Pablo
        Attached Files

        Comment


          #19
          The data and settings are now correct, and this is certainly a mystery as your code is now basically the same as the working Simple Cube sample.

          Try looking at the Records in the fetchData callback and logging their contents - perhaps some DataSource setting or other customization has actually modified them such that the _valueProperty is not present by the time the Records are provided to the CubeGrid.

          Comment


            #20
            Thanks isomorphic for your help.

            I have several questions:

            - Can the value property be a double or float type field? Or it must be an integer type?

            - Do I need to convert the records into listgrid records to pass them to the cubegrid? It looks like in the simple cube example, you pass the records as ListGridRecords. How can I convert from one class to the other.

            Here is my Datasource definition with all the operation Bindings. I only use the operation Binding with ID "ingresosFetch".

            Code:
            <DataSource
            ID="ingresos"
            serverType="sql"
            tableName="ingresos"
            >
            <fields>
            <field name="ingresoID" type="sequence" title="ingresoID" primaryKey="true" hidden="true"/>
            <field name="numeroFacturaIngreso" type="integer" title="NUMERO FACTURA"/>
            <field name="fechaFacturaIngreso" type="date" title="FECHA FACTURA"/>
            <field name="clienteID" type="integer" title="CLIENTE" foreignKey="clientes.clienteID" displayField="denominacionSocial" valueField="clienteID"/> 
            <field name="ofertaID" type="integer" title="OFERTA" foreignKey="ofertas.ofertaID" displayField="tituloOferta" valueField="ofertaID"/> 
            <field name="serieIngresosID" type="integer" title="SERIE INGRESOS" foreignKey="seriesIngresos.serieIngresosID" displayField="nombreSerieIngresos" valueField="serieIngresosID"/> 
            <field name="fechaCobro" type="date" title="FECHA COBRO"/>
            <field name="iva" type="text" title="IVA" hint="%"/>
            <field name="baseImponible" type="float" title="BASE IMPONIBLE" canEdit="false" hint="€"/>
            <field name="importeIVA" type="float" title="IMPORTE IVA" canEdit="false" hint="€"/>
            <field name="importeTotal" type="float" title="IMPORTE TOTAL" canEdit="false" hint="€"/>
            <field name="prefacturaIngresos" type="boolean" title="ES PREFACTURA"/>
            
            </fields>
            
            <operationBindings>
            
            <operationBinding operationType="fetch" operationId="numFacturaMax">
            <customSQL>
            SELECT MAX(numeroFacturaIngreso) AS numFacturaIngreso FROM ingresos
            </customSQL>
            </operationBinding>
            
            <operationBinding operationType="fetch" operationId="ingresosFetch">
            
            <customSQL>
            
            SELECT SI.nombreSerieIngresos AS serie,O.tituloOferta AS oferta, MONTHNAME(fechaFacturaIngreso) as mes, SUM(`baseImponible`) AS _value FROM `ingresos` AS I INNER JOIN seriesIngresos AS SI ON I.serieIngresosID = SI.serieIngresosID INNER JOIN ofertas AS O ON I.ofertaID = O.ofertaID GROUP BY serie,oferta,mes
            </customSQL>
            
            </operationBinding>
            
            <operationBinding operationType="fetch" operationId="serieIngresosFetch">
            
            <customSQL>
            
            SELECT DISTINCT(I.serieIngresosID) AS serieIngreso,SI.nombreSerieIngresos AS nombreSerieIngreso FROM `ingresos` AS I INNER JOIN seriesIngresos AS SI ON I.serieIngresosID = SI.serieIngresosID INNER JOIN ofertas AS O ON I.ofertaID = O.ofertaID 
            
            </customSQL>
            
            </operationBinding>
            
            <operationBinding operationType="fetch" operationId="ofertaIngresosFetch">
            
            <customSQL>
            
            SELECT DISTINCT(I.ofertaID) AS ofertaID,O.tituloOferta AS tituloOferta FROM `ingresos` AS I INNER JOIN seriesIngresos AS SI ON I.serieIngresosID = SI.serieIngresosID INNER JOIN ofertas AS O ON I.ofertaID = O.ofertaID 
            
            </customSQL>
            
            </operationBinding>
            
            <operationBinding operationType="fetch" operationId="mesIngresosFetch">
            
            <customSQL>
            
            SELECT DISTINCT(MONTHNAME(fechaFacturaIngreso)) AS mes FROM `ingresos` AS I INNER JOIN seriesIngresos AS SI ON I.serieIngresosID = SI.serieIngresosID INNER JOIN ofertas AS O ON I.ofertaID = O.ofertaID 
            
            </customSQL>
            
            </operationBinding>
            
            
            </operationBindings>
            
            
            
            
            
            </DataSource>

            I hope you could help me find the problem.

            Thanks in advance,

            Pablo

            Comment


              #21
              Double and float is fine, no ListGridRecord conversion is not necessary. For more help follow the troubleshooting approach indicated in previous post.

              Comment


                #22
                Hi isomorphic,

                I have troubleshoot as you said and I cant find the problem.

                I have included in the code the functionallity to show the values in the console via System.out.println and to show the values in a grid, and in both cases it works perfect. But the cubegrid doesnt show the values.

                Here is the code I used:

                Code:
                
                	final CubeGrid advancedCube = new CubeGrid();
                            	
                           	 if(SC.hasDrawing()) {  
                	    	    	   advancedCube.setEnableCharting(true);  
                	                } 
                   	       
                   	       		advancedCube.setWidth100();
                
                   	             advancedCube.setHeight100();
                
                   	            // advancedCube.setFacets(serie,oferta,mes);
                   	             
                   	             advancedCube.setHideEmptyFacetValues(true);
                					
                   	             advancedCube.setShowCellContextMenus(true);
                   	             
                   	             advancedCube.setRowFacets("serie","oferta");
                   	             advancedCube.setColumnFacets("mes");
                   	             advancedCube.setValueProperty("_value"); 
                           	
                       	    DSRequest requestIngresos = new DSRequest();
                
                       	    requestIngresos.setOperationId("ingresosFetch");
                
                 	            DataSource.get("ingresos").fetchData(null, new DSCallback() {
                
                 	                     @Override
                
                 	                     public void execute(DSResponse response, Object rawData, DSRequest request) {
                
                 	                    	 advancedCube.setData(response.getData());
                           	
                 	                    	 ListGrid grid = new ListGrid();
                 	                    	 grid.setHeight(300);
                 	                    	 ListGridField serie = new ListGridField("serie");
                 	                    	ListGridField _value = new ListGridField("_value");
                 	                    	
                 	                    	grid.setFields(serie,_value);
                	                    	 
                 	                    	 
                 	                    	 for (int i=0; i<response.getData().length; i++)
                 	                    	 {
                 	                    		 System.out.println("Grid:"+response.getData()[i].getAttribute("serie")+" - "+response.getData()[i].getAttribute("_value"));
                 	                    		 
                 	                    	 }
                 	                    	 
                 	                    	 grid.setData(response.getData());
                 	                    	 
                 	                    	 VLOInformes.addMember(advancedCube);
                 	                    	 VLOInformes.addMember(grid);
                
                 	                     }
                 	            },requestIngresos);
                				
                				
                			}
                    	});
                I attach an image of the result I get in the browser, which shows the result in the grid.

                Hope this could help us find the problem.

                Thanks in advance,

                Pablo
                Attached Files

                Comment


                  #23
                  Actually, from the screenshot, that's not just not showing values, that's got to be a JavaScript error. If so, please use the instructions in the FAQ to get the stack trace from the Developer Console.

                  The other thing that would help is to actually turn this into a test case we can run to see the problem. You could do this by replacing your server DataSource with a client-only DataSource.

                  Comment


                    #24
                    Hi isomorphic,

                    No javascript errors shown in the developer console.

                    I have developed a testcase you can use to test it and see if you can find what is the problem.

                    I attach the following files:

                    TestCase.java: Class where is the onmoduleload() method and where I draw the cubegrid and the listgrid.

                    testcase.ds.xml: the datasource definition file

                    testcase.sql: the sql script to import the table with the values I get from the sql fetch operation in the posts before.

                    As you would see, the listgrid populates perfect but the cubegrid just shows the facets, not the values.

                    I hope where are narrowing the problem to get it working soon.

                    Thanks in advance and looking forward your answer.

                    Pablo
                    Attached Files

                    Comment


                      #25
                      Hi isomorphic, did you reproduce the problem.

                      I think we are getting nearer.

                      Thanks for the effort!

                      Pablo

                      Comment


                        #26
                        Hi isomorphic,

                        Did you reproduce the problem?

                        Is this the way the cubegrid needs to be used?

                        I need to develop a module in my app with cubegrid but I am getting the problem and I cant go on.

                        I hope you could reproduce the problem to find a solution, or in other way tell me how to use the cubegrid from a fetch operation.

                        Thanks in advance and looking forward your answer.

                        Pablo

                        Comment


                          #27
                          Hi Pablo
                          We spent some time attempting to reproduce this with your test case and it's working for us.

                          We tested using the most recent SGWT 3.0p branch power edition download (Dated March 5, 2012), and the analytics jar from the same date.

                          We tested by modifying the default "built in ds" example, using the following steps from a fresh download of the sgwt power package:

                          1- set up the "Built in ds" sample in Eclipse

                          2- added analytics.jar to the classpath and inherit the analytics module in the gwt.xml file

                          3- adding the mysql-connector-java jar to the classpath of the project (so the jdbc driver is available)

                          4- added your TestCase.java class to the client package in the sample (tweaking the source to remove the two (unused) references to resources in org.gwtmultipage.client)

                          5- added the testcase.ds.xml file to the ds directory and modified the BuiltInDS.html file to load the new dataSource:
                          Code:
                              <script src="builtinds/sc/DataSourceLoader?dataSource=supplyItem,animals,employees,testcase"></script>
                          6- modified the server.properties file to make the default database be "Mysql" rather than "HSQLDB" (and of course ensuring the properties refer to the live mysql instance)

                          7- Execute the .sql script to build the database table and import your test data to the mysql database.


                          --
                          Having taken these steps we should be seeing exactly what you're seeing, but we're not. For us the CubeGrid and the ListGrid both populate with data. Note that if you run the app when the dataSource contains no data we were seeing an exception you mentioned earlier in the thread [i]this.rowFields[0] is undefined but this went away as soon as we ran the .sql script to import valid test data.

                          If you haven't already, you should probably test against the most recent nightly.
                          If that doesn't get things working for you there must be something else going on with your setup. Either there are application differences between the test case and your live app code that are responsible, or its something else, like a browser specific bug. Not much more we can suggest without seeing the problem on our end

                          Thanks
                          Isomorphic Software

                          Comment

                          Working...
                          X