001    /*
002    // $Id: DrillReplaceTransform.java 246 2009-06-11 00:35:21Z jhyde $
003    // This software is subject to the terms of the Eclipse Public License v1.0
004    // Agreement, available at the following URL:
005    // http://www.eclipse.org/legal/epl-v10.html.
006    // Copyright (C) 2008-2008 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package org.olap4j.transform;
011    
012    import org.olap4j.Axis;
013    import org.olap4j.CellSet;
014    import org.olap4j.mdx.ParseTreeNode;
015    import org.olap4j.metadata.Member;
016    
017    /**
018     * Drill replace transformation
019     *
020     * <p>Description: Replaces a member at a specific position on an axis by its
021     * children. The member to drill is identified from a CellSet with the axis,
022     * positionOrdinalInAxis and memberOrdinalInPosition arguments.
023     *
024     * <p>Example of use: the user clicks on a member in a crosstab axis, in order
025     * to see its children.
026     *
027     * <p>Applicability: this transform is applicable only to members in a query
028     * that are drillable, i.e. non-leaf members. The CellSet resulting from the
029     * execution of the initial MDX query must also be available.
030     *
031     * @author etdub
032     * @version $Id: DrillReplaceTransform.java 246 2009-06-11 00:35:21Z jhyde $
033     * @since Jul 30, 2008
034     */
035    public class DrillReplaceTransform extends AxisTransform {
036    
037        // private final int positionOrdinalInAxis;
038        // private final int memberOrdinalInPosition;
039        // private final CellSet cellSet;
040    
041        // private final Position positionToDrill;
042        private final Member memberToDrill;
043        // private final List<Member> pathToMember;
044    
045        /**
046         * ctor
047         *
048         * @param axis axis (of the resulting CellSet) the member to be drilled
049         * @param positionOrdinalInAxis position ordinal in axis of the member to
050         *                              be drilled
051         * @param memberOrdinalInPosition ordinal in position of the member to be
052         *                                drilled
053         * @param cellSet the CellSet resulting from execution of the query to be
054         *                transformed
055         */
056        public DrillReplaceTransform(
057            Axis axis,
058            int positionOrdinalInAxis,
059            int memberOrdinalInPosition,
060            CellSet cellSet)
061        {
062            super(axis);
063    
064            // this.positionOrdinalInAxis = positionOrdinalInAxis;
065            // this.memberOrdinalInPosition = memberOrdinalInPosition;
066            // this.cellSet = cellSet;
067    
068            // Position positionToDrill =
069            //     TransformUtil.getPositionFromCellSet(axis, positionOrdinalInAxis,
070            //          cellSet);
071            memberToDrill = TransformUtil.getMemberFromCellSet(
072                axis, positionOrdinalInAxis, memberOrdinalInPosition, cellSet);
073            // pathToMember = getPathToMember(positionToDrill,
074            //        memberOrdinalInPosition);
075        }
076    
077        public String getName() {
078            return "Drill Replace On Member";
079        }
080    
081        public String getDescription() {
082            return "Drills and replace (by its children) a member on an axis";
083        }
084    
085        @Override
086        protected ParseTreeNode processAxisExp(ParseTreeNode exp) {
087            // FIXME: for now only 1 dimension on an axis is supported,
088            // (naive implementation only used for proof of concept)
089            return MdxHelper.makeSetCallNode(
090                    MdxHelper.makeChildrenCallNode(
091                            MdxHelper.makeMemberNode(memberToDrill)));
092        }
093    
094    }
095    
096    // End DrillReplaceTransform.java