protected void run() throws Exception
{
println("Creating a Custom Member of the MdmMeasureDimension\n");
// Get the measures and the Source objects for the measures.
MdmMeasure mdmUnitPrice = getMdmMeasure("UNIT_PRICE_AW");
NumberSource unitPrice = (NumberSource) mdmUnitPrice.getSource();
MdmMeasure mdmUnitCost = getMdmMeasure("UNIT_COST_AW");
NumberSource unitCost = (NumberSource) mdmUnitCost.getSource();
// Get the primary dimensions for the measures.
MdmPrimaryDimension mdmProdDim = getMdmPrimaryDimension("PRODUCT_AW");
MdmPrimaryDimension mdmTimeDim = getMdmPrimaryDimension("TIME_AW");
// Get the default level hierarchies of the dimensions.
MdmLevelHierarchy mdmProdPrimary = (MdmLevelHierarchy)
mdmProdDim.getDefaultHierarchy();
MdmLevelHierarchy mdmCalendarYear = (MdmLevelHierarchy)
mdmTimeDim.getDefaultHierarchy();
// Get the Source objects for the hierarchies.
StringSource prodHier = (StringSource) mdmProdPrimary.getSource();
StringSource calendarYear = (StringSource) mdmCalendarYear.getSource();
// Get the root MdmSchema.
MdmSchema rootSchema = getMdmMetadataProvider().getRootSchema();
// Get the MdmMeasureDimension of the root MdmSchema, and the Source for it.
MdmMeasureDimension mdmMeasDim = rootSchema.getMeasureDimension();
StringSource measDim = (StringSource) mdmMeasDim.getSource();
// Specify a calculation for the custom measure.
Source calculation = unitPrice.minus(unitCost);
// Create custom measure as a custom member of the MdmMeasureDimension.
MdmMeasure mdmMarkup = mdmMeasDim.createCustomMeasure("MARKUP_AW",
rootSchema,
calculation,
10);
// Set the short and long value descriptions.
mdmMarkup.setShortDescription("UNIT_PRICE_AW MINUS UNIT_COST_AW");
mdmMarkup.setDescription("Unit price minus unit cost.");
// Produce a Source that specifies the values of the members of the
// measure dimension.
Source measDimSel = measDim.selectValues(new String[]
{mdmMarkup.getValue(),
mdmUnitCost.getValue(),
mdmUnitPrice.getValue()});
// Get the Source objects for the short value description attributes
// of the Product and Time dimensions.