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) 2007-2011 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.olap4j; 011 012import mondrian.olap.Property; 013import mondrian.rolap.*; 014 015import org.olap4j.metadata.Datatype; 016import org.olap4j.metadata.Measure; 017 018/** 019 * Implementation of {@link org.olap4j.metadata.Measure} 020 * for the Mondrian OLAP engine, 021 * as a wrapper around a mondrian 022 * {@link mondrian.rolap.RolapStoredMeasure}. 023 * 024 * @author jhyde 025 * @since Dec 10, 2007 026 */ 027class MondrianOlap4jMeasure 028 extends MondrianOlap4jMember 029 implements Measure 030{ 031 MondrianOlap4jMeasure( 032 MondrianOlap4jSchema olap4jSchema, 033 RolapMeasure measure) 034 { 035 super(olap4jSchema, measure); 036 } 037 038 public Aggregator getAggregator() { 039 if (!(member instanceof RolapStoredMeasure)) { 040 return Aggregator.UNKNOWN; 041 } 042 final RolapAggregator aggregator = 043 ((RolapStoredMeasure) member).getAggregator(); 044 if (aggregator == RolapAggregator.Avg) { 045 return Aggregator.AVG; 046 } else if (aggregator == RolapAggregator.Count) { 047 return Aggregator.COUNT; 048 } else if (aggregator == RolapAggregator.DistinctCount) { 049 return Aggregator.UNKNOWN; 050 } else if (aggregator == RolapAggregator.Max) { 051 return Aggregator.MAX; 052 } else if (aggregator == RolapAggregator.Min) { 053 return Aggregator.MIN; 054 } else if (aggregator == RolapAggregator.Sum) { 055 return Aggregator.SUM; 056 } else { 057 return Aggregator.UNKNOWN; 058 } 059 } 060 061 public Datatype getDatatype() { 062 final String datatype = 063 (String) member.getPropertyValue(Property.DATATYPE.getName()); 064 if (datatype != null) { 065 if (datatype.equals("Integer")) { 066 return Datatype.INTEGER; 067 } else if (datatype.equals("Numeric")) { 068 return Datatype.DOUBLE; 069 } 070 } 071 return Datatype.STRING; 072 } 073} 074 075// End MondrianOlap4jMeasure.java