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