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) 2006-2011 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.rolap;
011
012import mondrian.olap.Annotation;
013import mondrian.olap.MondrianDef;
014
015import java.util.Map;
016
017/**
018 * Measure which is defined in a virtual cube, and based on a stored measure
019 * in one of the virtual cube's base cubes.
020 *
021 * @author jhyde
022 * @since Aug 18, 2006
023 */
024public class RolapVirtualCubeMeasure
025    extends RolapMemberBase
026    implements RolapStoredMeasure
027{
028    /**
029     * The measure in the underlying cube.
030     */
031    private final RolapStoredMeasure cubeMeasure;
032    private final Map<String, Annotation> annotationMap;
033
034    public RolapVirtualCubeMeasure(
035        RolapMember parentMember,
036        RolapLevel level,
037        RolapStoredMeasure cubeMeasure,
038        Map<String, Annotation> annotationMap)
039    {
040        super(parentMember, level, cubeMeasure.getName());
041        this.cubeMeasure = cubeMeasure;
042        this.annotationMap = annotationMap;
043    }
044
045    public Object getPropertyValue(String propertyName, boolean matchCase) {
046        // Look first in this member (against the virtual cube), then
047        // fallback on the base measure.
048        // This allows, for instance, a measure to be invisible in a virtual
049        // cube but visible in its base cube.
050        Object value = super.getPropertyValue(propertyName, matchCase);
051        if (value == null) {
052            value = cubeMeasure.getPropertyValue(propertyName, matchCase);
053        }
054        return value;
055    }
056
057    public RolapCube getCube() {
058        return cubeMeasure.getCube();
059    }
060
061    public Object getStarMeasure() {
062        return cubeMeasure.getStarMeasure();
063    }
064
065    public MondrianDef.Expression getMondrianDefExpression() {
066        return cubeMeasure.getMondrianDefExpression();
067    }
068
069    public RolapAggregator getAggregator() {
070        return cubeMeasure.getAggregator();
071    }
072
073    public RolapResult.ValueFormatter getFormatter() {
074        return cubeMeasure.getFormatter();
075    }
076
077    public Map<String, Annotation> getAnnotationMap() {
078        return annotationMap;
079    }
080}
081
082// End RolapVirtualCubeMeasure.java