println("Creating a Cube and Pivoting Its Edges");
// Get the MdmMeasure for units.
MdmMeasure mdmUnits = getMdmMeasure("UNITS_AW");
// Get the Source for the measure.
Source units = mdmUnits.getSource();
// Get the dimensions of the measure and the default hierarchies of
// the dimensions.
MdmPrimaryDimension mdmProdDim = getMdmPrimaryDimension("DEPARTMENT");
MdmPrimaryDimension mdmTimeDim = getMdmPrimaryDimension("MYTIME");
MdmPrimaryDimension mdmChanDim = getMdmPrimaryDimension("MEDIA");
MdmValueHierarchy mdmProdDefLvlHier = (MdmValueHierarchy)
mdmProdDim.getDefaultHierarchy();
MdmLevelHierarchy mdmTimeDefLvlHier = (MdmLevelHierarchy)
mdmTimeDim.getDefaultHierarchy();
MdmLevelHierarchy mdmChanDefLvlHier = (MdmLevelHierarchy)
mdmChanDim.getDefaultHierarchy();
// Get the Source objects for the hierarchies.
StringSource prodHier = (StringSource) mdmProdDefLvlHier.getSource();
StringSource timeHier = (StringSource) mdmTimeDefLvlHier.getSource();
StringSource chanHier = (StringSource) mdmChanDefLvlHier.getSource();
// Get the DataProvider.
ExpressDataProvider dp = getExpressDataProvider();
// Get the short description attribute for the dimensions and the
// Source objects for the attributes.
MdmAttribute mdmProdShortDescr =
mdmProdDim.getShortValueDescriptionAttribute();
Source prodShortDescr = mdmProdShortDescr.getSource();
MdmAttribute mdmTimeShortDescr =
mdmTimeDim.getShortValueDescriptionAttribute();
Source timeShortDescr = mdmTimeShortDescr.getSource();
// Get the short description attribute for the channel dimension.
MdmAttribute mdmChanShortDescr =
mdmChanDim.getShortValueDescriptionAttribute();
Source chanShortDescr = mdmChanShortDescr.getSource();
// Create Parameter objects with values from the CUSTOMER_AW and
// PRODUCT_AW dimensions.
StringParameter prodParam =
new StringParameter(dp, "DEPT::DEPT::0");
// Create parameterized Source objects for the default hierarchies of
// the CUSTOMER_AW and PRODUCT_AW dimensions.
StringSource prodParamSrc = dp.createParameterizedSource(prodParam);
// Create derived Source objects from the hierarchies, using the
// parameterized Source objects as the comparison Source objects.
Source paramProdSel = prodHier.join(prodHier.value(), prodParamSrc);
// Select elements from the other dimensions of the measure
Source timeSel = timeHier.selectValues(new String[]
{"TIMEHIER::DAY::20110101",
"TIMEHIER::DAY::20110102",
"TIMEHIER::DAY::20110103"});
Source chanSel = chanHier.selectValues(new String[]
{"MEDIA::MEDIA::0",
"MEDIA::MEDIA::1",
"MEDIA::MEDIA::2"});
// Join the dimension selections to the short description attributes
// for the dimensions.
Source columnEdge = chanSel.join(chanShortDescr);
Source rowEdge = timeSel.join(timeShortDescr);
Source page1 = paramProdSel.join(prodShortDescr);
// Join the dimension selections to the measure.
Source cube = units.join(columnEdge)
.join(rowEdge)
.join(page1);
// Prepare and commit the current Transaction.
prepareAndCommit();