OLAPTableView: Customizing an OLAP Table |
Data Source: OLAP Information Map
This example includes the following customizations:
Please install the latest webAF template updates prior to building this example. For more information about the server-side example templates used by this example, see Web Application Example Templates and Built-in Web Application Templates and Options.
The following example is not meant to be a complete Web application, rather it is to show how to use a particular component(s). The example does not address the issue of immediately freeing up resources when the user navigates off the Web application or closes the Web browser. Any necessary resources created in the example will stay around until the associated HTTPSession times out. If this example is used in a multi-user environment, it is possible to exhaust the available resources until HTTPSessions time out and free up their associated resources.
The following assumptions are made for all SAS AppDev Studio examples that use an information map as a data source. Please refer to the SAS Intelligence Platform administration documentation for information about any of these topics.
OLAPTableView
.InfoMapOLAPTableViewExampleControllerServlet.java
file in the Files Tab
of the Project Navigator.
Replace ENTER_MAP_NAME_HERE
in the following code:
String mapName = ENTER_MAP_NAME_HERE;with URL string for your information map.
omr_password
) in the
sas_metadata_source_omr.properties
file located in the
web-inf\conf
directory.
This password is used when deploying Foundation Services.metadata-password
)
under the InfoMapOLAPTableViewExampleControllerServlet's initial parameters in the
web.xml
file located in the web-inf
directory.
This password is used to get a user and session context from the Foundation Services.Set the columnPageSize and rowPageSize properties on the OLAPTableView tag.
<sas:OLAPTableView columnPageSize="4" rowPageSize="4"> </sas:OLAPTableView>
<sas:StyleMapKey key="OLAPTABLEVIEW_ROW_HEADER_STYLE" classid="OLAPTableRowHeader" style="background-color: lightgreen;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_HEADER_STYLE" classid="OLAPTableColumnHeader" style="background-color: lightblue;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_MEASURE_HEADER_STYLE" classid="OLAPTableColumnMeasureHeader" style="background-color: aqua;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_ROW_MEASURE_HEADER_STYLE" classid="OLAPTableRowMeasureHeader" style="background-color: yellow;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_ROW_TITLE_HEADER_STYLE" classid="OLAPTableRowTitleHeader" style="background-color: lime;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_EMPTY_ROW_TITLE_HEADER_STYLE" classid="OLAPTableEmptyRowTitleHeader" style="background-color: lime;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_COLUMN_TITLE_HEADER_STYLE" classid="OLAPTableColumnTitleHeader" style="background-color: lightskyblue;"/> <sas:StyleMapKey key="OLAPTABLEVIEW_DATA_STYLE" classid="OLAPTableData" style="background-color: orange;"/>
DataSelection dataSelection = DataSelectionFactory.newSampleDataSelection(informationMap, null);
with the following one:
DataSelection dataSelection = populateDataSelection(informationMap);
/* * Create and populate a data selection from an information map. * This example puts PRODUCTS on the rows and CUSTOMERS on the columns, * and then two measures on the columns. * Note that PRODUCTS and CUSTOMERS may not exist in your information map, * use items that do exist. */ private DataSelection populateDataSelection(InformationMap informationMap) throws MetadataException { DataSelection dataSelection = DataSelectionFactory.newDataSelection(informationMap); List dataItemList = informationMap.getObjects(false, DataItem.class); BusinessModel model = dataSelection.getBusinessModel(); // Add some items for (Iterator iter = dataItemList.iterator(); iter.hasNext();) { DataItem dataItem = (DataItem) iter.next(); Role currentRole = null; // NOTE: these labels (DEMOGRAPHICS and CUSTOMERS) are only samples, // use labels that exist in your InformationMap. if (dataItem.getLabel().equalsIgnoreCase("PRODUCT")) currentRole = Role.ROW; else if (dataItem.getLabel().equalsIgnoreCase("CUSTOMERS")) currentRole = Role.COLUMN; if (currentRole != null) dataSelection.addResultItem(dataItem, currentRole); } // Add some measures int numMeasures = 0; int numMeasuresToInclude = 2; for (Iterator iter = dataItemList.iterator(); iter.hasNext();) { DataItem dataItem = (DataItem) iter.next(); if (BusinessQueryOLAPUtil.isInMeasureDimension(informationMap,dataItem)) { dataSelection.addResultItem(dataItem, Role.COLUMN); if (++numMeasures >= numMeasuresToInclude) break; } } return dataSelection;
import com.sas.iquery.metadata.MetadataException; import com.sas.iquery.metadata.business.BusinessModel; import com.sas.iquery.metadata.business.DataItem; import com.sas.iquery.metadata.business.Role; import com.sas.iquery.util.BusinessQueryOLAPUtil; import java.util.Iterator; import java.util.List;