// dimension, and the Source objects for them.
MdmPrimaryDimension mdmCustDim = getMdmPrimaryDimension("CUSTOMER_AW");
MdmLevelHierarchy mdmShipmentsHIer = (MdmLevelHierarchy)
getContext().getHierarchyByName(mdmCustDim, "SHIPMENTS_AW");
Source custDim = mdmCustDim.getSource();
StringSource shipments = (StringSource) mdmShipmentsHIer.getSource();
// Get the parent attribute for the hierarchy and the value description
// attribute for the dimension, and the Source objects for them.
MdmAttribute mdmParentAttr = mdmShipmentsHIer.getParentAttribute();
MdmAttribute mdmCustValDescAttr = mdmCustDim.getValueDescriptionAttribute();
Source shipmentsParentAttr = mdmParentAttr.getSource();
Source custValDescAttr = mdmCustValDescAttr.getSource();
// Specify a parent value from the hierarchy.
Source parentValue =
shipments.selectValue("SHIPMENTS_AW::WAREHOUSE_AW::17");
// Example 1: Using the full recursiveJoin method signature.
// Create a Source that specifies the parent value and its children.
Source parentAndChildren =
shipments.recursiveJoin(custDim.value(),
parentValue,
shipmentsParentAttr,
Source.COMPARISON_RULE_SELECT,
true,
true,
5,
false);
// Create a Source that has the value descriptions for the parent and
// child values.
Source parentAndChildrenWithDescr = custValDescAttr.join(parentAndChildren);
// Prepare and commit the Transaction.
prepareAndCommit();
// Create a Cursor for parentAndChildrenWithDescr and display its values.
println("\nUsing the full recursiveJoin method signature.");
getContext().displayResult(parentAndChildrenWithDescr);
// Example 2: recursiveJoin(Source joined, String comparison,
// Source parent, int comparisonRule)
// Using a single String as the comparison, select the parent values and
// their children.
Source parentAndChildrenShortcut =
shipments.recursiveJoin(custDim.value(),
"SHIPMENTS_AW::WAREHOUSE_AW::17",
shipmentsParentAttr,
Source.COMPARISON_RULE_SELECT);
// Add the value descriptions to the selections.
Source parentAndChildrenShortcutWithDescr =
custValDescAttr.join(parentAndChildrenShortcut);
prepareAndCommit();
println("\nUsing the recursiveJoin(Source joined, " +
"String comparison,\n" +
"Source parent, int comparisonRule) method.");
getContext().displayResult(parentAndChildrenShortcutWithDescr);
// Example 3: recursiveJoin(Source joined, String[] comparison,
// Source parent, int comparisonRule)
// Using a String array as the comparison, select the parent values and
// their children.
Source parentsAndChildrenShortcut =
shipments.recursiveJoin(custDim.value(),
new String[]
{"SHIPMENTS_AW::WAREHOUSE_AW::17",
"SHIPMENTS_AW::WAREHOUSE_AW::18"},
shipmentsParentAttr,
Source.COMPARISON_RULE_SELECT);
// Add the value descriptions to the selections.
Source parentsAndChildrenShortcutWithDescr =
custValDescAttr.join(parentsAndChildrenShortcut);
prepareAndCommit();
println("\nUsing the recursiveJoin(Source joined, " +
"String[] comparison,\n" +
"Source parent, int comparisonRule) method.");
getContext().displayResult(parentsAndChildrenShortcutWithDescr);
// Example 4: selectDescendants(Source comparison, Source parent)
// Select the parent value and its descendants.
Source parentAndChildrenShortcut2 =
shipments.selectDescendants(
getExpressDataProvider()
.createConstantSource("SHIPMENTS_AW::WAREHOUSE_AW::17"),
shipmentsParentAttr);
// Add the value descriptions to the selections.
Source parentAndChildrenShortcut2WithDescr =
custValDescAttr.join(parentAndChildrenShortcut2);
prepareAndCommit();
println("\nUsing the selectDescendants(Source comparison, " +
"Source parent) method.");
getContext().displayResult(parentAndChildrenShortcut2WithDescr);
// Example 5: sortDescendingHierarchically(Source joined, Source parent,
// boolean parentsFirst,
// boolean parentsRestrictedToBase)
// Select the descendants of a REGION value, which is the level above the
// WAREHOUSE level.
Source custSel = shipments.selectDescendants(
getExpressDataProvider()
.createConstantSource("SHIPMENTS_AW::REGION_AW::8"),
shipmentsParentAttr);
// Sort the selection hierarchically in descending order, with the parent
// values appearing after their children.