001    /*
002    // $Id: //open/mondrian-release/3.2/src/main/mondrian/rolap/RolapVirtualCubeMeasure.java#2 $
003    // This software is subject to the terms of the Eclipse Public License v1.0
004    // Agreement, available at the following URL:
005    // http://www.eclipse.org/legal/epl-v10.html.
006    // Copyright (C) 2006-2010 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package mondrian.rolap;
011    
012    import mondrian.olap.*;
013    
014    import java.util.Map;
015    
016    /**
017     * Measure which is defined in a virtual cube, and based on a stored measure
018     * in one of the virtual cube's base cubes.
019     *
020     * @author jhyde
021     * @version $Id: //open/mondrian-release/3.2/src/main/mondrian/rolap/RolapVirtualCubeMeasure.java#2 $
022     * @since Aug 18, 2006
023     */
024    public 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 CellFormatter getFormatter() {
074            return cubeMeasure.getFormatter();
075        }
076    
077        public Map<String, Annotation> getAnnotationMap() {
078            return annotationMap;
079        }
080    }
081    
082    // End RolapVirtualCubeMeasure.java