Multi-Dimensional Standard Table Example

 

The following coding example reads data items from an information map that uses a multi-dimension data.

/**

*

* A simple method creates a result set for a simple multidimensional table.

*

* @param list of data items in an information map.

* @param input data selection

* @return modified  data selection

*

* @throws Exception

*/

private  com.sas.iquery.execution2.ResultSetInterface SimpleOLAPTableDisplay(java.util.List dsDataItems, com.sas.iquery.metadata.business.DataSelection ds) throws Exception      

          // Create connection and assign roles to data items.

          java.util.Map results =null;

com.sas.iquery.dataretrieval.QueryConnector m_queryConnector = new com.sas.iquery.dataretrieval.QueryConnector();

  for(int i = 0; i < dsDataItems.size(); i++)

{         com.sas.iquery.metadata.business.DataItem tdi = (com.sas.iquery.metadata.business.DataItem)dsDataItems.get(i);

String label = tdi.getLabel();

 

// Assign Column to Sales_sum measure, all other dataitem will be assigned a role of ROW

if ( label.equalsIgnoreCase("SALES_SUM") )

{ ds.addResultItem(tdi, com.sas.iquery.metadata.business.Role.COLUMN);

}

else

{ ds.addResultItem(tdi, com.sas.iquery.metadata.business.Role.ROW);

}

}

 

// Perform query and get results.

java.util.List selections = new java.util.ArrayList();

selections.add( ds );

ds.setID("SimpleOLAPTable");

results = m_queryConnector.retrieveQueryResultMap( selections );

 

// Get Results interface to display table if desired.

com.sas.iquery.execution2.ResultSetInterface resultSet = (com.sas.iquery.execution2.ResultSetInterface)results.get( ds.getID() );

return resultSet;

}