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