To code a SortSpecification
object, create the following objects, which are found in the oracle.dss.selection
package, as needed:
ConditionSortStep
-- Used for alphabetical, chronological, hierarchical, measure-based, and attribute-based sorting. If hierarchical sorting is specified, then only a single hierarchical ConditionSortStep
is allowed.
MemberSortStep
-- Used for manual sorting such as "Move X before Y."
Note: All ConditionSortStep
objects are evaluated before MemberSortStep
objects.
Sort ascending by product name. The following code creates the required ConditionSortStep.
//strProductDim is the unique identifier of the Product dimension //strStandardHier is the unique identifier of the Standard hierarchy // SortSpec sortSpec = new SortSpec(); ConditionSortStep condSortStep1 = new ConditionSortStep ( strProductDim, strStandardHier, ConditionSortStep.ALPHABETICAL, ConditionSortStep.ASCENDING); sortSpec.addConditionSortStep (condSortStep1);
Sort by sales, descending, for January, 2002, for regions of the world, and for the total channel. You can use a QDR in measure-based sorting to reference the desired data.
The following code creates the QDR.
//strSalesMeasure is the unique identifier for the Sales measure //strSalesMeasureDim is the unique identifier for the Sales measure dimension //strTimeDim is the unique identifier for the Time dimension //strGeogDim is the unique identifier for the Geography dimension //strChannelDim is the unique identifier for the Channel dimension // m_qdr1 = new OlapQDR (strSalesMeasureDim, strTimeDim + ":JAN2002; " + strGeogDim + ":WORLD;" + strChannelDim + ":TOTALCHANNEL"); m_qdr1.addDimMemberPair (strSalesMeasureDim, strSalesMeasure);
The following code uses m_qdr1 to create a measure-based ConditionSortStep.
ConditionSortStep condSortStep2 = new ConditionSortStep ( strProductDim, strStandardHier, ConditionSortStep.MEASURE, ConditionSortStep.DESCENDING, strSalesMeas, m_qdr1); sortSpec.addConditionSortStep (condSortStep2);
Move the Accounting Division members first.
Vector vAcc = new Vector (); vAcc.addElement ("ACCDIV"); MemberSortStep memberSortStep1 = new MemberSortStep ( strProductDim, new MemberStep (strProductDim, vAcc), MemberSortStep.FIRST, null); sortSpec.addMemberSortStep (memberSortStep1);
The following code adds a SortSpec object to an existing selection sel.
sel.setSortSpec (sortSpec);