001    /*
002    // This software is subject to the terms of the Common Public License
003    // Agreement, available at the following URL:
004    // http://www.opensource.org/licenses/cpl.html.
005    // Copyright (C) 2004-2005 TONBELLER AG
006    // All Rights Reserved.
007    // You must accept the terms of that agreement to use this software.
008    */
009    package mondrian.rolap;
010    
011    import java.util.List;
012    
013    import mondrian.olap.Evaluator;
014    import mondrian.rolap.sql.TupleConstraint;
015    import mondrian.rolap.sql.MemberChildrenConstraint;
016    import mondrian.rolap.sql.SqlQuery;
017    import mondrian.rolap.aggmatcher.AggStar;
018    
019    /**
020     * TupleConstaint which restricts the result of a tuple sqlQuery to a
021     * set of parents.  All parents must belong to the same level.
022     *
023     * @author av
024     * @since Nov 10, 2005
025     * @version $Id: //open/mondrian/src/main/mondrian/rolap/DescendantsConstraint.java#12 $
026     */
027    class DescendantsConstraint implements TupleConstraint {
028        List<RolapMember> parentMembers;
029        MemberChildrenConstraint mcc;
030    
031        /**
032         * Creates a DescendantsConstraint.
033         *
034         * @param parentMembers list of parents all from the same level
035         * @param mcc the constraint that would return the children for each single parent
036         */
037        public DescendantsConstraint(
038            List<RolapMember> parentMembers,
039            MemberChildrenConstraint mcc)
040        {
041            this.parentMembers = parentMembers;
042            this.mcc = mcc;
043        }
044    
045        public void addConstraint(SqlQuery sqlQuery, RolapCube baseCube) {
046            mcc.addMemberConstraint(sqlQuery, baseCube, null, parentMembers);
047        }
048    
049        public void addLevelConstraint(
050            SqlQuery sqlQuery,
051            RolapCube baseCube,
052            AggStar aggStar,
053            RolapLevel level)
054        {
055            mcc.addLevelConstraint(sqlQuery, baseCube, aggStar, level);
056        }
057    
058        public MemberChildrenConstraint getMemberChildrenConstraint(RolapMember parent) {
059            return mcc;
060        }
061    
062        /**
063         * {@inheritDoc}
064         *
065         * <p>This implementation returns null, because descendants is not cached.
066         */
067        public Object getCacheKey() {
068            return null;
069        }
070    
071        public Evaluator getEvaluator() {
072            return null;
073        }
074    }
075    
076    // End DescendantsConstraint.java