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-2012 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.olap4j; 011 012import mondrian.olap.*; 013 014import org.olap4j.CellSetAxisMetaData; 015import org.olap4j.CellSetMetaData; 016import org.olap4j.impl.ArrayNamedListImpl; 017import org.olap4j.metadata.*; 018import org.olap4j.metadata.Cube; 019import org.olap4j.metadata.Property; 020 021import java.sql.SQLException; 022 023/** 024 * Implementation of {@link org.olap4j.CellSetMetaData} 025 * for the Mondrian OLAP engine. 026 * 027 * @author jhyde 028 * @since Jun 13, 2007 029 */ 030class MondrianOlap4jCellSetMetaData implements CellSetMetaData { 031 final MondrianOlap4jStatement olap4jStatement; 032 final Query query; 033 private final NamedList<CellSetAxisMetaData> axesMetaData = 034 new ArrayNamedListImpl<CellSetAxisMetaData>() { 035 public String getName(Object axisMetaData) { 036 return ((CellSetAxisMetaData)axisMetaData) 037 .getAxisOrdinal().name(); 038 } 039 }; 040 private final MondrianOlap4jCellSetAxisMetaData filterAxisMetaData; 041 042 MondrianOlap4jCellSetMetaData( 043 MondrianOlap4jStatement olap4jStatement, 044 Query query) 045 { 046 this.olap4jStatement = olap4jStatement; 047 this.query = query; 048 049 for (final QueryAxis queryAxis : query.getAxes()) { 050 axesMetaData.add( 051 new MondrianOlap4jCellSetAxisMetaData( 052 this, queryAxis)); 053 } 054 filterAxisMetaData = 055 new MondrianOlap4jCellSetAxisMetaData( 056 this, query.getSlicerAxis()); 057 } 058 059 // implement CellSetMetaData 060 061 public NamedList<Property> getCellProperties() { 062 final ArrayNamedListImpl<Property> list = 063 new ArrayNamedListImpl<Property>() { 064 public String getName(Object property) { 065 return ((Property)property).getName(); 066 } 067 }; 068 for (Property property : Property.StandardCellProperty.values()) { 069 if (query.hasCellProperty(property.getName())) { 070 list.add(property); 071 } 072 } 073 for (Property property 074 : MondrianOlap4jProperty.CELL_EXTENSIONS.values()) 075 { 076 if (query.hasCellProperty(property.getName())) { 077 list.add(property); 078 } 079 } 080 return list; 081 } 082 083 public Cube getCube() { 084 return olap4jStatement.olap4jConnection.toOlap4j(query.getCube()); 085 } 086 087 public NamedList<CellSetAxisMetaData> getAxesMetaData() { 088 return axesMetaData; 089 } 090 091 public CellSetAxisMetaData getFilterAxisMetaData() { 092 return filterAxisMetaData; 093 } 094 095 // implement ResultSetMetaData 096 097 public int getColumnCount() throws SQLException { 098 throw new UnsupportedOperationException(); 099 } 100 101 public boolean isAutoIncrement(int column) throws SQLException { 102 throw new UnsupportedOperationException(); 103 } 104 105 public boolean isCaseSensitive(int column) throws SQLException { 106 throw new UnsupportedOperationException(); 107 } 108 109 public boolean isSearchable(int column) throws SQLException { 110 throw new UnsupportedOperationException(); 111 } 112 113 public boolean isCurrency(int column) throws SQLException { 114 throw new UnsupportedOperationException(); 115 } 116 117 public int isNullable(int column) throws SQLException { 118 throw new UnsupportedOperationException(); 119 } 120 121 public boolean isSigned(int column) throws SQLException { 122 throw new UnsupportedOperationException(); 123 } 124 125 public int getColumnDisplaySize(int column) throws SQLException { 126 throw new UnsupportedOperationException(); 127 } 128 129 public String getColumnLabel(int column) throws SQLException { 130 throw new UnsupportedOperationException(); 131 } 132 133 public String getColumnName(int column) throws SQLException { 134 throw new UnsupportedOperationException(); 135 } 136 137 public String getSchemaName(int column) throws SQLException { 138 throw new UnsupportedOperationException(); 139 } 140 141 public int getPrecision(int column) throws SQLException { 142 throw new UnsupportedOperationException(); 143 } 144 145 public int getScale(int column) throws SQLException { 146 throw new UnsupportedOperationException(); 147 } 148 149 public String getTableName(int column) throws SQLException { 150 throw new UnsupportedOperationException(); 151 } 152 153 public String getCatalogName(int column) throws SQLException { 154 throw new UnsupportedOperationException(); 155 } 156 157 public int getColumnType(int column) throws SQLException { 158 throw new UnsupportedOperationException(); 159 } 160 161 public String getColumnTypeName(int column) throws SQLException { 162 throw new UnsupportedOperationException(); 163 } 164 165 public boolean isReadOnly(int column) throws SQLException { 166 throw new UnsupportedOperationException(); 167 } 168 169 public boolean isWritable(int column) throws SQLException { 170 throw new UnsupportedOperationException(); 171 } 172 173 public boolean isDefinitelyWritable(int column) throws SQLException { 174 throw new UnsupportedOperationException(); 175 } 176 177 public String getColumnClassName(int column) throws SQLException { 178 throw new UnsupportedOperationException(); 179 } 180 181 // implement Wrapper 182 183 public <T> T unwrap(Class<T> iface) throws SQLException { 184 if (iface.isInstance(this)) { 185 return iface.cast(this); 186 } 187 throw this.olap4jStatement.olap4jConnection.helper.createException( 188 "does not implement '" + iface + "'"); 189 } 190 191 public boolean isWrapperFor(Class<?> iface) throws SQLException { 192 return iface.isInstance(this); 193 } 194 195} 196 197// End MondrianOlap4jCellSetMetaData.java