001/* 002// $Id: DrillReplaceTransform.java 482 2012-01-05 23:27:27Z jhyde $ 003// 004// Licensed to Julian Hyde under one or more contributor license 005// agreements. See the NOTICE file distributed with this work for 006// additional information regarding copyright ownership. 007// 008// Julian Hyde licenses this file to you under the Apache License, 009// Version 2.0 (the "License"); you may not use this file except in 010// compliance with the License. You may obtain a copy of the License at: 011// 012// http://www.apache.org/licenses/LICENSE-2.0 013// 014// Unless required by applicable law or agreed to in writing, software 015// distributed under the License is distributed on an "AS IS" BASIS, 016// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 017// See the License for the specific language governing permissions and 018// limitations under the License. 019*/ 020package org.olap4j.transform; 021 022import org.olap4j.Axis; 023import org.olap4j.CellSet; 024import org.olap4j.mdx.ParseTreeNode; 025import org.olap4j.metadata.Member; 026 027/** 028 * Drill replace transformation 029 * 030 * <p>Description: Replaces a member at a specific position on an axis by its 031 * children. The member to drill is identified from a CellSet with the axis, 032 * positionOrdinalInAxis and memberOrdinalInPosition arguments. 033 * 034 * <p>Example of use: the user clicks on a member in a crosstab axis, in order 035 * to see its children. 036 * 037 * <p>Applicability: this transform is applicable only to members in a query 038 * that are drillable, i.e. non-leaf members. The CellSet resulting from the 039 * execution of the initial MDX query must also be available. 040 * 041 * @author etdub 042 * @version $Id: DrillReplaceTransform.java 482 2012-01-05 23:27:27Z jhyde $ 043 * @since Jul 30, 2008 044 */ 045public class DrillReplaceTransform extends AxisTransform { 046 047 // private final int positionOrdinalInAxis; 048 // private final int memberOrdinalInPosition; 049 // private final CellSet cellSet; 050 051 // private final Position positionToDrill; 052 private final Member memberToDrill; 053 // private final List<Member> pathToMember; 054 055 /** 056 * ctor 057 * 058 * @param axis axis (of the resulting CellSet) the member to be drilled 059 * @param positionOrdinalInAxis position ordinal in axis of the member to 060 * be drilled 061 * @param memberOrdinalInPosition ordinal in position of the member to be 062 * drilled 063 * @param cellSet the CellSet resulting from execution of the query to be 064 * transformed 065 */ 066 public DrillReplaceTransform( 067 Axis axis, 068 int positionOrdinalInAxis, 069 int memberOrdinalInPosition, 070 CellSet cellSet) 071 { 072 super(axis); 073 074 // this.positionOrdinalInAxis = positionOrdinalInAxis; 075 // this.memberOrdinalInPosition = memberOrdinalInPosition; 076 // this.cellSet = cellSet; 077 078 // Position positionToDrill = 079 // TransformUtil.getPositionFromCellSet(axis, positionOrdinalInAxis, 080 // cellSet); 081 memberToDrill = TransformUtil.getMemberFromCellSet( 082 axis, positionOrdinalInAxis, memberOrdinalInPosition, cellSet); 083 // pathToMember = getPathToMember(positionToDrill, 084 // memberOrdinalInPosition); 085 } 086 087 public String getName() { 088 return "Drill Replace On Member"; 089 } 090 091 public String getDescription() { 092 return "Drills and replace (by its children) a member on an axis"; 093 } 094 095 @Override 096 protected ParseTreeNode processAxisExp(ParseTreeNode exp) { 097 // FIXME: for now only 1 dimension on an axis is supported, 098 // (naive implementation only used for proof of concept) 099 return MdxHelper.makeSetCallNode( 100 MdxHelper.makeChildrenCallNode( 101 MdxHelper.makeMemberNode(memberToDrill))); 102 } 103 104} 105 106// End DrillReplaceTransform.java 107 108