001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2004-2005 TONBELLER AG
008// Copyright (C) 2006-2012 Pentaho and others
009// All Rights Reserved.
010*/
011package mondrian.rolap;
012
013import mondrian.olap.Evaluator;
014import mondrian.rolap.aggmatcher.AggStar;
015import mondrian.rolap.sql.*;
016
017import java.util.List;
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 */
026class DescendantsConstraint implements TupleConstraint {
027    List<RolapMember> parentMembers;
028    MemberChildrenConstraint mcc;
029
030    /**
031     * Creates a DescendantsConstraint.
032     *
033     * @param parentMembers list of parents all from the same level
034     * @param mcc the constraint that would return the children for each single
035     * 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(
046        SqlQuery sqlQuery,
047        RolapCube baseCube,
048        AggStar aggStar)
049    {
050        mcc.addMemberConstraint(sqlQuery, baseCube, aggStar, parentMembers);
051    }
052
053    public void addLevelConstraint(
054        SqlQuery sqlQuery,
055        RolapCube baseCube,
056        AggStar aggStar,
057        RolapLevel level)
058    {
059        mcc.addLevelConstraint(sqlQuery, baseCube, aggStar, level);
060    }
061
062    public MemberChildrenConstraint getMemberChildrenConstraint(
063        RolapMember parent)
064    {
065        return mcc;
066    }
067
068    /**
069     * {@inheritDoc}
070     *
071     * <p>This implementation returns null, because descendants is not cached.
072     */
073    public Object getCacheKey() {
074        return null;
075    }
076
077    public Evaluator getEvaluator() {
078        return null;
079    }
080}
081
082// End DescendantsConstraint.java