001    /*
002    // $Id: //open/mondrian/src/main/mondrian/rolap/sql/TupleConstraint.java#10 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 2004-2005 TONBELLER AG
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package mondrian.rolap.sql;
011    
012    import mondrian.olap.Evaluator;
013    import mondrian.rolap.RolapCube;
014    import mondrian.rolap.RolapLevel;
015    import mondrian.rolap.RolapMember;
016    import mondrian.rolap.aggmatcher.AggStar;
017    
018    /**
019     * Restricts the SQL result of {@link mondrian.rolap.TupleReader}. This is also
020     * used by
021     * {@link mondrian.rolap.SqlMemberSource#getMembersInLevel(RolapLevel, int, int, TupleConstraint)}.
022     *
023     * @see mondrian.rolap.TupleReader
024     * @see mondrian.rolap.SqlMemberSource
025     *
026     * @author av
027     * @version $Id: //open/mondrian/src/main/mondrian/rolap/sql/TupleConstraint.java#10 $
028     */
029    public interface TupleConstraint extends SqlConstraint {
030        /**
031         * Modifies a Level.Members query.
032         *
033         * @param sqlQuery the query to modify
034         * @param baseCube base cube for virtual cube constraints
035         */
036        public void addConstraint(SqlQuery sqlQuery, RolapCube baseCube);
037    
038        /**
039         * Will be called multiple times for every "group by" level in
040         * Level.Members query, i.e. the level that contains the members and all
041         * parent levels except All.
042         * If the condition requires so,
043         * it may join the levels table to the fact table.
044         *
045         * @param query the query to modify
046         * @param baseCube base cube for virtual cube constraints
047         * @param aggStar Aggregate table, or null if query is against fact table
048         * @param level the level which is accessed in the Level.Members query
049         */
050        public void addLevelConstraint(
051            SqlQuery query,
052            RolapCube baseCube,
053            AggStar aggStar,
054            RolapLevel level);
055    
056        /**
057         * When the members of a level are fetched, the result is grouped
058         * by into parents and their children. These parent/children are
059         * stored in the parent/children cache, whose key consists of the parent
060         * and the MemberChildrenConstraint#hashKey(). So we need a matching
061         * MemberChildrenConstraint to store the parent with its children into
062         * the parent/children cache.
063         * <p>
064         * The returned MemberChildrenConstraint must be one that would have returned
065         * the same children for the given parent as the MemberLevel query has found
066         * for that parent.
067         * <p>
068         * If null is returned, the parent/children will not be cached (but
069         * the level/members still will be).
070         */
071        MemberChildrenConstraint getMemberChildrenConstraint(RolapMember parent);
072    
073        /**
074         * @return the evaluator currently associated with the constraint; null
075         * if there is no associated evaluator
076         */
077        public Evaluator getEvaluator();
078    }
079    
080    // End TupleConstraint.java