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.rolap.sql.MemberChildrenConstraint;
014    import mondrian.rolap.sql.SqlQuery;
015    import mondrian.rolap.aggmatcher.AggStar;
016    
017    /**
018     * Restricts the SQL result set to the parent member of a
019     * MemberChildren query.  If called with a calculated member an
020     * exception will be thrown.
021     *
022     * @version $Id: //open/mondrian/src/main/mondrian/rolap/DefaultMemberChildrenConstraint.java#11 $
023     */
024    public class DefaultMemberChildrenConstraint
025        implements MemberChildrenConstraint {
026    
027        private static final MemberChildrenConstraint instance
028            = new DefaultMemberChildrenConstraint();
029    
030        /** we have no state, so all instances are equal */
031        private static final Object cacheKey = new Object();
032    
033        protected DefaultMemberChildrenConstraint() {
034        }
035    
036        public void addMemberConstraint(
037            SqlQuery sqlQuery,
038            RolapCube baseCube,
039            AggStar aggStar,
040            RolapMember parent)
041        {
042            SqlConstraintUtils.addMemberConstraint(
043                    sqlQuery, baseCube, aggStar, parent, true);
044        }
045    
046        public void addMemberConstraint(
047            SqlQuery sqlQuery,
048            RolapCube baseCube,
049            AggStar aggStar,
050            List<RolapMember> parents)
051        {
052            SqlConstraintUtils.addMemberConstraint(
053                sqlQuery, baseCube, aggStar, parents, true, false);
054        }
055    
056        public void addLevelConstraint(
057            SqlQuery query,
058            RolapCube baseCube,
059            AggStar aggStar,
060            RolapLevel level) {
061        }
062    
063        public String toString() {
064            return "DefaultMemberChildrenConstraint";
065        }
066    
067        public Object getCacheKey() {
068            return cacheKey;
069        }
070    
071        public static MemberChildrenConstraint instance() {
072            return instance;
073        }
074    
075        public int getMaxRows() {
076            return 0;
077        }
078    }
079    
080    // End DefaultMemberChildrenConstraint.java
081