// Get the CUSTOMER_AW dimension.
MdmPrimaryDimension mdmCustDim = getMdmPrimaryDimension("CUSTOMER_AW");
// Get the MARKET_SEGMENT_AW hierarchy of the dimension and the Source for it.
MdmHierarchy mdmMarketSegment =
getContext().getHierarchyByName(mdmCustDim, "MARKET_SEGMENT_AW");
StringSource mktSegment = (StringSource)mdmMarketSegment.getSource();
// Get the ancestors attribute of the hierarchy and the Source for it.
MdmAttribute mdmMarketSegmentAncestorsAttr =
mdmMarketSegment.getAncestorsAttribute();
Source mktSegmentAncestors = mdmMarketSegmentAncestorsAttr.getSource();
// Reverse the ancestors relation to get the descendants relation.
Source mktSegmentDescendants =
mktSegment.join(mktSegmentAncestors, mktSegment.value());