Share on Google+Share on Google+

Create OLAPQuary in OLAPDataGrid control in Flex4

Advertisement
There are the following procedure for creating a query:

Create OLAPQuary in OLAPDataGrid control in Flex4:

There are the following procedure for creating a query:

1. Make a cube for a query.
2. Make an instance of the OLAPOuery class which is used to represent the query.
3. Make an instance of the OLAPQueryAxis class to represent the rows of the          query.
4. Make an instance of the OLAPSet class to define the members that provide the row axis information.
5. Make an instance of the OLAPQueryAxis class to represent the columns of the query.
6. Make an instance of the OLAPSet class to define the members that provide the column axis information.
7. Make an instance of the OLAPQueryAxis class to specify a slicer axis (Optionally).
8. Make an instance of the OLAPSet class to define the members that provide the slicer axis information.
9. Execute the Query.
10.Now pass the query results to the OLAPDataGrid control.

Example:

 

// Create Quary

public function getQuery(cube:IOLAPCube):IOLAPQuery {

// instance of OLAPQuery

var query:OLAPQuery = new OLAPQuery;

// instance of OLAPQueryAxis class for row

var rowQueryAxis:IOLAPQueryAxis =

query.getAxis(OLAPQuery.ROW_AXIS);

// instance of OLAPSet class

var productSet:OLAPSet = new OLAPSet;

productSet.addElements(

cube.findDimension("ProductDimention").findAttribute("Product").children);

rowQueryAxis.addSet(productSet);

// instance of OLAPQueryAxis class for column

var colQueryAxis:IOLAPQueryAxis =

query.getAxis(OLAPQuery.COLUMN_AXIS);

// instance of OLAPSet class

var quarterSet:OLAPSet= new OLAPSet;

quarterSet.addElements(

cube.findDimension("QuarterDimention").findAttribute("Quarter").children);

colQueryAxis.addSet(quarterSet);

return query;

}

// Execute the Quary

public function runQuery(event:CubeEvent):void {

var cube:IOLAPCube = IOLAPCube(event.currentTarget);

var query:IOLAPQuery = getQuery(cube);

var token:AsyncToken = cube.execute(query);

token.addResponder(new AsyncResponder(showResult, showFault));

}

// Query Fault

public function showFault(result:Object, token:Object):void {

Alert.show("Error in query.");

}

// Query Success

public function showResult(result:Object, token:Object):void {

if (!result) {

Alert.show("No results from query.");

return;

}

productDataGrid.dataProvider= result as OLAPResult;

}

Advertisements

Advertisement

Posted on: June 19, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.